diff --git a/include/errno.h b/include/errno.h new file mode 100644 index 0000000000..f1761777c5 --- /dev/null +++ b/include/errno.h @@ -0,0 +1 @@ +extern int errno; diff --git a/src/platform/src/lib.rs b/src/platform/src/lib.rs index 63fc300c1c..0719f8b843 100644 --- a/src/platform/src/lib.rs +++ b/src/platform/src/lib.rs @@ -29,6 +29,7 @@ use core::fmt; use types::*; #[thread_local] +#[no_mangle] pub static mut errno: c_int = 0; pub unsafe fn c_str(s: *const c_char) -> &'static [u8] { diff --git a/tests/error.c b/tests/error.c new file mode 100644 index 0000000000..f904b7349b --- /dev/null +++ b/tests/error.c @@ -0,0 +1,8 @@ +#include +#include +#include + +int main(int argc, char** argv) { + chdir("nonexistent"); + printf("errno: %d\n", errno); +}