Переглянути джерело

Merge pull request #27 from sajattack/master

add test for errno
Jeremy Soller 7 роки тому
батько
коміт
633b5474db
3 змінених файлів з 10 додано та 0 видалено
  1. 1 0
      include/errno.h
  2. 1 0
      src/platform/src/lib.rs
  3. 8 0
      tests/error.c

+ 1 - 0
include/errno.h

@@ -0,0 +1 @@
+extern int errno;

+ 1 - 0
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] {

+ 8 - 0
tests/error.c

@@ -0,0 +1,8 @@
+#include <unistd.h>
+#include <stdio.h>
+#include <errno.h>
+
+int main(int argc, char** argv) {
+    chdir("nonexistent"); 
+    printf("errno: %d\n", errno);
+}