diff --git a/.travis.yml b/.travis.yml index b7721b5e6049f..fbd4753c9826e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -101,6 +101,12 @@ matrix: - os: linux env: TARGET=mips-unknown-linux-gnu rust: beta + - os: linux + env: TARGET=asmjs-unknown-emscripten + rust: stable + - os: linux + env: TARGET=wasm32-unknown-emscripten + rust: stable # beta - os: linux diff --git a/Cargo.lock b/Cargo.lock index 6fae715e9cfd0..cd0b7c0f29cb7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -43,12 +43,12 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.23" -source = "registry+https://github.com/rust-lang/crates.io-index" +version = "0.2.24" [[package]] name = "libc" version = "0.2.24" +source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "log" @@ -66,7 +66,7 @@ version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", @@ -102,7 +102,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum ctest 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4714dea251b5a487400bd9f772810cca11e5fe361e1918805c9f1ce35d177e22" "checksum gcc 0.3.51 (registry+https://github.com/rust-lang/crates.io-index)" = "120d07f202dcc3f72859422563522b66fe6463a4c513df062874daad05f85f0a" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -"checksum libc 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)" = "e7eb6b826bfc1fdea7935d46556250d1799b7fe2d9f7951071f4291710665e3e" +"checksum libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)" = "38f5c2b18a287cf78b4097db62e20f43cace381dc76ae5c0a3073067f78b7ddc" "checksum log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "880f77541efa6e5cc74e76910c9884d9859683118839d6a1dc3b11e63512565b" "checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" "checksum syntex_syntax 0.27.0 (registry+https://github.com/rust-lang/crates.io-index)" = "82b078749c05271b2aebae7230331c903c38128d5a3dec72625d9e3a411a5b69" diff --git a/ci/docker/asmjs-unknown-emscripten/Dockerfile b/ci/docker/asmjs-unknown-emscripten/Dockerfile new file mode 100644 index 0000000000000..7de85251e6d43 --- /dev/null +++ b/ci/docker/asmjs-unknown-emscripten/Dockerfile @@ -0,0 +1,20 @@ +FROM ubuntu:16.04 + +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + ca-certificates \ + curl \ + gcc \ + git \ + libc6-dev \ + python \ + xz-utils + +COPY emscripten.sh / +RUN bash /emscripten.sh + +ENV PATH=$PATH:/rust/bin + +COPY emscripten-entry.sh / +ENTRYPOINT ["/emscripten-entry.sh"] + diff --git a/ci/docker/wasm32-unknown-emscripten/Dockerfile b/ci/docker/wasm32-unknown-emscripten/Dockerfile new file mode 100644 index 0000000000000..7de85251e6d43 --- /dev/null +++ b/ci/docker/wasm32-unknown-emscripten/Dockerfile @@ -0,0 +1,20 @@ +FROM ubuntu:16.04 + +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + ca-certificates \ + curl \ + gcc \ + git \ + libc6-dev \ + python \ + xz-utils + +COPY emscripten.sh / +RUN bash /emscripten.sh + +ENV PATH=$PATH:/rust/bin + +COPY emscripten-entry.sh / +ENTRYPOINT ["/emscripten-entry.sh"] + diff --git a/ci/emscripten-entry.sh b/ci/emscripten-entry.sh new file mode 100755 index 0000000000000..acaebfe8c7cbe --- /dev/null +++ b/ci/emscripten-entry.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# Copyright 2017 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +set -ex + +source /emsdk-portable/emsdk_env.sh &> /dev/null + +# emsdk-portable provides a node binary, but we need version 8 to run wasm +export PATH="/node-v8.0.0-linux-x64/bin:$PATH" + +exec "$@" diff --git a/ci/emscripten.sh b/ci/emscripten.sh new file mode 100644 index 0000000000000..0ca578a6c3d3c --- /dev/null +++ b/ci/emscripten.sh @@ -0,0 +1,53 @@ +# Copyright 2017 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +set -ex + +hide_output() { + set +x + on_err=" +echo ERROR: An error was encountered with the build. +cat /tmp/build.log +exit 1 +" + trap "$on_err" ERR + bash -c "while true; do sleep 30; echo \$(date) - building ...; done" & + PING_LOOP_PID=$! + $@ &> /tmp/build.log + trap - ERR + kill $PING_LOOP_PID + rm -f /tmp/build.log + set -x +} + +cd / +curl -L https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz | \ + tar -xz + +cd /emsdk-portable +./emsdk update +hide_output ./emsdk install sdk-1.37.14-64bit +./emsdk activate sdk-1.37.14-64bit + +# Compile and cache libc +source ./emsdk_env.sh +echo "main(){}" > a.c +HOME=/emsdk-portable/ emcc a.c +HOME=/emsdk-portable/ emcc -s BINARYEN=1 a.c +rm -f a.* + +# Make emsdk usable by any user +cp /root/.emscripten /emsdk-portable +chmod a+rxw -R /emsdk-portable + +# node 8 is required to run wasm +cd / +curl -L https://nodejs.org/dist/v8.0.0/node-v8.0.0-linux-x64.tar.xz | \ + tar -xJ diff --git a/ci/run.sh b/ci/run.sh index 3ddc7b3954768..08bb8cc92a5d7 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -168,6 +168,10 @@ case "$TARGET" in qemu-aarch64 -L /usr/aarch64-linux-gnu/ $CARGO_TARGET_DIR/$TARGET/debug/libc-test ;; + *-emscripten) + cd $CARGO_TARGET_DIR/$TARGET/debug/deps/ && node ../libc-test.js + ;; + *-rumprun-netbsd) rumprun-bake hw_virtio /tmp/libc-test.img $CARGO_TARGET_DIR/$TARGET/debug/libc-test qemu-system-x86_64 -nographic -vga none -m 64 \ diff --git a/libc-test/Cargo.toml b/libc-test/Cargo.toml index 4e7c88450e6ae..5bf8629adb268 100644 --- a/libc-test/Cargo.toml +++ b/libc-test/Cargo.toml @@ -8,4 +8,4 @@ build = "build.rs" libc = { path = ".." } [build-dependencies] -ctest = "0.1" +ctest = "0.1.3" diff --git a/libc-test/build.rs b/libc-test/build.rs index d573baaf908c5..a444a2e24240b 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -13,7 +13,8 @@ fn main() { let linux = target.contains("unknown-linux"); let android = target.contains("android"); let apple = target.contains("apple"); - let musl = target.contains("musl"); + let emscripten = target.contains("asm"); + let musl = target.contains("musl") || emscripten; let uclibc = target.contains("uclibc"); let freebsd = target.contains("freebsd"); let dragonfly = target.contains("dragonfly"); @@ -25,7 +26,7 @@ fn main() { let mut cfg = ctest::TestGenerator::new(); // Pull in extra goodies - if linux || android { + if linux || android || emscripten { cfg.define("_GNU_SOURCE", None); } else if netbsd { cfg.define("_NETBSD_SOURCE", Some("1")); @@ -165,7 +166,7 @@ fn main() { } } - if linux { + if linux || emscripten { cfg.header("mqueue.h"); cfg.header("ucontext.h"); cfg.header("sys/signalfd.h"); @@ -186,7 +187,7 @@ fn main() { } } - if linux || android { + if linux || android || emscripten { cfg.header("malloc.h"); cfg.header("net/ethernet.h"); cfg.header("netpacket/packet.h"); @@ -242,7 +243,7 @@ fn main() { cfg.header("sys/ioctl_compat.h"); } - if linux || freebsd || dragonfly || netbsd || apple { + if linux || emscripten || freebsd || dragonfly || netbsd || apple { if !uclibc { cfg.header("aio.h"); } @@ -361,6 +362,9 @@ fn main() { "FILE_ATTRIBUTE_INTEGRITY_STREAM" | "ERROR_NOTHING_TO_TERMINATE" if mingw => true, + // not defined + "IUTF8" | "ENOATTR" | "EXTA" | "EXTB" if emscripten => true, + "SIG_IGN" => true, // sighandler_t weirdness // types on musl are defined a little differently @@ -433,6 +437,32 @@ fn main() { "prlimit" | "prlimit64" | // non-int in 2nd arg "strerror_r" if linux => true, // actually xpg-something-or-other + // not defined or fails to link + "aio_cancel" | "aio_error" | "aio_fsync" | "aio_read" | "aio_return"| "aio_suspend" | + "aio_write" | "clock_nanosleep" | "clone" | "daemon" | "endspent" | "epoll_create" | + "epoll_create1" | "epoll_ctl" | "epoll_pwait" | "epoll_wait" | "eventfd" | + "faccessat" | "fallocate" | "fgetxattr" | "flistxattr" | "forkpty" | "fremovexattr" | + "fsetxattr" | "ftok" | "futimes" | "getdtablesize" | "getgrgid" | "getgrnam" | + "getpwnam_r" | "getpwuid_r" | "getspent" | "getspnam" | "getxattr" | "initgroups" | + "lgetxattr" | "listxattr" | "llistxattr" | "lremovexattr" | "lsetxattr" | "lutimes" | + "mount" | "mq_close" | "mq_getattr" | "mq_open" | "mq_receive" | "mq_send" | + "mq_setattr" | "mq_unlink" | "msgctl" | "msgget" | "msgrcv" | "msgsnd" | "pclose" | + "popen" | "ppoll" | "prctl" | "prlimit" | "prlimit64" | "process_vm_readv" | + "process_vm_writev" | "pthread_atfork" | "pthread_attr_getguardsize" | + "pthread_kill" | "pthread_mutexattr_getpshared" | "pthread_mutex_timedlock" | + "pthread_getschedparam" | "pthread_setschedparam" | "pthread_setschedprio" | + "pthread_sigmask" | "ptrace" | "quotactl" | "readahead" | "reboot" | "removexattr" | + "sched_getaffinity" | "sched_getparam" | "sched_get_priority_max" | + "sched_get_priority_min" | "sched_getscheduler" | "sched_rr_get_interval" | + "sched_setaffinity" | "sched_setparam" | "sched_setscheduler" | "sem_close" | + "semctl" | "semget" | "semop" | "sem_open" | "sem_timedwait" | "sem_unlink" | + "sendfile" | "setfsgid" | "setfsuid" | "sethostname" | "setns" | "setspent" | + "settimeofday" | "setxattr" | "shmat" | "shmctl" | "shmdt" | "shmget" | + "sigaltstack" | "signalfd" | "sigsuspend" | "sigtimedwait" | "sigwait" | + "sigwaitinfo" | "splice" | "sync_file_range" | "sysinfo" | "tee" | "umount" | + "umount2" | "unshare" | "vmsplice" | "swapoff" | "vhangup" | "swapon" | + "personality" | "syscall" if emscripten => true, + // int vs uint. Sorry musl, your prototype declarations are "correct" in the sense that // they match the interface defined by Linux verbatim, but they conflict with other // send*/recv* syscalls diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 14bf9c5393e28..b994d1f930a55 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -62,7 +62,7 @@ s! { pub ru_nvcsw: c_long, pub ru_nivcsw: c_long, - #[cfg(any(target_env = "musl"))] + #[cfg(any(target_env = "musl", target_os = "emscripten"))] __reserved: [c_long; 16], } diff --git a/src/unix/notbsd/android/mod.rs b/src/unix/notbsd/android/mod.rs index 2a7d572dc5cc5..3b4b49e478474 100644 --- a/src/unix/notbsd/android/mod.rs +++ b/src/unix/notbsd/android/mod.rs @@ -6,6 +6,7 @@ pub type clock_t = ::c_long; pub type time_t = ::c_long; pub type suseconds_t = ::c_long; pub type off_t = ::c_long; +pub type loff_t = ::c_longlong; pub type blkcnt_t = ::c_ulong; pub type blksize_t = ::c_ulong; pub type nlink_t = u32; @@ -148,6 +149,7 @@ s! { } pub const O_TRUNC: ::c_int = 512; +pub const O_TMPFILE: ::c_int = 0o20000000 | ::O_DIRECTORY; pub const O_CLOEXEC: ::c_int = 0x80000; diff --git a/src/unix/notbsd/linux/mips/mod.rs b/src/unix/notbsd/linux/mips/mod.rs index b2ad107caedf9..65e4b717991b4 100644 --- a/src/unix/notbsd/linux/mips/mod.rs +++ b/src/unix/notbsd/linux/mips/mod.rs @@ -1,3 +1,8 @@ +pub type loff_t = ::c_longlong; +pub type dev_t = u64; +pub type ino64_t = u64; +pub type off64_t = i64; +pub type blkcnt64_t = i64; pub type fsblkcnt_t = ::c_ulong; pub type fsfilcnt_t = ::c_ulong; pub type rlim_t = c_ulong; @@ -72,6 +77,7 @@ pub const O_ACCMODE: ::c_int = 3; pub const O_DIRECT: ::c_int = 0x8000; pub const O_DIRECTORY: ::c_int = 0x10000; pub const O_NOFOLLOW: ::c_int = 0x20000; +pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY; pub const ST_RELATIME: ::c_ulong = 4096; pub const NI_MAXHOST: ::socklen_t = 1025; diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index 7404f2ce43af7..743a48bfafee0 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -3,13 +3,9 @@ use dox::{mem, Option}; pub type useconds_t = u32; -pub type dev_t = u64; pub type socklen_t = u32; pub type pthread_t = c_ulong; pub type mode_t = u32; -pub type ino64_t = u64; -pub type off64_t = i64; -pub type blkcnt64_t = i64; pub type rlim64_t = u64; pub type shmatt_t = ::c_ulong; pub type mqd_t = ::c_int; @@ -68,20 +64,20 @@ s! { pub struct pthread_mutex_t { #[cfg(any(target_arch = "mips", target_arch = "arm", - target_arch = "powerpc"))] + target_arch = "powerpc", target_os = "emscripten"))] __align: [::c_long; 0], #[cfg(not(any(target_arch = "mips", target_arch = "arm", - target_arch = "powerpc")))] + target_arch = "powerpc", target_os = "emscripten")))] __align: [::c_longlong; 0], size: [u8; __SIZEOF_PTHREAD_MUTEX_T], } pub struct pthread_rwlock_t { #[cfg(any(target_arch = "mips", target_arch = "arm", - target_arch = "powerpc"))] + target_arch = "powerpc", target_os = "emscripten"))] __align: [::c_long; 0], #[cfg(not(any(target_arch = "mips", target_arch = "arm", - target_arch = "powerpc")))] + target_arch = "powerpc", target_os = "emscripten")))] __align: [::c_longlong; 0], size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], } @@ -99,9 +95,9 @@ s! { } pub struct pthread_cond_t { - #[cfg(any(target_env = "musl"))] + #[cfg(any(target_env = "musl", target_os = "emscripten"))] __align: [*const ::c_void; 0], - #[cfg(not(any(target_env = "musl")))] + #[cfg(not(any(target_env = "musl", target_os = "emscripten")))] __align: [::c_longlong; 0], size: [u8; __SIZEOF_PTHREAD_COND_T], } @@ -747,30 +743,64 @@ f! { set1.bits == set2.bits } - pub fn major(dev: ::dev_t) -> ::c_uint { - let mut major = 0; - major |= (dev & 0x00000000000fff00) >> 8; - major |= (dev & 0xfffff00000000000) >> 32; - major as ::c_uint - } - - pub fn minor(dev: ::dev_t) -> ::c_uint { - let mut minor = 0; - minor |= (dev & 0xfffff00000000000) >> 0; - minor |= (dev & 0x00000ffffff00000) >> 12; - minor as ::c_uint - } - pub fn makedev(major: ::c_uint, minor: ::c_uint) -> ::dev_t { let major = major as ::dev_t; let minor = minor as ::dev_t; let mut dev = 0; dev |= (major & 0x00000fff) << 8; - dev |= (major & 0xfffff000) << 32; + dev |= (major & 0xfffff000) << 31 << 1; // allow exceeding_bitshifts dev |= (minor & 0x000000ff) << 0; dev |= (minor & 0xffffff00) << 12; dev } + + pub fn major(dev: ::dev_t) -> ::c_uint { + cfg_if! { + if #[cfg(target_os = "emscripten")] { + // see + // https://github.com/kripken/emscripten/blob/ + // master/system/include/libc/sys/sysmacros.h + fn inner(dev: ::dev_t) -> ::c_uint { + let mut major = 0; + major |= (dev & 0x00000fff) >> 8; + major |= (dev & 0xfffff000) >> 31 >> 1; + major as ::c_uint + } + } else { + fn inner(dev: ::dev_t) -> ::c_uint { + let mut major = 0; + major |= (dev & 0x00000000000fff00) >> 8; + major |= (dev & 0xfffff00000000000) >> 32; + major as ::c_uint + } + } + }; + inner(dev) + } + + pub fn minor(dev: ::dev_t) -> ::c_uint { + cfg_if! { + if #[cfg(target_os = "emscripten")] { + // see + // https://github.com/kripken/emscripten/blob/ + // master/system/include/libc/sys/sysmacros.h + fn inner(dev: ::dev_t) -> ::c_uint { + let mut minor = 0; + minor |= (dev & 0x000000ff) >> 0; + minor |= (dev & 0xffffff00) >> 12; + minor as ::c_uint + } + } else { + fn inner(dev: ::dev_t) -> ::c_uint { + let mut minor = 0; + minor |= (dev & 0xfffff00000000000) >> 0; + minor |= (dev & 0x00000ffffff00000) >> 12; + minor as ::c_uint + } + } + }; + inner(dev) + } } extern { diff --git a/src/unix/notbsd/linux/musl/b32/arm.rs b/src/unix/notbsd/linux/musl/b32/arm.rs index ce198aca9285e..0399f58bd64eb 100644 --- a/src/unix/notbsd/linux/musl/b32/arm.rs +++ b/src/unix/notbsd/linux/musl/b32/arm.rs @@ -1,5 +1,16 @@ pub type c_char = u8; pub type wchar_t = u32; +pub type loff_t = ::c_longlong; +pub type ino_t = u64; +pub type off_t = i64; +pub type blkcnt_t = i64; +pub type blksize_t = ::c_long; +pub type fsblkcnt_t = ::c_ulonglong; +pub type fsfilcnt_t = ::c_ulonglong; +pub type dev_t = u64; +pub type ino64_t = u64; +pub type off64_t = i64; +pub type blkcnt64_t = i64; s! { pub struct stat { @@ -109,8 +120,11 @@ s! { } } +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24; + pub const O_DIRECT: ::c_int = 0x4000; pub const O_DIRECTORY: ::c_int = 0x10000; +pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY; pub const O_NOFOLLOW: ::c_int = 0x20000; pub const O_ASYNC: ::c_int = 0x2000; @@ -236,6 +250,8 @@ pub const ENOTRECOVERABLE: ::c_int = 131; pub const ERFKILL: ::c_int = 132; pub const EHWPOISON: ::c_int = 133; +pub const POSIX_MADV_DONTNEED: ::c_int = 4; + pub const SO_REUSEADDR: ::c_int = 2; pub const SO_TYPE: ::c_int = 3; pub const SO_ERROR: ::c_int = 4; diff --git a/src/unix/notbsd/linux/musl/b32/asmjs.rs b/src/unix/notbsd/linux/musl/b32/asmjs.rs index e890a34585f9c..59ecbb555f6ec 100644 --- a/src/unix/notbsd/linux/musl/b32/asmjs.rs +++ b/src/unix/notbsd/linux/musl/b32/asmjs.rs @@ -1,5 +1,16 @@ -pub type c_char = u8; -pub type wchar_t = u32; +pub type c_char = i8; +pub type wchar_t = i32; +pub type loff_t = i32; +pub type ino_t = u32; +pub type off_t = i32; +pub type blkcnt_t = i32; +pub type blksize_t = i32; +pub type fsblkcnt_t = u32; +pub type fsfilcnt_t = u32; +pub type dev_t = u32; +pub type ino64_t = u32; +pub type off64_t = i32; +pub type blkcnt64_t = i32; s! { pub struct stat { @@ -109,8 +120,11 @@ s! { } } +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 28; + pub const O_DIRECT: ::c_int = 0x4000; pub const O_DIRECTORY: ::c_int = 0x10000; +pub const O_TMPFILE: ::c_int = 0o20000000; pub const O_NOFOLLOW: ::c_int = 0x20000; pub const O_ASYNC: ::c_int = 0x2000; @@ -236,6 +250,8 @@ pub const ENOTRECOVERABLE: ::c_int = 131; pub const ERFKILL: ::c_int = 132; pub const EHWPOISON: ::c_int = 133; +pub const POSIX_MADV_DONTNEED: ::c_int = 0; + pub const SO_REUSEADDR: ::c_int = 2; pub const SO_TYPE: ::c_int = 3; pub const SO_ERROR: ::c_int = 4; diff --git a/src/unix/notbsd/linux/musl/b32/mips.rs b/src/unix/notbsd/linux/musl/b32/mips.rs index 23c1a267e664a..2e92960f7a4df 100644 --- a/src/unix/notbsd/linux/musl/b32/mips.rs +++ b/src/unix/notbsd/linux/musl/b32/mips.rs @@ -1,5 +1,16 @@ pub type c_char = i8; pub type wchar_t = ::c_int; +pub type loff_t = ::c_longlong; +pub type ino_t = u64; +pub type off_t = i64; +pub type blkcnt_t = i64; +pub type blksize_t = ::c_long; +pub type fsblkcnt_t = ::c_ulonglong; +pub type fsfilcnt_t = ::c_ulonglong; +pub type dev_t = u64; +pub type ino64_t = u64; +pub type off64_t = i64; +pub type blkcnt64_t = i64; s! { pub struct stat { @@ -117,8 +128,11 @@ s! { } } +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24; + pub const O_DIRECT: ::c_int = 0o100000; pub const O_DIRECTORY: ::c_int = 0o200000; +pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY; pub const O_NOFOLLOW: ::c_int = 0o400000; pub const O_ASYNC: ::c_int = 0o10000; @@ -238,6 +252,8 @@ pub const ENOTRECOVERABLE: ::c_int = 166; pub const EHWPOISON: ::c_int = 168; pub const ERFKILL: ::c_int = 167; +pub const POSIX_MADV_DONTNEED: ::c_int = 4; + pub const SOCK_STREAM: ::c_int = 2; pub const SOCK_DGRAM: ::c_int = 1; pub const SOCK_SEQPACKET: ::c_int = 5; diff --git a/src/unix/notbsd/linux/musl/b32/mod.rs b/src/unix/notbsd/linux/musl/b32/mod.rs index 61eb6dba17414..4a9a6877ac563 100644 --- a/src/unix/notbsd/linux/musl/b32/mod.rs +++ b/src/unix/notbsd/linux/musl/b32/mod.rs @@ -4,7 +4,10 @@ pub type nlink_t = u32; s! { pub struct pthread_attr_t { - __size: [u32; 9] + #[cfg(target_os = "emscripten")] + __size: [u32; 11], + #[cfg(not(target_os = "emscripten"))] + __size: [u32; 9], } pub struct sigset_t { @@ -33,7 +36,6 @@ s! { } pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32; -pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24; cfg_if! { if #[cfg(any(target_arch = "x86"))] { diff --git a/src/unix/notbsd/linux/musl/b32/x86.rs b/src/unix/notbsd/linux/musl/b32/x86.rs index 9daeb58b99869..da8ccb6c87dcd 100644 --- a/src/unix/notbsd/linux/musl/b32/x86.rs +++ b/src/unix/notbsd/linux/musl/b32/x86.rs @@ -1,5 +1,16 @@ pub type c_char = i8; pub type wchar_t = i32; +pub type loff_t = ::c_longlong; +pub type ino_t = u64; +pub type off_t = i64; +pub type blkcnt_t = i64; +pub type blksize_t = ::c_long; +pub type fsblkcnt_t = ::c_ulonglong; +pub type fsfilcnt_t = ::c_ulonglong; +pub type dev_t = u64; +pub type ino64_t = u64; +pub type off64_t = i64; +pub type blkcnt64_t = i64; s! { pub struct stat { @@ -122,8 +133,11 @@ s! { } } +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24; + pub const O_DIRECT: ::c_int = 0x4000; pub const O_DIRECTORY: ::c_int = 0x10000; +pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY; pub const O_NOFOLLOW: ::c_int = 0x20000; pub const O_ASYNC: ::c_int = 0x2000; @@ -249,6 +263,8 @@ pub const ENOTRECOVERABLE: ::c_int = 131; pub const ERFKILL: ::c_int = 132; pub const EHWPOISON: ::c_int = 133; +pub const POSIX_MADV_DONTNEED: ::c_int = 4; + pub const SO_REUSEADDR: ::c_int = 2; pub const SO_TYPE: ::c_int = 3; pub const SO_ERROR: ::c_int = 4; diff --git a/src/unix/notbsd/linux/musl/b64/mod.rs b/src/unix/notbsd/linux/musl/b64/mod.rs index fab0b58fed9b7..8e1a2fd2ec4ca 100644 --- a/src/unix/notbsd/linux/musl/b64/mod.rs +++ b/src/unix/notbsd/linux/musl/b64/mod.rs @@ -2,6 +2,17 @@ pub type wchar_t = i32; pub type c_long = i64; pub type c_ulong = u64; pub type nlink_t = u64; +pub type loff_t = ::c_longlong; +pub type ino_t = u64; +pub type off_t = i64; +pub type blkcnt_t = i64; +pub type blksize_t = ::c_long; +pub type fsblkcnt_t = ::c_ulonglong; +pub type fsfilcnt_t = ::c_ulonglong; +pub type dev_t = u64; +pub type ino64_t = u64; +pub type off64_t = i64; +pub type blkcnt64_t = i64; s! { pub struct stat { @@ -139,6 +150,7 @@ pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const O_DIRECT: ::c_int = 0x4000; pub const O_DIRECTORY: ::c_int = 0x10000; +pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY; pub const O_NOFOLLOW: ::c_int = 0x20000; pub const O_ASYNC: ::c_int = 0x2000; @@ -265,6 +277,8 @@ pub const ENOTRECOVERABLE: ::c_int = 131; pub const ERFKILL: ::c_int = 132; pub const EHWPOISON: ::c_int = 133; +pub const POSIX_MADV_DONTNEED: ::c_int = 4; + pub const SO_REUSEADDR: ::c_int = 2; pub const SO_TYPE: ::c_int = 3; pub const SO_ERROR: ::c_int = 4; diff --git a/src/unix/notbsd/linux/musl/mod.rs b/src/unix/notbsd/linux/musl/mod.rs index b365028b76aca..593023fb2a02d 100644 --- a/src/unix/notbsd/linux/musl/mod.rs +++ b/src/unix/notbsd/linux/musl/mod.rs @@ -1,13 +1,6 @@ pub type clock_t = c_long; pub type time_t = c_long; pub type suseconds_t = c_long; -pub type ino_t = u64; -pub type off_t = i64; -pub type blkcnt_t = i64; - -pub type blksize_t = c_long; -pub type fsblkcnt_t = ::c_ulonglong; -pub type fsfilcnt_t = ::c_ulonglong; pub type rlim_t = ::c_ulonglong; s! { @@ -131,10 +124,9 @@ pub const O_ACCMODE: ::c_int = 0o10000003; pub const O_NDELAY: ::c_int = O_NONBLOCK; pub const NI_MAXHOST: ::socklen_t = 255; pub const PTHREAD_STACK_MIN: ::size_t = 2048; -pub const POSIX_FADV_DONTNEED: ::c_int = 4; pub const POSIX_FADV_NOREUSE: ::c_int = 5; -pub const POSIX_MADV_DONTNEED: ::c_int = 4; +pub const POSIX_FADV_DONTNEED: ::c_int = 4; pub const RLIM_INFINITY: ::rlim_t = !0; pub const RLIMIT_RTTIME: ::c_int = 15; diff --git a/src/unix/notbsd/linux/other/mod.rs b/src/unix/notbsd/linux/other/mod.rs index b7a11a85e9627..ef4b6df69251e 100644 --- a/src/unix/notbsd/linux/other/mod.rs +++ b/src/unix/notbsd/linux/other/mod.rs @@ -1,7 +1,12 @@ +pub type loff_t = ::c_longlong; pub type fsblkcnt_t = ::c_ulong; pub type fsfilcnt_t = ::c_ulong; pub type rlim_t = c_ulong; pub type __priority_which_t = ::c_uint; +pub type dev_t = u64; +pub type ino64_t = u64; +pub type off64_t = i64; +pub type blkcnt64_t = i64; s! { pub struct aiocb { @@ -169,6 +174,8 @@ s! { } } +pub const O_TMPFILE: ::c_int = 0o20000000 | ::O_DIRECTORY; + pub const __UT_LINESIZE: usize = 32; pub const __UT_NAMESIZE: usize = 32; pub const __UT_HOSTSIZE: usize = 256; diff --git a/src/unix/notbsd/linux/s390x.rs b/src/unix/notbsd/linux/s390x.rs index 1c0cd56d6f14c..52557b7302edb 100644 --- a/src/unix/notbsd/linux/s390x.rs +++ b/src/unix/notbsd/linux/s390x.rs @@ -8,6 +8,7 @@ pub type fsfilcnt_t = u64; pub type ino_t = u64; pub type nlink_t = u64; pub type off_t = i64; +pub type loff_t = ::c_longlong; pub type rlim_t = u64; pub type suseconds_t = i64; pub type time_t = i64; @@ -16,6 +17,10 @@ pub type greg_t = u64; pub type clock_t = i64; pub type __fsword_t = ::c_long; pub type __priority_which_t = ::c_uint; +pub type dev_t = u64; +pub type ino64_t = u64; +pub type off64_t = i64; +pub type blkcnt64_t = i64; s! { pub struct aiocb { @@ -366,6 +371,7 @@ pub const O_FSYNC: ::c_int = 0x101000; pub const O_DIRECT: ::c_int = 0x4000; pub const O_DIRECTORY: ::c_int = 0x10000; pub const O_NOFOLLOW: ::c_int = 0x20000; +pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY; pub const SOCK_NONBLOCK: ::c_int = O_NONBLOCK; diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index e10d28b304d70..95cc9c21c4e50 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -4,7 +4,6 @@ pub type sa_family_t = u16; pub type pthread_key_t = ::c_uint; pub type speed_t = ::c_uint; pub type tcflag_t = ::c_uint; -pub type loff_t = ::c_longlong; pub type clockid_t = ::c_int; pub type key_t = ::c_int; pub type id_t = ::c_uint; @@ -103,13 +102,13 @@ s! { pub struct sched_param { pub sched_priority: ::c_int, - #[cfg(any(target_env = "musl"))] + #[cfg(any(target_env = "musl", target_os = "emscripten"))] pub sched_ss_low_priority: ::c_int, - #[cfg(any(target_env = "musl"))] + #[cfg(any(target_env = "musl", target_os = "emscripten"))] pub sched_ss_repl_period: ::timespec, - #[cfg(any(target_env = "musl"))] + #[cfg(any(target_env = "musl", target_os = "emscripten"))] pub sched_ss_init_budget: ::timespec, - #[cfg(any(target_env = "musl"))] + #[cfg(any(target_env = "musl", target_os = "emscripten"))] pub sched_ss_max_repl: ::c_int, } @@ -255,7 +254,6 @@ pub const RUSAGE_SELF: ::c_int = 0; pub const O_RDONLY: ::c_int = 0; pub const O_WRONLY: ::c_int = 1; pub const O_RDWR: ::c_int = 2; -pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY; pub const SOCK_CLOEXEC: ::c_int = O_CLOEXEC;