Skip to content

Commit

Permalink
Auto merge of #524 - mersinvald:pshared_attrs, r=alexcrichton
Browse files Browse the repository at this point in the history
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!
  • Loading branch information
bors committed Feb 17, 2017
2 parents 7a3754f + c0c7de7 commit 532d80c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/unix/bsd/apple/mod.rs
Expand Up @@ -1460,6 +1460,14 @@ extern {
pub fn pthread_setname_np(name: *const ::c_char) -> ::c_int;
pub fn pthread_get_stackaddr_np(thread: ::pthread_t) -> *mut ::c_void;
pub fn pthread_get_stacksize_np(thread: ::pthread_t) -> ::size_t;
pub fn pthread_condattr_setpshared(attr: *mut pthread_condattr_t,
pshared: ::c_int) -> ::c_int;
pub fn pthread_condattr_getpshared(attr: *const pthread_condattr_t,
pshared: *mut ::c_int) -> ::c_int;
pub fn pthread_mutexattr_setpshared(attr: *mut pthread_mutexattr_t,
pshared: ::c_int) -> ::c_int;
pub fn pthread_mutexattr_getpshared(attr: *const pthread_mutexattr_t,
pshared: *mut ::c_int) -> ::c_int;
pub fn __error() -> *mut ::c_int;
pub fn backtrace(buf: *mut *mut ::c_void,
sz: ::c_int) -> ::c_int;
Expand Down
8 changes: 8 additions & 0 deletions src/unix/bsd/freebsdlike/mod.rs
Expand Up @@ -872,6 +872,14 @@ extern {
pub fn pthread_attr_getstack(attr: *const ::pthread_attr_t,
stackaddr: *mut *mut ::c_void,
stacksize: *mut ::size_t) -> ::c_int;
pub fn pthread_condattr_setpshared(attr: *mut pthread_condattr_t,
pshared: ::c_int) -> ::c_int;
pub fn pthread_condattr_getpshared(attr: *const pthread_condattr_t,
pshared: *mut ::c_int) -> ::c_int;
pub fn pthread_mutexattr_setpshared(attr: *mut pthread_mutexattr_t,
pshared: ::c_int) -> ::c_int;
pub fn pthread_mutexattr_getpshared(attr: *const pthread_mutexattr_t,
pshared: *mut ::c_int) -> ::c_int;
pub fn getpriority(which: ::c_int, who: ::c_int) -> ::c_int;
pub fn setpriority(which: ::c_int, who: ::c_int, prio: ::c_int) -> ::c_int;

Expand Down
8 changes: 8 additions & 0 deletions src/unix/notbsd/mod.rs
Expand Up @@ -845,6 +845,10 @@ extern {
clock_id: *mut clockid_t) -> ::c_int;
pub fn pthread_condattr_setclock(attr: *mut pthread_condattr_t,
clock_id: clockid_t) -> ::c_int;
pub fn pthread_condattr_setpshared(attr: *mut pthread_condattr_t,
pshared: ::c_int) -> ::c_int;
pub fn pthread_condattr_getpshared(attr: *const pthread_condattr_t,
pshared: *mut ::c_int) -> ::c_int;
pub fn sched_getaffinity(pid: ::pid_t,
cpusetsize: ::size_t,
cpuset: *mut cpu_set_t) -> ::c_int;
Expand All @@ -859,6 +863,10 @@ extern {
flg: ::c_int) -> ::c_int;
pub fn pthread_mutex_timedlock(lock: *mut pthread_mutex_t,
abstime: *const ::timespec) -> ::c_int;
pub fn pthread_mutexattr_setpshared(attr: *mut pthread_mutexattr_t,
pshared: ::c_int) -> ::c_int;
pub fn pthread_mutexattr_getpshared(attr: *const pthread_mutexattr_t,
pshared: *mut ::c_int) -> ::c_int;
pub fn ptsname_r(fd: ::c_int,
buf: *mut ::c_char,
buflen: ::size_t) -> ::c_int;
Expand Down

0 comments on commit 532d80c

Please sign in to comment.