Auto merge of #2245 - devnexen:pthread_spinlock_fbsd, r=JohnTitor

freebsd adding pthread_spinlock api
This commit is contained in:
bors 2021-06-16 02:29:14 +00:00
commit 599ae1bc9d
2 changed files with 26 additions and 0 deletions

View file

@ -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,
}
});

View file

@ -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")]