Skip to content

Commit

Permalink
Use FUTEX_ constants from libc
Browse files Browse the repository at this point in the history
  • Loading branch information
faern committed May 25, 2019
1 parent 3132b95 commit 5e2d677
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ backtrace = { version = "0.3.2", optional = true }
rustc_version = "0.2"

[target.'cfg(unix)'.dependencies]
libc = "0.2.27"
libc = "0.2.55"

[target.'cfg(target_os = "redox")'.dependencies]
redox_syscall = "0.1"
Expand Down
8 changes: 2 additions & 6 deletions core/src/thread_parker/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ use core::{
use libc;
use std::{thread, time::Instant};

const FUTEX_WAIT: i32 = 0;
const FUTEX_WAKE: i32 = 1;
const FUTEX_PRIVATE: i32 = 128;

// x32 Linux uses a non-standard type for tv_nsec in timespec.
// See https://sourceware.org/bugzilla/show_bug.cgi?id=16437
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
Expand Down Expand Up @@ -104,7 +100,7 @@ impl ThreadParker {
libc::syscall(
libc::SYS_futex,
&self.futex,
FUTEX_WAIT | FUTEX_PRIVATE,
libc::FUTEX_WAIT | libc::FUTEX_PRIVATE_FLAG,
1,
ts_ptr,
)
Expand Down Expand Up @@ -132,7 +128,7 @@ impl super::UnparkHandleT for UnparkHandle {
// The thread data may have been freed at this point, but it doesn't
// matter since the syscall will just return EFAULT in that case.
let r =
unsafe { libc::syscall(libc::SYS_futex, self.futex, FUTEX_WAKE | FUTEX_PRIVATE, 1) };
unsafe { libc::syscall(libc::SYS_futex, self.futex, libc::FUTEX_WAKE | libc::FUTEX_PRIVATE_FLAG, 1) };
debug_assert!(r == 0 || r == 1 || r == -1);
if r == -1 {
debug_assert_eq!(unsafe { *libc::__errno_location() }, libc::EFAULT);
Expand Down

0 comments on commit 5e2d677

Please sign in to comment.