diff --git a/libc-test/build.rs b/libc-test/build.rs index 2cf2eba99dda8..5a5db751ec012 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -3227,8 +3227,6 @@ fn test_freebsd(target: &str) { fn test_emscripten(target: &str) { assert!(target.contains("emscripten")); - #[expect(unused_variables)] // remove once we need a version check - let emscripten = VERSIONS.emscripten.unwrap(); let mut cfg = ctest_cfg(); cfg.define("_GNU_SOURCE", None); // FIXME(emscripten): ?? @@ -3395,6 +3393,9 @@ fn test_emscripten(target: &str) { // https://github.com/emscripten-core/emscripten/blob/3.1.68/tools/system_libs.py#L1100 "execv" | "execve" | "execvp" | "execvpe" | "fexecve" | "wait4" => true, + // Emscripten's `pthread_kill` used to only be linkable when building with `-pthread` + "pthread_kill" if matches!(VERSIONS.emscripten, Some(v) if v < (6, 0)) => true, + _ => false, } }); diff --git a/src/new/common/posix/pthread.rs b/src/new/common/posix/pthread.rs index 17d390669a410..b50c21fe69e85 100644 --- a/src/new/common/posix/pthread.rs +++ b/src/new/common/posix/pthread.rs @@ -187,7 +187,12 @@ extern "C" { // FIXME(reorg): In recent POSIX versions, this is a signal.h function and not required // in pthread. - #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] + #[cfg(any( + target_os = "android", + target_os = "emscripten", + target_os = "l4re", + target_os = "linux" + ))] pub fn pthread_kill(thread: crate::pthread_t, sig: c_int) -> c_int; #[cfg(all(target_os = "linux", not(target_env = "ohos")))] @@ -298,7 +303,12 @@ extern "C" { // FIXME(reorg): In recent POSIX versions, this is a signal.h function and not required // in pthread. - #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] + #[cfg(any( + target_os = "android", + target_os = "emscripten", + target_os = "l4re", + target_os = "linux" + ))] pub fn pthread_sigmask( how: c_int, set: *const crate::sigset_t, diff --git a/src/new/emscripten/pthread.rs b/src/new/emscripten/pthread.rs index 21982b7979d43..cfd7a05a216a5 100644 --- a/src/new/emscripten/pthread.rs +++ b/src/new/emscripten/pthread.rs @@ -8,7 +8,9 @@ pub use crate::new::common::posix::pthread::{ pthread_condattr_setclock, pthread_condattr_setpshared, pthread_create, + pthread_kill, pthread_mutexattr_setpshared, pthread_rwlockattr_getpshared, pthread_rwlockattr_setpshared, + pthread_sigmask, }; diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index f3fd341ef304c..c5727d6c563a0 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -1458,6 +1458,14 @@ extern "C" { buflen: size_t, result: *mut *mut crate::group, ) -> c_int; + pub fn sigwait(set: *const crate::sigset_t, sig: *mut c_int) -> c_int; + pub fn sigwaitinfo(set: *const crate::sigset_t, info: *mut crate::siginfo_t) -> c_int; + pub fn sigtimedwait( + set: *const crate::sigset_t, + info: *mut crate::siginfo_t, + timeout: *const crate::timespec, + ) -> c_int; + pub fn faccessat(dirfd: c_int, pathname: *const c_char, mode: c_int, flags: c_int) -> c_int; } // Alias to 64 to mimic glibc's LFS64 support