From 50eab4369dc8898d43a07e1b2db6e04e49c44ba8 Mon Sep 17 00:00:00 2001 From: Dan Robertson Date: Sat, 10 Mar 2018 14:11:36 +0000 Subject: [PATCH 01/16] Add signal.h Create stubs for signal.h --- Cargo.lock | 9 +++ Cargo.toml | 1 + include/bits/signal.h | 10 ++++ include/bits/timespec.h | 5 ++ src/signal/Cargo.toml | 11 ++++ src/signal/build.rs | 11 ++++ src/signal/cbindgen.toml | 11 ++++ src/signal/src/lib.rs | 124 +++++++++++++++++++++++++++++++++++++++ src/signal/src/linux.rs | 48 +++++++++++++++ src/signal/src/redox.rs | 44 ++++++++++++++ 10 files changed, 274 insertions(+) create mode 100644 include/bits/signal.h create mode 100644 src/signal/Cargo.toml create mode 100644 src/signal/build.rs create mode 100644 src/signal/cbindgen.toml create mode 100644 src/signal/src/lib.rs create mode 100644 src/signal/src/linux.rs create mode 100644 src/signal/src/redox.rs diff --git a/Cargo.lock b/Cargo.lock index a0ced709f7..7201b3a890 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -278,6 +278,7 @@ dependencies = [ "platform 0.1.0", "resource 0.1.0", "semaphore 0.1.0", + "signal 0.1.0", "stat 0.1.0", "stdio 0.1.0", "stdlib 0.1.0", @@ -434,6 +435,14 @@ dependencies = [ "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "signal" +version = "0.1.0" +dependencies = [ + "cbindgen 0.5.0", + "platform 0.1.0", +] + [[package]] name = "smallvec" version = "0.6.0" diff --git a/Cargo.toml b/Cargo.toml index 55d8d5e913..b7721a9a4e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,6 +22,7 @@ semaphore = { path = "src/semaphore" } mman = { path = "src/mman" } platform = { path = "src/platform" } resource = { path = "src/resource" } +signal = { path = "src/signal" } stat = { path = "src/stat" } stdio = { path = "src/stdio" } stdlib = { path = "src/stdlib" } diff --git a/include/bits/signal.h b/include/bits/signal.h new file mode 100644 index 0000000000..8a6a8345d2 --- /dev/null +++ b/include/bits/signal.h @@ -0,0 +1,10 @@ +#ifndef _BITS_SIGNAL_H +#define _BITS_SIGNAL_H + +typedef struct sigaction { + void (*sa_handler)(uintptr_t); + sigset_t sa_mask; + uintptr_t sa_flags; +}; + +#endif diff --git a/include/bits/timespec.h b/include/bits/timespec.h index 52d696fc31..5f36eaa8cc 100644 --- a/include/bits/timespec.h +++ b/include/bits/timespec.h @@ -1,4 +1,9 @@ +#ifndef _BITS_TIMESPEC_H +#define _BITS_TIMESPEC_H + typedef struct { time_t tv_sec; long tv_nsec; } timespec; + +#endif diff --git a/src/signal/Cargo.toml b/src/signal/Cargo.toml new file mode 100644 index 0000000000..b1847d0801 --- /dev/null +++ b/src/signal/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "signal" +version = "0.1.0" +authors = ["Dan Robertson "] +build = "build.rs" + +[build-dependencies] +cbindgen = { path = "../../cbindgen" } + +[dependencies] +platform = { path = "../platform" } diff --git a/src/signal/build.rs b/src/signal/build.rs new file mode 100644 index 0000000000..011ccd1588 --- /dev/null +++ b/src/signal/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/signal.h"); +} diff --git a/src/signal/cbindgen.toml b/src/signal/cbindgen.toml new file mode 100644 index 0000000000..87d334c40d --- /dev/null +++ b/src/signal/cbindgen.toml @@ -0,0 +1,11 @@ +sys_includes = ["sys/types.h"] +include_guard = "_SIGNAL_H" +trailer = "#include " +language = "C" + +[defines] +"target_os=linux" = "__linux__" +"target_os=redox" = "__redox__" + +[enum] +prefix_with_name = true diff --git a/src/signal/src/lib.rs b/src/signal/src/lib.rs new file mode 100644 index 0000000000..80ec786e33 --- /dev/null +++ b/src/signal/src/lib.rs @@ -0,0 +1,124 @@ +//! signal implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/signal.h.html + +#![no_std] + +extern crate platform; + +#[cfg(target_os = "linux")] +#[path = "linux.rs"] +pub mod sys; + +#[cfg(target_os = "redox")] +#[path = "redox.rs"] +pub mod sys; + +pub use sys::*; + +use platform::types::*; + +#[repr(C)] +pub struct sigaction { + pub sa_handler: extern "C" fn(usize), + pub sa_mask: sigset_t, + pub sa_flags: usize, +} + +#[no_mangle] +pub extern "C" fn kill(pid: pid_t, sig: c_int) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn killpg(pgrp: pid_t, sig: c_int) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn raise(sig: c_int) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn sigaction(sig: c_int, act: *const sigaction, oact: *const sigaction) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn sigaddset(set: *mut sigset_t, signo: c_int) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn sigdelset(set: *mut sigset_t, signo: c_int) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn sigemptyset(set: *mut sigset_t) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn sigfillset(set: *mut sigset_t) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn sighold(sig: c_int) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn sigignore(sig: c_int) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn siginterrupt(sig: c_int, flag: c_int) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn sigismember(set: *const sigset_t, signo: c_int) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn signal(sig: c_int, func: fn(c_int)) -> fn(c_int) { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn sigpause(sig: c_int) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn sigpending(set: *mut sigset_t) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn sigprocmask(how: c_int, set: *const sigset_t, oset: *mut sigset_t) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn sigrelse(sig: c_int) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn sigset(sig: c_int, func: fn(c_int)) -> fn(c_int) { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn sigsuspend(sigmask: *const sigset_t) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn sigwait(set: *const sigset_t, sig: *mut c_int) -> c_int { + unimplemented!(); +} diff --git a/src/signal/src/linux.rs b/src/signal/src/linux.rs new file mode 100644 index 0000000000..63eff1c144 --- /dev/null +++ b/src/signal/src/linux.rs @@ -0,0 +1,48 @@ +#[repr(C)] +pub struct sigset_t { + pub bits: [u64; 16], +} + +pub const SIGHUP: usize = 1; +pub const SIGINT: usize = 2; +pub const SIGQUIT: usize = 3; +pub const SIGILL: usize = 4; +pub const SIGTRAP: usize = 5; +pub const SIGABRT: usize = 6; +pub const SIGIOT: usize = SIGABRT; +pub const SIGBUS: usize = 7; +pub const SIGFPE: usize = 8; +pub const SIGKILL: usize = 9; +pub const SIGUSR1: usize = 10; +pub const SIGSEGV: usize = 11; +pub const SIGUSR2: usize = 12; +pub const SIGPIPE: usize = 13; +pub const SIGALRM: usize = 14; +pub const SIGTERM: usize = 15; +pub const SIGSTKFLT: usize = 16; +pub const SIGCHLD: usize = 17; +pub const SIGCONT: usize = 18; +pub const SIGSTOP: usize = 19; +pub const SIGTSTP: usize = 20; +pub const SIGTTIN: usize = 21; +pub const SIGTTOU: usize = 22; +pub const SIGURG: usize = 23; +pub const SIGXCPU: usize = 24; +pub const SIGXFSZ: usize = 25; +pub const SIGVTALRM: usize = 26; +pub const SIGPROF: usize = 27; +pub const SIGWINCH: usize = 28; +pub const SIGIO: usize = 29; +pub const SIGPOLL: usize = 29; +pub const SIGPWR: usize = 30; +pub const SIGSYS: usize = 31; +pub const SIGUNUSED: usize = SIGSYS; + +pub const SA_NOCLDSTOP: usize = 1; +pub const SA_NOCLDWAIT: usize = 2; +pub const SA_SIGINFO: usize = 4; +pub const SA_ONSTACK: usize = 0x08000000; +pub const SA_RESTART: usize = 0x10000000; +pub const SA_NODEFER: usize = 0x40000000; +pub const SA_RESETHAND: usize = 0x80000000; +pub const SA_RESTORER: usize = 0x04000000; diff --git a/src/signal/src/redox.rs b/src/signal/src/redox.rs new file mode 100644 index 0000000000..54cb42adc5 --- /dev/null +++ b/src/signal/src/redox.rs @@ -0,0 +1,44 @@ +#[repr(C)] +pub struct sigset_t { + pub bits: [u64; 2], +} + +pub const SIGHUP: usize = 1; +pub const SIGINT: usize = 2; +pub const SIGQUIT: usize = 3; +pub const SIGILL: usize = 4; +pub const SIGTRAP: usize = 5; +pub const SIGBUS: usize = 7; +pub const SIGFPE: usize = 8; +pub const SIGKILL: usize = 9; +pub const SIGUSR1: usize = 10; +pub const SIGSEGV: usize = 11; +pub const SIGUSR2: usize = 12; +pub const SIGPIPE: usize = 13; +pub const SIGALRM: usize = 14; +pub const SIGTERM: usize = 15; +pub const SIGSTKFLT: usize = 16; +pub const SIGCHLD: usize = 17; +pub const SIGCONT: usize = 18; +pub const SIGSTOP: usize = 19; +pub const SIGTSTP: usize = 20; +pub const SIGTTIN: usize = 21; +pub const SIGTTOU: usize = 22; +pub const SIGURG: usize = 23; +pub const SIGXCPU: usize = 24; +pub const SIGXFSZ: usize = 25; +pub const SIGVTALRM: usize = 26; +pub const SIGPROF: usize = 27; +pub const SIGWINCH: usize = 28; +pub const SIGIO: usize = 29; +pub const SIGPWR: usize = 30; +pub const SIGSYS: usize = 31; + +pub const SA_NOCLDSTOP: usize = 0x00000001; +pub const SA_NOCLDWAIT: usize = 0x00000002; +pub const SA_SIGINFO: usize = 0x00000004; +pub const SA_RESTORER: usize = 0x04000000; +pub const SA_ONSTACK: usize = 0x08000000; +pub const SA_RESTART: usize = 0x10000000; +pub const SA_NODEFER: usize = 0x40000000; +pub const SA_RESETHAND: usize = 0x80000000; From a1de0ef8a1eb442a12ec16cb40b1a37c881fe2be Mon Sep 17 00:00:00 2001 From: Andrii Zymohliad Date: Mon, 12 Mar 2018 14:55:02 +0800 Subject: [PATCH 02/16] Implement strstr(), add strstr test --- src/string/src/lib.rs | 18 ++++++++++++++++-- tests/Makefile | 1 + tests/expected/string/strstr.stderr | 0 tests/expected/string/strstr.stdout | 3 +++ tests/string/strstr.c | 18 ++++++++++++++++++ 5 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 tests/expected/string/strstr.stderr create mode 100644 tests/expected/string/strstr.stdout create mode 100644 tests/string/strstr.c diff --git a/src/string/src/lib.rs b/src/string/src/lib.rs index ca56dff001..04b8c93bcd 100644 --- a/src/string/src/lib.rs +++ b/src/string/src/lib.rs @@ -299,8 +299,22 @@ pub unsafe extern "C" fn strspn(s1: *const c_char, s2: *const c_char) -> c_ulong } #[no_mangle] -pub extern "C" fn strstr(s1: *const c_char, s2: *const c_char) -> *mut c_char { - unimplemented!(); +pub unsafe extern "C" fn strstr(s1: *const c_char, s2: *const c_char) -> *mut c_char { + let mut i = 0; + while *s1.offset(i) != 0 { + let mut j = 0; + while *s2.offset(j) != 0 && *s1.offset(j + i) != 0 { + if *s2.offset(j) != *s1.offset(j + i) { + break; + } + j += 1; + if *s2.offset(j) == 0 { + return s1.offset(i) as *mut c_char; + } + } + i += 1; + } + ptr::null_mut() } #[no_mangle] diff --git a/tests/Makefile b/tests/Makefile index a252889605..ecd259335b 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -27,6 +27,7 @@ EXPECT_BINS=\ string/strchr \ string/strrchr \ string/strspn \ + string/strstr \ unlink \ write diff --git a/tests/expected/string/strstr.stderr b/tests/expected/string/strstr.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/expected/string/strstr.stdout b/tests/expected/string/strstr.stdout new file mode 100644 index 0000000000..e978edff7f --- /dev/null +++ b/tests/expected/string/strstr.stdout @@ -0,0 +1,3 @@ +rust +libc we trust +NULL diff --git a/tests/string/strstr.c b/tests/string/strstr.c new file mode 100644 index 0000000000..1f6796a2f1 --- /dev/null +++ b/tests/string/strstr.c @@ -0,0 +1,18 @@ +#include +#include + +int main(int argc, char* argv[]) { + // should be "rust" + char* str1 = strstr("In relibc we trust", "rust"); + printf("%s\n", (str1) ? str1 : "NULL"); + + // should be "libc we trust" + char* str2 = strstr("In relibc we trust", "libc"); + printf("%s\n", (str2) ? str2 : "NULL"); + + // should be "NULL" + char* str3 = strstr("In relibc we trust", "bugs"); + printf("%s\n", (str3) ? str3 : "NULL"); + + return 0; +} From 1e969afd43b83477a2251e72400970d690d058b8 Mon Sep 17 00:00:00 2001 From: Andrii Zymohliad Date: Mon, 12 Mar 2018 18:01:12 +0800 Subject: [PATCH 03/16] Implement strpbrk(), add strpbrk test --- src/string/src/lib.rs | 11 +++++++++-- tests/Makefile | 1 + tests/expected/string/strpbrk.stderr | 0 tests/expected/string/strpbrk.stdout | 3 +++ tests/string/strpbrk.c | 21 +++++++++++++++++++++ 5 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 tests/expected/string/strpbrk.stderr create mode 100644 tests/expected/string/strpbrk.stdout create mode 100644 tests/string/strpbrk.c diff --git a/src/string/src/lib.rs b/src/string/src/lib.rs index 04b8c93bcd..ef348830ee 100644 --- a/src/string/src/lib.rs +++ b/src/string/src/lib.rs @@ -250,8 +250,15 @@ pub unsafe extern "C" fn strncpy(s1: *mut c_char, s2: *const c_char, n: usize) - } #[no_mangle] -pub extern "C" fn strpbrk(s1: *const c_char, s2: *const c_char) -> *mut c_char { - unimplemented!(); +pub unsafe extern "C" fn strpbrk(s1: *const c_char, s2: *const c_char) -> *mut c_char { + let mut i = 0; + while *s1.offset(i) != 0 { + if !strchr(s2, *s1.offset(i) as i32).is_null() { + return s1.offset(i) as *mut c_char; + } + i += 1; + } + ptr::null_mut() } #[no_mangle] diff --git a/tests/Makefile b/tests/Makefile index ecd259335b..351d48df23 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -28,6 +28,7 @@ EXPECT_BINS=\ string/strrchr \ string/strspn \ string/strstr \ + string/strpbrk \ unlink \ write diff --git a/tests/expected/string/strpbrk.stderr b/tests/expected/string/strpbrk.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/expected/string/strpbrk.stdout b/tests/expected/string/strpbrk.stdout new file mode 100644 index 0000000000..7a6bc8b089 --- /dev/null +++ b/tests/expected/string/strpbrk.stdout @@ -0,0 +1,3 @@ +The quick drawn fix jumps over the lazy bug +lazy bug +NULL diff --git a/tests/string/strpbrk.c b/tests/string/strpbrk.c new file mode 100644 index 0000000000..40cae665b1 --- /dev/null +++ b/tests/string/strpbrk.c @@ -0,0 +1,21 @@ +#include +#include + +int main(int argc, char* argv[]) { + char* str = "The quick drawn fix jumps over the lazy bug"; + + // should be "The quick drawn fix jumps over the lazy bug" + char* str1 = strpbrk(str, "From The Very Beginning"); + printf("%s\n", (str1) ? str1 : "NULL"); + + // should be "lazy bug" + char* str2 = strpbrk(str, "lzbg"); + printf("%s\n", (str2) ? str2 : "NULL"); + + + // should be "NULL" + char* str3 = strpbrk(str, "404"); + printf("%s\n", (str3) ? str3 : "NULL"); + + return 0; +} From c4620be999234328e7aca7edccffdba8232071af Mon Sep 17 00:00:00 2001 From: Andrii Zymohliad Date: Mon, 12 Mar 2018 18:22:39 +0800 Subject: [PATCH 04/16] Prettify strpbrk and strstr tests --- tests/string/strpbrk.c | 15 +++++++-------- tests/string/strstr.c | 12 ++++++------ 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/tests/string/strpbrk.c b/tests/string/strpbrk.c index 40cae665b1..dc0ebf7c53 100644 --- a/tests/string/strpbrk.c +++ b/tests/string/strpbrk.c @@ -2,20 +2,19 @@ #include int main(int argc, char* argv[]) { - char* str = "The quick drawn fix jumps over the lazy bug"; + char* source = "The quick drawn fix jumps over the lazy bug"; // should be "The quick drawn fix jumps over the lazy bug" - char* str1 = strpbrk(str, "From The Very Beginning"); - printf("%s\n", (str1) ? str1 : "NULL"); + char* res1 = strpbrk(source, "From The Very Beginning"); + printf("%s\n", (res1) ? res1 : "NULL"); // should be "lazy bug" - char* str2 = strpbrk(str, "lzbg"); - printf("%s\n", (str2) ? str2 : "NULL"); - + char* res2 = strpbrk(source, "lzbg"); + printf("%s\n", (res2) ? res2 : "NULL"); // should be "NULL" - char* str3 = strpbrk(str, "404"); - printf("%s\n", (str3) ? str3 : "NULL"); + char* res3 = strpbrk(source, "404"); + printf("%s\n", (res3) ? res3 : "NULL"); return 0; } diff --git a/tests/string/strstr.c b/tests/string/strstr.c index 1f6796a2f1..6a074d18d8 100644 --- a/tests/string/strstr.c +++ b/tests/string/strstr.c @@ -3,16 +3,16 @@ int main(int argc, char* argv[]) { // should be "rust" - char* str1 = strstr("In relibc we trust", "rust"); - printf("%s\n", (str1) ? str1 : "NULL"); + char* res1 = strstr("In relibc we trust", "rust"); + printf("%s\n", (res1) ? res1 : "NULL"); // should be "libc we trust" - char* str2 = strstr("In relibc we trust", "libc"); - printf("%s\n", (str2) ? str2 : "NULL"); + char* res2 = strstr("In relibc we trust", "libc"); + printf("%s\n", (res2) ? res2 : "NULL"); // should be "NULL" - char* str3 = strstr("In relibc we trust", "bugs"); - printf("%s\n", (str3) ? str3 : "NULL"); + char* res3 = strstr("In relibc we trust", "bugs"); + printf("%s\n", (res3) ? res3 : "NULL"); return 0; } From d6a7942ec457872e701cf9830362b0a07e9072d4 Mon Sep 17 00:00:00 2001 From: Tom Almeida Date: Wed, 14 Mar 2018 01:01:23 +0800 Subject: [PATCH 05/16] Change the type of byteset from [u8] to [usize] in strcspn and strspn. Hopefully this is the last bug in these! --- src/string/src/lib.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/string/src/lib.rs b/src/string/src/lib.rs index ca56dff001..9c89220184 100644 --- a/src/string/src/lib.rs +++ b/src/string/src/lib.rs @@ -8,6 +8,8 @@ extern crate errno; extern crate platform; extern crate stdlib; +pub use compiler_builtins::mem::*; + use platform::types::*; use errno::*; use core::cmp; @@ -125,7 +127,7 @@ pub unsafe extern "C" fn strcspn(s1: *const c_char, s2: *const c_char) -> c_ulon // The below logic is effectively ripped from the musl implementation - let mut byteset = [0u8; 32 / mem::size_of::()]; + let mut byteset = [0usize; 32 / mem::size_of::()]; let mut i = 0; while *s2.offset(i) != 0 { @@ -277,7 +279,7 @@ pub unsafe extern "C" fn strspn(s1: *const c_char, s2: *const c_char) -> c_ulong // The below logic is effectively ripped from the musl implementation - let mut byteset = [0u8; 32 / mem::size_of::()]; + let mut byteset = [0usize; 32 / mem::size_of::()]; let mut i = 0; while *s2.offset(i) != 0 { From ca82b6df5bdccb7556c986b666a2554f4166ddd8 Mon Sep 17 00:00:00 2001 From: Tom Almeida Date: Wed, 14 Mar 2018 01:03:48 +0800 Subject: [PATCH 06/16] remove erroneous import in string --- src/string/src/lib.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/string/src/lib.rs b/src/string/src/lib.rs index 9c89220184..cef3406e02 100644 --- a/src/string/src/lib.rs +++ b/src/string/src/lib.rs @@ -8,8 +8,6 @@ extern crate errno; extern crate platform; extern crate stdlib; -pub use compiler_builtins::mem::*; - use platform::types::*; use errno::*; use core::cmp; From d3e44da5272c036e1e445be9ff5290ebbfe08d86 Mon Sep 17 00:00:00 2001 From: Dan Robertson Date: Tue, 13 Mar 2018 23:27:32 +0000 Subject: [PATCH 07/16] Add the no_mangle attribute to fns Add the no_mangle attribute to functions without it. --- src/fenv/src/lib.rs | 11 +++++++++++ src/float/src/lib.rs | 1 + 2 files changed, 12 insertions(+) diff --git a/src/fenv/src/lib.rs b/src/fenv/src/lib.rs index b97e7e3b5e..49ad7d29cf 100644 --- a/src/fenv/src/lib.rs +++ b/src/fenv/src/lib.rs @@ -17,46 +17,57 @@ pub struct fenv_t { pub cw: u64, } +#[no_mangle] pub unsafe extern "C" fn feclearexcept(excepts: c_int) -> c_int { unimplemented!(); } +#[no_mangle] pub unsafe extern "C" fn fegenenv(envp: *mut fenv_t) -> c_int { unimplemented!(); } +#[no_mangle] pub unsafe extern "C" fn fegetexceptflag(flagp: *mut fexcept_t, excepts: c_int) -> c_int { unimplemented!(); } +#[no_mangle] pub unsafe extern "C" fn fegetround() -> c_int { FE_TONEAREST } +#[no_mangle] pub unsafe extern "C" fn feholdexcept(envp: *mut fenv_t) -> c_int { unimplemented!(); } +#[no_mangle] pub unsafe extern "C" fn feraiseexcept(except: c_int) -> c_int { unimplemented!(); } +#[no_mangle] pub unsafe extern "C" fn fesetenv(envp: *const fenv_t) -> c_int { unimplemented!(); } +#[no_mangle] pub unsafe extern "C" fn fesetexceptflag(flagp: *const fexcept_t, excepts: c_int) -> c_int { unimplemented!(); } +#[no_mangle] pub unsafe extern "C" fn fesetround(round: c_int) -> c_int { unimplemented!(); } +#[no_mangle] pub unsafe extern "C" fn fetestexcept(excepts: c_int) -> c_int { unimplemented!(); } +#[no_mangle] pub unsafe extern "C" fn feupdateenv(envp: *const fenv_t) -> c_int { unimplemented!(); } diff --git a/src/float/src/lib.rs b/src/float/src/lib.rs index e594fdba78..723e0d6fb4 100644 --- a/src/float/src/lib.rs +++ b/src/float/src/lib.rs @@ -11,6 +11,7 @@ use fenv::{fegetround, FE_TONEAREST}; pub const FLT_RADIX: c_int = 2; +#[no_mangle] pub unsafe extern "C" fn flt_rounds() -> c_int { match fegetround() { FE_TONEAREST => 1, From 40efea056b787f38bde154fcfe000258b58e1046 Mon Sep 17 00:00:00 2001 From: Andrii Zymohliad Date: Wed, 14 Mar 2018 08:06:51 +0800 Subject: [PATCH 08/16] Reimplement strpbrk() using strcspn() --- src/string/src/lib.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/string/src/lib.rs b/src/string/src/lib.rs index ef348830ee..47e562bcc2 100644 --- a/src/string/src/lib.rs +++ b/src/string/src/lib.rs @@ -251,14 +251,12 @@ pub unsafe extern "C" fn strncpy(s1: *mut c_char, s2: *const c_char, n: usize) - #[no_mangle] pub unsafe extern "C" fn strpbrk(s1: *const c_char, s2: *const c_char) -> *mut c_char { - let mut i = 0; - while *s1.offset(i) != 0 { - if !strchr(s2, *s1.offset(i) as i32).is_null() { - return s1.offset(i) as *mut c_char; - } - i += 1; + let p = s1.offset(strcspn(s1, s2) as isize); + if *p != 0 { + p as *mut c_char + } else { + ptr::null_mut() } - ptr::null_mut() } #[no_mangle] From 9d46fa4d8c5fbde1d6520f7635d6f83e8c3653df Mon Sep 17 00:00:00 2001 From: Tom Almeida Date: Wed, 14 Mar 2018 08:48:56 +0800 Subject: [PATCH 09/16] Missed having both loops look at themselves. I'm not sure how long this has been here. --- src/string/src/lib.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/string/src/lib.rs b/src/string/src/lib.rs index ca56dff001..b97f8773fa 100644 --- a/src/string/src/lib.rs +++ b/src/string/src/lib.rs @@ -8,6 +8,8 @@ extern crate errno; extern crate platform; extern crate stdlib; +pub use compiler_builtins::mem::*; + use platform::types::*; use errno::*; use core::cmp; @@ -135,9 +137,9 @@ pub unsafe extern "C" fn strcspn(s1: *const c_char, s2: *const c_char) -> c_ulon } i = 0; // reset - while *s2.offset(i) != 0 { - if byteset[(*s2.offset(i) as usize) / (8 * byteset.len())] - & 1 << (*s2.offset(i) as usize % (8 * byteset.len())) > 0 + while *s1.offset(i) != 0 { + if byteset[(*s1.offset(i) as usize) / (8 * byteset.len())] + & 1 << (*s1.offset(i) as usize % (8 * byteset.len())) > 0 { break; } @@ -287,9 +289,9 @@ pub unsafe extern "C" fn strspn(s1: *const c_char, s2: *const c_char) -> c_ulong } i = 0; // reset - while *s2.offset(i) != 0 { - if byteset[(*s2.offset(i) as usize) / (8 * byteset.len())] - & 1 << (*s2.offset(i) as usize % (8 * byteset.len())) < 1 + while *s1.offset(i) != 0 { + if byteset[(*s1.offset(i) as usize) / (8 * byteset.len())] + & 1 << (*s1.offset(i) as usize % (8 * byteset.len())) < 1 { break; } From d058390b7568340b5792060fb5bb8d5dad14b87d Mon Sep 17 00:00:00 2001 From: Tom Almeida Date: Wed, 14 Mar 2018 08:56:18 +0800 Subject: [PATCH 10/16] The erroneous use came back! --- src/string/src/lib.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/string/src/lib.rs b/src/string/src/lib.rs index 4f42613567..5b5c15832b 100644 --- a/src/string/src/lib.rs +++ b/src/string/src/lib.rs @@ -8,8 +8,6 @@ extern crate errno; extern crate platform; extern crate stdlib; -pub use compiler_builtins::mem::*; - use platform::types::*; use errno::*; use core::cmp; From 1d6115fd095e4475b5891937b5c7f2b0288b265b Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Tue, 13 Mar 2018 19:41:31 -0600 Subject: [PATCH 11/16] Update cbindgen and lock file --- Cargo.lock | 272 ++++++++++++++--------------------------------------- cbindgen | 2 +- 2 files changed, 69 insertions(+), 205 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d695d178dc..2351f79c04 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -23,20 +23,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cbindgen" -version = "0.5.1" +version = "0.5.2" dependencies = [ "clap 2.31.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.29 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.21 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", - "standalone-syn 0.12.10 (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.6 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cc" -version = "1.0.6" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -74,7 +75,7 @@ dependencies = [ name = "ctype" version = "0.1.0" dependencies = [ - "cbindgen 0.5.1", + "cbindgen 0.5.2", "platform 0.1.0", ] @@ -87,7 +88,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "errno" version = "0.1.0" dependencies = [ - "cbindgen 0.5.1", + "cbindgen 0.5.2", "platform 0.1.0", ] @@ -95,7 +96,7 @@ dependencies = [ name = "fcntl" version = "0.1.0" dependencies = [ - "cbindgen 0.5.1", + "cbindgen 0.5.2", "platform 0.1.0", ] @@ -103,7 +104,7 @@ dependencies = [ name = "fenv" version = "0.1.0" dependencies = [ - "cbindgen 0.5.1", + "cbindgen 0.5.2", "platform 0.1.0", ] @@ -111,7 +112,7 @@ dependencies = [ name = "float" version = "0.1.0" dependencies = [ - "cbindgen 0.5.1", + "cbindgen 0.5.2", "fenv 0.1.0", "platform 0.1.0", ] @@ -134,7 +135,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "grp" version = "0.1.0" dependencies = [ - "cbindgen 0.5.1", + "cbindgen 0.5.2", "platform 0.1.0", ] @@ -177,7 +178,7 @@ dependencies = [ name = "mman" version = "0.1.0" dependencies = [ - "cbindgen 0.5.1", + "cbindgen 0.5.2", "platform 0.1.0", ] @@ -186,34 +187,6 @@ name = "num-traits" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "owning_ref" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "stable_deref_trait 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "parking_lot" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot_core 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "parking_lot_core" -version = "0.2.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "platform" version = "0.1.0" @@ -232,11 +205,8 @@ dependencies = [ [[package]] name = "quote" -version = "0.4.2" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "ralloc" @@ -316,87 +286,11 @@ dependencies = [ name = "resource" version = "0.1.0" dependencies = [ - "cbindgen 0.5.1", + "cbindgen 0.5.2", "platform 0.1.0", "sys_time 0.1.0", ] -[[package]] -name = "rustc-ap-proc_macro" -version = "40.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rustc-ap-rustc_errors 40.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-syntax 40.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-syntax_pos 40.0.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rustc-ap-rustc_cratesio_shim" -version = "40.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rustc-ap-rustc_data_structures" -version = "40.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot_core 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-serialize 40.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "stable_deref_trait 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rustc-ap-rustc_errors" -version = "40.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rustc-ap-rustc_data_structures 40.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-serialize 40.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-syntax_pos 40.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rustc-ap-serialize" -version = "40.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "rustc-ap-syntax" -version = "40.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-rustc_cratesio_shim 40.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-rustc_data_structures 40.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-rustc_errors 40.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-serialize 40.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-syntax_pos 40.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rustc-ap-syntax_pos" -version = "40.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rustc-ap-rustc_data_structures 40.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-serialize 40.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "sc" version = "0.2.2" @@ -406,36 +300,35 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "semaphore" version = "0.1.0" dependencies = [ - "cbindgen 0.5.1", + "cbindgen 0.5.2", "platform 0.1.0", ] [[package]] name = "serde" -version = "1.0.29" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde_derive 1.0.29 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.21 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_derive" -version = "1.0.29" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive_internals 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.12.14 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive_internals 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_derive_internals" -version = "0.20.0" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.12.14 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", + "synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -446,45 +339,24 @@ dependencies = [ "dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.29 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "smallvec" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "stable_deref_trait" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "standalone-proc-macro2" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rustc-ap-proc_macro 40.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "standalone-quote" -version = "0.4.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rustc-ap-proc_macro 40.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "standalone-proc-macro2 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "standalone-syn" -version = "0.12.10" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rustc-ap-proc_macro 40.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "standalone-proc-macro2 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "standalone-quote 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "standalone-quote 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -492,7 +364,7 @@ dependencies = [ name = "stat" version = "0.1.0" dependencies = [ - "cbindgen 0.5.1", + "cbindgen 0.5.2", "platform 0.1.0", ] @@ -500,7 +372,7 @@ dependencies = [ name = "stdio" version = "0.1.0" dependencies = [ - "cbindgen 0.5.1", + "cbindgen 0.5.2", "errno 0.1.0", "platform 0.1.0", "va_list 0.1.0", @@ -510,7 +382,7 @@ dependencies = [ name = "stdlib" version = "0.1.0" dependencies = [ - "cbindgen 0.5.1", + "cbindgen 0.5.2", "ctype 0.1.0", "errno 0.1.0", "platform 0.1.0", @@ -521,7 +393,7 @@ dependencies = [ name = "string" version = "0.1.0" dependencies = [ - "cbindgen 0.5.1", + "cbindgen 0.5.2", "compiler_builtins 0.1.0 (git+https://github.com/rust-lang-nursery/compiler-builtins.git)", "errno 0.1.0", "platform 0.1.0", @@ -535,19 +407,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "syn" -version = "0.12.14" +version = "0.11.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", + "synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "synom" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "sys_time" version = "0.1.0" dependencies = [ - "cbindgen 0.5.1", + "cbindgen 0.5.2", "platform 0.1.0", ] @@ -560,15 +440,6 @@ dependencies = [ "remove_dir_all 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "term" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "termion" version = "1.5.1" @@ -591,7 +462,7 @@ dependencies = [ name = "time" version = "0.1.0" dependencies = [ - "cbindgen 0.5.1", + "cbindgen 0.5.2", "platform 0.1.0", ] @@ -600,7 +471,7 @@ name = "toml" version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.29 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -613,6 +484,11 @@ name = "unicode-width" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "unicode-xid" +version = "0.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "unicode-xid" version = "0.1.0" @@ -622,7 +498,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "unistd" version = "0.1.0" dependencies = [ - "cbindgen 0.5.1", + "cbindgen 0.5.2", "platform 0.1.0", ] @@ -637,7 +513,7 @@ dependencies = [ name = "va_list-helper" version = "0.0.2" dependencies = [ - "cc 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -649,7 +525,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "wait" version = "0.1.0" dependencies = [ - "cbindgen 0.5.1", + "cbindgen 0.5.2", "platform 0.1.0", "resource 0.1.0", ] @@ -658,7 +534,7 @@ dependencies = [ name = "wctype" version = "0.1.0" dependencies = [ - "cbindgen 0.5.1", + "cbindgen 0.5.2", "platform 0.1.0", ] @@ -695,7 +571,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum atty 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "af80143d6f7608d746df1520709e5d141c96f240b0e62b0aa41bdfb53374d9d4" "checksum bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b3c30d3802dfb7281680d6285f2ccdaa8c2d8fee41f93805dba5c4cf50dc23cf" -"checksum cc 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "fedf677519ac9e865c4ff43ef8f930773b37ed6e6ea61b6b83b400a7b5787f49" +"checksum cc 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "87f38f122db5615319a985757e526c00161d924d19b71a0f3e80c52bab1adcf6" "checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de" "checksum clap 2.31.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5dc18f6f4005132120d9711636b32c46a233fad94df6217fa1d81c5e97a9f200" "checksum compiler_builtins 0.1.0 (git+https://github.com/rust-lang-nursery/compiler-builtins.git)" = "" @@ -708,41 +584,29 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" "checksum log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "89f010e843f2b1a31dbd316b3b8d443758bc634bed37aabade59c686d644e0a2" "checksum num-traits 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3c2bd9b9d21e48e956b763c9f37134dc62d9e95da6edb3f672cacb6caf3cd3" -"checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37" -"checksum parking_lot 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "9fd9d732f2de194336fb02fe11f9eed13d9e76f13f4315b4d88a14ca411750cd" -"checksum parking_lot_core 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "538ef00b7317875071d5e00f603f24d16f0b474c1a5fc0ccb8b454ca72eafa79" "checksum proc-macro2 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cd07deb3c6d1d9ff827999c7f9b04cdfd66b1b17ae508e14fe47b620f2282ae0" -"checksum quote 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1eca14c727ad12702eb4b6bfb5a232287dcf8385cb8ca83a3eeaf6519c44c408" +"checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" "checksum rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "eba5f8cb59cc50ed56be8880a5c7b496bfd9bd26394e176bc67884094145c2c5" "checksum redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)" = "0d92eecebad22b767915e4d529f89f28ee96dbbf5a4810d2b844373f136417fd" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" "checksum remove_dir_all 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b5d2f806b0fcdabd98acd380dc8daef485e22bcb7cddc811d1337967f2528cf5" -"checksum rustc-ap-proc_macro 40.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d96f017dd18a6925618e1caf4a375ba2a5a175471172e18cc4855ac0587231ff" -"checksum rustc-ap-rustc_cratesio_shim 40.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6773cafaa546d932d62eb22fe854772f4d1b973245b36727c893a9fea3dbc4c6" -"checksum rustc-ap-rustc_data_structures 40.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a64e8c55c343448d6a0904e2066710be2734284d904b52b8fd064ca201ca854b" -"checksum rustc-ap-rustc_errors 40.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ad6d84133da5f6b51c544b981c6b405e79db0a4fca41e34d77849846ed3b9121" -"checksum rustc-ap-serialize 40.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "43d227b1b3de1ec6d3fb48e10799d08c073c57e45f536766e1d897d46b737e0b" -"checksum rustc-ap-syntax 40.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b6e525fc674e8a75eaed08a90a6df7adfa73a66135056577722185dd7ca0771" -"checksum rustc-ap-syntax_pos 40.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e157f53ad5c4a6cf9ae5b5be15325dd2eeca190c03ab9873cc1460788767e5e9" "checksum sc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4ebbb026ba4a707c25caec2db5ef59ad8b41f7ad77cad06257e06229c891f376" -"checksum serde 1.0.29 (registry+https://github.com/rust-lang/crates.io-index)" = "4763b773978e495252615e814d2ad04773b2c1f85421c7913869a537f35cb406" -"checksum serde_derive 1.0.29 (registry+https://github.com/rust-lang/crates.io-index)" = "8ab31f00ae5574bb643c196d5e302961c122da1c768604c6d16a35c5d551948a" -"checksum serde_derive_internals 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1fc848d073be32cd982380c06587ea1d433bc1a4c4a111de07ec2286a3ddade8" +"checksum serde 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)" = "c73f63e08b33f6e59dfb3365b009897ebc3a3edc4af6e4f3ce8e483cf3d80ce7" +"checksum serde_derive 1.0.21 (registry+https://github.com/rust-lang/crates.io-index)" = "652bc323d694dc925829725ec6c890156d8e70ae5202919869cb00fe2eff3788" +"checksum serde_derive_internals 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)" = "32f1926285523b2db55df263d2aa4eb69ddcfa7a7eade6430323637866b513ab" "checksum serde_json 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "fab6c4d75bedcf880711c85e39ebf8ccc70d0eba259899047ec5d7436643ee17" -"checksum smallvec 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44db0ecb22921ef790d17ae13a3f6d15784183ff5f2a01aa32098c7498d2b4b9" -"checksum stable_deref_trait 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "15132e0e364248108c5e2c02e3ab539be8d6f5d52a01ca9bbf27ed657316f02b" -"checksum standalone-proc-macro2 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "04b0e28c7fb04d85743490bd2a24bd0ec0ff6efc74e7c848748fd9fd2b105410" -"checksum standalone-quote 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "45bd227b8113ff91db4f6eadcc73928dc602af00a851f4fe65f3c1cb1a96b5e1" -"checksum standalone-syn 0.12.10 (registry+https://github.com/rust-lang/crates.io-index)" = "d800cb9b3b2e08877667aace544bb0882ea3d5cf3ae83c2730a9032becf1f6bd" +"checksum standalone-quote 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dcedac1d6d98e7e9d1d6e628f5635af9566688ae5f6cea70a3976f495ae8d839" +"checksum standalone-syn 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "115808f5187c07c23cb93eee49d542fae54c6e8285d3a24c6ff683fcde9243db" "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" -"checksum syn 0.12.14 (registry+https://github.com/rust-lang/crates.io-index)" = "8c5bc2d6ff27891209efa5f63e9de78648d7801f085e4653701a692ce938d6fd" +"checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" +"checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" "checksum tempdir 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f73eebdb68c14bcb24aef74ea96079830e7fa7b31a6106e42ea7ee887c1e134e" -"checksum term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "fa63644f74ce96fbeb9b794f66aff2a52d601cbd5e80f4b97123e3899f4570f1" "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" "checksum textwrap 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c0b59b6b4b44d867f1370ef1bd91bfb262bf07bf0ae65c202ea2fbc16153b693" "checksum toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a7540f4ffc193e0d3c94121edb19b055670d369f77d5804db11ae053a45b6e7e" "checksum unborrow 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e92e959f029e4f8ee25d70d15ab58d2b46f98a17bc238b9265ff0c26f6f3d67f" "checksum unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "bf3a113775714a22dcb774d8ea3655c53a32debae63a063acc00a91cc586245f" +"checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum vec_map 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "887b5b631c2ad01628bbbaa7dd4c869f80d3186688f8d0b6f58774fbe324988c" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" diff --git a/cbindgen b/cbindgen index fe26d47afd..d14295f3ca 160000 --- a/cbindgen +++ b/cbindgen @@ -1 +1 @@ -Subproject commit fe26d47afd3e959a8cd73f81f430b061d28c4c3b +Subproject commit d14295f3ca588f1d1752ea0a579f0597dd2ce248 From 996fad709238e5c4e24395f1c4ff8c90dfb984e5 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Tue, 13 Mar 2018 19:52:15 -0600 Subject: [PATCH 12/16] Fix fcntl header constants --- src/fcntl/cbindgen.toml | 4 ++++ src/fcntl/src/lib.rs | 52 ++++++++++++++++++++++++++++++++++++----- src/fcntl/src/linux.rs | 8 ------- src/fcntl/src/redox.rs | 20 ---------------- 4 files changed, 50 insertions(+), 34 deletions(-) delete mode 100644 src/fcntl/src/linux.rs delete mode 100644 src/fcntl/src/redox.rs diff --git a/src/fcntl/cbindgen.toml b/src/fcntl/cbindgen.toml index e9893c078d..19d473cd4a 100644 --- a/src/fcntl/cbindgen.toml +++ b/src/fcntl/cbindgen.toml @@ -3,5 +3,9 @@ include_guard = "_FCNTL_H" trailer = "#include " language = "C" +[defines] +"target_os = linux" = "__linux__" +"target_os = redox" = "__redox__" + [enum] prefix_with_name = true diff --git a/src/fcntl/src/lib.rs b/src/fcntl/src/lib.rs index 0c0fa43ce2..0e5048277a 100644 --- a/src/fcntl/src/lib.rs +++ b/src/fcntl/src/lib.rs @@ -6,15 +6,55 @@ extern crate platform; use platform::types::*; -pub use sys::*; - #[cfg(target_os = "linux")] -#[path = "linux.rs"] -pub mod sys; +pub const O_RDONLY: c_int = 0x0000; +#[cfg(target_os = "linux")] +pub const O_WRONLY: c_int = 0x0001; +#[cfg(target_os = "linux")] +pub const O_RDWR: c_int = 0x0002; +#[cfg(target_os = "linux")] +pub const O_CREAT: c_int = 0x0040; +#[cfg(target_os = "linux")] +pub const O_TRUNC: c_int = 0x0200; +#[cfg(target_os = "linux")] +pub const O_ACCMODE: c_int = O_RDONLY | O_WRONLY | O_RDWR; #[cfg(target_os = "redox")] -#[path = "redox.rs"] -pub mod sys; +pub const O_RDONLY: c_int = 0x0001_0000; +#[cfg(target_os = "redox")] +pub const O_WRONLY: c_int = 0x0002_0000; +#[cfg(target_os = "redox")] +pub const O_RDWR: c_int = 0x0003_0000; +#[cfg(target_os = "redox")] +pub const O_NONBLOCK: c_int = 0x0004_0000; +#[cfg(target_os = "redox")] +pub const O_APPEND: c_int = 0x0008_0000; +#[cfg(target_os = "redox")] +pub const O_SHLOCK: c_int = 0x0010_0000; +#[cfg(target_os = "redox")] +pub const O_EXLOCK: c_int = 0x0020_0000; +#[cfg(target_os = "redox")] +pub const O_ASYNC: c_int = 0x0040_0000; +#[cfg(target_os = "redox")] +pub const O_FSYNC: c_int = 0x0080_0000; +#[cfg(target_os = "redox")] +pub const O_CLOEXEC: c_int = 0x0100_0000; +#[cfg(target_os = "redox")] +pub const O_CREAT: c_int = 0x0200_0000; +#[cfg(target_os = "redox")] +pub const O_TRUNC: c_int = 0x0400_0000; +#[cfg(target_os = "redox")] +pub const O_EXCL: c_int = 0x0800_0000; +#[cfg(target_os = "redox")] +pub const O_DIRECTORY: c_int = 0x1000_0000; +#[cfg(target_os = "redox")] +pub const O_STAT: c_int = 0x2000_0000; +#[cfg(target_os = "redox")] +pub const O_SYMLINK: c_int = 0x4000_0000; +#[cfg(target_os = "redox")] +pub const O_NOFOLLOW: c_int = 0x8000_0000; +#[cfg(target_os = "redox")] +pub const O_ACCMODE: c_int = O_RDONLY | O_WRONLY | O_RDWR; pub const F_DUPFD: c_int = 0; pub const F_GETFD: c_int = 1; diff --git a/src/fcntl/src/linux.rs b/src/fcntl/src/linux.rs deleted file mode 100644 index fd68ffcf14..0000000000 --- a/src/fcntl/src/linux.rs +++ /dev/null @@ -1,8 +0,0 @@ -use platform::types::*; - -pub const O_RDONLY: c_int = 0x0000; -pub const O_WRONLY: c_int = 0x0001; -pub const O_RDWR: c_int = 0x0002; -pub const O_CREAT: c_int = 0x0040; -pub const O_TRUNC: c_int = 0x0200; -pub const O_ACCMODE: c_int = O_RDONLY | O_WRONLY | O_RDWR; diff --git a/src/fcntl/src/redox.rs b/src/fcntl/src/redox.rs deleted file mode 100644 index 1ea3ca45de..0000000000 --- a/src/fcntl/src/redox.rs +++ /dev/null @@ -1,20 +0,0 @@ -use platform::types::*; - -pub const O_RDONLY: c_int = 0x0001_0000; -pub const O_WRONLY: c_int = 0x0002_0000; -pub const O_RDWR: c_int = 0x0003_0000; -pub const O_NONBLOCK: c_int = 0x0004_0000; -pub const O_APPEND: c_int = 0x0008_0000; -pub const O_SHLOCK: c_int = 0x0010_0000; -pub const O_EXLOCK: c_int = 0x0020_0000; -pub const O_ASYNC: c_int = 0x0040_0000; -pub const O_FSYNC: c_int = 0x0080_0000; -pub const O_CLOEXEC: c_int = 0x0100_0000; -pub const O_CREAT: c_int = 0x0200_0000; -pub const O_TRUNC: c_int = 0x0400_0000; -pub const O_EXCL: c_int = 0x0800_0000; -pub const O_DIRECTORY: c_int = 0x1000_0000; -pub const O_STAT: c_int = 0x2000_0000; -pub const O_SYMLINK: c_int = 0x4000_0000; -pub const O_NOFOLLOW: c_int = 0x8000_0000; -pub const O_ACCMODE: c_int = O_RDONLY | O_WRONLY | O_RDWR; From cfe98ab3b2ef0d211e092c846a80b969fad82f92 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Tue, 13 Mar 2018 19:58:52 -0600 Subject: [PATCH 13/16] Fix constants in signal.h --- src/signal/src/lib.rs | 178 ++++++++++++++++++++++++++++++++++++++-- src/signal/src/linux.rs | 48 ----------- src/signal/src/redox.rs | 44 ---------- 3 files changed, 172 insertions(+), 98 deletions(-) delete mode 100644 src/signal/src/linux.rs delete mode 100644 src/signal/src/redox.rs diff --git a/src/signal/src/lib.rs b/src/signal/src/lib.rs index 80ec786e33..9a4e781785 100644 --- a/src/signal/src/lib.rs +++ b/src/signal/src/lib.rs @@ -4,17 +4,183 @@ extern crate platform; +use platform::types::*; + #[cfg(target_os = "linux")] -#[path = "linux.rs"] -pub mod sys; +#[repr(C)] +pub struct sigset_t { + pub bits: [u64; 16], +} + +#[cfg(target_os = "linux")] +pub const SIGHUP: usize = 1; +#[cfg(target_os = "linux")] +pub const SIGINT: usize = 2; +#[cfg(target_os = "linux")] +pub const SIGQUIT: usize = 3; +#[cfg(target_os = "linux")] +pub const SIGILL: usize = 4; +#[cfg(target_os = "linux")] +pub const SIGTRAP: usize = 5; +#[cfg(target_os = "linux")] +pub const SIGABRT: usize = 6; +#[cfg(target_os = "linux")] +pub const SIGIOT: usize = SIGABRT; +#[cfg(target_os = "linux")] +pub const SIGBUS: usize = 7; +#[cfg(target_os = "linux")] +pub const SIGFPE: usize = 8; +#[cfg(target_os = "linux")] +pub const SIGKILL: usize = 9; +#[cfg(target_os = "linux")] +pub const SIGUSR1: usize = 10; +#[cfg(target_os = "linux")] +pub const SIGSEGV: usize = 11; +#[cfg(target_os = "linux")] +pub const SIGUSR2: usize = 12; +#[cfg(target_os = "linux")] +pub const SIGPIPE: usize = 13; +#[cfg(target_os = "linux")] +pub const SIGALRM: usize = 14; +#[cfg(target_os = "linux")] +pub const SIGTERM: usize = 15; +#[cfg(target_os = "linux")] +pub const SIGSTKFLT: usize = 16; +#[cfg(target_os = "linux")] +pub const SIGCHLD: usize = 17; +#[cfg(target_os = "linux")] +pub const SIGCONT: usize = 18; +#[cfg(target_os = "linux")] +pub const SIGSTOP: usize = 19; +#[cfg(target_os = "linux")] +pub const SIGTSTP: usize = 20; +#[cfg(target_os = "linux")] +pub const SIGTTIN: usize = 21; +#[cfg(target_os = "linux")] +pub const SIGTTOU: usize = 22; +#[cfg(target_os = "linux")] +pub const SIGURG: usize = 23; +#[cfg(target_os = "linux")] +pub const SIGXCPU: usize = 24; +#[cfg(target_os = "linux")] +pub const SIGXFSZ: usize = 25; +#[cfg(target_os = "linux")] +pub const SIGVTALRM: usize = 26; +#[cfg(target_os = "linux")] +pub const SIGPROF: usize = 27; +#[cfg(target_os = "linux")] +pub const SIGWINCH: usize = 28; +#[cfg(target_os = "linux")] +pub const SIGIO: usize = 29; +#[cfg(target_os = "linux")] +pub const SIGPOLL: usize = 29; +#[cfg(target_os = "linux")] +pub const SIGPWR: usize = 30; +#[cfg(target_os = "linux")] +pub const SIGSYS: usize = 31; +#[cfg(target_os = "linux")] +pub const SIGUNUSED: usize = SIGSYS; + +#[cfg(target_os = "linux")] +pub const SA_NOCLDSTOP: usize = 1; +#[cfg(target_os = "linux")] +pub const SA_NOCLDWAIT: usize = 2; +#[cfg(target_os = "linux")] +pub const SA_SIGINFO: usize = 4; +#[cfg(target_os = "linux")] +pub const SA_ONSTACK: usize = 0x08000000; +#[cfg(target_os = "linux")] +pub const SA_RESTART: usize = 0x10000000; +#[cfg(target_os = "linux")] +pub const SA_NODEFER: usize = 0x40000000; +#[cfg(target_os = "linux")] +pub const SA_RESETHAND: usize = 0x80000000; +#[cfg(target_os = "linux")] +pub const SA_RESTORER: usize = 0x04000000; #[cfg(target_os = "redox")] -#[path = "redox.rs"] -pub mod sys; +#[repr(C)] +pub struct sigset_t { + pub bits: [u64; 2], +} -pub use sys::*; +#[cfg(target_os = "redox")] +pub const SIGHUP: usize = 1; +#[cfg(target_os = "redox")] +pub const SIGINT: usize = 2; +#[cfg(target_os = "redox")] +pub const SIGQUIT: usize = 3; +#[cfg(target_os = "redox")] +pub const SIGILL: usize = 4; +#[cfg(target_os = "redox")] +pub const SIGTRAP: usize = 5; +#[cfg(target_os = "redox")] +pub const SIGBUS: usize = 7; +#[cfg(target_os = "redox")] +pub const SIGFPE: usize = 8; +#[cfg(target_os = "redox")] +pub const SIGKILL: usize = 9; +#[cfg(target_os = "redox")] +pub const SIGUSR1: usize = 10; +#[cfg(target_os = "redox")] +pub const SIGSEGV: usize = 11; +#[cfg(target_os = "redox")] +pub const SIGUSR2: usize = 12; +#[cfg(target_os = "redox")] +pub const SIGPIPE: usize = 13; +#[cfg(target_os = "redox")] +pub const SIGALRM: usize = 14; +#[cfg(target_os = "redox")] +pub const SIGTERM: usize = 15; +#[cfg(target_os = "redox")] +pub const SIGSTKFLT: usize = 16; +#[cfg(target_os = "redox")] +pub const SIGCHLD: usize = 17; +#[cfg(target_os = "redox")] +pub const SIGCONT: usize = 18; +#[cfg(target_os = "redox")] +pub const SIGSTOP: usize = 19; +#[cfg(target_os = "redox")] +pub const SIGTSTP: usize = 20; +#[cfg(target_os = "redox")] +pub const SIGTTIN: usize = 21; +#[cfg(target_os = "redox")] +pub const SIGTTOU: usize = 22; +#[cfg(target_os = "redox")] +pub const SIGURG: usize = 23; +#[cfg(target_os = "redox")] +pub const SIGXCPU: usize = 24; +#[cfg(target_os = "redox")] +pub const SIGXFSZ: usize = 25; +#[cfg(target_os = "redox")] +pub const SIGVTALRM: usize = 26; +#[cfg(target_os = "redox")] +pub const SIGPROF: usize = 27; +#[cfg(target_os = "redox")] +pub const SIGWINCH: usize = 28; +#[cfg(target_os = "redox")] +pub const SIGIO: usize = 29; +#[cfg(target_os = "redox")] +pub const SIGPWR: usize = 30; +#[cfg(target_os = "redox")] +pub const SIGSYS: usize = 31; -use platform::types::*; +#[cfg(target_os = "redox")] +pub const SA_NOCLDSTOP: usize = 0x00000001; +#[cfg(target_os = "redox")] +pub const SA_NOCLDWAIT: usize = 0x00000002; +#[cfg(target_os = "redox")] +pub const SA_SIGINFO: usize = 0x00000004; +#[cfg(target_os = "redox")] +pub const SA_RESTORER: usize = 0x04000000; +#[cfg(target_os = "redox")] +pub const SA_ONSTACK: usize = 0x08000000; +#[cfg(target_os = "redox")] +pub const SA_RESTART: usize = 0x10000000; +#[cfg(target_os = "redox")] +pub const SA_NODEFER: usize = 0x40000000; +#[cfg(target_os = "redox")] +pub const SA_RESETHAND: usize = 0x80000000; #[repr(C)] pub struct sigaction { diff --git a/src/signal/src/linux.rs b/src/signal/src/linux.rs deleted file mode 100644 index 63eff1c144..0000000000 --- a/src/signal/src/linux.rs +++ /dev/null @@ -1,48 +0,0 @@ -#[repr(C)] -pub struct sigset_t { - pub bits: [u64; 16], -} - -pub const SIGHUP: usize = 1; -pub const SIGINT: usize = 2; -pub const SIGQUIT: usize = 3; -pub const SIGILL: usize = 4; -pub const SIGTRAP: usize = 5; -pub const SIGABRT: usize = 6; -pub const SIGIOT: usize = SIGABRT; -pub const SIGBUS: usize = 7; -pub const SIGFPE: usize = 8; -pub const SIGKILL: usize = 9; -pub const SIGUSR1: usize = 10; -pub const SIGSEGV: usize = 11; -pub const SIGUSR2: usize = 12; -pub const SIGPIPE: usize = 13; -pub const SIGALRM: usize = 14; -pub const SIGTERM: usize = 15; -pub const SIGSTKFLT: usize = 16; -pub const SIGCHLD: usize = 17; -pub const SIGCONT: usize = 18; -pub const SIGSTOP: usize = 19; -pub const SIGTSTP: usize = 20; -pub const SIGTTIN: usize = 21; -pub const SIGTTOU: usize = 22; -pub const SIGURG: usize = 23; -pub const SIGXCPU: usize = 24; -pub const SIGXFSZ: usize = 25; -pub const SIGVTALRM: usize = 26; -pub const SIGPROF: usize = 27; -pub const SIGWINCH: usize = 28; -pub const SIGIO: usize = 29; -pub const SIGPOLL: usize = 29; -pub const SIGPWR: usize = 30; -pub const SIGSYS: usize = 31; -pub const SIGUNUSED: usize = SIGSYS; - -pub const SA_NOCLDSTOP: usize = 1; -pub const SA_NOCLDWAIT: usize = 2; -pub const SA_SIGINFO: usize = 4; -pub const SA_ONSTACK: usize = 0x08000000; -pub const SA_RESTART: usize = 0x10000000; -pub const SA_NODEFER: usize = 0x40000000; -pub const SA_RESETHAND: usize = 0x80000000; -pub const SA_RESTORER: usize = 0x04000000; diff --git a/src/signal/src/redox.rs b/src/signal/src/redox.rs deleted file mode 100644 index 54cb42adc5..0000000000 --- a/src/signal/src/redox.rs +++ /dev/null @@ -1,44 +0,0 @@ -#[repr(C)] -pub struct sigset_t { - pub bits: [u64; 2], -} - -pub const SIGHUP: usize = 1; -pub const SIGINT: usize = 2; -pub const SIGQUIT: usize = 3; -pub const SIGILL: usize = 4; -pub const SIGTRAP: usize = 5; -pub const SIGBUS: usize = 7; -pub const SIGFPE: usize = 8; -pub const SIGKILL: usize = 9; -pub const SIGUSR1: usize = 10; -pub const SIGSEGV: usize = 11; -pub const SIGUSR2: usize = 12; -pub const SIGPIPE: usize = 13; -pub const SIGALRM: usize = 14; -pub const SIGTERM: usize = 15; -pub const SIGSTKFLT: usize = 16; -pub const SIGCHLD: usize = 17; -pub const SIGCONT: usize = 18; -pub const SIGSTOP: usize = 19; -pub const SIGTSTP: usize = 20; -pub const SIGTTIN: usize = 21; -pub const SIGTTOU: usize = 22; -pub const SIGURG: usize = 23; -pub const SIGXCPU: usize = 24; -pub const SIGXFSZ: usize = 25; -pub const SIGVTALRM: usize = 26; -pub const SIGPROF: usize = 27; -pub const SIGWINCH: usize = 28; -pub const SIGIO: usize = 29; -pub const SIGPWR: usize = 30; -pub const SIGSYS: usize = 31; - -pub const SA_NOCLDSTOP: usize = 0x00000001; -pub const SA_NOCLDWAIT: usize = 0x00000002; -pub const SA_SIGINFO: usize = 0x00000004; -pub const SA_RESTORER: usize = 0x04000000; -pub const SA_ONSTACK: usize = 0x08000000; -pub const SA_RESTART: usize = 0x10000000; -pub const SA_NODEFER: usize = 0x40000000; -pub const SA_RESETHAND: usize = 0x80000000; From b2d01a67f28b562bc1981cd8efc9b0217b81f20d Mon Sep 17 00:00:00 2001 From: Tom Almeida Date: Wed, 14 Mar 2018 10:55:01 +0800 Subject: [PATCH 14/16] Actual working tests on strspn and strcspn --- tests/string/strcspn.c | 5 +++-- tests/string/strspn.c | 9 ++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/string/strcspn.c b/tests/string/strcspn.c index fa433d7e4f..859d880435 100644 --- a/tests/string/strcspn.c +++ b/tests/string/strcspn.c @@ -2,8 +2,9 @@ #include int main(int argc, char* argv[]) { - printf("%ld\n", strcspn("hello", "world")); // should be 2 - printf("%ld\n", strcspn("banana", "world")); // should be 6 + char *world = "world"; + printf("%ld\n", strcspn("hello", world)); // should be 2 + printf("%ld\n", strcspn("banana", world)); // should be 6 return 0; } diff --git a/tests/string/strspn.c b/tests/string/strspn.c index 9e4fc70c5b..52431a70ff 100644 --- a/tests/string/strspn.c +++ b/tests/string/strspn.c @@ -2,9 +2,12 @@ #include int main(int argc, char* argv[]) { - printf("%lu\n", strspn("hello", "hello")); // should be 5 - printf("%lu\n", strspn("world", "wendy")); // should be 1 - printf("%lu\n", strspn("banana", "apple")); // should be 0 + char *hello = "hello"; + char *world = "world"; + char *banana = "banana"; + printf("%lu\n", strspn(hello, "hello")); // should be 5 + printf("%lu\n", strspn(world, "wendy")); // should be 1 + printf("%lu\n", strspn(banana, "apple")); // should be 0 return 0; } From 6d110ef0cb7845fd6869201e6a2d80bd2803951d Mon Sep 17 00:00:00 2001 From: Dan Robertson Date: Thu, 15 Mar 2018 00:46:16 +0000 Subject: [PATCH 15/16] Use a sys module for OS specific information Update cbindgen to parse modules with a path attribute and revert the following commits: - 996fad709238e5c4e24395f1c4ff8c90dfb984e5. - cfe98ab3b2ef0d211e092c846a80b969fad82f92. --- cbindgen | 2 +- src/fcntl/src/lib.rs | 52 ++--------- src/fcntl/src/linux.rs | 8 ++ src/fcntl/src/redox.rs | 20 +++++ src/signal/src/lib.rs | 186 +++------------------------------------- src/signal/src/linux.rs | 48 +++++++++++ src/signal/src/redox.rs | 44 ++++++++++ 7 files changed, 137 insertions(+), 223 deletions(-) create mode 100644 src/fcntl/src/linux.rs create mode 100644 src/fcntl/src/redox.rs create mode 100644 src/signal/src/linux.rs create mode 100644 src/signal/src/redox.rs diff --git a/cbindgen b/cbindgen index d14295f3ca..95821b3bbe 160000 --- a/cbindgen +++ b/cbindgen @@ -1 +1 @@ -Subproject commit d14295f3ca588f1d1752ea0a579f0597dd2ce248 +Subproject commit 95821b3bbe857354e3fb1efa96ed5252ecc3ec3e diff --git a/src/fcntl/src/lib.rs b/src/fcntl/src/lib.rs index 0e5048277a..0c0fa43ce2 100644 --- a/src/fcntl/src/lib.rs +++ b/src/fcntl/src/lib.rs @@ -6,55 +6,15 @@ extern crate platform; use platform::types::*; +pub use sys::*; + #[cfg(target_os = "linux")] -pub const O_RDONLY: c_int = 0x0000; -#[cfg(target_os = "linux")] -pub const O_WRONLY: c_int = 0x0001; -#[cfg(target_os = "linux")] -pub const O_RDWR: c_int = 0x0002; -#[cfg(target_os = "linux")] -pub const O_CREAT: c_int = 0x0040; -#[cfg(target_os = "linux")] -pub const O_TRUNC: c_int = 0x0200; -#[cfg(target_os = "linux")] -pub const O_ACCMODE: c_int = O_RDONLY | O_WRONLY | O_RDWR; +#[path = "linux.rs"] +pub mod sys; #[cfg(target_os = "redox")] -pub const O_RDONLY: c_int = 0x0001_0000; -#[cfg(target_os = "redox")] -pub const O_WRONLY: c_int = 0x0002_0000; -#[cfg(target_os = "redox")] -pub const O_RDWR: c_int = 0x0003_0000; -#[cfg(target_os = "redox")] -pub const O_NONBLOCK: c_int = 0x0004_0000; -#[cfg(target_os = "redox")] -pub const O_APPEND: c_int = 0x0008_0000; -#[cfg(target_os = "redox")] -pub const O_SHLOCK: c_int = 0x0010_0000; -#[cfg(target_os = "redox")] -pub const O_EXLOCK: c_int = 0x0020_0000; -#[cfg(target_os = "redox")] -pub const O_ASYNC: c_int = 0x0040_0000; -#[cfg(target_os = "redox")] -pub const O_FSYNC: c_int = 0x0080_0000; -#[cfg(target_os = "redox")] -pub const O_CLOEXEC: c_int = 0x0100_0000; -#[cfg(target_os = "redox")] -pub const O_CREAT: c_int = 0x0200_0000; -#[cfg(target_os = "redox")] -pub const O_TRUNC: c_int = 0x0400_0000; -#[cfg(target_os = "redox")] -pub const O_EXCL: c_int = 0x0800_0000; -#[cfg(target_os = "redox")] -pub const O_DIRECTORY: c_int = 0x1000_0000; -#[cfg(target_os = "redox")] -pub const O_STAT: c_int = 0x2000_0000; -#[cfg(target_os = "redox")] -pub const O_SYMLINK: c_int = 0x4000_0000; -#[cfg(target_os = "redox")] -pub const O_NOFOLLOW: c_int = 0x8000_0000; -#[cfg(target_os = "redox")] -pub const O_ACCMODE: c_int = O_RDONLY | O_WRONLY | O_RDWR; +#[path = "redox.rs"] +pub mod sys; pub const F_DUPFD: c_int = 0; pub const F_GETFD: c_int = 1; diff --git a/src/fcntl/src/linux.rs b/src/fcntl/src/linux.rs new file mode 100644 index 0000000000..fd68ffcf14 --- /dev/null +++ b/src/fcntl/src/linux.rs @@ -0,0 +1,8 @@ +use platform::types::*; + +pub const O_RDONLY: c_int = 0x0000; +pub const O_WRONLY: c_int = 0x0001; +pub const O_RDWR: c_int = 0x0002; +pub const O_CREAT: c_int = 0x0040; +pub const O_TRUNC: c_int = 0x0200; +pub const O_ACCMODE: c_int = O_RDONLY | O_WRONLY | O_RDWR; diff --git a/src/fcntl/src/redox.rs b/src/fcntl/src/redox.rs new file mode 100644 index 0000000000..1ea3ca45de --- /dev/null +++ b/src/fcntl/src/redox.rs @@ -0,0 +1,20 @@ +use platform::types::*; + +pub const O_RDONLY: c_int = 0x0001_0000; +pub const O_WRONLY: c_int = 0x0002_0000; +pub const O_RDWR: c_int = 0x0003_0000; +pub const O_NONBLOCK: c_int = 0x0004_0000; +pub const O_APPEND: c_int = 0x0008_0000; +pub const O_SHLOCK: c_int = 0x0010_0000; +pub const O_EXLOCK: c_int = 0x0020_0000; +pub const O_ASYNC: c_int = 0x0040_0000; +pub const O_FSYNC: c_int = 0x0080_0000; +pub const O_CLOEXEC: c_int = 0x0100_0000; +pub const O_CREAT: c_int = 0x0200_0000; +pub const O_TRUNC: c_int = 0x0400_0000; +pub const O_EXCL: c_int = 0x0800_0000; +pub const O_DIRECTORY: c_int = 0x1000_0000; +pub const O_STAT: c_int = 0x2000_0000; +pub const O_SYMLINK: c_int = 0x4000_0000; +pub const O_NOFOLLOW: c_int = 0x8000_0000; +pub const O_ACCMODE: c_int = O_RDONLY | O_WRONLY | O_RDWR; diff --git a/src/signal/src/lib.rs b/src/signal/src/lib.rs index 9a4e781785..80ec786e33 100644 --- a/src/signal/src/lib.rs +++ b/src/signal/src/lib.rs @@ -4,184 +4,18 @@ extern crate platform; +#[cfg(target_os = "linux")] +#[path = "linux.rs"] +pub mod sys; + +#[cfg(target_os = "redox")] +#[path = "redox.rs"] +pub mod sys; + +pub use sys::*; + use platform::types::*; -#[cfg(target_os = "linux")] -#[repr(C)] -pub struct sigset_t { - pub bits: [u64; 16], -} - -#[cfg(target_os = "linux")] -pub const SIGHUP: usize = 1; -#[cfg(target_os = "linux")] -pub const SIGINT: usize = 2; -#[cfg(target_os = "linux")] -pub const SIGQUIT: usize = 3; -#[cfg(target_os = "linux")] -pub const SIGILL: usize = 4; -#[cfg(target_os = "linux")] -pub const SIGTRAP: usize = 5; -#[cfg(target_os = "linux")] -pub const SIGABRT: usize = 6; -#[cfg(target_os = "linux")] -pub const SIGIOT: usize = SIGABRT; -#[cfg(target_os = "linux")] -pub const SIGBUS: usize = 7; -#[cfg(target_os = "linux")] -pub const SIGFPE: usize = 8; -#[cfg(target_os = "linux")] -pub const SIGKILL: usize = 9; -#[cfg(target_os = "linux")] -pub const SIGUSR1: usize = 10; -#[cfg(target_os = "linux")] -pub const SIGSEGV: usize = 11; -#[cfg(target_os = "linux")] -pub const SIGUSR2: usize = 12; -#[cfg(target_os = "linux")] -pub const SIGPIPE: usize = 13; -#[cfg(target_os = "linux")] -pub const SIGALRM: usize = 14; -#[cfg(target_os = "linux")] -pub const SIGTERM: usize = 15; -#[cfg(target_os = "linux")] -pub const SIGSTKFLT: usize = 16; -#[cfg(target_os = "linux")] -pub const SIGCHLD: usize = 17; -#[cfg(target_os = "linux")] -pub const SIGCONT: usize = 18; -#[cfg(target_os = "linux")] -pub const SIGSTOP: usize = 19; -#[cfg(target_os = "linux")] -pub const SIGTSTP: usize = 20; -#[cfg(target_os = "linux")] -pub const SIGTTIN: usize = 21; -#[cfg(target_os = "linux")] -pub const SIGTTOU: usize = 22; -#[cfg(target_os = "linux")] -pub const SIGURG: usize = 23; -#[cfg(target_os = "linux")] -pub const SIGXCPU: usize = 24; -#[cfg(target_os = "linux")] -pub const SIGXFSZ: usize = 25; -#[cfg(target_os = "linux")] -pub const SIGVTALRM: usize = 26; -#[cfg(target_os = "linux")] -pub const SIGPROF: usize = 27; -#[cfg(target_os = "linux")] -pub const SIGWINCH: usize = 28; -#[cfg(target_os = "linux")] -pub const SIGIO: usize = 29; -#[cfg(target_os = "linux")] -pub const SIGPOLL: usize = 29; -#[cfg(target_os = "linux")] -pub const SIGPWR: usize = 30; -#[cfg(target_os = "linux")] -pub const SIGSYS: usize = 31; -#[cfg(target_os = "linux")] -pub const SIGUNUSED: usize = SIGSYS; - -#[cfg(target_os = "linux")] -pub const SA_NOCLDSTOP: usize = 1; -#[cfg(target_os = "linux")] -pub const SA_NOCLDWAIT: usize = 2; -#[cfg(target_os = "linux")] -pub const SA_SIGINFO: usize = 4; -#[cfg(target_os = "linux")] -pub const SA_ONSTACK: usize = 0x08000000; -#[cfg(target_os = "linux")] -pub const SA_RESTART: usize = 0x10000000; -#[cfg(target_os = "linux")] -pub const SA_NODEFER: usize = 0x40000000; -#[cfg(target_os = "linux")] -pub const SA_RESETHAND: usize = 0x80000000; -#[cfg(target_os = "linux")] -pub const SA_RESTORER: usize = 0x04000000; - -#[cfg(target_os = "redox")] -#[repr(C)] -pub struct sigset_t { - pub bits: [u64; 2], -} - -#[cfg(target_os = "redox")] -pub const SIGHUP: usize = 1; -#[cfg(target_os = "redox")] -pub const SIGINT: usize = 2; -#[cfg(target_os = "redox")] -pub const SIGQUIT: usize = 3; -#[cfg(target_os = "redox")] -pub const SIGILL: usize = 4; -#[cfg(target_os = "redox")] -pub const SIGTRAP: usize = 5; -#[cfg(target_os = "redox")] -pub const SIGBUS: usize = 7; -#[cfg(target_os = "redox")] -pub const SIGFPE: usize = 8; -#[cfg(target_os = "redox")] -pub const SIGKILL: usize = 9; -#[cfg(target_os = "redox")] -pub const SIGUSR1: usize = 10; -#[cfg(target_os = "redox")] -pub const SIGSEGV: usize = 11; -#[cfg(target_os = "redox")] -pub const SIGUSR2: usize = 12; -#[cfg(target_os = "redox")] -pub const SIGPIPE: usize = 13; -#[cfg(target_os = "redox")] -pub const SIGALRM: usize = 14; -#[cfg(target_os = "redox")] -pub const SIGTERM: usize = 15; -#[cfg(target_os = "redox")] -pub const SIGSTKFLT: usize = 16; -#[cfg(target_os = "redox")] -pub const SIGCHLD: usize = 17; -#[cfg(target_os = "redox")] -pub const SIGCONT: usize = 18; -#[cfg(target_os = "redox")] -pub const SIGSTOP: usize = 19; -#[cfg(target_os = "redox")] -pub const SIGTSTP: usize = 20; -#[cfg(target_os = "redox")] -pub const SIGTTIN: usize = 21; -#[cfg(target_os = "redox")] -pub const SIGTTOU: usize = 22; -#[cfg(target_os = "redox")] -pub const SIGURG: usize = 23; -#[cfg(target_os = "redox")] -pub const SIGXCPU: usize = 24; -#[cfg(target_os = "redox")] -pub const SIGXFSZ: usize = 25; -#[cfg(target_os = "redox")] -pub const SIGVTALRM: usize = 26; -#[cfg(target_os = "redox")] -pub const SIGPROF: usize = 27; -#[cfg(target_os = "redox")] -pub const SIGWINCH: usize = 28; -#[cfg(target_os = "redox")] -pub const SIGIO: usize = 29; -#[cfg(target_os = "redox")] -pub const SIGPWR: usize = 30; -#[cfg(target_os = "redox")] -pub const SIGSYS: usize = 31; - -#[cfg(target_os = "redox")] -pub const SA_NOCLDSTOP: usize = 0x00000001; -#[cfg(target_os = "redox")] -pub const SA_NOCLDWAIT: usize = 0x00000002; -#[cfg(target_os = "redox")] -pub const SA_SIGINFO: usize = 0x00000004; -#[cfg(target_os = "redox")] -pub const SA_RESTORER: usize = 0x04000000; -#[cfg(target_os = "redox")] -pub const SA_ONSTACK: usize = 0x08000000; -#[cfg(target_os = "redox")] -pub const SA_RESTART: usize = 0x10000000; -#[cfg(target_os = "redox")] -pub const SA_NODEFER: usize = 0x40000000; -#[cfg(target_os = "redox")] -pub const SA_RESETHAND: usize = 0x80000000; - #[repr(C)] pub struct sigaction { pub sa_handler: extern "C" fn(usize), diff --git a/src/signal/src/linux.rs b/src/signal/src/linux.rs new file mode 100644 index 0000000000..63eff1c144 --- /dev/null +++ b/src/signal/src/linux.rs @@ -0,0 +1,48 @@ +#[repr(C)] +pub struct sigset_t { + pub bits: [u64; 16], +} + +pub const SIGHUP: usize = 1; +pub const SIGINT: usize = 2; +pub const SIGQUIT: usize = 3; +pub const SIGILL: usize = 4; +pub const SIGTRAP: usize = 5; +pub const SIGABRT: usize = 6; +pub const SIGIOT: usize = SIGABRT; +pub const SIGBUS: usize = 7; +pub const SIGFPE: usize = 8; +pub const SIGKILL: usize = 9; +pub const SIGUSR1: usize = 10; +pub const SIGSEGV: usize = 11; +pub const SIGUSR2: usize = 12; +pub const SIGPIPE: usize = 13; +pub const SIGALRM: usize = 14; +pub const SIGTERM: usize = 15; +pub const SIGSTKFLT: usize = 16; +pub const SIGCHLD: usize = 17; +pub const SIGCONT: usize = 18; +pub const SIGSTOP: usize = 19; +pub const SIGTSTP: usize = 20; +pub const SIGTTIN: usize = 21; +pub const SIGTTOU: usize = 22; +pub const SIGURG: usize = 23; +pub const SIGXCPU: usize = 24; +pub const SIGXFSZ: usize = 25; +pub const SIGVTALRM: usize = 26; +pub const SIGPROF: usize = 27; +pub const SIGWINCH: usize = 28; +pub const SIGIO: usize = 29; +pub const SIGPOLL: usize = 29; +pub const SIGPWR: usize = 30; +pub const SIGSYS: usize = 31; +pub const SIGUNUSED: usize = SIGSYS; + +pub const SA_NOCLDSTOP: usize = 1; +pub const SA_NOCLDWAIT: usize = 2; +pub const SA_SIGINFO: usize = 4; +pub const SA_ONSTACK: usize = 0x08000000; +pub const SA_RESTART: usize = 0x10000000; +pub const SA_NODEFER: usize = 0x40000000; +pub const SA_RESETHAND: usize = 0x80000000; +pub const SA_RESTORER: usize = 0x04000000; diff --git a/src/signal/src/redox.rs b/src/signal/src/redox.rs new file mode 100644 index 0000000000..54cb42adc5 --- /dev/null +++ b/src/signal/src/redox.rs @@ -0,0 +1,44 @@ +#[repr(C)] +pub struct sigset_t { + pub bits: [u64; 2], +} + +pub const SIGHUP: usize = 1; +pub const SIGINT: usize = 2; +pub const SIGQUIT: usize = 3; +pub const SIGILL: usize = 4; +pub const SIGTRAP: usize = 5; +pub const SIGBUS: usize = 7; +pub const SIGFPE: usize = 8; +pub const SIGKILL: usize = 9; +pub const SIGUSR1: usize = 10; +pub const SIGSEGV: usize = 11; +pub const SIGUSR2: usize = 12; +pub const SIGPIPE: usize = 13; +pub const SIGALRM: usize = 14; +pub const SIGTERM: usize = 15; +pub const SIGSTKFLT: usize = 16; +pub const SIGCHLD: usize = 17; +pub const SIGCONT: usize = 18; +pub const SIGSTOP: usize = 19; +pub const SIGTSTP: usize = 20; +pub const SIGTTIN: usize = 21; +pub const SIGTTOU: usize = 22; +pub const SIGURG: usize = 23; +pub const SIGXCPU: usize = 24; +pub const SIGXFSZ: usize = 25; +pub const SIGVTALRM: usize = 26; +pub const SIGPROF: usize = 27; +pub const SIGWINCH: usize = 28; +pub const SIGIO: usize = 29; +pub const SIGPWR: usize = 30; +pub const SIGSYS: usize = 31; + +pub const SA_NOCLDSTOP: usize = 0x00000001; +pub const SA_NOCLDWAIT: usize = 0x00000002; +pub const SA_SIGINFO: usize = 0x00000004; +pub const SA_RESTORER: usize = 0x04000000; +pub const SA_ONSTACK: usize = 0x08000000; +pub const SA_RESTART: usize = 0x10000000; +pub const SA_NODEFER: usize = 0x40000000; +pub const SA_RESETHAND: usize = 0x80000000; From f1d802dc1e1eb733baafd513ec8cde1c026a9ec9 Mon Sep 17 00:00:00 2001 From: Dan Robertson Date: Thu, 15 Mar 2018 01:07:44 +0000 Subject: [PATCH 16/16] signal: sigaction struct should not be a typedef The sigaction struct should not be a typedef, but the sigset_t struct should be a typedef. --- include/bits/signal.h | 10 ---------- src/signal/cbindgen.toml | 2 +- src/signal/src/lib.rs | 2 ++ src/signal/src/linux.rs | 2 +- src/signal/src/redox.rs | 2 +- src/wait/cbindgen.toml | 1 + 6 files changed, 6 insertions(+), 13 deletions(-) delete mode 100644 include/bits/signal.h diff --git a/include/bits/signal.h b/include/bits/signal.h deleted file mode 100644 index 8a6a8345d2..0000000000 --- a/include/bits/signal.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef _BITS_SIGNAL_H -#define _BITS_SIGNAL_H - -typedef struct sigaction { - void (*sa_handler)(uintptr_t); - sigset_t sa_mask; - uintptr_t sa_flags; -}; - -#endif diff --git a/src/signal/cbindgen.toml b/src/signal/cbindgen.toml index 87d334c40d..c69f579e82 100644 --- a/src/signal/cbindgen.toml +++ b/src/signal/cbindgen.toml @@ -1,6 +1,6 @@ sys_includes = ["sys/types.h"] include_guard = "_SIGNAL_H" -trailer = "#include " +style = "Tag" language = "C" [defines] diff --git a/src/signal/src/lib.rs b/src/signal/src/lib.rs index 80ec786e33..052cb13770 100644 --- a/src/signal/src/lib.rs +++ b/src/signal/src/lib.rs @@ -23,6 +23,8 @@ pub struct sigaction { pub sa_flags: usize, } +pub type sigset_t = sys_sigset_t; + #[no_mangle] pub extern "C" fn kill(pid: pid_t, sig: c_int) -> c_int { unimplemented!(); diff --git a/src/signal/src/linux.rs b/src/signal/src/linux.rs index 63eff1c144..628e813390 100644 --- a/src/signal/src/linux.rs +++ b/src/signal/src/linux.rs @@ -1,5 +1,5 @@ #[repr(C)] -pub struct sigset_t { +pub struct sys_sigset_t { pub bits: [u64; 16], } diff --git a/src/signal/src/redox.rs b/src/signal/src/redox.rs index 54cb42adc5..b5108b5a62 100644 --- a/src/signal/src/redox.rs +++ b/src/signal/src/redox.rs @@ -1,5 +1,5 @@ #[repr(C)] -pub struct sigset_t { +pub struct sys_sigset_t { pub bits: [u64; 2], } diff --git a/src/wait/cbindgen.toml b/src/wait/cbindgen.toml index 186d5f9573..528282cf3a 100644 --- a/src/wait/cbindgen.toml +++ b/src/wait/cbindgen.toml @@ -1,5 +1,6 @@ sys_includes = ["sys/types.h", "sys/resource.h"] include_guard = "_SYS_WAIT_H" +style = "Tag" language = "C" [enum]