From 7250a68be72501c610cf6fe4b7cee61742390b9e Mon Sep 17 00:00:00 2001 From: David Carlier Date: Wed, 16 Jun 2021 19:15:11 +0100 Subject: pthread_spinlock api remaining bsd systems --- src/unix/bsd/freebsdlike/dragonfly/mod.rs | 8 ++++++++ src/unix/bsd/netbsdlike/mod.rs | 5 +++++ src/unix/bsd/netbsdlike/netbsd/mod.rs | 8 ++++++++ src/unix/bsd/netbsdlike/openbsd/mod.rs | 2 ++ 4 files changed, 23 insertions(+) (limited to 'src') diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index b9bdafed4e..8092db5705 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -26,6 +26,8 @@ pub type cpuset_t = cpumask_t; pub type cpu_set_t = cpumask_t; pub type register_t = ::c_long; +pub type umtx_t = ::c_int; +pub type pthread_spinlock_t = ::uintptr_t; #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum sem {} @@ -1269,6 +1271,12 @@ extern "C" { needle: *const ::c_void, needlelen: ::size_t, ) -> *mut ::c_void; + 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; + pub fn sched_getaffinity(pid: ::pid_t, cpusetsize: ::size_t, mask: *mut cpu_set_t) -> ::c_int; pub fn sched_setaffinity(pid: ::pid_t, cpusetsize: ::size_t, mask: *const cpu_set_t) -> ::c_int; diff --git a/src/unix/bsd/netbsdlike/mod.rs b/src/unix/bsd/netbsdlike/mod.rs index 7e7269fcff..7f030abc98 100644 --- a/src/unix/bsd/netbsdlike/mod.rs +++ b/src/unix/bsd/netbsdlike/mod.rs @@ -712,6 +712,11 @@ extern "C" { lock: *mut pthread_mutex_t, abstime: *const ::timespec, ) -> ::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; pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int; pub fn getgrouplist( diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 0aee1ec515..ee308cf7c8 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -12,6 +12,7 @@ pub type lwpid_t = ::c_uint; pub type shmatt_t = ::c_uint; pub type cpuid_t = u64; pub type cpuset_t = _cpuset; +pub type pthread_spin_t = ::c_uchar; // elf.h @@ -209,6 +210,12 @@ s! { ptr_private: *mut ::c_void, } + pub struct pthread_spinlock_t { + pts_magic: ::c_uint, + pts_spin: ::pthread_spin_t, + pts_flags: ::c_int, + } + pub struct kevent { pub ident: ::uintptr_t, pub filter: u32, @@ -2067,6 +2074,7 @@ extern "C" { size: ::size_t, set: *mut cpuset_t, ) -> ::c_int; + pub fn _cpuset_create() -> *mut cpuset_t; pub fn _cpuset_destroy(set: *mut cpuset_t); pub fn _cpuset_clr(cpu: cpuid_t, set: *mut cpuset_t) -> ::c_int; diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index c5d45b4543..038048ef17 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -14,6 +14,7 @@ pub type pthread_cond_t = *mut ::c_void; pub type pthread_condattr_t = *mut ::c_void; pub type pthread_rwlock_t = *mut ::c_void; pub type pthread_rwlockattr_t = *mut ::c_void; +pub type pthread_spinlock_t = ::uintptr_t; pub type caddr_t = *mut ::c_char; // elf.h @@ -1530,6 +1531,7 @@ extern "C" { pub fn pthread_main_np() -> ::c_int; pub fn pthread_set_name_np(tid: ::pthread_t, name: *const ::c_char); pub fn pthread_stackseg_np(thread: ::pthread_t, sinfo: *mut ::stack_t) -> ::c_int; + pub fn sysctl( name: *const ::c_int, namelen: ::c_uint, -- cgit v1.2.1