diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2016-01-14 04:22:19 +0530 |
|---|---|---|
| committer | Manish Goregaokar <manishsmail@gmail.com> | 2016-01-14 11:04:42 +0530 |
| commit | 837a8decb6f7ca27718fa6f75391ba04f7d37753 (patch) | |
| tree | 3920402c3fa430c0d07026de9e9eb97e6765d21a | |
| parent | 4ff1d20ad71c01adcaa61ea1c11f3ea14ce8c983 (diff) | |
| parent | 667ee8a57b86f5f3e12ff9bd780d6f16dc4129d8 (diff) | |
| download | rust-837a8decb6f7ca27718fa6f75391ba04f7d37753.tar.gz rust-837a8decb6f7ca27718fa6f75391ba04f7d37753.zip | |
Rollup merge of #30837 - semarie:openbsd-libc, r=alexcrichton
The following PR updates libc version to latest commits for correctly support openbsd. It corrects several points in rustc to be compatible with libc changes. r? @alexcrichton
| -rw-r--r-- | src/libstd/rand/os.rs | 2 | ||||
| -rw-r--r-- | src/libstd/sys/unix/fs.rs | 6 | ||||
| -rw-r--r-- | src/libstd/sys/unix/stack_overflow.rs | 10 | ||||
| -rw-r--r-- | src/libtest/lib.rs | 19 |
4 files changed, 27 insertions, 10 deletions
diff --git a/src/libstd/rand/os.rs b/src/libstd/rand/os.rs index 0ba0e01ce29..23a368a30a5 100644 --- a/src/libstd/rand/os.rs +++ b/src/libstd/rand/os.rs @@ -222,7 +222,7 @@ mod imp { // getentropy(2) permits a maximum buffer size of 256 bytes for s in v.chunks_mut(256) { let ret = unsafe { - libc::syscall(libc::NR_GETENTROPY, s.as_mut_ptr(), s.len()) + libc::getentropy(s.as_mut_ptr() as *mut libc::c_void, s.len()) }; if ret == -1 { panic!("unexpected getentropy error: {}", errno()); diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs index e8575a6c21c..10fda3fcd7f 100644 --- a/src/libstd/sys/unix/fs.rs +++ b/src/libstd/sys/unix/fs.rs @@ -204,7 +204,8 @@ impl DirEntry { #[cfg(any(target_os = "macos", target_os = "ios", - target_os = "netbsd"))] + target_os = "netbsd", + target_os = "openbsd"))] fn name_bytes(&self) -> &[u8] { unsafe { ::slice::from_raw_parts(self.entry.d_name.as_ptr() as *const u8, @@ -213,8 +214,7 @@ impl DirEntry { } #[cfg(any(target_os = "freebsd", target_os = "dragonfly", - target_os = "bitrig", - target_os = "openbsd"))] + target_os = "bitrig"))] fn name_bytes(&self) -> &[u8] { unsafe { ::slice::from_raw_parts(self.entry.d_name.as_ptr() as *const u8, diff --git a/src/libstd/sys/unix/stack_overflow.rs b/src/libstd/sys/unix/stack_overflow.rs index 776acd20b06..fc49f4257be 100644 --- a/src/libstd/sys/unix/stack_overflow.rs +++ b/src/libstd/sys/unix/stack_overflow.rs @@ -59,19 +59,19 @@ mod imp { static mut PAGE_SIZE: usize = 0; #[cfg(any(target_os = "linux", target_os = "android"))] - unsafe fn siginfo_si_addr(info: *mut libc::siginfo_t) -> *mut libc::c_void { + unsafe fn siginfo_si_addr(info: *mut libc::siginfo_t) -> usize { #[repr(C)] struct siginfo_t { a: [libc::c_int; 3], // si_signo, si_code, si_errno, si_addr: *mut libc::c_void, } - (*(info as *const siginfo_t)).si_addr + (*(info as *const siginfo_t)).si_addr as usize } #[cfg(not(any(target_os = "linux", target_os = "android")))] - unsafe fn siginfo_si_addr(info: *mut libc::siginfo_t) -> *mut libc::c_void { - (*info).si_addr + unsafe fn siginfo_si_addr(info: *mut libc::siginfo_t) -> usize { + (*info).si_addr as usize } // Signal handler for the SIGSEGV and SIGBUS handlers. We've got guard pages @@ -98,7 +98,7 @@ mod imp { use sys_common::util::report_overflow; let guard = thread_info::stack_guard().unwrap_or(0); - let addr = siginfo_si_addr(info) as usize; + let addr = siginfo_si_addr(info); // If the faulting address is within the guard page, then we print a // message saying so. diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 2945d20ceb1..dcc344c4ffd 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -919,7 +919,6 @@ fn get_concurrency() -> usize { #[cfg(any(target_os = "freebsd", target_os = "dragonfly", target_os = "bitrig", - target_os = "openbsd", target_os = "netbsd"))] fn num_cpus() -> usize { let mut cpus: libc::c_uint = 0; @@ -946,6 +945,24 @@ fn get_concurrency() -> usize { } cpus as usize } + + #[cfg(target_os = "openbsd")] + fn num_cpus() -> usize { + let mut cpus: libc::c_uint = 0; + let mut cpus_size = std::mem::size_of_val(&cpus); + let mut mib = [libc::CTL_HW, libc::HW_NCPU, 0, 0]; + + unsafe { + libc::sysctl(mib.as_mut_ptr(), 2, + &mut cpus as *mut _ as *mut _, + &mut cpus_size as *mut _ as *mut _, + 0 as *mut _, 0); + } + if cpus < 1 { + cpus = 1; + } + cpus as usize + } } pub fn filter_tests(opts: &TestOpts, tests: Vec<TestDescAndFn>) -> Vec<TestDescAndFn> { |
