summaryrefslogtreecommitdiff
path: root/src/sched.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/sched.rs')
-rw-r--r--src/sched.rs16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/sched.rs b/src/sched.rs
index 064deb8c..3b48b4ad 100644
--- a/src/sched.rs
+++ b/src/sched.rs
@@ -80,7 +80,8 @@ mod sched_linux_like {
if field >= CpuSet::count() {
Err(Error::Sys(Errno::EINVAL))
} else {
- Ok(unsafe { libc::CPU_SET(field, &mut self.cpu_set) })
+ unsafe { libc::CPU_SET(field, &mut self.cpu_set); }
+ Ok(())
}
}
@@ -90,7 +91,8 @@ mod sched_linux_like {
if field >= CpuSet::count() {
Err(Error::Sys(Errno::EINVAL))
} else {
- Ok(unsafe { libc::CPU_CLR(field, &mut self.cpu_set) })
+ unsafe { libc::CPU_CLR(field, &mut self.cpu_set);}
+ Ok(())
}
}
@@ -100,6 +102,12 @@ mod sched_linux_like {
}
}
+ impl Default for CpuSet {
+ fn default() -> Self {
+ Self::new()
+ }
+ }
+
/// `sched_setaffinity` set a thread's CPU affinity mask
/// ([`sched_setaffinity(2)`](http://man7.org/linux/man-pages/man2/sched_setaffinity.2.html))
///
@@ -181,8 +189,8 @@ mod sched_linux_like {
let res = unsafe {
let combined = flags.bits() | signal.unwrap_or(0);
- let ptr = stack.as_mut_ptr().offset(stack.len() as isize);
- let ptr_aligned = ptr.offset((ptr as usize % 16) as isize * -1);
+ let ptr = stack.as_mut_ptr().add(stack.len());
+ let ptr_aligned = ptr.sub(ptr as usize % 16);
libc::clone(
mem::transmute(
callback as extern "C" fn(*mut Box<dyn FnMut() -> isize>) -> i32,