Skip to content

Commit

Permalink
Auto merge of #2455 - awidegreen:add_pthread_mutex_robust_support, r=…
Browse files Browse the repository at this point in the history
…JohnTitor

Adds pthread_mutexattr_[g|s]etrobust and pthread_mutex_consistent bindings

Adds pthread_mutexattr_[g|s]etrobust and pthread_mutex_consistent bindings

FreeBSD:
https://cgit.freebsd.org/src/tree/include/pthread.h?id=65436b2e1207a98a1c752c14f8c059238c0eafda#n140

Linux:
https://sourceware.org/git?p=glibc.git;a=blob;f=sysdeps/htl/bits/pthreadtypes.h;h=74127aea488a69af8fb63b8f353307e5d401a62b;hb=HEAD#l83
  • Loading branch information
bors committed Oct 19, 2021
2 parents 6172388 + 5ddd015 commit 5d7f90c
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
3 changes: 3 additions & 0 deletions libc-test/semver/freebsd.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1650,9 +1650,12 @@ pthread_getcpuclockid
pthread_getthreadid_np
pthread_kill
pthread_main_np
pthread_mutex_consistent
pthread_mutex_timedlock
pthread_mutexattr_getpshared
pthread_mutexattr_setpshared
pthread_mutexattr_getrobust
pthread_mutexattr_setrobust
pthread_rwlockattr_getpshared
pthread_rwlockattr_setpshared
pthread_setaffinity_np
Expand Down
3 changes: 3 additions & 0 deletions libc-test/semver/linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2897,9 +2897,12 @@ pthread_getattr_np
pthread_getcpuclockid
pthread_getschedparam
pthread_kill
pthread_mutex_consistent
pthread_mutex_timedlock
pthread_mutexattr_getpshared
pthread_mutexattr_setpshared
pthread_mutexattr_getrobust
pthread_mutexattr_setrobust
pthread_rwlockattr_setpshared
pthread_setaffinity_np
pthread_setschedparam
Expand Down
13 changes: 13 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,8 @@ pub const EXTATTR_NAMESPACE_SYSTEM: ::c_int = 2;

pub const PTHREAD_STACK_MIN: ::size_t = MINSIGSTKSZ;
pub const PTHREAD_MUTEX_ADAPTIVE_NP: ::c_int = 4;
pub const PTHREAD_MUTEX_STALLED: ::c_int = 0;
pub const PTHREAD_MUTEX_ROBUST: ::c_int = 1;
pub const SIGSTKSZ: ::size_t = MINSIGSTKSZ + 32768;
pub const SF_NODISKIO: ::c_int = 0x00000001;
pub const SF_MNOWAIT: ::c_int = 0x00000002;
Expand Down Expand Up @@ -1808,6 +1810,17 @@ extern "C" {
cpusetp: *const cpuset_t,
) -> ::c_int;

pub fn pthread_mutex_consistent(mutex: *mut ::pthread_mutex_t) -> ::c_int;

pub fn pthread_mutexattr_getrobust(
attr: *mut ::pthread_mutexattr_t,
robust: *mut ::c_int,
) -> ::c_int;
pub fn pthread_mutexattr_setrobust(
attr: *mut ::pthread_mutexattr_t,
robust: ::c_int,
) -> ::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;
Expand Down
11 changes: 11 additions & 0 deletions src/unix/linux_like/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1491,6 +1491,8 @@ pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0;
pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1;
pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2;
pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL;
pub const PTHREAD_MUTEX_STALLED: ::c_int = 0;
pub const PTHREAD_MUTEX_ROBUST: ::c_int = 1;
pub const PTHREAD_PROCESS_PRIVATE: ::c_int = 0;
pub const PTHREAD_PROCESS_SHARED: ::c_int = 1;
pub const __SIZEOF_PTHREAD_COND_T: usize = 48;
Expand Down Expand Up @@ -3619,6 +3621,7 @@ extern "C" {
timeout: *const ::timespec,
sigmask: *const sigset_t,
) -> ::c_int;
pub fn pthread_mutex_consistent(mutex: *mut pthread_mutex_t) -> ::c_int;
pub fn pthread_mutex_timedlock(
lock: *mut pthread_mutex_t,
abstime: *const ::timespec,
Expand Down Expand Up @@ -3734,6 +3737,14 @@ extern "C" {
attr: *const pthread_mutexattr_t,
pshared: *mut ::c_int,
) -> ::c_int;
pub fn pthread_mutexattr_getrobust(
attr: *const pthread_mutexattr_t,
robustness: *mut ::c_int,
) -> ::c_int;
pub fn pthread_mutexattr_setrobust(
attr: *mut pthread_mutexattr_t,
robustness: ::c_int,
) -> ::c_int;
pub fn popen(command: *const c_char, mode: *const c_char) -> *mut ::FILE;
pub fn faccessat(
dirfd: ::c_int,
Expand Down

0 comments on commit 5d7f90c

Please sign in to comment.