浏览代码

Merge branch 'master' into 'master'

Add the few last things to get gcc_complete working

See merge request redox-os/relibc!146
Jeremy Soller 6 年之前
父节点
当前提交
1f1665fd58
共有 70 个文件被更改,包括 971 次插入133 次删除
  1. 22 4
      Cargo.lock
  2. 3 1
      Cargo.toml
  3. 1 0
      Makefile
  4. 14 0
      include/assert.h
  5. 195 0
      include/bits/inttypes.h
  6. 11 0
      include/bits/sys/stat.h
  7. 2 0
      include/complex.h
  8. 2 2
      include/setjmp.h
  9. 1 1
      include/stdint.h
  10. 14 0
      src/inttypes/Cargo.toml
  11. 11 0
      src/inttypes/build.rs
  12. 7 0
      src/inttypes/cbindgen.toml
  13. 74 0
      src/inttypes/src/lib.rs
  14. 2 0
      src/lib.rs
  15. 1 1
      src/platform/src/lib.rs
  16. 4 0
      src/platform/src/linux/mod.rs
  17. 0 7
      src/setjmp/Cargo.toml
  18. 0 72
      src/setjmp/build.rs
  19. 0 6
      src/setjmp/cbindgen.toml
  20. 0 0
      src/setjmp/src/impl/README.md
  21. 0 0
      src/setjmp/src/impl/aarch64/longjmp.s
  22. 0 0
      src/setjmp/src/impl/aarch64/setjmp.s
  23. 0 0
      src/setjmp/src/impl/arm/longjmp.s
  24. 0 0
      src/setjmp/src/impl/arm/setjmp.s
  25. 0 0
      src/setjmp/src/impl/bin/.gitignore
  26. 0 0
      src/setjmp/src/impl/i386/longjmp.s
  27. 0 0
      src/setjmp/src/impl/i386/setjmp.s
  28. 0 0
      src/setjmp/src/impl/m68k/longjmp.s
  29. 0 0
      src/setjmp/src/impl/m68k/setjmp.s
  30. 0 0
      src/setjmp/src/impl/microblaze/longjmp.s
  31. 0 0
      src/setjmp/src/impl/microblaze/setjmp.s
  32. 0 0
      src/setjmp/src/impl/mips/longjmp.S
  33. 0 0
      src/setjmp/src/impl/mips/setjmp.S
  34. 0 0
      src/setjmp/src/impl/mips64/longjmp.S
  35. 0 0
      src/setjmp/src/impl/mips64/setjmp.S
  36. 0 0
      src/setjmp/src/impl/mipsn32/longjmp.S
  37. 0 0
      src/setjmp/src/impl/mipsn32/setjmp.S
  38. 0 0
      src/setjmp/src/impl/or1k/longjmp.s
  39. 0 0
      src/setjmp/src/impl/or1k/setjmp.s
  40. 0 0
      src/setjmp/src/impl/powerpc/longjmp.S
  41. 0 0
      src/setjmp/src/impl/powerpc/setjmp.S
  42. 0 0
      src/setjmp/src/impl/powerpc64/longjmp.s
  43. 0 0
      src/setjmp/src/impl/powerpc64/setjmp.s
  44. 0 0
      src/setjmp/src/impl/s390x/longjmp.s
  45. 0 0
      src/setjmp/src/impl/s390x/setjmp.s
  46. 0 0
      src/setjmp/src/impl/sh/longjmp.S
  47. 0 0
      src/setjmp/src/impl/sh/setjmp.S
  48. 0 0
      src/setjmp/src/impl/x32/longjmp.s
  49. 0 0
      src/setjmp/src/impl/x32/setjmp.s
  50. 0 0
      src/setjmp/src/impl/x86_64/longjmp.s
  51. 0 0
      src/setjmp/src/impl/x86_64/setjmp.s
  52. 29 2
      src/setjmp/src/lib.rs
  53. 4 0
      src/signal/src/lib.rs
  54. 13 8
      src/stdlib/src/lib.rs
  55. 1 0
      src/sys_stat/cbindgen.toml
  56. 28 28
      src/sys_stat/src/lib.rs
  57. 1 0
      src/sys_time/cbindgen.toml
  58. 11 0
      src/sys_utsname/Cargo.toml
  59. 11 0
      src/sys_utsname/build.rs
  60. 5 0
      src/sys_utsname/cbindgen.toml
  61. 28 0
      src/sys_utsname/src/lib.rs
  62. 1 0
      src/unistd/Cargo.toml
  63. 49 0
      src/unistd/src/lib.rs
  64. 394 0
      src/wchar/src/lib.rs
  65. 3 1
      tests/.gitignore
  66. 2 0
      tests/Makefile
  67. 14 0
      tests/assert.c
  68. 0 0
      tests/expected/assert.stderr
  69. 1 0
      tests/expected/assert.stdout
  70. 12 0
      tests/gethostname.c

+ 22 - 4
Cargo.lock

@@ -148,6 +148,17 @@ dependencies = [
  "sys_socket 0.1.0",
 ]
 
+[[package]]
+name = "inttypes"
+version = "0.1.0"
+dependencies = [
+ "cbindgen 0.5.2",
+ "ctype 0.1.0",
+ "errno 0.1.0",
+ "platform 0.1.0",
+ "stdlib 0.1.0",
+]
+
 [[package]]
 name = "itoa"
 version = "0.4.1"
