Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OpenBSD's futex.h. #2761

Merged
merged 3 commits into from Apr 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions libc-test/build.rs
Expand Up @@ -434,6 +434,7 @@ fn test_openbsd(target: &str) {
"signal.h",
"string.h",
"sys/file.h",
"sys/futex.h",
"sys/ioctl.h",
"sys/ipc.h",
"sys/mman.h",
Expand Down Expand Up @@ -505,6 +506,9 @@ fn test_openbsd(target: &str) {
// https://marc.info/?l=openbsd-cvs&m=154723400730318
"mincore" => true,

// futex() has volatile arguments, but that doesn't exist in Rust.
"futex" => true,

_ => false,
}
});
Expand Down
5 changes: 5 additions & 0 deletions libc-test/semver/openbsd.txt
Expand Up @@ -215,6 +215,10 @@ FIONREAD
FIOSETOWN
FLUSHO
FOPEN_MAX
FUTEX_WAIT
FUTEX_WAKE
FUTEX_REQUEUE
FUTEX_PRIVATE_FLAG
F_GETOWN
F_LOCK
F_RDLCK
Expand Down Expand Up @@ -987,6 +991,7 @@ fsid_t
fstatfs
ftok
fusefs_args
futex
futimes
getdomainname
getdtablesize
Expand Down
15 changes: 15 additions & 0 deletions src/unix/bsd/netbsdlike/openbsd/mod.rs
Expand Up @@ -1519,6 +1519,12 @@ pub const WCONTINUED: ::c_int = 8;
pub const FIND: ::ACTION = 0;
pub const ENTER: ::ACTION = 1;

// futex.h
pub const FUTEX_WAIT: ::c_int = 1;
pub const FUTEX_WAKE: ::c_int = 2;
pub const FUTEX_REQUEUE: ::c_int = 3;
pub const FUTEX_PRIVATE_FLAG: ::c_int = 128;

const_fn! {
{const} fn _ALIGN(p: usize) -> usize {
(p + _ALIGNBYTES) & !_ALIGNBYTES
Expand Down Expand Up @@ -1703,6 +1709,15 @@ extern "C" {
pub fn hcreate(nelt: ::size_t) -> ::c_int;
pub fn hdestroy();
pub fn hsearch(entry: ::ENTRY, action: ::ACTION) -> *mut ::ENTRY;

// futex.h
pub fn futex(
uaddr: *mut u32,
op: ::c_int,
val: ::c_int,
timeout: *const ::timespec,
uaddr2: *mut u32,
) -> ::c_int;
}

#[link(name = "execinfo")]
Expand Down