summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Hou <david.hou314@gmail.com>2016-11-06 12:14:33 -0800
committerDavid Hou <david.hou314@gmail.com>2016-11-06 12:14:33 -0800
commit4f2c9b6b98d076451145dd4da34483720a9a9d1b (patch)
tree742a130b7802e6ada26510b4e6aec3593b37a95d
parentf8d4c315f5f54d76a986a69f5ffcc51172537c09 (diff)
downloadnix-4f2c9b6b98d076451145dd4da34483720a9a9d1b.zip
Change SigFlags into an enum.
-rw-r--r--src/sys/signal.rs24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/sys/signal.rs b/src/sys/signal.rs
index 345e69e3..39ed30b7 100644
--- a/src/sys/signal.rs
+++ b/src/sys/signal.rs
@@ -206,12 +206,12 @@ bitflags!{
}
}
-bitflags!{
- flags SigFlags: libc::c_int {
- const SIG_BLOCK = libc::SIG_BLOCK,
- const SIG_UNBLOCK = libc::SIG_UNBLOCK,
- const SIG_SETMASK = libc::SIG_SETMASK,
- }
+#[repr(i32)]
+#[derive(Clone, Copy, PartialEq)]
+pub enum SigFlags {
+ SIG_BLOCK = libc::SIG_BLOCK,
+ SIG_UNBLOCK = libc::SIG_UNBLOCK,
+ SIG_SETMASK = libc::SIG_SETMASK,
}
#[derive(Clone, Copy)]
@@ -268,23 +268,23 @@ impl SigSet {
/// Gets the currently blocked (masked) set of signals for the calling thread.
pub fn thread_get_mask() -> Result<SigSet> {
let mut oldmask: SigSet = unsafe { mem::uninitialized() };
- try!(pthread_sigmask(SigFlags::empty(), None, Some(&mut oldmask)));
+ try!(pthread_sigmask(SigFlags::SIG_SETMASK, None, Some(&mut oldmask)));
Ok(oldmask)
}
/// Sets the set of signals as the signal mask for the calling thread.
pub fn thread_set_mask(&self) -> Result<()> {
- pthread_sigmask(SIG_SETMASK, Some(self), None)
+ pthread_sigmask(SigFlags::SIG_SETMASK, Some(self), None)
}
/// Adds the set of signals to the signal mask for the calling thread.
pub fn thread_block(&self) -> Result<()> {
- pthread_sigmask(SIG_BLOCK, Some(self), None)
+ pthread_sigmask(SigFlags::SIG_BLOCK, Some(self), None)
}
/// Removes the set of signals from the signal mask for the calling thread.
pub fn thread_unblock(&self) -> Result<()> {
- pthread_sigmask(SIG_UNBLOCK, Some(self), None)
+ pthread_sigmask(SigFlags::SIG_UNBLOCK, Some(self), None)
}
/// Sets the set of signals as the signal mask, and returns the old mask.
@@ -377,7 +377,7 @@ pub fn pthread_sigmask(how: SigFlags,
let res = unsafe {
// if set or oldset is None, pass in null pointers instead
- libc::pthread_sigmask(how.bits(),
+ libc::pthread_sigmask(how as libc::c_int,
set.map_or_else(|| ptr::null::<libc::sigset_t>(),
|s| &s.sigset as *const libc::sigset_t),
oldset.map_or_else(|| ptr::null_mut::<libc::sigset_t>(),
@@ -457,7 +457,7 @@ mod tests {
let mask2 = SigSet::empty();
mask.add(SIGUSR2);
- let oldmask = mask2.thread_swap_mask(SIG_SETMASK).unwrap();
+ let oldmask = mask2.thread_swap_mask(SigFlags::SIG_SETMASK).unwrap();
assert!(oldmask.contains(SIGUSR1));
assert!(!oldmask.contains(SIGUSR2));