@@ -274,6 +285,7 @@ dependencies = [
  "fenv 0.1.0",
  "float 0.1.0",
  "grp 0.1.0",
+ "inttypes 0.1.0",
  "locale 0.1.0",
  "netinet 0.1.0",
  "platform 0.1.0",
@@ -288,6 +300,7 @@ dependencies = [
  "sys_socket 0.1.0",
  "sys_stat 0.1.0",
  "sys_time 0.1.0",
+ "sys_utsname 0.1.0",
  "sys_wait 0.1.0",
  "time 0.1.0",
  "unistd 0.1.0",
@@ -355,10 +368,6 @@ dependencies = [
 [[package]]
 name = "setjmp"
 version = "0.1.0"
-dependencies = [
- "cbindgen 0.5.2",
- "platform 0.1.0",
-]
 
 [[package]]
 name = "signal"
@@ -486,6 +495,14 @@ dependencies = [
  "platform 0.1.0",
 ]
 
+[[package]]
+name = "sys_utsname"
+version = "0.1.0"
+dependencies = [
+ "cbindgen 0.5.2",
+ "platform 0.1.0",
+]
+
 [[package]]
 name = "sys_wait"
 version = "0.1.0"
@@ -567,6 +584,7 @@ dependencies = [
  "platform 0.1.0",
  "stdio 0.1.0",
  "string 0.1.0",
+ "sys_utsname 0.1.0",
 ]
 
 [[package]]

+ 3 - 1
Cargo.toml

@@ -20,6 +20,7 @@ fcntl = { path = "src/fcntl" }
 fenv = { path = "src/fenv" }
 float = { path = "src/float" }
 grp = { path = "src/grp" }
+inttypes = { path = "src/inttypes" }
 locale = { path = "src/locale" }
 netinet = { path = "src/netinet" }
 platform = { path = "src/platform" }
@@ -34,6 +35,7 @@ sys_resource = { path = "src/sys_resource" }
 sys_socket = { path = "src/sys_socket" }
 sys_stat = { path = "src/sys_stat" }
 sys_time = { path = "src/sys_time" }
+sys_utsname = { path = "src/sys_utsname" }
 sys_wait = { path = "src/sys_wait" }
 time = { path = "src/time" }
 unistd = { path = "src/unistd" }
@@ -42,7 +44,7 @@ wctype = { path = "src/wctype" }
 [dependencies.compiler_builtins]
 git = "https://github.com/rust-lang-nursery/compiler-builtins.git"
 default-features = false
-features = ["no-lang-items"]
+features = ["no-lang-items", "mangled-names"]
 
 [profile.dev]
 panic = "abort"

+ 1 - 0
Makefile

@@ -40,6 +40,7 @@ install: all
 	cp -v "$(BUILD)/debug/crt0.o" "$(DESTDIR)/lib"
 	cp -rv "openlibm/include"/* "$(DESTDIR)/include"
 	cp -rv "openlibm/src"/*.h "$(DESTDIR)/include"
+	cp -v "$(BUILD)/openlibm/libopenlibm.a" "$(DESTDIR)/lib/libm.a"
 
 libc: $(BUILD)/debug/libc.a $(BUILD)/debug/crt0.o
 

+ 14 - 0
include/assert.h

@@ -0,0 +1,14 @@
+#ifndef _ASSERT_H
+#define _ASSERT_H
+
+#ifdef NDEBUG
+# define assert(cond)
+#else
+# include <stdio.h>
+# define assert(cond) if (!(cond)) { \
+    fprintf(stderr, "%s: %s:%d: Assertion `%s` failed.\n", __func__, __FILE__, __LINE__, #cond); \
+    abort(); \
+    }
+#endif
+
+#endif

+ 195 - 0
include/bits/inttypes.h

@@ -0,0 +1,195 @@
+#ifndef _BITS_INTTYPE_H
+#define _BITS_INTTYPE_H
+
+#define PRId8  "hhd"
+#define PRId16 "hd"
+#define PRId32 "ld"
+#define PRId64 "Ld"
+
+#define PRIdLEAST8  "hhd"
+#define PRIdLEAST16 "hd"
+#define PRIdLEAST32 "ld"
+#define PRIdLEAST64 "Ld"
+
+#define PRIdFAST8  "hhd"
+#define PRIdFAST16 "hd"
+#define PRIdFAST32 "ld"
+#define PRIdFAST64 "Ld"
+
+#define PRIi8  "hhi"
+#define PRIi16 "hi"
+#define PRIi32 "li"
+#define PRIi64 "Li"
+
+#define PRIiLEAST8  "hhi"
+#define PRIiLEAST16 "hi"
+#define PRIiLEAST32 "li"
+#define PRIiLEAST64 "Li"
+
+#define PRIiFAST8  "hhi"
+#define PRIiFAST16 "hi"
+#define PRIiFAST32 "li"
+#define PRIiFAST64 "Li"
+
+#define PRIo8  "hho"
+#define PRIo16 "ho"
+#define PRIo32 "lo"
+#define PRIo64 "Lo"
+
+#define PRIoLEAST8  "hho"
+#define PRIoLEAST16 "ho"
+#define PRIoLEAST32 "lo"
+#define PRIoLEAST64 "Lo"
+
+#define PRIoFAST8  "hho"
+#define PRIoFAST16 "ho"
+#define PRIoFAST32 "lo"
+#define PRIoFAST64 "Lo"
+
+#define PRIu8  "hhu"
+#define PRIu16 "hu"
+#define PRIu32 "lu"
+#define PRIu64 "Lu"
+
+#define PRIuLEAST8  "hhu"
+#define PRIuLEAST16 "hu"
+#define PRIuLEAST32 "lu"
+#define PRIuLEAST64 "Lu"
+
+#define PRIuFAST8  "hhu"
+#define PRIuFAST16 "hu"
+#define PRIuFAST32 "lu"
+#define PRIuFAST64 "Lu"
+
+#define PRIx8  "hhx"
+#define PRIx16 "hx"
+#define PRIx32 "lx"
+#define PRIx64 "Lx"
+
+#define PRIxLEAST8  "hhx"
+#define PRIxLEAST16 "hx"
+#define PRIxLEAST32 "lx"
+#define PRIxLEAST64 "Lx"
+
+#define PRIxFAST8  "hhx"
+#define PRIxFAST16 "hx"
+#define PRIxFAST32 "lx"
+#define PRIxFAST64 "Lx"
+
+#define PRIX8  "hhX"
+#define PRIX16 "hX"
+#define PRIX32 "lX"
+#define PRIX64 "LX"
+
+#define PRIXLEAST8  "hhX"
+#define PRIXLEAST16 "hX"
+#define PRIXLEAST32 "lX"
+#define PRIXLEAST64 "LX"
+
+#define PRIXFAST8  "hhX"
+#define PRIXFAST16 "hX"
+#define PRIXFAST32 "lX"
+#define PRIXFAST64 "LX"
+
+#define PRIdMAX "jd"
+#define PRIiMAX "ji"
+#define PRIoMAX "jo"
+#define PRIuMAX "ju"
+#define PRIxMAX "jx"
+#define PRIXMAX "jX"
+
+#define PRIdPTR "td"
+#define PRIiPTR "ti"
+#define PRIoPTR "to"
+#define PRIuPTR "tu"
+#define PRIxPTR "tx"
+#define PRIXPTR "tX"
+
+#define SCNd8  "hhd"
+#define SCNd16 "hd"
+#define SCNd32 "ld"
+#define SCNd64 "Ld"
+
+#define SCNdLEAST8  "hhd"
+#define SCNdLEAST16 "hd"
+#define SCNdLEAST32 "ld"
+#define SCNdLEAST64 "Ld"
+
+#define SCNdFAST8  "hhd"
+#define SCNdFAST16 "hd"
+#define SCNdFAST32 "ld"
+#define SCNdFAST64 "Ld"
+
+#define SCNi8  "hhi"
+#define SCNi16 "hi"
+#define SCNi32 "li"
+#define SCNi64 "Li"
+
+#define SCNiLEAST8  "hhi"
+#define SCNiLEAST16 "hi"
+#define SCNiLEAST32 "li"
+#define SCNiLEAST64 "Li"
+
+#define SCNiFAST8  "hhi"
+#define SCNiFAST16 "hi"
+#define SCNiFAST32 "li"
+#define SCNiFAST64 "Li"
+
+#define SCNo8  "hho"
+#define SCNo16 "ho"
+#define SCNo32 "lo"
+#define SCNo64 "Lo"
+
+#define SCNoLEAST8  "hho"
+#define SCNoLEAST16 "ho"
+#define SCNoLEAST32 "lo"
+#define SCNoLEAST64 "Lo"
+
+#define SCNoFAST8  "hho"
+#define SCNoFAST16 "ho"
+#define SCNoFAST32 "lo"
+#define SCNoFAST64 "Lo"
+
+#define SCNu8  "hhu"
+#define SCNu16 "hu"
+#define SCNu32 "lu"
+#define SCNu64 "Lu"
+
+#define SCNuLEAST8  "hhu"
+#define SCNuLEAST16 "hu"
+#define SCNuLEAST32 "lu"
+#define SCNuLEAST64 "Lu"
+
+#define SCNuFAST8  "hhu"
+#define SCNuFAST16 "hu"
+#define SCNuFAST32 "lu"
+#define SCNuFAST64 "Lu"
+
+#define SCNx8  "hhx"
+#define SCNx16 "hx"
+#define SCNx32 "lx"
+#define SCNx64 "Lx"
+
+#define SCNxLEAST8  "hhx"
+#define SCNxLEAST16 "hx"
+#define SCNxLEAST32 "lx"
+#define SCNxLEAST64 "Lx"
+
+#define SCNxFAST8  "hhx"
+#define SCNxFAST16 "hx"
+#define SCNxFAST32 "lx"
+#define SCNxFAST64 "Lx"
+
+#define SCNdMAX "jd"
+#define SCNiMAX "ji"
+#define SCNoMAX "jo"
+#define SCNuMAX "ju"
+#define SCNxMAX "jx"
+
+#define SCNdPTR "td"
+#define SCNiPTR "ti"
+#define SCNoPTR "to"
+#define SCNuPTR "tu"
+#define SCNxPTR "tx"
+
+#endif

+ 11 - 0
include/bits/sys/stat.h

@@ -0,0 +1,11 @@
+#ifndef _BITS_STAT_H
+#define _BITS_STAT_H
+
+#define S_ISDIR(mode) mode & S_IFMT == S_IFDIR
+#define S_ISCHR(mode) mode & S_IFMT == S_IFCHR
+#define S_ISBLK(mode) mode & S_IFMT == S_IFBLK
+#define S_ISREG(mode) mode & S_IFMT == S_IFREG
+#define S_ISIFO(mode) mode & S_IFMT == S_IFIFO
+#define S_ISLNK(mode) mode & S_IFMT == S_IFLNK
+
+#endif

+ 2 - 0
include/complex.h

@@ -0,0 +1,2 @@
+#define OPENLIBM_USE_HOST_FENV_H 1
+#include <openlibm.h>

+ 2 - 2
include/bits/setjmp.h → include/setjmp.h

@@ -1,5 +1,5 @@
-#ifndef _BITS_SETJMP_H
-#define _BITS_SETJMP_H
+#ifndef _SETJMP_H
+#define _SETJMP_H
 
 #ifdef __arch64__
 typedef unsigned long jmp_buf[22];

+ 1 - 1
include/stdint.h

@@ -125,6 +125,6 @@ typedef uint64_t uintptr_t;
 
 #define SIZE_MAX UINT64_MAX
 
-typedef int sig_atomic_t;
+typedef long sig_atomic_t;
 
 #endif /* _STDINT_H */

+ 14 - 0
src/inttypes/Cargo.toml

@@ -0,0 +1,14 @@
+[package]
+name = "inttypes"
+version = "0.1.0"
+authors = ["jD91mZM2 <me@krake.one>"]
+build = "build.rs"
+
+[build-dependencies]
+cbindgen = { path = "../../cbindgen" }
+
+[dependencies]
+ctype = { path = "../ctype" }
+errno = { path = "../errno" }
+platform = { path = "../platform" }
+stdlib = { path = "../stdlib" }

+ 11 - 0
src/inttypes/build.rs

@@ -0,0 +1,11 @@
+extern crate cbindgen;
+
+use std::{env, fs};
+
+fn main() {
+    let crate_dir = env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set");
+    fs::create_dir_all("../../target/include").expect("failed to create include directory");
+    cbindgen::generate(crate_dir)
+        .expect("failed to generate bindings")
+        .write_to_file("../../target/include/inttypes.h");
+}

+ 7 - 0
src/inttypes/cbindgen.toml

@@ -0,0 +1,7 @@
+sys_includes = ["stdint.h"]
+include_guard = "_INTTYPES_H"
+trailer = "#include <bits/inttypes.h>"
+language = "C"
+
+[enum]
+prefix_with_name = true

+ 74 - 0
src/inttypes/src/lib.rs

@@ -0,0 +1,74 @@
+#[macro_use] extern crate stdlib;
+extern crate ctype;
+extern crate errno;
+extern crate platform;
+
+use errno::*;
+use platform::types::*;
+
+#[no_mangle]
+pub extern "C" fn imaxabs(i: intmax_t) -> intmax_t {
+    i.abs()
+}
+
+#[no_mangle]
+#[repr(C)]
+pub struct intmaxdiv_t {
+    quot: intmax_t,
+    rem: intmax_t
+}
+
+#[no_mangle]
+pub extern "C" fn imaxdiv(i: intmax_t, j: intmax_t) -> intmaxdiv_t {
+    intmaxdiv_t {
+        quot: i / j,
+        rem: i % j
+    }
+}
+
+#[no_mangle]
+pub unsafe extern "C" fn strtoimax(s: *const c_char,
+                                   endptr: *mut *mut c_char,
+                                   base: c_int)
+                                   -> intmax_t {
+    use stdlib::*;
+    strto_impl!(
+        intmax_t,
+        false,
+        intmax_t::max_value(),
+        intmax_t::min_value(),
+        s,
+        endptr,
+        base
+    )
+}
+
+#[no_mangle]
+pub unsafe extern "C" fn strtoumax(s: *const c_char,
+                                   endptr: *mut *mut c_char,
+                                   base: c_int)
+                                   -> uintmax_t {
+    use stdlib::*;
+    strto_impl!(
+        uintmax_t,
+        false,
+        uintmax_t::max_value(),
+        uintmax_t::min_value(),
+        s,
+        endptr,
+        base
+    )
+}
+
+#[allow(unused)]
+#[no_mangle]
+pub extern "C" fn wcstoimax(nptr: *const wchar_t, endptr: *mut *mut wchar_t,
+                  base: c_int) -> intmax_t {
+    unimplemented!();
+}
+#[allow(unused)]
+#[no_mangle]
+pub extern "C" fn wcstoumax(nptr: *const wchar_t, endptr: *mut *mut wchar_t,
+                  base: c_int) -> uintmax_t {
+    unimplemented!();
+}

+ 2 - 0
src/lib.rs

@@ -16,6 +16,7 @@ pub extern crate locale;
 pub extern crate netinet;
 pub extern crate semaphore;
 pub extern crate setjmp;
+pub extern crate signal;
 pub extern crate stdio;
 pub extern crate stdlib;
 pub extern crate string;
@@ -24,6 +25,7 @@ pub extern crate sys_resource;
 pub extern crate sys_socket;
 pub extern crate sys_stat;
 pub extern crate sys_time;
+pub extern crate sys_utsname;
 pub extern crate sys_wait;
 pub extern crate time;
 pub extern crate unistd;

+ 1 - 1
src/platform/src/lib.rs

@@ -10,7 +10,7 @@ extern crate sc;
 
 #[cfg(all(not(feature = "no_std"), target_os = "redox"))]
 #[macro_use]
-extern crate syscall;
+pub extern crate syscall;
 
 pub use sys::*;
 

+ 4 - 0
src/platform/src/linux/mod.rs

@@ -198,6 +198,10 @@ pub fn stat(file: *const c_char, buf: *mut stat) -> c_int {
     e(unsafe { syscall!(NEWFSTATAT, AT_FDCWD, file, buf, 0) }) as c_int
 }
 
+pub fn uname(utsname: usize) -> c_int {
+    e(unsafe { syscall!(UNAME, utsname, 0) }) as c_int
+}
+
 pub fn unlink(path: *const c_char) -> c_int {
     e(unsafe { syscall!(UNLINKAT, AT_FDCWD, path, 0) }) as c_int
 }

+ 0 - 7
src/setjmp/Cargo.toml

@@ -2,10 +2,3 @@
 name = "setjmp"
 version = "0.1.0"
 authors = ["Jeremy Soller <jackpot51@gmail.com>"]
-build = "build.rs"
-
-[build-dependencies]
-cbindgen = { path = "../../cbindgen" }
-
-[dependencies]
-platform = { path = "../platform" }

+ 0 - 72
src/setjmp/build.rs

@@ -1,72 +0,0 @@
-extern crate cbindgen;
-
-use std::{env, fs, process::Command};
-
-fn compile(file: &str, object: &str, output: &str) {
-    let status = Command::new("gcc")
-        .args(&["-c", file, "-o", object])
-        .status()
-        .expect("failed to run gcc to compile assembly");
-
-    if !status.success() {
-        panic!("compilation error");
-    }
-
-    let status = Command::new("ar")
-        .args(&["rcs", output, object])
-        .status()
-        .expect("failed to run ar to convert object to a static library");
-
-    if !status.success() {
-        panic!("error converting object to static library");
-    }
-}
-
-fn main() {
-    println!("cargo:rustc-link-lib=static=setjmp");
-    println!("cargo:rustc-link-lib=static=longjmp");
-
-    macro_rules! detect_arch {
-        ($($($token:tt);+),+) => {
-            $(
-                detect_arch!(inner $($token);+);
-            )+
-        };
-        (inner $arch:expr) => {
-            detect_arch!(inner $arch; ".s");
-        };
-        (inner $arch:expr; $ext:expr) => {
-            #[cfg(target_arch = $arch)] {
-                compile(concat!("impl/", $arch, "/setjmp", $ext), "impl/bin/setjmp.o", "impl/bin/libsetjmp.a");
-                compile(concat!("impl/", $arch, "/longjmp", $ext), "impl/bin/longjmp.o", "impl/bin/liblongjmp.a");
-
-                let dir = env::current_dir().expect("failed to find current directory");
-                println!("cargo:rustc-link-search=native={}/impl/bin", dir.display());
-            }
-        };
-    }
-
-    detect_arch! {
-        "aarch64",
-        "arm",
-        "i386",
-        "m68k",
-        "microblaze",
-        "mips"; ".S",
-        "mips64"; ".S",
-        "mipsn32"; ".S",
-        "or1k",
-        "powerpc"; ".S",
-        "powerpc64",
-        "s390x",
-        "sh"; ".S",
-        "x32",
-        "x86_64"
-    }
-
-    let crate_dir = env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set");
-    fs::create_dir_all("../../target/include").expect("failed to create include directory");
-    cbindgen::generate(crate_dir)
-        .expect("failed to generate bindings")
-        .write_to_file("../../target/include/setjmp.h");
-}

+ 0 - 6
src/setjmp/cbindgen.toml

@@ -1,6 +0,0 @@
-include_guard = "_SETJMP_H"
-trailer = "#include <bits/setjmp.h>"
-language = "C"
-
-[enum]
-prefix_with_name = true

+ 0 - 0
src/setjmp/impl/README.md → src/setjmp/src/impl/README.md


+ 0 - 0
src/setjmp/impl/aarch64/longjmp.s → src/setjmp/src/impl/aarch64/longjmp.s


+ 0 - 0
src/setjmp/impl/aarch64/setjmp.s → src/setjmp/src/impl/aarch64/setjmp.s


+ 0 - 0
src/setjmp/impl/arm/longjmp.s → src/setjmp/src/impl/arm/longjmp.s


+ 0 - 0
src/setjmp/impl/arm/setjmp.s → src/setjmp/src/impl/arm/setjmp.s


+ 0 - 0
src/setjmp/impl/bin/.gitignore → src/setjmp/src/impl/bin/.gitignore


+ 0 - 0
src/setjmp/impl/i386/longjmp.s → src/setjmp/src/impl/i386/longjmp.s


+ 0 - 0
src/setjmp/impl/i386/setjmp.s → src/setjmp/src/impl/i386/setjmp.s


+ 0 - 0
src/setjmp/impl/m68k/longjmp.s → src/setjmp/src/impl/m68k/longjmp.s


+ 0 - 0
src/setjmp/impl/m68k/setjmp.s → src/setjmp/src/impl/m68k/setjmp.s


+ 0 - 0
src/setjmp/impl/microblaze/longjmp.s → src/setjmp/src/impl/microblaze/longjmp.s


+ 0 - 0
src/setjmp/impl/microblaze/setjmp.s → src/setjmp/src/impl/microblaze/setjmp.s


+ 0 - 0
src/setjmp/impl/mips/longjmp.S → src/setjmp/src/impl/mips/longjmp.S


+ 0 - 0
src/setjmp/impl/mips/setjmp.S → src/setjmp/src/impl/mips/setjmp.S


+ 0 - 0
src/setjmp/impl/mips64/longjmp.S → src/setjmp/src/impl/mips64/longjmp.S


+ 0 - 0
src/setjmp/impl/mips64/setjmp.S → src/setjmp/src/impl/mips64/setjmp.S


+ 0 - 0
src/setjmp/impl/mipsn32/longjmp.S → src/setjmp/src/impl/mipsn32/longjmp.S


+ 0 - 0
src/setjmp/impl/mipsn32/setjmp.S → src/setjmp/src/impl/mipsn32/setjmp.S


+ 0 - 0
src/setjmp/impl/or1k/longjmp.s → src/setjmp/src/impl/or1k/longjmp.s


+ 0 - 0
src/setjmp/impl/or1k/setjmp.s → src/setjmp/src/impl/or1k/setjmp.s


+ 0 - 0
src/setjmp/impl/powerpc/longjmp.S → src/setjmp/src/impl/powerpc/longjmp.S


+ 0 - 0
src/setjmp/impl/powerpc/setjmp.S → src/setjmp/src/impl/powerpc/setjmp.S


+ 0 - 0
src/setjmp/impl/powerpc64/longjmp.s → src/setjmp/src/impl/powerpc64/longjmp.s


+ 0 - 0
src/setjmp/impl/powerpc64/setjmp.s → src/setjmp/src/impl/powerpc64/setjmp.s


+ 0 - 0
src/setjmp/impl/s390x/longjmp.s → src/setjmp/src/impl/s390x/longjmp.s


+ 0 - 0
src/setjmp/impl/s390x/setjmp.s → src/setjmp/src/impl/s390x/setjmp.s


+ 0 - 0
src/setjmp/impl/sh/longjmp.S → src/setjmp/src/impl/sh/longjmp.S


+ 0 - 0
src/setjmp/impl/sh/setjmp.S → src/setjmp/src/impl/sh/setjmp.S


+ 0 - 0
src/setjmp/impl/x32/longjmp.s → src/setjmp/src/impl/x32/longjmp.s


+ 0 - 0
src/setjmp/impl/x32/setjmp.s → src/setjmp/src/impl/x32/setjmp.s


+ 0 - 0
src/setjmp/impl/x86_64/longjmp.s → src/setjmp/src/impl/x86_64/longjmp.s


+ 0 - 0
src/setjmp/impl/x86_64/setjmp.s → src/setjmp/src/impl/x86_64/setjmp.s


+ 29 - 2
src/setjmp/src/lib.rs

@@ -1,6 +1,33 @@
 //! setjmp implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/setjmp.h.html
 
 #![no_std]
+#![feature(global_asm)]
 
-// EMPTY FILE.
-// This project is here because of the build.rs file which will compile musl's existing code for setjmp.
+macro_rules! platform_specific {
+    ($($arch:expr,$ext:expr;)+) => {
+        $(
+            #[cfg(target_arch = $arch)]
+            global_asm!(include_str!(concat!("impl/", $arch, "/setjmp.", $ext)));
+            #[cfg(target_arch = $arch)]
+            global_asm!(include_str!(concat!("impl/", $arch, "/longjmp.", $ext)));
+        )+
+    }
+}
+
+platform_specific! {
+    "aarch64","s";
+    "arm","s";
+    "i386","s";
+    "m68k","s";
+    "microblaze","s";
+    "mips","S";
+    "mips64","S";
+    "mipsn32","S";
+    "or1k","s";
+    "powerpc","S";
+    "powerpc64","s";
+    "s390x","s";
+    "sh","S";
+    "x32","s";
+    "x86_64","s";
+}

+ 4 - 0
src/signal/src/lib.rs

@@ -12,6 +12,10 @@ pub mod sys;
 #[path = "redox.rs"]
 pub mod sys;
 
+pub const SIG_BLOCK:   c_int = 0;
+pub const SIG_UNBLOCK: c_int = 1;
+pub const SIG_SETMASK: c_int = 2;
+
 pub use sys::*;
 
 use platform::types::*;

+ 13 - 8
src/stdlib/src/lib.rs

@@ -553,7 +553,7 @@ pub unsafe extern "C" fn strtod(s: *const c_char, endptr: *mut *mut c_char) -> c
     }
 }
 
