summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-06-16 02:29:14 +0000
committerbors <bors@rust-lang.org>2021-06-16 02:29:14 +0000
commit599ae1bc9d52e8d0ecb0f0ad9b69ec64ea87622f (patch)
tree1bf9005546a445a60a58f5fb585e2712de67a216
parent5971b5383ea4059d162c598fc96698b4c9ac53be (diff)
parente8e75a874956f2c3c3de4710fd61f2fcf2422f90 (diff)
downloadrust-libc-599ae1bc9d52e8d0ecb0f0ad9b69ec64ea87622f.tar.gz
Auto merge of #2245 - devnexen:pthread_spinlock_fbsd, r=JohnTitor
freebsd adding pthread_spinlock api
-rwxr-xr-xlibc-test/build.rs3
-rw-r--r--src/unix/bsd/freebsdlike/freebsd/mod.rs23
2 files changed, 26 insertions, 0 deletions
diff --git a/libc-test/build.rs b/libc-test/build.rs
index 98fd9ea566..2380bab7a1 100755
--- a/libc-test/build.rs
+++ b/libc-test/build.rs
@@ -2002,6 +2002,9 @@ fn test_freebsd(target: &str) {
// not available until FreeBSD 12, and is an anonymous union there.
("xucred", "cr_pid__c_anonymous_union") => true,
+ // m_owner field is a volatile __lwpid_t
+ ("umutex", "m_owner") => true,
+
_ => false,
}
});
diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs
index dfcb194f7f..1468f252cf 100644
--- a/src/unix/bsd/freebsdlike/freebsd/mod.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs
@@ -21,6 +21,8 @@ pub type mqd_t = *mut ::c_void;
pub type posix_spawnattr_t = *mut ::c_void;
pub type posix_spawn_file_actions_t = *mut ::c_void;
+pub type pthread_spinlock_t = *mut __c_anonymous_pthread_spinlock;
+
s! {
pub struct aiocb {
pub aio_fildes: ::c_int,
@@ -140,6 +142,21 @@ s! {
pub struct cap_rights_t {
cr_rights: [u64; 2],
}
+
+ pub struct umutex {
+ m_owner: ::lwpid_t,
+ m_flags: u32,
+ m_ceilings: [u32; 2],
+ m_rb_link: ::uintptr_t,
+ #[cfg(target_pointer_width = "32")]
+ m_pad: u32,
+ m_spare: [u32; 2],
+
+ }
+
+ pub struct __c_anonymous_pthread_spinlock {
+ s_clock: umutex,
+ }
}
s_no_extra_traits! {
@@ -1588,6 +1605,12 @@ extern "C" {
cpusetp: *const cpuset_t,
) -> ::c_int;
+ pub fn pthread_spin_init(lock: *mut pthread_spinlock_t, pshared: ::c_int) -> ::c_int;
+ pub fn pthread_spin_destroy(lock: *mut pthread_spinlock_t) -> ::c_int;
+ pub fn pthread_spin_lock(lock: *mut pthread_spinlock_t) -> ::c_int;
+ pub fn pthread_spin_trylock(lock: *mut pthread_spinlock_t) -> ::c_int;
+ pub fn pthread_spin_unlock(lock: *mut pthread_spinlock_t) -> ::c_int;
+
#[cfg_attr(all(target_os = "freebsd", freebsd11), link_name = "statfs@FBSD_1.0")]
pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int;
#[cfg_attr(all(target_os = "freebsd", freebsd11), link_name = "fstatfs@FBSD_1.0")]