Browse Source

Fix definition of errno to match what is used by musl

Jeremy Soller 5 years ago
parent
commit
38099fe3d9
2 changed files with 4 additions and 3 deletions
  1. 1 1
      include/bits/errno.h
  2. 3 2
      src/header/errno/mod.rs

+ 1 - 1
include/bits/errno.h

@@ -7,7 +7,7 @@ extern "C" {
 
 #define ENOTSUP EOPNOTSUPP
 
-extern __thread int errno;
+#define errno (*__errno_location())
 
 #ifdef __cplusplus
 } // extern "C"

+ 3 - 2
src/header/errno/mod.rs

@@ -3,14 +3,15 @@
 use platform;
 use platform::types::*;
 
+//TODO: Consider removing, provided for compatibility with newlib
 #[no_mangle]
 pub unsafe extern "C" fn __errno() -> *mut c_int {
-    &mut platform::errno
+    __errno_location()
 }
 
 #[no_mangle]
 pub unsafe extern "C" fn __errno_location() -> *mut c_int {
-    __errno()
+    &mut platform::errno
 }
 
 pub const EPERM: c_int = 1; /* Operation not permitted */