-fn is_positive(ch: c_char) -> Option<(bool, isize)> {
+pub fn is_positive(ch: c_char) -> Option<(bool, isize)> {
     match ch {
         0 => None,
         ch if ch == b'+' as c_char => Some((true, 1)),
@@ -562,7 +562,7 @@ fn is_positive(ch: c_char) -> Option<(bool, isize)> {
     }
 }
 
-fn detect_base(s: *const c_char) -> Option<(c_int, isize)> {
+pub fn detect_base(s: *const c_char) -> Option<(c_int, isize)> {
     let first = unsafe { *s } as u8;
     match first {
         0 => None,
@@ -581,7 +581,7 @@ fn detect_base(s: *const c_char) -> Option<(c_int, isize)> {
     }
 }
 
-unsafe fn convert_octal(s: *const c_char) -> Option<(c_ulong, isize, bool)> {
+pub unsafe fn convert_octal(s: *const c_char) -> Option<(c_ulong, isize, bool)> {
     if *s != 0 && *s == b'0' as c_char {
         if let Some((val, idx, overflow)) = convert_integer(s.offset(1), 8) {
             Some((val, idx + 1, overflow))
@@ -594,7 +594,7 @@ unsafe fn convert_octal(s: *const c_char) -> Option<(c_ulong, isize, bool)> {
     }
 }
 
-unsafe fn convert_hex(s: *const c_char) -> Option<(c_ulong, isize, bool)> {
+pub unsafe fn convert_hex(s: *const c_char) -> Option<(c_ulong, isize, bool)> {
     if (*s != 0 && *s == b'0' as c_char)
         && (*s.offset(1) != 0 && (*s.offset(1) == b'x' as c_char || *s.offset(1) == b'X' as c_char))
     {
@@ -604,7 +604,7 @@ unsafe fn convert_hex(s: *const c_char) -> Option<(c_ulong, isize, bool)> {
     }
 }
 
-fn convert_integer(s: *const c_char, base: c_int) -> Option<(c_ulong, isize, bool)> {
+pub fn convert_integer(s: *const c_char, base: c_int) -> Option<(c_ulong, isize, bool)> {
     // -1 means the character is invalid
     #[cfg_attr(rustfmt, rustfmt_skip)]
     const LOOKUP_TABLE: [c_long; 256] = [
@@ -658,6 +658,7 @@ fn convert_integer(s: *const c_char, base: c_int) -> Option<(c_ulong, isize, boo
     }
 }
 
+#[macro_export]
 macro_rules! strto_impl {
     (
         $rettype:ty,
@@ -675,7 +676,11 @@ macro_rules! strto_impl {
 
         let set_endptr = |idx: isize| {
             if !$endptr.is_null() {
-                *$endptr = $s.offset(idx);
+                // This is stupid, but apparently strto* functions want
+                // const input but mut output, yet the man page says
+                // "stores the address of the first invalid character in *endptr"
+                // so obviously it doesn't want us to clone it.
+                *$endptr = $s.offset(idx) as *mut _;
             }
         };
 
@@ -767,7 +772,7 @@ macro_rules! strto_impl {
 
 #[no_mangle]
 pub unsafe extern "C" fn strtoul(s: *const c_char,
-                                 endptr: *mut *const c_char,
+                                 endptr: *mut *mut c_char,
                                  base: c_int)
                                  -> c_ulong {
     strto_impl!(
@@ -783,7 +788,7 @@ pub unsafe extern "C" fn strtoul(s: *const c_char,
 
 #[no_mangle]
 pub unsafe extern "C" fn strtol(s: *const c_char,
-                                endptr: *mut *const c_char,
+                                endptr: *mut *mut c_char,
                                 base: c_int)
                                 -> c_long {
     strto_impl!(

+ 1 - 0
src/sys_stat/cbindgen.toml

@@ -1,5 +1,6 @@
 sys_includes = ["sys/types.h"]
 include_guard = "_SYS_STAT_H"
+trailer = "#include <bits/sys/stat.h>"
 language = "C"
 style = "Tag"
 

+ 28 - 28
src/sys_stat/src/lib.rs

@@ -6,31 +6,31 @@ extern crate platform;
 
 use platform::types::*;
 
-pub const S_IFMT: c_int = 00170000;
-pub const S_IFBLK: c_int = 0060000;
-pub const S_IFCHR: c_int = 0020000;
-pub const S_IFIFO: c_int = 0010000;
-pub const S_IFREG: c_int = 0100000;
-pub const S_IFDIR: c_int = 0040000;
-pub const S_IFLNK: c_int = 0120000;
-
-pub const S_IRWXU: c_int = 00700;
-pub const S_IRUSR: c_int = 00400;
-pub const S_IWUSR: c_int = 00200;
-pub const S_IXUSR: c_int = 00100;
-
-pub const S_IRWXG: c_int = 00070;
-pub const S_IRGRP: c_int = 00040;
-pub const S_IWGRP: c_int = 00020;
-pub const S_IXGRP: c_int = 00010;
-
-pub const S_IRWXO: c_int = 00007;
-pub const S_IROTH: c_int = 00004;
-pub const S_IWOTH: c_int = 00002;
-pub const S_IXOTH: c_int = 00001;
-pub const S_ISUID: c_int = 04000;
-pub const S_ISGID: c_int = 02000;
-pub const S_ISVTX: c_int = 01000;
+pub const S_IFMT: c_int = 0o0170000;
+pub const S_IFBLK: c_int = 0o060000;
+pub const S_IFCHR: c_int = 0o020000;
+pub const S_IFIFO: c_int = 0o010000;
+pub const S_IFREG: c_int = 0o100000;
+pub const S_IFDIR: c_int = 0o040000;
+pub const S_IFLNK: c_int = 0o120000;
+
+pub const S_IRWXU: c_int = 0o0700;
+pub const S_IRUSR: c_int = 0o0400;
+pub const S_IWUSR: c_int = 0o0200;
+pub const S_IXUSR: c_int = 0o0100;
+
+pub const S_IRWXG: c_int = 0o0070;
+pub const S_IRGRP: c_int = 0o0040;
+pub const S_IWGRP: c_int = 0o0020;
+pub const S_IXGRP: c_int = 0o0010;
+
+pub const S_IRWXO: c_int = 0o0007;
+pub const S_IROTH: c_int = 0o0004;
+pub const S_IWOTH: c_int = 0o0002;
+pub const S_IXOTH: c_int = 0o0001;
+pub const S_ISUID: c_int = 0o4000;
+pub const S_ISGID: c_int = 0o2000;
+pub const S_ISVTX: c_int = 0o1000;
 
 #[repr(C)]
 pub struct stat {
@@ -43,9 +43,9 @@ pub struct stat {
     pub st_rdev: dev_t,
     pub st_size: off_t,
     pub st_blksize: blksize_t,
-    pub st_atim: time_t,
-    pub st_mtim: time_t,
-    pub st_ctim: time_t,
+    pub st_atime: time_t,
+    pub st_mtime: time_t,
+    pub st_ctime: time_t,
     pub st_blocks: blkcnt_t,
 }
 

+ 1 - 0
src/sys_time/cbindgen.toml

@@ -1,6 +1,7 @@
 sys_includes = ["sys/types.h"]
 include_guard = "_SYS_TIME_H"
 language = "C"
+style = "Both"
 
 [enum]
 prefix_with_name = true

+ 11 - 0
src/sys_utsname/Cargo.toml

@@ -0,0 +1,11 @@
+[package]
+name = "sys_utsname"
+version = "0.1.0"
+authors = ["jD91mZM2 <me@krake.one>"]
+build = "build.rs"
+
+[build-dependencies]
+cbindgen = { path = "../../cbindgen" }
+
+[dependencies]
+platform = { path = "../platform" }

+ 11 - 0
src/sys_utsname/build.rs

@@ -0,0 +1,11 @@
+extern crate cbindgen;
+
+use std::{env, fs};
+
+fn main() {
+    let crate_dir = env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set");
+    fs::create_dir_all("../../target/include").expect("failed to create include directory");
+    cbindgen::generate(crate_dir)
+        .expect("failed to generate bindings")
+        .write_to_file("../../target/include/sys/utsname.h");
+}

+ 5 - 0
src/sys_utsname/cbindgen.toml

@@ -0,0 +1,5 @@
+include_guard = "_SYS_UTSNAME_H"
+language = "C"
+
+[enum]
+prefix_with_name = true

+ 28 - 0
src/sys_utsname/src/lib.rs

@@ -0,0 +1,28 @@
+//! sys/utsname implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/sysutsname.h.html
+
+#![no_std]
+#![cfg(target_os = "linux")]
+
+extern crate platform;
+
+use core::ptr;
+use platform::types::*;
+
+const LENGTH: usize = 65;
+
+#[allow(non_camel_case)]
+#[no_mangle]
+#[repr(C)]
+pub struct utsname {
+    pub sysname:    [c_char; LENGTH],
+    pub nodename:   [c_char; LENGTH],
+    pub release:    [c_char; LENGTH],
+    pub version:    [c_char; LENGTH],
+    pub machine:    [c_char; LENGTH],
+    pub domainname: [c_char; LENGTH]
+}
+
+#[no_mangle]
+pub unsafe extern "C" fn uname(uts: *mut utsname) -> c_int {
+    platform::uname(uts as usize)
+}

+ 1 - 0
src/unistd/Cargo.toml

@@ -11,3 +11,4 @@ cbindgen = { path = "../../cbindgen" }
 platform = { path = "../platform" }
 stdio = { path = "../stdio" }
 string = { path = "../string" }
+sys_utsname = { path = "../sys_utsname" }

+ 49 - 0
src/unistd/src/lib.rs

@@ -5,6 +5,7 @@
 extern crate platform;
 extern crate stdio;
 extern crate string;
+extern crate sys_utsname;
 
 pub use platform::types::*;
 pub use getopt::*;
@@ -199,6 +200,54 @@ pub extern "C" fn gethostid() -> c_long {
     unimplemented!();
 }
 
+#[no_mangle]
+pub unsafe extern "C" fn gethostname(mut name: *mut c_char, len: size_t) -> c_int {
+    #[cfg(target_os = "linux")] {
+        use core::mem;
+
+        // len only needs to be mutable on linux
+        let mut len = len;
+
+        let mut uts: sys_utsname::utsname = mem::uninitialized();
+        let err = sys_utsname::uname(&mut uts);
+        if err < 0 {
+            mem::forget(uts);
+            return err;
+        }
+        for c in uts.nodename.iter() {
+            if len == 0 { break; }
+            len -= 1;
+
+            *name = *c;
+
+            if *name == 0 {
+                // We do want to copy the zero also, so we check this after the copying.
+                break;
+            }
+
+            name = name.offset(1);
+        }
+        0
+    }
+    #[cfg(target_os = "redox")] {
+        use platform::{FileReader, Read};
+        use platform::syscall::flag::*;
+
+        let fd = platform::open("/etc/hostname\0",as_ptr(), 0, O_RDONLY);
+        if fd < 0 {
+            return fd;
+        }
+        let reader = FileReader(fd);
+        for _ in 0..len {
+            if !reader.read_u8(&mut *name) {
+                *name = 0;
+                break;
+            }
+            name = name.offset(1);
+        }
+    }
+}
+
 #[no_mangle]
 pub extern "C" fn getlogin() -> *mut c_char {
     unimplemented!();

+ 394 - 0
src/wchar/src/lib.rs

@@ -0,0 +1,394 @@
+//! wchar implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/string.h.html
+
+#![no_std]
+
+extern crate errno;
+extern crate platform;
+extern crate stdlib;
+extern crate string;
+extern crate time;
+
+use platform::types::*;
+use errno::*;
+use time::*;
+use core::cmp;
+use core::usize;
+use core::ptr;
+use core::mem;
+use string::*;
+
+pub type wint_t = i32;
+
+#[repr(C)]
+pub struct mbstate_t {
+    pub mbs_count: c_int,
+    pub mbs_length: c_int,
+    pub mbs_wch: wint_t,
+}
+
+#[no_mangle]
+pub unsafe extern "C" fn btowc(c: c_int) -> wint_t {
+    //Check for EOF
+    if c == -1 {
+        return -1;
+    }
+
+    let uc = c as u8;
+    let c = uc as c_char;
+    let mut ps: mbstate_t = mbstate_t {
+        mbs_count: 0,
+        mbs_length: 0,
+        mbs_wch: 0,
+    };
+    let mut wc: wchar_t = 0;
+    let saved_errno = platform::errno;
+    let status = mbrtowc(&mut wc, &c as (*const c_char), 1, &mut ps);
+    if status == usize::max_value() || status == usize::max_value() - 1 {
+        platform::errno = saved_errno;
+        return platform::errno;
+    }
+    return wc as wint_t;
+}
+
+#[no_mangle]
+pub extern "C" fn getwchar() -> wint_t {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub unsafe extern "C" fn mbsinit(ps: *const mbstate_t) -> c_int {
+    if ps.is_null() || (*ps).mbs_count == 0 {
+        return 1;
+    } else {
+        return 0;
+    }
+}
+
+#[no_mangle]
+pub unsafe extern "C" fn mbrlen(s: *const c_char, n: usize, ps: *mut mbstate_t) -> usize {
+    static mut internal: mbstate_t = mbstate_t {
+        mbs_count: 0,
+        mbs_length: 0,
+        mbs_wch: 0,
+    };
+    return mbrtowc(ptr::null_mut(), s, n, &mut internal);
+}
+
+//Only works for utf8!
+#[no_mangle]
+pub unsafe extern "C" fn mbrtowc(
+    pwc: *mut wchar_t,
+    s: *const c_char,
+    n: usize,
+    ps: *mut mbstate_t,
+) -> usize {
+    static mut internal: mbstate_t = mbstate_t {
+        mbs_count: 0,
+        mbs_length: 0,
+        mbs_wch: 0,
+    };
+
+    if ps.is_null() {
+        let ps = &mut internal;
+    }
+    if s.is_null() {
+        let xs: [c_char; 1] = [0];
+        utf8_mbrtowc(pwc, &xs[0] as *const c_char, 1, ps);
+    }
+
+    return utf8_mbrtowc(pwc, s, n, ps);
+}
+
+#[no_mangle]
+unsafe extern "C" fn utf8_mbrtowc(
+    pwc: *mut wchar_t,
+    s: *const c_char,
+    n: usize,
+    ps: *mut mbstate_t,
+) -> usize {
+    let mut i: usize = 0;
+
+    while !(i > 0 && (*ps).mbs_count == 0) {
+        if (n <= i) {
+            return -2isize as usize;
+        }
+        let c = s.offset(i as isize);
+        let uc = c as u8;
+
+        if (*ps).mbs_count == 0 {
+            //1 byte sequence - 00–7F
+            if (uc & 0b10000000) == 0b00000000 {
+                (*ps).mbs_count = 0;
+                (*ps).mbs_length = 1;
+                (*ps).mbs_wch = (uc as wchar_t & 0b1111111) as wint_t;
+            }
+            //2 byte sequence - C2–DF
+            else if (uc & 0b11100000) == 0b11000000 {
+                (*ps).mbs_count = 1;
+                (*ps).mbs_length = 2;
+                (*ps).mbs_wch = (uc as wchar_t & 0b11111) as wint_t;
+            }
+            //3 byte sequence - E0–EF
+            else if (uc & 0b11110000) == 0b11100000 {
+                (*ps).mbs_count = 2;
+                (*ps).mbs_length = 3;
+                (*ps).mbs_wch = (uc as wchar_t & 0b1111) as wint_t;
+            }
+            //4 byte sequence - F0–F4
+            else if (uc & 0b11111000) == 0b11110000 {
+                (*ps).mbs_count = 3;
+                (*ps).mbs_length = 4;
+                (*ps).mbs_wch = (uc as wchar_t & 0b111) as wint_t;
+            } else {
+                platform::errno = errno::EILSEQ;
+                return -1isize as usize;
+            }
+        } else {
+            if (uc & 0b11000000) != 0b10000000 {
+                platform::errno = errno::EILSEQ;
+                return -1isize as usize;
+            }
+
+            (*ps).mbs_wch = (*ps).mbs_wch << 6 | (uc & 0b00111111) as wint_t;
+            (*ps).mbs_count -= 1;
+        }
+
+        i += 1;
+    }
+
+    // Reject the character if it was produced with an overly long sequence.
+    if (*ps).mbs_length == 1 && 1 << 7 <= (*ps).mbs_wch {
+        platform::errno = errno::EILSEQ;
+        return -1isize as usize;
+    }
+    if (*ps).mbs_length == 2 && 1 << (5 + 1 * 6) <= (*ps).mbs_wch {
+        platform::errno = errno::EILSEQ;
+        return -1isize as usize;
+    }
+    if (*ps).mbs_length == 3 && 1 << (5 + 2 * 6) <= (*ps).mbs_wch {
+        platform::errno = errno::EILSEQ;
+        return -1isize as usize;
+    }
+    if (*ps).mbs_length == 4 && 1 << (5 + 3 * 6) <= (*ps).mbs_wch {
+        platform::errno = errno::EILSEQ;
+        return -1isize as usize;
+    }
+
+    // The definition of UTF-8 prohibits encoding character numbers between
+    // U+D800 and U+DFFF, which are reserved for use with the UTF-16 encoding
+    // form (as surrogate pairs) and do not directly represent characters.
+    if 0xD800 <= (*ps).mbs_wch && (*ps).mbs_wch <= 0xDFFF {
+        platform::errno = errno::EILSEQ;
+        return -1isize as usize;
+    }
+    // RFC 3629 limits UTF-8 to 0x0 through 0x10FFFF.
+    if 0x10FFFF <= (*ps).mbs_wch {
+        platform::errno = errno::EILSEQ;
+        return -1isize as usize;
+    }
+
+    let result: wchar_t = (*ps).mbs_wch as wchar_t;
+
+    if !pwc.is_null() {
+        *pwc = result;
+    }
+
+    (*ps).mbs_length = 0;
+    (*ps).mbs_wch = 0;
+
+    return if result != 0 { i } else { 0 };
+}
+
+#[no_mangle]
+pub extern "C" fn mbsrtowcs(
+    dst: *mut wchar_t,
+    src: *mut *const c_char,
+    len: usize,
+    ps: *mut mbstate_t,
+) -> usize {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn putwchar(wc: wchar_t) -> wint_t {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn towlower(wc: wint_t) -> wint_t {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn towupper(wc: wint_t) -> wint_t {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn wcrtomb(s: *mut c_char, wc: wchar_t, ps: *mut mbstate_t) -> usize {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn wcscat(ws1: *mut wchar_t, ws2: *const wchar_t) -> *mut wchar_t {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn wcschr(ws1: *const wchar_t, ws2: wchar_t) -> *mut c_int {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn wcscmp(ws1: *const wchar_t, ws2: *const wchar_t) -> c_int {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn wcscoll(ws1: *const wchar_t, ws2: *const wchar_t) -> c_int {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn wcscpy(ws1: *mut wchar_t, ws2: *const wchar_t) -> *mut wchar_t {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn wcscspn(ws1: *const wchar_t, ws2: *const wchar_t) -> usize {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn wcsftime(
+    wcs: *mut wchar_t,
+    maxsize: usize,
+    format: *const wchar_t,
+    timptr: *mut tm,
+) -> usize {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn wcslen(ws: *const wchar_t) -> c_ulong {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn wcsncat(ws1: *mut wchar_t, ws2: *const wchar_t, n: usize) -> *mut wchar_t {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn wcsncmp(ws1: *const wchar_t, ws2: *const wchar_t, n: usize) -> c_int {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn wcsncpy(ws1: *mut wchar_t, ws2: *const wchar_t, n: usize) -> *mut wchar_t {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn wcspbrk(ws1: *const wchar_t, ws2: *const wchar_t) -> *mut wchar_t {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn wcsrchr(ws1: *const wchar_t, ws2: wchar_t) -> *mut wchar_t {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn wcsrtombs(
+    dst: *mut c_char,
+    src: *mut *const wchar_t,
+    len: usize,
+    ps: *mut mbstate_t,
+) -> usize {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn wcsspn(ws1: *const wchar_t, ws2: *const wchar_t) -> usize {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn wcsstr(ws1: *const wchar_t, ws2: *const wchar_t) -> *mut wchar_t {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn wcstod(nptr: *const wchar_t, endptr: *mut *mut wchar_t) -> f64 {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn wcstok(
+    ws1: *mut wchar_t,
+    ws2: *const wchar_t,
+    ptr: *mut *mut wchar_t,
+) -> *mut wchar_t {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn wcstol(nptr: *const wchar_t, endptr: *mut *mut wchar_t, base: c_int) -> c_long {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn wcstoul(nptr: *const wchar_t, endptr: *mut *mut wchar_t, base: c_int) -> c_ulong {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn wcswcs(ws1: *const wchar_t, ws2: *const wchar_t) -> *mut wchar_t {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn wcswidth(pwcs: *const wchar_t, n: usize) -> c_int {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn wcsxfrm(ws1: *mut wchar_t, ws2: *const wchar_t, n: usize) -> usize {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn wctob(c: wint_t) -> c_int {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn wcwidth(wc: wchar_t) -> c_int {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn wmemchr(ws: *const wchar_t, wc: wchar_t, n: usize) -> *mut c_int {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn wmemcmp(ws1: *const wchar_t, ws2: *const wchar_t, n: usize) -> c_int {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn wmemcpy(ws1: *mut wchar_t, ws2: *const wchar_t, n: usize) -> *mut wchar_t {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn wmemmove(ws1: *mut wchar_t, ws2: *const wchar_t, n: usize) -> *mut wchar_t {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn wmemset(ws1: *mut wchar_t, ws2: wchar_t, n: usize) -> *mut wchar_t {
+    unimplemented!();
+}

+ 3 - 1
tests/.gitignore

@@ -1,6 +1,7 @@
 /*.out
 /gen/
 /alloc
+/assert
 /args
 /atof
 /atoi
@@ -14,8 +15,9 @@
 /fcntl
 /fsync
 /ftruncate
-/getid
 /getc_unget
+/gethostname
+/getid
 /link
 /locale
 /math

+ 2 - 0
tests/Makefile

@@ -1,5 +1,6 @@
 # Binaries that should generate the same output every time
 EXPECT_BINS=\
+	assert \
 	atof \
 	atoi \
 	brk \
@@ -57,6 +58,7 @@ BINS=\
 	$(EXPECT_BINS) \
 	alloc \
 	chdir \
+	gethostname \
 	getid \
 	setid
 

+ 14 - 0
tests/assert.c

@@ -0,0 +1,14 @@
+#include <assert.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+int main() {
+    assert(1 == 1);
+    assert(1 + 1 == 2);
+
+    puts("yay!");
+
+    //This fails, but I can't test it because that'd
+    //make the test fail lol
+    //assert(42 == 1337);
+}

+ 0 - 0
tests/expected/assert.stderr


+ 1 - 0
tests/expected/assert.stdout

@@ -0,0 +1 @@
+yay!

+ 12 - 0
tests/gethostname.c

@@ -0,0 +1,12 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+
+int main() {
+    char* hostname = malloc(256);
+    if (gethostname(hostname, 256) == 0) {
+        printf("Hostname: %s\n", hostname);
+    } else {
+        puts("error getting hostname");
+    }
+}