diff --git a/Cargo.lock b/Cargo.lock index eac21f7880b5f2d53211c9a95aa471ea1e72d231..ae6d67375aa1d59dccc69144518686d0d56f0e04 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11,7 +11,7 @@ name = "atty" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -32,7 +32,7 @@ dependencies = [ "serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)", "standalone-syn 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", - "toml 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -70,7 +70,7 @@ dependencies = [ [[package]] name = "compiler_builtins" version = "0.1.0" -source = "git+https://github.com/rust-lang-nursery/compiler-builtins.git#939cbca6e9d829265d6cf006d3532142a4061cd3" +source = "git+https://github.com/rust-lang-nursery/compiler-builtins.git?rev=fe74674f6e4be76d47b66f67d529ebf4186f4eb1#fe74674f6e4be76d47b66f67d529ebf4186f4eb1" [[package]] name = "core_io" @@ -123,7 +123,7 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.43" +version = "0.2.44" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -176,7 +176,7 @@ dependencies = [ name = "ralloc_shim" version = "0.1.1" dependencies = [ - "redox_syscall 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", "sc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -186,7 +186,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -213,7 +213,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "redox_syscall" -version = "0.1.42" +version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -221,7 +221,7 @@ name = "redox_termios" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "redox_syscall 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -230,13 +230,13 @@ version = "0.1.0" dependencies = [ "cbitset 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", - "compiler_builtins 0.1.0 (git+https://github.com/rust-lang-nursery/compiler-builtins.git)", + "compiler_builtins 0.1.0 (git+https://github.com/rust-lang-nursery/compiler-builtins.git?rev=fe74674f6e4be76d47b66f67d529ebf4186f4eb1)", "core_io 0.1.20181107", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "posix-regex 0.1.0", "ralloc 1.0.0", "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", "sc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "spin 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "va_list 0.1.0", @@ -370,8 +370,8 @@ name = "termion" version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -385,7 +385,7 @@ dependencies = [ [[package]] name = "toml" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", @@ -457,12 +457,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "f159dfd43363c4d08055a07703eb7a3406b0dac4d0584d96965a3262db3c9d16" "checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4" "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" -"checksum compiler_builtins 0.1.0 (git+https://github.com/rust-lang-nursery/compiler-builtins.git)" = "<none>" +"checksum compiler_builtins 0.1.0 (git+https://github.com/rust-lang-nursery/compiler-builtins.git?rev=fe74674f6e4be76d47b66f67d529ebf4186f4eb1)" = "<none>" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" "checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" "checksum lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a374c89b9db55895453a74c1e38861d9deec0b01b405a82516e9d5de4820dea1" -"checksum libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)" = "76e3a3ef172f1a0b9a9ff0dd1491ae5e6c948b94479a3021819ba7d860c8645d" +"checksum libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)" = "10923947f84a519a45c8fefb7dd1b3e8c08747993381adee176d7a82b4195311" "checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" "checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1" @@ -472,7 +472,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e464cd887e869cddcae8792a4ee31d23c7edd516700695608f5b98c67ee0131c" "checksum rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1961a422c4d189dfb50ffa9320bf1f2a9bd54ecb92792fb9477f99a1045f3372" "checksum rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0905b6b7079ec73b314d4c748701f6931eb79fd97c668caa3f1899b22b32c6db" -"checksum redox_syscall 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "cf8fb82a4d1c9b28f1c26c574a5b541f5ffb4315f6c9a791fa47b6a04438fe93" +"checksum redox_syscall 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "679da7508e9a6390aeaf7fbd02a800fdc64b73fe2204dd2c8ae66d22d9d5ad5d" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" "checksum rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c5f5376ea5e30ce23c03eb77cbe4962b988deead10910c372b226388b594c084" @@ -492,7 +492,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8" "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" "checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6" -"checksum toml 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "4a2ecc31b0351ea18b3fe11274b8db6e4d82bce861bbb22e6dbed40417902c65" +"checksum toml 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)" = "19782e145d5abefb03758958f06ea35f7b1d8421b534140e0238fd3d0bfd66e3" "checksum unborrow 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e92e959f029e4f8ee25d70d15ab58d2b46f98a17bc238b9265ff0c26f6f3d67f" "checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526" "checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" diff --git a/Cargo.toml b/Cargo.toml index c4060981372ce39a4d1795d6be1ee1f80d61055b..eb0906a9f1ff5985cc631ccf2139804806ab61b9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,6 +24,7 @@ va_list = { path = "va_list", features = ["no_std"] } [dependencies.compiler_builtins] git = "https://github.com/rust-lang-nursery/compiler-builtins.git" +rev = "fe74674f6e4be76d47b66f67d529ebf4186f4eb1" default-features = false features = ["no-lang-items", "mangled-names"] diff --git a/core_io b/core_io index a4ddc38063ddb2f2ff1b17f772b8b50f7f3baecd..8f253772c98389e8394eca99ba7ac72addf79dba 160000 --- a/core_io +++ b/core_io @@ -1 +1 @@ -Subproject commit a4ddc38063ddb2f2ff1b17f772b8b50f7f3baecd +Subproject commit 8f253772c98389e8394eca99ba7ac72addf79dba diff --git a/src/header/regex/mod.rs b/src/header/regex/mod.rs index 3742a34c7c4c76a9364086510ec43c423696e0c2..79e9c411b66f322cab694ebb4f98e1cb7419a732 100644 --- a/src/header/regex/mod.rs +++ b/src/header/regex/mod.rs @@ -149,7 +149,7 @@ pub extern "C" fn regexec( #[no_mangle] #[linkage = "weak"] // redefined in GIT -pub extern "C" fn regerror(code: c_int, _regex: *const regex_t, out: *mut c_char, max: c_int) { +pub extern "C" fn regerror(code: c_int, _regex: *const regex_t, out: *mut c_char, max: size_t) -> size_t { let string = match code { 0 => "No error\0", REG_NOMATCH => "No match\0", @@ -174,6 +174,8 @@ pub extern "C" fn regerror(code: c_int, _regex: *const regex_t, out: *mut c_char string.as_ptr(), out as *mut u8, string.len().min(max as usize), - ) + ); } + + string.len() } diff --git a/src/header/signal/linux.rs b/src/header/signal/linux.rs index a874b2652791fd71a5e43d180ea0e9ac97b7d1d2..2d3b71d2c3be282674bb1e97f49561b81195c99d 100644 --- a/src/header/signal/linux.rs +++ b/src/header/signal/linux.rs @@ -1,19 +1,21 @@ // Needs to be defined in assembly because it can't have a function prologue +// rax is register, 15 is RT_SIGRETURN #[cfg(target_arch = "x86_64")] global_asm!( " .global __restore_rt __restore_rt: - mov $15, %rax # <- rax is register, 15 is RT_SIGRETURN + mov $15, %rax syscall " ); +// x8 is register, 139 is RT_SIGRETURN #[cfg(target_arch = "aarch64")] global_asm!( " .global __restore_rt __restore_rt: - mov x8, #139 # <- x8 is register, 139 is RT_SIGRETURN + mov x8, #139 svc 0 " ); diff --git a/src/header/signal/redox.rs b/src/header/signal/redox.rs index 9dc41126fc3e742f8bb0f1cca263d5d11b23a73e..331997d1dbebbcaf2e6ea3dde075e09a3b83c90d 100644 --- a/src/header/signal/redox.rs +++ b/src/header/signal/redox.rs @@ -1,19 +1,21 @@ // Needs to be defined in assembly because it can't have a function prologue +// rax is register, 119 is SIGRETURN #[cfg(target_arch = "x86_64")] global_asm!( " .global __restore_rt __restore_rt: - mov $119, %rax # <- rax is register, 119 is SIGRETURN + mov $119, %rax int $0x80 " ); +// x8 is register, 119 is SIGRETURN #[cfg(target_arch = "aarch64")] global_asm!( " .global __restore_rt __restore_rt: - mov x8, #119 # <- x8 is register, 119 is SIGRETURN + mov x8, #119 svc 0 " ); diff --git a/src/header/stdio/mod.rs b/src/header/stdio/mod.rs index b1153663971808301a7c4e9d7357e7b9ab2f9640..9dc4e8cbf5588f4034e03144fec7384d9ff7c30c 100644 --- a/src/header/stdio/mod.rs +++ b/src/header/stdio/mod.rs @@ -563,10 +563,10 @@ pub unsafe extern "C" fn funlockfile(file: *mut FILE) { #[no_mangle] pub extern "C" fn fwrite( ptr: *const c_void, - size: usize, - count: usize, + size: size_t, + count: size_t, stream: *mut FILE, -) -> usize { +) -> size_t { let mut stream = unsafe { &mut *stream }.lock(); let buf = unsafe { slice::from_raw_parts_mut(ptr as *mut u8, size as usize * count as usize) }; let mut written = 0; @@ -929,7 +929,7 @@ pub unsafe extern "C" fn vprintf(format: *const c_char, ap: va_list) -> c_int { #[no_mangle] pub unsafe extern "C" fn vsnprintf( s: *mut c_char, - n: usize, + n: size_t, format: *const c_char, ap: va_list, ) -> c_int { diff --git a/src/header/stdlib/mod.rs b/src/header/stdlib/mod.rs index e518b050562bfab8b06538049195927924033a6f..859b7bba8d535ad067bf2015fff0dd9498628215 100644 --- a/src/header/stdlib/mod.rs +++ b/src/header/stdlib/mod.rs @@ -855,7 +855,7 @@ pub unsafe extern "C" fn strtoull( s: *const c_char, endptr: *mut *mut c_char, base: c_int, -) -> c_ulong { +) -> c_ulonglong { strtoul(s, endptr, base) } @@ -864,7 +864,7 @@ pub unsafe extern "C" fn strtoll( s: *const c_char, endptr: *mut *mut c_char, base: c_int, -) -> c_long { +) -> c_longlong { strtol(s, endptr, base) } diff --git a/src/header/string/mod.rs b/src/header/string/mod.rs index 013da7c493a68168649fc02c979f4185f4179014..0162e409f7b6cf18ad4ab688c753ff4411b0bf04 100644 --- a/src/header/string/mod.rs +++ b/src/header/string/mod.rs @@ -16,7 +16,7 @@ pub unsafe extern "C" fn memccpy( dest: *mut c_void, src: *const c_void, c: c_int, - n: usize, + n: size_t, ) -> *mut c_void { let to = memchr(src, c, n); if to.is_null() { @@ -30,7 +30,7 @@ pub unsafe extern "C" fn memccpy( } #[no_mangle] -pub unsafe extern "C" fn memchr(s: *const c_void, c: c_int, n: usize) -> *mut c_void { +pub unsafe extern "C" fn memchr(s: *const c_void, c: c_int, n: size_t) -> *mut c_void { let mut s = s as *const u8; let c = c as u8; let mut n = n; @@ -72,7 +72,7 @@ pub unsafe extern "C" fn memchr(s: *const c_void, c: c_int, n: usize) -> *mut c_ } #[no_mangle] -pub unsafe extern "C" fn memcmp(s1: *const c_void, s2: *const c_void, n: usize) -> c_int { +pub unsafe extern "C" fn memcmp(s1: *const c_void, s2: *const c_void, n: size_t) -> c_int { let (div, rem) = (n / mem::size_of::<usize>(), n % mem::size_of::<usize>()); let mut a = s1 as *const usize; let mut b = s2 as *const usize; @@ -104,7 +104,7 @@ pub unsafe extern "C" fn memcmp(s1: *const c_void, s2: *const c_void, n: usize) } #[no_mangle] -pub unsafe extern "C" fn memcpy(s1: *mut c_void, s2: *const c_void, n: usize) -> *mut c_void { +pub unsafe extern "C" fn memcpy(s1: *mut c_void, s2: *const c_void, n: size_t) -> *mut c_void { let mut i = 0; while i + 7 < n { *(s1.offset(i as isize) as *mut u64) = *(s2.offset(i as isize) as *const u64); @@ -118,7 +118,7 @@ pub unsafe extern "C" fn memcpy(s1: *mut c_void, s2: *const c_void, n: usize) -> } #[no_mangle] -pub unsafe extern "C" fn memmove(s1: *mut c_void, s2: *const c_void, n: usize) -> *mut c_void { +pub unsafe extern "C" fn memmove(s1: *mut c_void, s2: *const c_void, n: size_t) -> *mut c_void { if s2 < s1 as *const c_void { // copy from end let mut i = n; @@ -138,7 +138,7 @@ pub unsafe extern "C" fn memmove(s1: *mut c_void, s2: *const c_void, n: usize) - } #[no_mangle] -pub unsafe extern "C" fn memset(s: *mut c_void, c: c_int, n: usize) -> *mut c_void { +pub unsafe extern "C" fn memset(s: *mut c_void, c: c_int, n: size_t) -> *mut c_void { let mut i = 0; while i < n { *(s as *mut u8).offset(i as isize) = c as u8; @@ -231,7 +231,7 @@ pub unsafe extern "C" fn strdup(s1: *const c_char) -> *mut c_char { } #[no_mangle] -pub unsafe extern "C" fn strndup(s1: *const c_char, size: usize) -> *mut c_char { +pub unsafe extern "C" fn strndup(s1: *const c_char, size: size_t) -> *mut c_char { let len = strnlen(s1, size); // the "+ 1" is to account for the NUL byte @@ -272,7 +272,7 @@ pub unsafe extern "C" fn strlen(s: *const c_char) -> size_t { } #[no_mangle] -pub unsafe extern "C" fn strnlen(s: *const c_char, size: usize) -> size_t { +pub unsafe extern "C" fn strnlen(s: *const c_char, size: size_t) -> size_t { let mut i = 0; while i < size { if *s.offset(i as isize) == 0 { @@ -284,7 +284,7 @@ pub unsafe extern "C" fn strnlen(s: *const c_char, size: usize) -> size_t { } #[no_mangle] -pub unsafe extern "C" fn strncat(s1: *mut c_char, s2: *const c_char, n: usize) -> *mut c_char { +pub unsafe extern "C" fn strncat(s1: *mut c_char, s2: *const c_char, n: size_t) -> *mut c_char { let mut idx = strlen(s1 as *const _) as isize; for i in 0..n as isize { if *s2.offset(i) == 0 { @@ -300,7 +300,7 @@ pub unsafe extern "C" fn strncat(s1: *mut c_char, s2: *const c_char, n: usize) - } #[no_mangle] -pub unsafe extern "C" fn strncmp(s1: *const c_char, s2: *const c_char, n: usize) -> c_int { +pub unsafe extern "C" fn strncmp(s1: *const c_char, s2: *const c_char, n: size_t) -> c_int { let s1 = core::slice::from_raw_parts(s1 as *const c_uchar, n); let s2 = core::slice::from_raw_parts(s2 as *const c_uchar, n); @@ -315,7 +315,7 @@ pub unsafe extern "C" fn strncmp(s1: *const c_char, s2: *const c_char, n: usize) } #[no_mangle] -pub unsafe extern "C" fn strncpy(dst: *mut c_char, src: *const c_char, n: usize) -> *mut c_char { +pub unsafe extern "C" fn strncpy(dst: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char { let mut i = 0; while *src.offset(i) != 0 && (i as usize) < n { @@ -446,7 +446,7 @@ pub extern "C" fn strtok_r( } #[no_mangle] -pub unsafe extern "C" fn strxfrm(s1: *mut c_char, s2: *const c_char, n: usize) -> size_t { +pub unsafe extern "C" fn strxfrm(s1: *mut c_char, s2: *const c_char, n: size_t) -> size_t { // relibc has no locale stuff (yet) let len = strlen(s2); if len < n { diff --git a/src/header/sys_mman/mod.rs b/src/header/sys_mman/mod.rs index 013050a053bd119c99c07f11fa1a37d3f5f4ba54..9ff48c1faa8e1aa41f2b1e1422993f0fb32e154f 100644 --- a/src/header/sys_mman/mod.rs +++ b/src/header/sys_mman/mod.rs @@ -24,7 +24,7 @@ pub extern "C" fn mlockall(flags: c_int) -> c_int { #[no_mangle] pub unsafe extern "C" fn mmap( addr: *mut c_void, - len: usize, + len: size_t, prot: c_int, flags: c_int, fildes: c_int, @@ -54,7 +54,7 @@ pub extern "C" fn munlockall() -> c_int { } #[no_mangle] -pub unsafe extern "C" fn munmap(addr: *mut c_void, len: usize) -> c_int { +pub unsafe extern "C" fn munmap(addr: *mut c_void, len: size_t) -> c_int { Sys::munmap(addr, len) }