Skip to content

Commit

Permalink
Auto merge of #2764 - vityafx:add-more-posix-functions-for-emscripten…
Browse files Browse the repository at this point in the history
…, r=<try>

Add pthread_[s,g]etschedparam to emscripten.

Closes #2754

The functions are available in emscripten when built with the posix threads support.
  • Loading branch information
bors committed Sep 13, 2022
2 parents a74954e + 78a91f3 commit f15a98e
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ci/emscripten-entry.sh
Expand Up @@ -7,6 +7,6 @@ source /emsdk-portable/emsdk_env.sh &> /dev/null

# emsdk-portable provides a node binary, but we need version 8 to run wasm
# NOTE: Do not forget to sync Node.js version with `emscripten.sh`!
export PATH="/node-v14.17.0-linux-x64/bin:$PATH"
export PATH="/node-v18.0.0-linux-x64/bin:$PATH"

exec "$@"
4 changes: 2 additions & 2 deletions ci/emscripten.sh
Expand Up @@ -2,7 +2,7 @@

set -ex

EMSDK_VERSION=1.39.20
EMSDK_VERSION=3.1.9

hide_output() {
set +x
Expand Down Expand Up @@ -39,5 +39,5 @@ chmod a+rxw -R /emsdk-portable
# node 8 is required to run wasm
# NOTE: Do not forget to sync Node.js version with `emscripten-entry.sh`!
cd /
curl --retry 5 -L https://nodejs.org/dist/v14.17.0/node-v14.17.0-linux-x64.tar.xz | \
curl --retry 5 -L https://nodejs.org/dist/v18.0.0/node-v18.0.0-linux-x64.tar.xz | \
tar -xJ
7 changes: 7 additions & 0 deletions ci/run.sh
Expand Up @@ -109,6 +109,13 @@ if [ "$TARGET" = "s390x-unknown-linux-gnu" ]; then
sleep 1
done
else
if [ "$TARGET" = "asmjs-unknown-emscripten" ]; then
# Rust uses -g4 by default what causes link issues.
# This should disable the -g4 option.
export RUSTFLAGS="-Cdebuginfo=0"
export EMCC_FLAGS="-s USE_PTHREADS=1 --shared-memory"
export EMCC_CFLAGS="-s USE_PTHREADS=1 --shared-memory"
fi
cargo test --no-default-features --manifest-path libc-test/Cargo.toml \
--target "${TARGET}" ${LIBC_CI_ZBUILD_STD+"-Zbuild-std"}

Expand Down
1 change: 0 additions & 1 deletion libc-test/build.rs
Expand Up @@ -2406,7 +2406,6 @@ fn test_emscripten(target: &str) {
"sys/reboot.h",
"sys/resource.h",
"sys/sem.h",
"sys/sendfile.h",
"sys/shm.h",
"sys/signalfd.h",
"sys/socket.h",
Expand Down
10 changes: 10 additions & 0 deletions src/unix/linux_like/emscripten/mod.rs
Expand Up @@ -1883,6 +1883,16 @@ extern "C" {
f: extern "C" fn(*mut ::c_void) -> *mut ::c_void,
value: *mut ::c_void,
) -> ::c_int;
pub fn pthread_setschedparam(
native: ::pthread_t,
policy: ::c_int,
param: *const ::sched_param,
) -> ::c_int;
pub fn pthread_getschedparam(
native: ::pthread_t,
policy: *mut ::c_int,
param: *mut ::sched_param,
) -> ::c_int;
}

cfg_if! {
Expand Down
8 changes: 4 additions & 4 deletions src/unix/linux_like/mod.rs
Expand Up @@ -108,13 +108,13 @@ s! {

pub struct sched_param {
pub sched_priority: ::c_int,
#[cfg(any(target_env = "musl", target_os = "emscripten"))]
#[cfg(target_env = "musl")]
pub sched_ss_low_priority: ::c_int,
#[cfg(any(target_env = "musl", target_os = "emscripten"))]
#[cfg(target_env = "musl")]
pub sched_ss_repl_period: ::timespec,
#[cfg(any(target_env = "musl", target_os = "emscripten"))]
#[cfg(target_env = "musl")]
pub sched_ss_init_budget: ::timespec,
#[cfg(any(target_env = "musl", target_os = "emscripten"))]
#[cfg(target_env = "musl")]
pub sched_ss_max_repl: ::c_int,
}

Expand Down

0 comments on commit f15a98e

Please sign in to comment.