Skip to content

Add pthread_getname_np, requires #define _GNU_SOURCE #789

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 28 additions & 28 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ fn main() {

if !netbsd && !openbsd && !uclibc {
cfg.header("execinfo.h");
// latest Arch Linux renamed from xlocale.h
// TODO add a switch for the older platforms
cfg.header("locale.h");
}

if openbsd {
Expand Down Expand Up @@ -446,6 +449,8 @@ fn main() {
"SIG_ERR" |
"SIG_IGN" => true, // sighandler_t weirdness
"SIGUNUSED" => true, // removed in glibc 2.26
"AF_MAX" => true,
"PF_MAX" => true,

// types on musl are defined a little differently
n if musl && n.contains("__SIZEOF_PTHREAD") => true,
Expand Down
3 changes: 3 additions & 0 deletions src/unix/bsd/apple/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2131,6 +2131,9 @@ extern {
-> ::c_int;
pub fn mach_absolute_time() -> u64;
pub fn mach_timebase_info(info: *mut ::mach_timebase_info) -> ::c_int;
pub fn pthread_getname_np(t: ::pthread_t,
name_buf: *mut ::c_char,
buf_len: ::size_t) -> ::c_int;
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;
Expand Down
3 changes: 3 additions & 0 deletions src/unix/bsd/netbsdlike/netbsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,9 @@ extern {
pid: ::pid_t,
addr: *mut ::c_void,
data: ::c_int) -> ::c_int;
pub fn pthread_getname_np(t: ::pthread_t,
name_buf: *mut ::c_char,
buf_len: ::c_int) -> ::c_int;
pub fn pthread_setname_np(t: ::pthread_t,
name: *const ::c_char,
arg: *mut ::c_void) -> ::c_int;
Expand Down
3 changes: 3 additions & 0 deletions src/unix/notbsd/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,9 @@ extern {
flags: ::c_int,
rqtp: *const ::timespec,
rmtp: *mut ::timespec) -> ::c_int;
// getname is not available, use prctl(PR_GET_NAME, ...)
pub fn pthread_setname_np(t: ::pthread_t,
name: *const ::c_char) -> ::c_int;
pub fn pthread_attr_getguardsize(attr: *const ::pthread_attr_t,
guardsize: *mut ::size_t) -> ::c_int;
pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int;
Expand Down
2 changes: 1 addition & 1 deletion src/unix/notbsd/linux/mips/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ pub const SIGEV_THREAD_ID: ::c_int = 4;
pub const EPOLLWAKEUP: ::c_int = 0x20000000;

#[doc(hidden)]
pub const AF_MAX: ::c_int = 42;
pub const AF_MAX: ::c_int = 44;
#[doc(hidden)]
pub const PF_MAX: ::c_int = AF_MAX;

Expand Down
9 changes: 8 additions & 1 deletion src/unix/notbsd/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1339,7 +1339,7 @@ extern {
pub fn setfsgid(gid: ::gid_t) -> ::c_int;
pub fn setfsuid(uid: ::uid_t) -> ::c_int;

// Not available now on Android
/// Not available now on Android
pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char,
mode: ::mode_t) -> ::c_int;
pub fn if_nameindex() -> *mut if_nameindex;
Expand Down Expand Up @@ -1473,6 +1473,13 @@ extern {
flags: ::c_int,
rqtp: *const ::timespec,
rmtp: *mut ::timespec) -> ::c_int;
/// musl and Android are incompete 2017-11-25
#[cfg(not(target_env = "musl"))]
pub fn pthread_getname_np(t: ::pthread_t,
name_buf: *mut ::c_char,
buf_len: ::size_t) -> ::c_int;
pub fn pthread_setname_np(t: ::pthread_t,
name: *const ::c_char) -> ::c_int;
pub fn pthread_attr_getguardsize(attr: *const ::pthread_attr_t,
guardsize: *mut ::size_t) -> ::c_int;
pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int;
Expand Down
5 changes: 5 additions & 0 deletions src/unix/notbsd/linux/musl/b32/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ pub const MINSIGSTKSZ: ::size_t = 2048;
pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32;
pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24;

#[doc(hidden)]
pub const AF_MAX: ::c_int = 44;
#[doc(hidden)]
pub const PF_MAX: ::c_int = AF_MAX;

cfg_if! {
if #[cfg(any(target_arch = "x86"))] {
mod x86;
Expand Down
2 changes: 1 addition & 1 deletion src/unix/notbsd/linux/musl/b64/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pub const MINSIGSTKSZ: ::size_t = 6144;
pub const SIGSTKSZ: ::size_t = 12288;

#[doc(hidden)]
pub const PF_MAX: ::c_int = 43;
pub const PF_MAX: ::c_int = 44;
#[doc(hidden)]
pub const AF_MAX: ::c_int = PF_MAX;

Expand Down
2 changes: 1 addition & 1 deletion src/unix/notbsd/linux/musl/b64/powerpc64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub const SIGSTKSZ: ::size_t = 8192;
pub const MINSIGSTKSZ: ::size_t = 2048;

#[doc(hidden)]
pub const AF_MAX: ::c_int = 42;
pub const AF_MAX: ::c_int = 44;
#[doc(hidden)]
pub const PF_MAX: ::c_int = AF_MAX;

Expand Down
2 changes: 1 addition & 1 deletion src/unix/notbsd/linux/musl/b64/x86_64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,6 @@ pub const SIGSTKSZ: ::size_t = 8192;
pub const MINSIGSTKSZ: ::size_t = 2048;

#[doc(hidden)]
pub const AF_MAX: ::c_int = 42;
pub const AF_MAX: ::c_int = 44;
#[doc(hidden)]
pub const PF_MAX: ::c_int = AF_MAX;
2 changes: 1 addition & 1 deletion src/unix/notbsd/linux/other/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ pub const TIOCM_CD: ::c_int = TIOCM_CAR;
pub const TIOCM_RI: ::c_int = TIOCM_RNG;

#[doc(hidden)]
pub const AF_MAX: ::c_int = 42;
pub const AF_MAX: ::c_int = 44;
#[doc(hidden)]
pub const PF_MAX: ::c_int = AF_MAX;

Expand Down