From 311c7d9e3b317852cabfd6a0f9fff6cf6222ad08 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Tue, 19 Apr 2022 10:08:03 +0200 Subject: [PATCH 1/3] Add OpenBSD's futex.h. --- libc-test/build.rs | 1 + libc-test/semver/openbsd.txt | 5 +++++ src/unix/bsd/netbsdlike/openbsd/mod.rs | 15 +++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 27497fa718957..f378870e98c56 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -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", diff --git a/libc-test/semver/openbsd.txt b/libc-test/semver/openbsd.txt index 479cef344dd3b..58b3eedd12ee8 100644 --- a/libc-test/semver/openbsd.txt +++ b/libc-test/semver/openbsd.txt @@ -215,6 +215,10 @@ FIONREAD FIOSETOWN FLUSHO FOPEN_MAX +FUTEX_WAIT +FUTEX_WAKE +FUTEX_REQUEUE +FUTEX_PRIVATE_FLAG F_GETOWN F_LOCK F_RDLCK @@ -987,6 +991,7 @@ fsid_t fstatfs ftok fusefs_args +futex futimes getdomainname getdtablesize diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index 2d0ac634438a0..1f0b1a1ec0e65 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -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 @@ -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")] From 9a3cafa25d5521020e80cfc32f43218143d54967 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Tue, 19 Apr 2022 17:02:20 +0200 Subject: [PATCH 2/3] Ignore futex() in libc-test/build.rs on OpenBSD. --- libc-test/build.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index f378870e98c56..e26042b0e9894 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -506,6 +506,9 @@ fn test_openbsd(target: &str) { // https://marc.info/?l=openbsd-cvs&m=154723400730318 "mincore" => true, + // futex() has volative arguments, but that doesn't exist in Rust. + "futex" => true, + _ => false, } }); From e5b9bc023444e01f30e15286fb377cd50aa7a165 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Tue, 19 Apr 2022 17:46:28 +0200 Subject: [PATCH 3/3] Typo. Co-authored-by: Thom Chiovoloni --- libc-test/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index e26042b0e9894..226757c6ad8dc 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -506,7 +506,7 @@ fn test_openbsd(target: &str) { // https://marc.info/?l=openbsd-cvs&m=154723400730318 "mincore" => true, - // futex() has volative arguments, but that doesn't exist in Rust. + // futex() has volatile arguments, but that doesn't exist in Rust. "futex" => true, _ => false,