diff --git a/libc-test/tests/all.rs b/libc-test/tests/all.rs index 42a743c4..15d31814 100644 --- a/libc-test/tests/all.rs +++ b/libc-test/tests/all.rs @@ -1,5 +1,7 @@ +#![feature(alloc_system)] #![allow(bad_style, unused_imports)] +extern crate alloc_system; extern crate libc; extern crate libc_test; diff --git a/src/unix/other/bsdlike.rs b/src/unix/other/bsdlike.rs new file mode 100644 index 00000000..2928c2eb --- /dev/null +++ b/src/unix/other/bsdlike.rs @@ -0,0 +1,22 @@ +extern { + pub fn shm_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::c_int; + pub fn sysctl(name: *mut ::c_int, + namelen: ::c_uint, + oldp: *mut ::c_void, + oldlenp: *mut ::size_t, + newp: *mut ::c_void, + newlen: ::size_t) + -> ::c_int; + pub fn mincore(addr: *const ::c_void, len: ::size_t, + vec: *mut ::c_char) -> ::c_int; + pub fn sysctlbyname(name: *const ::c_char, + oldp: *mut ::c_void, + oldlenp: *mut ::size_t, + newp: *mut ::c_void, + newlen: ::size_t) + -> ::c_int; + pub fn sysctlnametomib(name: *const ::c_char, + mibp: *mut ::c_int, + sizep: *mut ::size_t) + -> ::c_int; +} diff --git a/src/unix/other.rs b/src/unix/other/mod.rs similarity index 66% rename from src/unix/other.rs rename to src/unix/other/mod.rs index c073a281..4f2d20ab 100644 --- a/src/unix/other.rs +++ b/src/unix/other/mod.rs @@ -13,12 +13,6 @@ extern { pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) -> ::c_int; - #[cfg(target_os = "macos")] - pub fn shm_open(name: *const ::c_char, oflag: ::c_int, ...) - -> ::c_int; - #[cfg(target_os = "linux")] - pub fn shm_open(name: *const ::c_char, oflag: ::c_int, - mode: ::mode_t) -> ::c_int; pub fn shm_unlink(name: *const ::c_char) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), @@ -80,38 +74,10 @@ cfg_if! { target_os = "bitrig", target_os = "netbsd", target_os = "openbsd"))] { - extern { - pub fn sysctl(name: *mut ::c_int, - namelen: ::c_uint, - oldp: *mut ::c_void, - oldlenp: *mut ::size_t, - newp: *mut ::c_void, - newlen: ::size_t) - -> ::c_int; - pub fn mincore(addr: *const ::c_void, len: ::size_t, - vec: *mut ::c_char) -> ::c_int; - pub fn sysctlbyname(name: *const ::c_char, - oldp: *mut ::c_void, - oldlenp: *mut ::size_t, - newp: *mut ::c_void, - newlen: ::size_t) - -> ::c_int; - pub fn sysctlnametomib(name: *const ::c_char, - mibp: *mut ::c_int, - sizep: *mut ::size_t) - -> ::c_int; - } + mod bsdlike; + pub use self::bsdlike::*; } else { - extern { - pub fn sysctl(name: *mut ::c_int, - namelen: ::c_int, - oldp: *mut ::c_void, - oldlenp: *mut ::size_t, - newp: *mut ::c_void, - newlen: ::size_t) - -> ::c_int; - pub fn mincore(addr: *mut ::c_void, len: ::size_t, - vec: *mut ::c_uchar) -> ::c_int; - } + mod notbsd; + pub use self::notbsd::*; } } diff --git a/src/unix/other/notbsd.rs b/src/unix/other/notbsd.rs new file mode 100644 index 00000000..f42ea1fe --- /dev/null +++ b/src/unix/other/notbsd.rs @@ -0,0 +1,14 @@ +extern { + pub fn shm_open(name: *const ::c_char, oflag: ::c_int, + mode: ::mode_t) -> ::c_int; + #[cfg(not(target_env = "musl"))] + pub fn sysctl(name: *mut ::c_int, + namelen: ::c_int, + oldp: *mut ::c_void, + oldlenp: *mut ::size_t, + newp: *mut ::c_void, + newlen: ::size_t) + -> ::c_int; + pub fn mincore(addr: *mut ::c_void, len: ::size_t, + vec: *mut ::c_uchar) -> ::c_int; +}