|
4 | 4 | all(target_os = "emscripten", target_feature = "atomics"),
|
5 | 5 | target_os = "freebsd",
|
6 | 6 | target_os = "openbsd",
|
7 |
| - target_os = "netbsd", |
8 | 7 | target_os = "dragonfly",
|
9 | 8 | ))]
|
10 | 9 |
|
11 | 10 | use crate::sync::atomic::AtomicU32;
|
12 | 11 | use crate::time::Duration;
|
13 | 12 |
|
14 |
| -#[cfg(target_os = "netbsd")] |
15 |
| -pub const SYS___futex: i32 = 166; |
16 |
| - |
17 | 13 | /// Wait for a futex_wake operation to wake us.
|
18 | 14 | ///
|
19 | 15 | /// Returns directly if the futex doesn't hold the expected value.
|
20 | 16 | ///
|
21 | 17 | /// Returns false on timeout, and true in all other cases.
|
22 |
| -#[cfg(any( |
23 |
| - target_os = "linux", |
24 |
| - target_os = "android", |
25 |
| - target_os = "freebsd", |
26 |
| - target_os = "netbsd" |
27 |
| -))] |
| 18 | +#[cfg(any(target_os = "linux", target_os = "android", target_os = "freebsd"))] |
28 | 19 | pub fn futex_wait(futex: &AtomicU32, expected: u32, timeout: Option<Duration>) -> bool {
|
29 | 20 | use super::time::Timespec;
|
30 | 21 | use crate::ptr::null;
|
@@ -65,19 +56,6 @@ pub fn futex_wait(futex: &AtomicU32, expected: u32, timeout: Option<Duration>) -
|
65 | 56 | crate::ptr::invalid_mut(umtx_timeout_size),
|
66 | 57 | umtx_timeout_ptr as *mut _,
|
67 | 58 | )
|
68 |
| - } else if #[cfg(target_os = "netbsd")] { |
69 |
| - // Netbsd's futex syscall takes addr2 and val2 as separate arguments. |
70 |
| - // (Both are unused for FUTEX_WAIT[_BITSET].) |
71 |
| - libc::syscall( |
72 |
| - SYS___futex, |
73 |
| - futex as *const AtomicU32, |
74 |
| - libc::FUTEX_WAIT_BITSET | libc::FUTEX_PRIVATE_FLAG, |
75 |
| - expected, |
76 |
| - timespec.as_ref().map_or(null(), |t| &t.t as *const libc::timespec), |
77 |
| - null::<u32>(), // addr2: This argument is unused for FUTEX_WAIT_BITSET. |
78 |
| - 0, // val2: This argument is unused for FUTEX_WAIT_BITSET. |
79 |
| - !0u32, // val3 / bitmask: A full bitmask, to make it behave like a regular FUTEX_WAIT. |
80 |
| - ) |
81 | 59 | } else {
|
82 | 60 | libc::syscall(
|
83 | 61 | libc::SYS_futex,
|
@@ -106,34 +84,20 @@ pub fn futex_wait(futex: &AtomicU32, expected: u32, timeout: Option<Duration>) -
|
106 | 84 | /// or false if no thread was waiting on this futex.
|
107 | 85 | ///
|
108 | 86 | /// On some platforms, this always returns false.
|
109 |
| -#[cfg(any(target_os = "linux", target_os = "android", target_os = "netbsd"))] |
| 87 | +#[cfg(any(target_os = "linux", target_os = "android"))] |
110 | 88 | pub fn futex_wake(futex: &AtomicU32) -> bool {
|
111 | 89 | let ptr = futex as *const AtomicU32;
|
112 | 90 | let op = libc::FUTEX_WAKE | libc::FUTEX_PRIVATE_FLAG;
|
113 |
| - unsafe { |
114 |
| - cfg_if::cfg_if! { |
115 |
| - if #[cfg(target_os = "netbsd")] { |
116 |
| - libc::syscall(SYS___futex, ptr, op, 1) > 0 |
117 |
| - } else { |
118 |
| - libc::syscall(libc::SYS_futex, ptr, op, 1) > 0 |
119 |
| - } |
120 |
| - } |
121 |
| - } |
| 91 | + unsafe { libc::syscall(libc::SYS_futex, ptr, op, 1) > 0 } |
122 | 92 | }
|
123 | 93 |
|
124 | 94 | /// Wake up all threads that are waiting on futex_wait on this futex.
|
125 |
| -#[cfg(any(target_os = "linux", target_os = "android", target_os = "netbsd"))] |
| 95 | +#[cfg(any(target_os = "linux", target_os = "android"))] |
126 | 96 | pub fn futex_wake_all(futex: &AtomicU32) {
|
127 | 97 | let ptr = futex as *const AtomicU32;
|
128 | 98 | let op = libc::FUTEX_WAKE | libc::FUTEX_PRIVATE_FLAG;
|
129 | 99 | unsafe {
|
130 |
| - cfg_if::cfg_if! { |
131 |
| - if #[cfg(target_os = "netbsd")] { |
132 |
| - libc::syscall(SYS___futex, ptr, op, i32::MAX); |
133 |
| - } else { |
134 |
| - libc::syscall(libc::SYS_futex, ptr, op, i32::MAX); |
135 |
| - } |
136 |
| - } |
| 100 | + libc::syscall(libc::SYS_futex, ptr, op, i32::MAX); |
137 | 101 | }
|
138 | 102 | }
|
139 | 103 |
|
|
0 commit comments