Skip to content

Commit 38c7e20

Browse files
committed
Use libc constants in sys/signal.rs.
1 parent da2cb87 commit 38c7e20

File tree

1 file changed

+27
-74
lines changed

1 file changed

+27
-74
lines changed

src/sys/signal.rs

+27-74
Original file line numberDiff line numberDiff line change
@@ -44,49 +44,39 @@ pub const SIGEMT: libc::c_int = 7;
4444

4545
pub const NSIG: libc::c_int = 32;
4646

47-
pub use self::signal::{
48-
SockFlag,
49-
50-
SA_NOCLDSTOP,
51-
SA_NOCLDWAIT,
52-
SA_NODEFER,
53-
SA_ONSTACK,
54-
SA_RESETHAND,
55-
SA_RESTART,
56-
SA_SIGINFO,
57-
};
58-
59-
pub use self::signal::{HowFlag, SIG_BLOCK, SIG_UNBLOCK, SIG_SETMASK};
6047
pub use self::signal::sigset_t;
6148

49+
50+
bitflags!{
51+
flags SockFlag: libc::c_int {
52+
const SA_NOCLDSTOP = libc::SA_NOCLDSTOP,
53+
const SA_NOCLDWAIT = libc::SA_NOCLDWAIT,
54+
const SA_NODEFER = libc::SA_NODEFER,
55+
const SA_ONSTACK = libc::SA_ONSTACK,
56+
const SA_RESETHAND = libc::SA_RESETHAND,
57+
const SA_RESTART = libc::SA_RESTART,
58+
const SA_SIGINFO = libc::SA_SIGINFO,
59+
}
60+
}
61+
62+
bitflags!{
63+
flags HowFlag: libc::c_int {
64+
const SIG_BLOCK = libc::SIG_BLOCK,
65+
const SIG_UNBLOCK = libc::SIG_UNBLOCK,
66+
const SIG_SETMASK = libc::SIG_SETMASK,
67+
}
68+
}
69+
6270
#[cfg(any(all(target_os = "linux",
6371
any(target_arch = "x86",
6472
target_arch = "x86_64",
6573
target_arch = "aarch64",
6674
target_arch = "arm")),
6775
target_os = "android"))]
6876
pub mod signal {
69-
use libc;
7077

71-
bitflags!(
72-
flags SockFlag: libc::c_ulong {
73-
const SA_NOCLDSTOP = 0x00000001,
74-
const SA_NOCLDWAIT = 0x00000002,
75-
const SA_NODEFER = 0x40000000,
76-
const SA_ONSTACK = 0x08000000,
77-
const SA_RESETHAND = 0x80000000,
78-
const SA_RESTART = 0x10000000,
79-
const SA_SIGINFO = 0x00000004,
80-
}
81-
);
82-
83-
bitflags!{
84-
flags HowFlag: libc::c_int {
85-
const SIG_BLOCK = 0,
86-
const SIG_UNBLOCK = 1,
87-
const SIG_SETMASK = 2,
88-
}
89-
}
78+
use libc;
79+
use super::SockFlag;
9080

9181
// This definition is not as accurate as it could be, {pid, uid, status} is
9282
// actually a giant union. Currently we're only interested in these fields,
@@ -130,26 +120,7 @@ pub mod signal {
130120
any(target_arch = "mips", target_arch = "mipsel")))]
131121
pub mod signal {
132122
use libc;
133-
134-
bitflags!(
135-
flags SockFlag: libc::c_uint {
136-
const SA_NOCLDSTOP = 0x00000001,
137-
const SA_NOCLDWAIT = 0x00001000,
138-
const SA_NODEFER = 0x40000000,
139-
const SA_ONSTACK = 0x08000000,
140-
const SA_RESETHAND = 0x80000000,
141-
const SA_RESTART = 0x10000000,
142-
const SA_SIGINFO = 0x00000008,
143-
}
144-
);
145-
146-
bitflags!{
147-
flags HowFlag: libc::c_int {
148-
const SIG_BLOCK = 1,
149-
const SIG_UNBLOCK = 2,
150-
const SIG_SETMASK = 3,
151-
}
152-
}
123+
use super::SockFlag;
153124

154125
// This definition is not as accurate as it could be, {pid, uid, status} is
155126
// actually a giant union. Currently we're only interested in these fields,
@@ -187,26 +158,7 @@ pub mod signal {
187158
target_os = "netbsd"))]
188159
pub mod signal {
189160
use libc;
190-
191-
bitflags!(
192-
flags SockFlag: libc::c_int {
193-
const SA_NOCLDSTOP = 0x0008,
194-
const SA_NOCLDWAIT = 0x0020,
195-
const SA_NODEFER = 0x0010,
196-
const SA_ONSTACK = 0x0001,
197-
const SA_RESETHAND = 0x0004,
198-
const SA_RESTART = 0x0002,
199-
const SA_SIGINFO = 0x0040,
200-
}
201-
);
202-
203-
bitflags!{
204-
flags HowFlag: libc::c_int {
205-
const SIG_BLOCK = 1,
206-
const SIG_UNBLOCK = 2,
207-
const SIG_SETMASK = 3,
208-
}
209-
}
161+
use super::SockFlag;
210162

211163
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "openbsd"))]
212164
pub type sigset_t = u32;
@@ -391,6 +343,7 @@ impl AsRef<sigset_t> for SigSet {
391343

392344
pub use self::signal::siginfo;
393345

346+
#[allow(unknown_lints)]
394347
#[allow(raw_pointer_derive)]
395348
#[derive(Clone, Copy)]
396349
pub enum SigHandler {
@@ -518,7 +471,7 @@ mod tests {
518471
let mask2 = SigSet::empty();
519472
mask.add(SIGUSR2).unwrap();
520473

521-
let oldmask = mask2.thread_swap_mask(signal::SIG_SETMASK).unwrap();
474+
let oldmask = mask2.thread_swap_mask(SIG_SETMASK).unwrap();
522475

523476
assert!(oldmask.contains(SIGUSR1).unwrap());
524477
assert!(!oldmask.contains(SIGUSR2).unwrap());

0 commit comments

Comments
 (0)