diff --git a/libc-test/build.rs b/libc-test/build.rs index b13a8369849c9..c1bfa119282b4 100755 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -5090,6 +5090,8 @@ fn test_linux(target: &str) { "posix_spawn_file_actions_addclosefrom_np" if gnu && sparc64 => true, // Needs glibc 2.35 or later. "posix_spawn_file_actions_addtcsetpgrp_np" if gnu && sparc64 => true, + // Needs glibc 2.42 or later. + "pthread_gettid_np" if gnu && versions.glibc.unwrap() < (2, 42) => true, // FIXME(linux): Deprecated since glibc 2.30. Remove fn once upstream does. "sysctl" if gnu => true, diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt index e765b15d5c2e6..3cf879f39e390 100644 --- a/libc-test/semver/android.txt +++ b/libc-test/semver/android.txt @@ -3829,6 +3829,7 @@ pthread_getattr_np pthread_getcpuclockid pthread_getschedparam pthread_getspecific +pthread_gettid_np pthread_join pthread_key_create pthread_key_delete diff --git a/libc-test/semver/linux-gnu.txt b/libc-test/semver/linux-gnu.txt index 88437e7b8485e..ed131210d845b 100644 --- a/libc-test/semver/linux-gnu.txt +++ b/libc-test/semver/linux-gnu.txt @@ -659,6 +659,7 @@ process_vm_readv process_vm_writev pthread_attr_getaffinity_np pthread_attr_setaffinity_np +pthread_gettid_np pthread_rwlockattr_getkind_np pthread_rwlockattr_getpshared pthread_rwlockattr_setkind_np diff --git a/src/new/bionic_libc/pthread.rs b/src/new/bionic_libc/pthread.rs index 4997547ff0905..db62dc4ce7844 100644 --- a/src/new/bionic_libc/pthread.rs +++ b/src/new/bionic_libc/pthread.rs @@ -2,6 +2,7 @@ pub use crate::new::common::linux_like::pthread::{ pthread_getattr_np, + pthread_gettid_np, pthread_setname_np, }; pub use crate::new::common::posix::pthread::{ diff --git a/src/new/common/linux_like/pthread.rs b/src/new/common/linux_like/pthread.rs index b54d385f9c05f..e76b704142a7c 100644 --- a/src/new/common/linux_like/pthread.rs +++ b/src/new/common/linux_like/pthread.rs @@ -13,6 +13,9 @@ extern "C" { #[cfg(target_os = "linux")] pub fn pthread_getname_np(thread: crate::pthread_t, name: *mut c_char, len: size_t) -> c_int; + #[cfg(any(target_os = "android", all(target_os = "linux", target_env = "gnu")))] + pub fn pthread_gettid_np(thread: crate::pthread_t) -> crate::pid_t; + #[cfg(any(target_os = "linux", target_os = "l4re"))] pub fn pthread_setaffinity_np( thread: crate::pthread_t, diff --git a/src/new/glibc/sysdeps/nptl/pthread.rs b/src/new/glibc/sysdeps/nptl/pthread.rs index cefc9e3002a41..bb45d2851fc50 100644 --- a/src/new/glibc/sysdeps/nptl/pthread.rs +++ b/src/new/glibc/sysdeps/nptl/pthread.rs @@ -28,6 +28,7 @@ pub use crate::new::common::linux_like::pthread::{ pthread_getaffinity_np, pthread_getattr_np, pthread_getname_np, + pthread_gettid_np, pthread_setaffinity_np, pthread_setname_np, };