Skip to content

Commit 532d80c

Browse files
committed
Auto merge of #524 - mersinvald:pshared_attrs, r=alexcrichton
Added *_setpshared and *_getpshared bindings Adding bindings to posix pthreads functions vital for IPC via shared memory. That's my first PR into libc and I'm not proficient in unix systems programming, so I would really appreciate if someone reviewed it in case I missed something regardrless of the passed tests. Thanks!
2 parents 7a3754f + c0c7de7 commit 532d80c

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

src/unix/bsd/apple/mod.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1460,6 +1460,14 @@ extern {
14601460
pub fn pthread_setname_np(name: *const ::c_char) -> ::c_int;
14611461
pub fn pthread_get_stackaddr_np(thread: ::pthread_t) -> *mut ::c_void;
14621462
pub fn pthread_get_stacksize_np(thread: ::pthread_t) -> ::size_t;
1463+
pub fn pthread_condattr_setpshared(attr: *mut pthread_condattr_t,
1464+
pshared: ::c_int) -> ::c_int;
1465+
pub fn pthread_condattr_getpshared(attr: *const pthread_condattr_t,
1466+
pshared: *mut ::c_int) -> ::c_int;
1467+
pub fn pthread_mutexattr_setpshared(attr: *mut pthread_mutexattr_t,
1468+
pshared: ::c_int) -> ::c_int;
1469+
pub fn pthread_mutexattr_getpshared(attr: *const pthread_mutexattr_t,
1470+
pshared: *mut ::c_int) -> ::c_int;
14631471
pub fn __error() -> *mut ::c_int;
14641472
pub fn backtrace(buf: *mut *mut ::c_void,
14651473
sz: ::c_int) -> ::c_int;

src/unix/bsd/freebsdlike/mod.rs

+8
Original file line numberDiff line numberDiff line change
@@ -872,6 +872,14 @@ extern {
872872
pub fn pthread_attr_getstack(attr: *const ::pthread_attr_t,
873873
stackaddr: *mut *mut ::c_void,
874874
stacksize: *mut ::size_t) -> ::c_int;
875+
pub fn pthread_condattr_setpshared(attr: *mut pthread_condattr_t,
876+
pshared: ::c_int) -> ::c_int;
877+
pub fn pthread_condattr_getpshared(attr: *const pthread_condattr_t,
878+
pshared: *mut ::c_int) -> ::c_int;
879+
pub fn pthread_mutexattr_setpshared(attr: *mut pthread_mutexattr_t,
880+
pshared: ::c_int) -> ::c_int;
881+
pub fn pthread_mutexattr_getpshared(attr: *const pthread_mutexattr_t,
882+
pshared: *mut ::c_int) -> ::c_int;
875883
pub fn getpriority(which: ::c_int, who: ::c_int) -> ::c_int;
876884
pub fn setpriority(which: ::c_int, who: ::c_int, prio: ::c_int) -> ::c_int;
877885

src/unix/notbsd/mod.rs

+8
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,10 @@ extern {
845845
clock_id: *mut clockid_t) -> ::c_int;
846846
pub fn pthread_condattr_setclock(attr: *mut pthread_condattr_t,
847847
clock_id: clockid_t) -> ::c_int;
848+
pub fn pthread_condattr_setpshared(attr: *mut pthread_condattr_t,
849+
pshared: ::c_int) -> ::c_int;
850+
pub fn pthread_condattr_getpshared(attr: *const pthread_condattr_t,
851+
pshared: *mut ::c_int) -> ::c_int;
848852
pub fn sched_getaffinity(pid: ::pid_t,
849853
cpusetsize: ::size_t,
850854
cpuset: *mut cpu_set_t) -> ::c_int;
@@ -859,6 +863,10 @@ extern {
859863
flg: ::c_int) -> ::c_int;
860864
pub fn pthread_mutex_timedlock(lock: *mut pthread_mutex_t,
861865
abstime: *const ::timespec) -> ::c_int;
866+
pub fn pthread_mutexattr_setpshared(attr: *mut pthread_mutexattr_t,
867+
pshared: ::c_int) -> ::c_int;
868+
pub fn pthread_mutexattr_getpshared(attr: *const pthread_mutexattr_t,
869+
pshared: *mut ::c_int) -> ::c_int;
862870
pub fn ptsname_r(fd: ::c_int,
863871
buf: *mut ::c_char,
864872
buflen: ::size_t) -> ::c_int;

0 commit comments

Comments
 (0)