summary refs log tree commit diff
path: root/src/libstd/sys/unix/stack_overflow.rs
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2015-11-02 16:23:22 -0800
committerAlex Crichton <alex@alexcrichton.com>2015-11-09 22:55:50 -0800
commit3d28b8b98e6e4f55ef4ecd8babf0a050f48a3d11 (patch)
tree343087c9e62da65e2780db851682280697064c5b /src/libstd/sys/unix/stack_overflow.rs
parentc8a29c2092cec369a751051a2bfed093522ff6e8 (diff)
downloadrust-3d28b8b98e6e4f55ef4ecd8babf0a050f48a3d11.tar.gz
rust-3d28b8b98e6e4f55ef4ecd8babf0a050f48a3d11.zip
std: Migrate to the new libc
* Delete `sys::unix::{c, sync}` as these are now all folded into libc itself
* Update all references to use `libc` as a result.
* Update all references to the new flat namespace.
* Moves all windows bindings into sys::c
Diffstat (limited to 'src/libstd/sys/unix/stack_overflow.rs')
-rw-r--r--src/libstd/sys/unix/stack_overflow.rs30
1 files changed, 23 insertions, 7 deletions
diff --git a/src/libstd/sys/unix/stack_overflow.rs b/src/libstd/sys/unix/stack_overflow.rs
index 5f624bc76b3..9a7f98d24cd 100644
--- a/src/libstd/sys/unix/stack_overflow.rs
+++ b/src/libstd/sys/unix/stack_overflow.rs
@@ -43,11 +43,11 @@ mod imp {
     use sys_common::util::report_overflow;
     use mem;
     use ptr;
-    use sys::c::{siginfo, sigaction, SIGBUS, SIG_DFL,
-                 SA_SIGINFO, SA_ONSTACK, sigaltstack,
-                 SIGSTKSZ, sighandler_t};
+    use libc::{sigaction, SIGBUS, SIG_DFL,
+               SA_SIGINFO, SA_ONSTACK, sigaltstack,
+               SIGSTKSZ, sighandler_t};
     use libc;
-    use libc::funcs::posix88::mman::{mmap, munmap};
+    use libc::{mmap, munmap};
     use libc::{SIGSEGV, PROT_READ, PROT_WRITE, MAP_PRIVATE, MAP_ANON};
     use libc::MAP_FAILED;
 
@@ -57,6 +57,22 @@ mod imp {
     // This is initialized in init() and only read from after
     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 {
+        #[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
+    }
+
+    #[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
+    }
+
     // Signal handler for the SIGSEGV and SIGBUS handlers. We've got guard pages
     // (unmapped pages) at the end of every thread's stack, so if a thread ends
     // up running into the guard page it'll trigger this handler. We want to
@@ -76,10 +92,10 @@ mod imp {
     // handler to work. For a more detailed explanation see the comments on
     // #26458.
     unsafe extern fn signal_handler(signum: libc::c_int,
-                                    info: *mut siginfo,
+                                    info: *mut libc::siginfo_t,
                                     _data: *mut libc::c_void) {
         let guard = thread_info::stack_guard().unwrap_or(0);
-        let addr = (*info).si_addr as usize;
+        let addr = siginfo_si_addr(info) as usize;
 
         // If the faulting address is within the guard page, then we print a
         // message saying so.
@@ -126,7 +142,7 @@ mod imp {
             panic!("failed to allocate an alternative stack");
         }
 
-        let mut stack: sigaltstack = mem::zeroed();
+        let mut stack: libc::stack_t = mem::zeroed();
 
         stack.ss_sp = alt_stack;
         stack.ss_flags = 0;