瀏覽代碼

Merge branch 'sigaltstack' into 'master'

Fix sigaltstack

See merge request redox-os/relibc!230
Jeremy Soller 5 年之前
父節點
當前提交
4621a824a8
共有 3 個文件被更改,包括 9 次插入3 次删除
  1. 2 0
      src/header/signal/linux.rs
  2. 5 3
      src/header/signal/mod.rs
  3. 2 0
      src/header/signal/redox.rs

+ 2 - 0
src/header/signal/linux.rs

@@ -68,4 +68,6 @@ pub const SA_RESTORER: usize = 0x0400_0000;
 pub const SS_ONSTACK: usize = 1;
 pub const SS_DISABLE: usize = 2;
 
+// Those two should be updated from kernel headers
 pub const MINSIGSTKSZ: usize = 2048;
+pub const SIGSTKSZ: usize = 8096;

+ 5 - 3
src/header/signal/mod.rs

@@ -38,14 +38,16 @@ pub struct sigaction {
 
 #[repr(C)]
 #[derive(Clone)]
-pub struct stack_t {
+pub struct sigaltstack {
     pub ss_sp: *mut c_void,
     pub ss_flags: c_int,
-    pub ss_size: c_uint,
+    pub ss_size: size_t,
 }
 
 pub type sigset_t = c_ulong;
 
+pub type stack_t = sigaltstack;
+
 #[no_mangle]
 pub extern "C" fn kill(pid: pid_t, sig: c_int) -> c_int {
     Sys::kill(pid, sig)
@@ -113,7 +115,7 @@ pub unsafe extern "C" fn sigaltstack(ss: *const stack_t, old_ss: *mut stack_t) -
         if (*ss).ss_flags != SS_DISABLE as c_int {
             return errno::EINVAL;
         }
-        if (*ss).ss_size < MINSIGSTKSZ as c_uint {
+        if (*ss).ss_size < MINSIGSTKSZ {
             return errno::ENOMEM;
         }
     }

+ 2 - 0
src/header/signal/redox.rs

@@ -65,4 +65,6 @@ pub const SA_RESETHAND: usize = 0x80000000;
 pub const SS_ONSTACK: usize = 0x00000001;
 pub const SS_DISABLE: usize = 0x00000002;
 
+// TODO: It's just a guess based on Linux
 pub const MINSIGSTKSZ: usize = 2048;
+pub const SIGSTKSZ: usize = 8096;