Skip to content

Commit 7250a68

Browse files
committed
pthread_spinlock api remaining bsd systems
1 parent 599ae1b commit 7250a68

File tree

11 files changed

+61
-0
lines changed

11 files changed

+61
-0
lines changed

libc-test/build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,8 @@ fn test_netbsd(target: &str) {
10991099
// conflicting with `p_type` macro from <resolve.h>.
11001100
("Elf32_Phdr", "p_type") => true,
11011101
("Elf64_Phdr", "p_type") => true,
1102+
// pthread_spin_t is a volatile uchar
1103+
("pthread_spinlock_t", "pts_spin") => true,
11021104
_ => false,
11031105
}
11041106
});

libc-test/semver/android.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3001,6 +3001,12 @@ pthread_self
30013001
pthread_setschedparam
30023002
pthread_setspecific
30033003
pthread_sigmask
3004+
pthread_spin_destroy
3005+
pthread_spin_init
3006+
pthread_spin_lock
3007+
pthread_spin_trylock
3008+
pthread_spin_unlock
3009+
pthread_spinlock_t
30043010
pthread_t
30053011
ptrace
30063012
ptrdiff_t

libc-test/semver/dragonfly.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,6 +1307,12 @@ pthread_mutexattr_setpshared
13071307
pthread_rwlockattr_getpshared
13081308
pthread_rwlockattr_setpshared
13091309
pthread_set_name_np
1310+
pthread_spin_destroy
1311+
pthread_spin_init
1312+
pthread_spin_lock
1313+
pthread_spin_trylock
1314+
pthread_spin_unlock
1315+
pthread_spinlock_t
13101316
ptrace
13111317
ptrace_io_desc
13121318
pututxline

libc-test/semver/freebsd.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,6 +1558,12 @@ pthread_rwlockattr_getpshared
15581558
pthread_rwlockattr_setpshared
15591559
pthread_setaffinity_np
15601560
pthread_set_name_np
1561+
pthread_spin_destroy
1562+
pthread_spin_init
1563+
pthread_spin_lock
1564+
pthread_spin_trylock
1565+
pthread_spin_unlock
1566+
pthread_spinlock_t
15611567
ptrace
15621568
ptrace_io_desc
15631569
ptrace_vm_entry

libc-test/semver/linux.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2913,6 +2913,12 @@ pthread_rwlockattr_setpshared
29132913
pthread_setaffinity_np
29142914
pthread_setschedparam
29152915
pthread_setschedprio
2916+
pthread_spin_destroy
2917+
pthread_spin_init
2918+
pthread_spin_lock
2919+
pthread_spin_trylock
2920+
pthread_spin_unlock
2921+
pthread_spinlock_t
29162922
ptrace
29172923
ptsname_r
29182924
pwrite64

libc-test/semver/netbsd.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,6 +1205,12 @@ pthread_getattr_np
12051205
pthread_getaffinity_np
12061206
pthread_kill
12071207
pthread_mutex_timedlock
1208+
pthread_spin_destroy
1209+
pthread_spin_init
1210+
pthread_spin_lock
1211+
pthread_spin_trylock
1212+
pthread_spin_unlock
1213+
pthread_spinlock_t
12081214
pthread_setaffinity_np
12091215
pthread_setname_np
12101216
ptrace

libc-test/semver/openbsd.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,6 +1008,12 @@ pthread_kill
10081008
pthread_main_np
10091009
pthread_mutex_timedlock
10101010
pthread_set_name_np
1011+
pthread_spin_destroy
1012+
pthread_spin_init
1013+
pthread_spin_lock
1014+
pthread_spin_trylock
1015+
pthread_spin_unlock
1016+
pthread_spinlock_t
10111017
pthread_stackseg_np
10121018
ptrace
10131019
ptrace_io_desc

src/unix/bsd/freebsdlike/dragonfly/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ pub type cpuset_t = cpumask_t;
2626
pub type cpu_set_t = cpumask_t;
2727

2828
pub type register_t = ::c_long;
29+
pub type umtx_t = ::c_int;
30+
pub type pthread_spinlock_t = ::uintptr_t;
2931

3032
#[cfg_attr(feature = "extra_traits", derive(Debug))]
3133
pub enum sem {}
@@ -1269,6 +1271,12 @@ extern "C" {
12691271
needle: *const ::c_void,
12701272
needlelen: ::size_t,
12711273
) -> *mut ::c_void;
1274+
pub fn pthread_spin_init(lock: *mut pthread_spinlock_t, pshared: ::c_int) -> ::c_int;
1275+
pub fn pthread_spin_destroy(lock: *mut pthread_spinlock_t) -> ::c_int;
1276+
pub fn pthread_spin_lock(lock: *mut pthread_spinlock_t) -> ::c_int;
1277+
pub fn pthread_spin_trylock(lock: *mut pthread_spinlock_t) -> ::c_int;
1278+
pub fn pthread_spin_unlock(lock: *mut pthread_spinlock_t) -> ::c_int;
1279+
12721280
pub fn sched_getaffinity(pid: ::pid_t, cpusetsize: ::size_t, mask: *mut cpu_set_t) -> ::c_int;
12731281
pub fn sched_setaffinity(pid: ::pid_t, cpusetsize: ::size_t, mask: *const cpu_set_t)
12741282
-> ::c_int;

src/unix/bsd/netbsdlike/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,11 @@ extern "C" {
712712
lock: *mut pthread_mutex_t,
713713
abstime: *const ::timespec,
714714
) -> ::c_int;
715+
pub fn pthread_spin_init(lock: *mut pthread_spinlock_t, pshared: ::c_int) -> ::c_int;
716+
pub fn pthread_spin_destroy(lock: *mut pthread_spinlock_t) -> ::c_int;
717+
pub fn pthread_spin_lock(lock: *mut pthread_spinlock_t) -> ::c_int;
718+
pub fn pthread_spin_trylock(lock: *mut pthread_spinlock_t) -> ::c_int;
719+
pub fn pthread_spin_unlock(lock: *mut pthread_spinlock_t) -> ::c_int;
715720
pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int;
716721

717722
pub fn getgrouplist(

src/unix/bsd/netbsdlike/netbsd/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pub type lwpid_t = ::c_uint;
1212
pub type shmatt_t = ::c_uint;
1313
pub type cpuid_t = u64;
1414
pub type cpuset_t = _cpuset;
15+
pub type pthread_spin_t = ::c_uchar;
1516

1617
// elf.h
1718

@@ -209,6 +210,12 @@ s! {
209210
ptr_private: *mut ::c_void,
210211
}
211212

213+
pub struct pthread_spinlock_t {
214+
pts_magic: ::c_uint,
215+
pts_spin: ::pthread_spin_t,
216+
pts_flags: ::c_int,
217+
}
218+
212219
pub struct kevent {
213220
pub ident: ::uintptr_t,
214221
pub filter: u32,
@@ -2067,6 +2074,7 @@ extern "C" {
20672074
size: ::size_t,
20682075
set: *mut cpuset_t,
20692076
) -> ::c_int;
2077+
20702078
pub fn _cpuset_create() -> *mut cpuset_t;
20712079
pub fn _cpuset_destroy(set: *mut cpuset_t);
20722080
pub fn _cpuset_clr(cpu: cpuid_t, set: *mut cpuset_t) -> ::c_int;

0 commit comments

Comments
 (0)