diff --git a/build.rs b/build.rs index 60dda363c7830..a4272bade9619 100644 --- a/build.rs +++ b/build.rs @@ -17,6 +17,7 @@ const ALLOWED_CFGS: &'static [&'static str] = &[ "libc_const_extern_fn", "libc_const_extern_fn_unstable", "libc_deny_warnings", + "musl_time64_abi", ]; // Extra values to allow for check-cfg. @@ -67,6 +68,12 @@ fn main() { Some(_) | None => (), } + // Some ABIs need to redirect time related symbols to their time64 + // equivalents. See #2088 and #1848 for more information. + if is_musl_time64_abi() { + set_cfg("musl_time64_abi"); + } + // On CI: deny all warnings if libc_ci { set_cfg("libc_deny_warnings"); @@ -213,3 +220,22 @@ fn set_cfg(cfg: &str) { } println!("cargo:rustc-cfg={}", cfg); } + +fn is_musl_time64_abi() -> bool { + match env::var("TARGET") { + Ok(target) => match &target[..] { + "arm-unknown-linux-musleabi" + | "arm-unknown-linux-musleabihf" + | "armv5te-unknown-linux-musleabi" + | "armv7-unknown-linux-musleabi" + | "armv7-unknown-linux-musleabihf" + | "i586-unknown-linux-musl" + | "i686-unknown-linux-musl" + | "mips-unknown-linux-musl" + | "mipsel-unknown-linux-musl" + | "powerpc-unknown-linux-musl" => true, + _ => false, + }, + Err(_) => false, + } +} diff --git a/ci/install-musl.sh b/ci/install-musl.sh index 7ea50916c4caf..b26495696cccc 100644 --- a/ci/install-musl.sh +++ b/ci/install-musl.sh @@ -5,7 +5,7 @@ set -ex -MUSL_VERSION=1.1.24 +MUSL_VERSION=1.2.3 MUSL="musl-${MUSL_VERSION}" # Download, configure, build, and install musl: diff --git a/libc-test/build.rs b/libc-test/build.rs index 16964b75e1d62..9317f164a8458 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -3301,6 +3301,23 @@ fn test_linux(target: &str) { // deprecated since glibc >= 2.29. This allows Rust binaries to link against // glibc versions older than 2.29. cfg.define("__GLIBC_USE_DEPRECATED_SCANF", None); + // Some targets use time64 symbols so set the musl_time64_abi appropriately. + // See #2088 and #1848 for more information. + match target { + "arm-unknown-linux-musleabi" + | "arm-unknown-linux-musleabihf" + | "armv5te-unknown-linux-musleabi" + | "armv7-unknown-linux-musleabi" + | "armv7-unknown-linux-musleabihf" + | "i586-unknown-linux-musl" + | "i686-unknown-linux-musl" + | "mips-unknown-linux-musl" + | "mipsel-unknown-linux-musl" + | "powerpc-unknown-linux-musl" => { + cfg.cfg("musl_time64_abi", None); + } + _ => {} + } headers! { cfg: "ctype.h", @@ -3506,6 +3523,10 @@ fn test_linux(target: &str) { // typedefs don't need any keywords t if t.ends_with("_t") => t.to_string(), + + // In MUSL, `flock64` is a typedef to `flock` and `stat64` is a typedef to `stat`. + "flock64" | "stat64" if musl => format!("struct {}", ty), + // put `struct` in front of all structs:. t if is_struct => format!("struct {}", t), // put `union` in front of all unions: @@ -3862,6 +3883,9 @@ fn test_linux(target: &str) { // - these constants are used by the glibc implementation. n if musl && n.contains("__SIZEOF_PTHREAD") => true, + // FIXME: ctest reports incorrect values for both Rust/libc and C/musl. + "IPC_STAT" if musl => true, + // FIXME: It was extended to 4096 since glibc 2.31 (Linux 5.4). // We should do so after a while. "SOMAXCONN" if gnu => true, diff --git a/src/unix/linux_like/emscripten/lfs64.rs b/src/unix/linux_like/emscripten/lfs64.rs index 1616cc90494be..a90a76695ffd2 100644 --- a/src/unix/linux_like/emscripten/lfs64.rs +++ b/src/unix/linux_like/emscripten/lfs64.rs @@ -106,7 +106,12 @@ pub unsafe extern "C" fn mmap64( // // These aliases are mostly fine though, neither function takes a LFS64-namespaced type as an // argument, nor do their names clash with any declared types. +// +// Targets wasm32-unknown-emscripten in CI recognize them as unused imports. +// Like the same one at src/unix/linux_like/linux/musl/lfs64.rs, here they are also allowed. +#[allow(unused_imports)] pub use open as open64; +#[allow(unused_imports)] pub use openat as openat64; #[inline] diff --git a/src/unix/linux_like/linux/arch/generic/mod.rs b/src/unix/linux_like/linux/arch/generic/mod.rs index 2f437e16db26a..3befa73dfcf0a 100644 --- a/src/unix/linux_like/linux/arch/generic/mod.rs +++ b/src/unix/linux_like/linux/arch/generic/mod.rs @@ -37,8 +37,25 @@ pub const SO_PASSCRED: ::c_int = 16; pub const SO_PEERCRED: ::c_int = 17; pub const SO_RCVLOWAT: ::c_int = 18; pub const SO_SNDLOWAT: ::c_int = 19; -pub const SO_RCVTIMEO: ::c_int = 20; -pub const SO_SNDTIMEO: ::c_int = 21; + +cfg_if! { + if #[cfg(not(musl_time64_abi))] { + pub const SO_RCVTIMEO: ::c_int = 20; + pub const SO_SNDTIMEO: ::c_int = 21; + pub const SO_TIMESTAMP: ::c_int = 29; + pub const SO_TIMESTAMPNS: ::c_int = 35; + pub const SO_TIMESTAMPING: ::c_int = 37; + pub const SCM_TIMESTAMPING: ::c_int = SO_TIMESTAMPING; + } else { + pub const SO_RCVTIMEO: ::c_int = 66; + pub const SO_SNDTIMEO: ::c_int = 67; + pub const SO_TIMESTAMP: ::c_int = 63; + pub const SO_TIMESTAMPNS: ::c_int = 64; + pub const SO_TIMESTAMPING: ::c_int = 65; + pub const SCM_TIMESTAMPING: ::c_int = 65; + } +} + // pub const SO_RCVTIMEO_OLD: ::c_int = 20; // pub const SO_SNDTIMEO_OLD: ::c_int = 21; pub const SO_SECURITY_AUTHENTICATION: ::c_int = 22; @@ -49,17 +66,14 @@ pub const SO_ATTACH_FILTER: ::c_int = 26; pub const SO_DETACH_FILTER: ::c_int = 27; pub const SO_GET_FILTER: ::c_int = SO_ATTACH_FILTER; pub const SO_PEERNAME: ::c_int = 28; -pub const SO_TIMESTAMP: ::c_int = 29; // pub const SO_TIMESTAMP_OLD: ::c_int = 29; pub const SO_ACCEPTCONN: ::c_int = 30; pub const SO_PEERSEC: ::c_int = 31; pub const SO_SNDBUFFORCE: ::c_int = 32; pub const SO_RCVBUFFORCE: ::c_int = 33; pub const SO_PASSSEC: ::c_int = 34; -pub const SO_TIMESTAMPNS: ::c_int = 35; // pub const SO_TIMESTAMPNS_OLD: ::c_int = 35; pub const SO_MARK: ::c_int = 36; -pub const SO_TIMESTAMPING: ::c_int = 37; // pub const SO_TIMESTAMPING_OLD: ::c_int = 37; pub const SO_PROTOCOL: ::c_int = 38; pub const SO_DOMAIN: ::c_int = 39; @@ -126,7 +140,6 @@ cfg_if! { // Defined in unix/linux_like/mod.rs // pub const SCM_TIMESTAMP: ::c_int = SO_TIMESTAMP; pub const SCM_TIMESTAMPNS: ::c_int = SO_TIMESTAMPNS; -pub const SCM_TIMESTAMPING: ::c_int = SO_TIMESTAMPING; // Ioctl Constants @@ -311,10 +324,7 @@ cfg_if! { pub const RLIMIT_NICE: ::c_int = 13; pub const RLIMIT_RTPRIO: ::c_int = 14; pub const RLIMIT_RTTIME: ::c_int = 15; - #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] - pub const RLIM_NLIMITS: ::c_int = 15; - #[allow(deprecated)] - #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] + pub const RLIM_NLIMITS: ::c_int = 16; pub const RLIMIT_NLIMITS: ::c_int = RLIM_NLIMITS; } } diff --git a/src/unix/linux_like/linux/arch/mips/mod.rs b/src/unix/linux_like/linux/arch/mips/mod.rs index 6a96aa9c3b159..c4aef6e551876 100644 --- a/src/unix/linux_like/linux/arch/mips/mod.rs +++ b/src/unix/linux_like/linux/arch/mips/mod.rs @@ -33,8 +33,15 @@ pub const SO_RCVLOWAT: ::c_int = 0x1004; // NOTE: These definitions are now being renamed with _OLD postfix, // but CI haven't support them yet. // Some related consts could be found in b32.rs and b64.rs -pub const SO_SNDTIMEO: ::c_int = 0x1005; -pub const SO_RCVTIMEO: ::c_int = 0x1006; +cfg_if! { + if #[cfg(target_env = "musl")] { + pub const SO_SNDTIMEO: ::c_int = 0x43; + pub const SO_RCVTIMEO: ::c_int = 0x42; + } else { + pub const SO_SNDTIMEO: ::c_int = 0x1005; + pub const SO_RCVTIMEO: ::c_int = 0x1006; + } +} // pub const SO_SNDTIMEO_OLD: ::c_int = 0x1005; // pub const SO_RCVTIMEO_OLD: ::c_int = 0x1006; pub const SO_ACCEPTCONN: ::c_int = 0x1009; @@ -88,9 +95,17 @@ pub const SO_BINDTOIFINDEX: ::c_int = 62; // NOTE: These definitions are now being renamed with _OLD postfix, // but CI haven't support them yet. // Some related consts could be found in b32.rs and b64.rs -pub const SO_TIMESTAMP: ::c_int = 29; -pub const SO_TIMESTAMPNS: ::c_int = 35; -pub const SO_TIMESTAMPING: ::c_int = 37; +cfg_if! { + if #[cfg(target_env = "musl")] { + pub const SO_TIMESTAMP: ::c_int = 63; + pub const SO_TIMESTAMPNS: ::c_int = 64; + pub const SO_TIMESTAMPING: ::c_int = 65; + } else { + pub const SO_TIMESTAMP: ::c_int = 29; + pub const SO_TIMESTAMPNS: ::c_int = 35; + pub const SO_TIMESTAMPING: ::c_int = 37; + } +} // pub const SO_TIMESTAMP_OLD: ::c_int = 29; // pub const SO_TIMESTAMPNS_OLD: ::c_int = 35; // pub const SO_TIMESTAMPING_OLD: ::c_int = 37; @@ -287,10 +302,7 @@ cfg_if! { pub const RLIMIT_NICE: ::c_int = 13; pub const RLIMIT_RTPRIO: ::c_int = 14; pub const RLIMIT_RTTIME: ::c_int = 15; - #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] - pub const RLIM_NLIMITS: ::c_int = 15; - #[allow(deprecated)] - #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] + pub const RLIM_NLIMITS: ::c_int = 16; pub const RLIMIT_NLIMITS: ::c_int = RLIM_NLIMITS; pub const RLIM_INFINITY: ::rlim_t = !0; } diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 2ce09ed168df8..19e19d8459d1f 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -322,6 +322,11 @@ s! { } pub struct input_event { + #[cfg(musl_time64_abi)] + pub input_event_sec: ::c_ulong, + #[cfg(musl_time64_abi)] + pub input_event_usec: ::c_ulong, + #[cfg(not(musl_time64_abi))] pub time: ::timeval, pub type_: ::__u16, pub code: ::__u16, @@ -5345,6 +5350,7 @@ cfg_if! { pub fn aio_fsync(op: ::c_int, aiocbp: *mut aiocb) -> ::c_int; pub fn aio_error(aiocbp: *const aiocb) -> ::c_int; pub fn aio_return(aiocbp: *mut aiocb) -> ::ssize_t; + #[cfg_attr(musl_time64_abi, link_name = "__aio_suspend_time64")] pub fn aio_suspend( aiocb_list: *const *const aiocb, nitems: ::c_int, @@ -5405,6 +5411,7 @@ cfg_if! { riovcnt: ::c_ulong, flags: ::c_ulong, ) -> isize; + #[cfg_attr(musl_time64_abi, link_name = "__futimes_time64")] pub fn futimes( fd: ::c_int, times: *const ::timeval @@ -5428,43 +5435,6 @@ cfg_if! { spbufp: *mut *mut spwd, ) -> ::c_int; - pub fn mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t; - pub fn mq_close(mqd: ::mqd_t) -> ::c_int; - pub fn mq_unlink(name: *const ::c_char) -> ::c_int; - pub fn mq_receive( - mqd: ::mqd_t, - msg_ptr: *mut ::c_char, - msg_len: ::size_t, - msg_prio: *mut ::c_uint, - ) -> ::ssize_t; - pub fn mq_timedreceive( - mqd: ::mqd_t, - msg_ptr: *mut ::c_char, - msg_len: ::size_t, - msg_prio: *mut ::c_uint, - abs_timeout: *const ::timespec, - ) -> ::ssize_t; - pub fn mq_send( - mqd: ::mqd_t, - msg_ptr: *const ::c_char, - msg_len: ::size_t, - msg_prio: ::c_uint, - ) -> ::c_int; - pub fn mq_timedsend( - mqd: ::mqd_t, - msg_ptr: *const ::c_char, - msg_len: ::size_t, - msg_prio: ::c_uint, - abs_timeout: *const ::timespec, - ) -> ::c_int; - pub fn mq_getattr(mqd: ::mqd_t, attr: *mut ::mq_attr) -> ::c_int; - pub fn mq_setattr( - mqd: ::mqd_t, - newattr: *const ::mq_attr, - oldattr: *mut ::mq_attr - ) -> ::c_int; - - pub fn pthread_mutex_consistent(mutex: *mut pthread_mutex_t) -> ::c_int; pub fn pthread_cancel(thread: ::pthread_t) -> ::c_int; pub fn pthread_mutexattr_getrobust( attr: *const pthread_mutexattr_t, @@ -5500,6 +5470,7 @@ extern "C" { pub fn seed48(xseed: *mut ::c_ushort) -> *mut ::c_ushort; pub fn lcong48(p: *mut ::c_ushort); + #[cfg_attr(musl_time64_abi, link_name = "__lutimes_time64")] pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int; pub fn setpwent(); @@ -5595,7 +5566,9 @@ extern "C" { pub fn fremovexattr(filedes: ::c_int, name: *const c_char) -> ::c_int; pub fn signalfd(fd: ::c_int, mask: *const ::sigset_t, flags: ::c_int) -> ::c_int; pub fn timerfd_create(clockid: ::clockid_t, flags: ::c_int) -> ::c_int; + #[cfg_attr(musl_time64_abi, link_name = "__timerfd_gettime64")] pub fn timerfd_gettime(fd: ::c_int, curr_value: *mut itimerspec) -> ::c_int; + #[cfg_attr(musl_time64_abi, link_name = "__timerfd_settime64")] pub fn timerfd_settime( fd: ::c_int, flags: ::c_int, @@ -5608,6 +5581,39 @@ extern "C" { id: ::c_int, data: *mut ::c_char, ) -> ::c_int; + pub fn mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t; + pub fn mq_close(mqd: ::mqd_t) -> ::c_int; + pub fn mq_unlink(name: *const ::c_char) -> ::c_int; + pub fn mq_receive( + mqd: ::mqd_t, + msg_ptr: *mut ::c_char, + msg_len: ::size_t, + msg_prio: *mut ::c_uint, + ) -> ::ssize_t; + #[cfg_attr(musl_time64_abi, link_name = "__mq_timedreceive_time64")] + pub fn mq_timedreceive( + mqd: ::mqd_t, + msg_ptr: *mut ::c_char, + msg_len: ::size_t, + msg_prio: *mut ::c_uint, + abs_timeout: *const ::timespec, + ) -> ::ssize_t; + pub fn mq_send( + mqd: ::mqd_t, + msg_ptr: *const ::c_char, + msg_len: ::size_t, + msg_prio: ::c_uint, + ) -> ::c_int; + #[cfg_attr(musl_time64_abi, link_name = "__mq_timedsend_time64")] + pub fn mq_timedsend( + mqd: ::mqd_t, + msg_ptr: *const ::c_char, + msg_len: ::size_t, + msg_prio: ::c_uint, + abs_timeout: *const ::timespec, + ) -> ::c_int; + pub fn mq_getattr(mqd: ::mqd_t, attr: *mut ::mq_attr) -> ::c_int; + pub fn mq_setattr(mqd: ::mqd_t, newattr: *const ::mq_attr, oldattr: *mut ::mq_attr) -> ::c_int; pub fn epoll_pwait( epfd: ::c_int, events: *mut ::epoll_event, @@ -5618,6 +5624,7 @@ extern "C" { pub fn dup3(oldfd: ::c_int, newfd: ::c_int, flags: ::c_int) -> ::c_int; pub fn mkostemp(template: *mut ::c_char, flags: ::c_int) -> ::c_int; pub fn mkostemps(template: *mut ::c_char, suffixlen: ::c_int, flags: ::c_int) -> ::c_int; + #[cfg_attr(musl_time64_abi, link_name = "__sigtimedwait_time64")] pub fn sigtimedwait( set: *const sigset_t, info: *mut siginfo_t, @@ -5731,6 +5738,7 @@ extern "C" { pub fn umount(target: *const ::c_char) -> ::c_int; pub fn sched_get_priority_max(policy: ::c_int) -> ::c_int; pub fn tee(fd_in: ::c_int, fd_out: ::c_int, len: ::size_t, flags: ::c_uint) -> ::ssize_t; + #[cfg_attr(musl_time64_abi, link_name = "__settimeofday_time64")] pub fn settimeofday(tv: *const ::timeval, tz: *const ::timezone) -> ::c_int; pub fn splice( fd_in: ::c_int, @@ -5744,7 +5752,9 @@ extern "C" { pub fn eventfd_read(fd: ::c_int, value: *mut eventfd_t) -> ::c_int; pub fn eventfd_write(fd: ::c_int, value: eventfd_t) -> ::c_int; + #[cfg_attr(musl_time64_abi, link_name = "__sched_rr_get_interval_time64")] pub fn sched_rr_get_interval(pid: ::pid_t, tp: *mut ::timespec) -> ::c_int; + #[cfg_attr(musl_time64_abi, link_name = "__sem_timedwait_time64")] pub fn sem_timedwait(sem: *mut sem_t, abstime: *const ::timespec) -> ::c_int; pub fn sem_getvalue(sem: *mut sem_t, sval: *mut ::c_int) -> ::c_int; pub fn sched_setparam(pid: ::pid_t, param: *const ::sched_param) -> ::c_int; @@ -5766,6 +5776,7 @@ extern "C" { pub fn personality(persona: ::c_ulong) -> ::c_int; pub fn prctl(option: ::c_int, ...) -> ::c_int; pub fn sched_getparam(pid: ::pid_t, param: *mut ::sched_param) -> ::c_int; + #[cfg_attr(musl_time64_abi, link_name = "__ppoll_time64")] pub fn ppoll( fds: *mut ::pollfd, nfds: nfds_t, @@ -5780,7 +5791,8 @@ extern "C" { attr: *mut pthread_mutexattr_t, protocol: ::c_int, ) -> ::c_int; - + pub fn pthread_mutex_consistent(mutex: *mut pthread_mutex_t) -> ::c_int; + #[cfg_attr(musl_time64_abi, link_name = "__pthread_mutex_timedlock_time64")] pub fn pthread_mutex_timedlock( lock: *mut pthread_mutex_t, abstime: *const ::timespec, @@ -5815,6 +5827,7 @@ extern "C" { ... ) -> ::c_int; pub fn sched_getscheduler(pid: ::pid_t) -> ::c_int; + #[cfg_attr(musl_time64_abi, link_name = "__clock_nanosleep_time64")] pub fn clock_nanosleep( clk_id: ::clockid_t, flags: ::c_int, @@ -6084,7 +6097,9 @@ extern "C" { ) -> ::c_int; pub fn timer_delete(timerid: ::timer_t) -> ::c_int; pub fn timer_getoverrun(timerid: ::timer_t) -> ::c_int; + #[cfg_attr(musl_time64_abi, link_name = "__timer_gettime64")] pub fn timer_gettime(timerid: ::timer_t, curr_value: *mut ::itimerspec) -> ::c_int; + #[cfg_attr(musl_time64_abi, link_name = "__timer_settime64")] pub fn timer_settime( timerid: ::timer_t, flags: ::c_int, diff --git a/src/unix/linux_like/linux/musl/b32/arm/mod.rs b/src/unix/linux_like/linux/musl/b32/arm/mod.rs index 58097f1434015..d4ea1291c6e13 100644 --- a/src/unix/linux_like/linux/musl/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/arm/mod.rs @@ -1,5 +1,6 @@ pub type c_char = u8; pub type wchar_t = u32; +pub type stat64 = ::stat; s! { pub struct stat { @@ -15,35 +16,22 @@ s! { pub st_size: ::off_t, pub st_blksize: ::blksize_t, pub st_blocks: ::blkcnt_t, - pub st_atime: ::time_t, - pub st_atime_nsec: ::c_long, - pub st_mtime: ::time_t, - pub st_mtime_nsec: ::c_long, - pub st_ctime: ::time_t, - pub st_ctime_nsec: ::c_long, + __st_atime32: ::c_long, + __st_atime32_nsec: ::c_long, + __st_mtime32: ::c_long, + __st_mtime32_nsec: ::c_long, + __st_ctime32: ::c_long, + __st_ctime32_nsec: ::c_long, pub st_ino: ::ino_t, - } - - pub struct stat64 { - pub st_dev: ::dev_t, - __st_dev_padding: ::c_int, - __st_ino_truncated: ::c_long, - pub st_mode: ::mode_t, - pub st_nlink: ::nlink_t, - pub st_uid: ::uid_t, - pub st_gid: ::gid_t, - pub st_rdev: ::dev_t, - __st_rdev_padding: ::c_int, - pub st_size: ::off_t, - pub st_blksize: ::blksize_t, - pub st_blocks: ::blkcnt_t, pub st_atime: ::time_t, pub st_atime_nsec: ::c_long, + __st_atime_nsec_padding: ::c_long, pub st_mtime: ::time_t, pub st_mtime_nsec: ::c_long, + __st_mtime_nsec_padding: ::c_long, pub st_ctime: ::time_t, pub st_ctime_nsec: ::c_long, - pub st_ino: ::ino_t, + __st_ctime_nsec_padding: ::c_long, } pub struct stack_t { @@ -67,34 +55,40 @@ s! { pub struct shmid_ds { pub shm_perm: ::ipc_perm, pub shm_segsz: ::size_t, - pub shm_atime: ::time_t, - __unused1: ::c_int, - pub shm_dtime: ::time_t, - __unused2: ::c_int, - pub shm_ctime: ::time_t, - __unused3: ::c_int, + __shm_atime_lo: ::c_ulong, + __shm_atime_hi: ::c_ulong, + __shm_dtime_lo: ::c_ulong, + __shm_dtime_hi: ::c_ulong, + __shm_ctime_lo: ::c_ulong, + __shm_ctime_hi: ::c_ulong, pub shm_cpid: ::pid_t, pub shm_lpid: ::pid_t, pub shm_nattch: ::c_ulong, __pad1: ::c_ulong, __pad2: ::c_ulong, + __pad3: ::c_ulong, + pub shm_atime: ::time_t, + pub shm_dtime: ::time_t, + pub shm_ctime: ::time_t, } pub struct msqid_ds { pub msg_perm: ::ipc_perm, - pub msg_stime: ::time_t, - __unused1: ::c_int, - pub msg_rtime: ::time_t, - __unused2: ::c_int, - pub msg_ctime: ::time_t, - __unused3: ::c_int, - __msg_cbytes: ::c_ulong, + __msg_stime_lo: ::c_ulong, + __msg_stime_hi: ::c_ulong, + __msg_rtime_lo: ::c_ulong, + __msg_rtime_hi: ::c_ulong, + __msg_ctime_lo: ::c_ulong, + __msg_ctime_hi: ::c_ulong, + pub msg_cbytes: ::c_ulong, pub msg_qnum: ::msgqnum_t, pub msg_qbytes: ::msglen_t, pub msg_lspid: ::pid_t, pub msg_lrpid: ::pid_t, - __pad1: ::c_ulong, - __pad2: ::c_ulong, + __unused: [::c_ulong; 2], + pub msg_stime: ::time_t, + pub msg_rtime: ::time_t, + pub msg_ctime: ::time_t, } pub struct statfs { diff --git a/src/unix/linux_like/linux/musl/b32/mips/mod.rs b/src/unix/linux_like/linux/musl/b32/mips/mod.rs index ab7a55b754c5e..539f25981c27c 100644 --- a/src/unix/linux_like/linux/musl/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/mips/mod.rs @@ -1,5 +1,6 @@ pub type c_char = i8; pub type wchar_t = ::c_int; +pub type stat64 = ::stat; s! { pub struct stat { @@ -13,39 +14,19 @@ s! { pub st_rdev: ::dev_t, __st_padding2: [::c_long; 2], pub st_size: ::off_t, - pub st_atime: ::time_t, - pub st_atime_nsec: ::c_long, - pub st_mtime: ::time_t, - pub st_mtime_nsec: ::c_long, - pub st_ctime: ::time_t, - pub st_ctime_nsec: ::c_long, + __st_atime32: ::c_long, + __st_atime32_nsec: ::c_long, + __st_mtime32: ::c_long, + __st_mtime32_nsec: ::c_long, + __st_ctime32: ::c_long, + __st_ctime32_nsec: ::c_long, pub st_blksize: ::blksize_t, __st_padding3: ::c_long, pub st_blocks: ::blkcnt_t, - __st_padding4: [::c_long; 14], - } - - pub struct stat64 { - pub st_dev: ::dev_t, - __st_padding1: [::c_long; 2], - pub st_ino: ::ino64_t, - pub st_mode: ::mode_t, - pub st_nlink: ::nlink_t, - pub st_uid: ::uid_t, - pub st_gid: ::gid_t, - pub st_rdev: ::dev_t, - __st_padding2: [::c_long; 2], - pub st_size: ::off_t, - pub st_atime: ::time_t, - pub st_atime_nsec: ::c_long, - pub st_mtime: ::time_t, - pub st_mtime_nsec: ::c_long, - pub st_ctime: ::time_t, - pub st_ctime_nsec: ::c_long, - pub st_blksize: ::blksize_t, - __st_padding3: ::c_long, - pub st_blocks: ::blkcnt64_t, - __st_padding4: [::c_long; 14], + pub st_atim: ::timespec, + pub st_mtim: ::timespec, + pub st_ctim: ::timespec, + __st_padding4: [::c_long; 2], } pub struct stack_t { @@ -69,40 +50,32 @@ s! { pub struct shmid_ds { pub shm_perm: ::ipc_perm, pub shm_segsz: ::size_t, - pub shm_atime: ::time_t, - pub shm_dtime: ::time_t, - pub shm_ctime: ::time_t, + __shm_atime_lo: ::c_ulong, + __shm_dtime_lo: ::c_ulong, + __shm_ctime_lo: ::c_ulong, pub shm_cpid: ::pid_t, pub shm_lpid: ::pid_t, pub shm_nattch: ::c_ulong, - __pad1: ::c_ulong, - __pad2: ::c_ulong, + __shm_atime_hi: ::c_ushort, + __shm_dtime_hi: ::c_ushort, + __shm_ctime_hi: ::c_ushort, + pub shm_atime: ::time_t, + pub shm_dtime: ::time_t, + pub shm_ctime: ::time_t, } pub struct msqid_ds { pub msg_perm: ::ipc_perm, - #[cfg(target_endian = "big")] - __unused1: ::c_int, - pub msg_stime: ::time_t, - #[cfg(target_endian = "little")] - __unused1: ::c_int, - #[cfg(target_endian = "big")] - __unused2: ::c_int, - pub msg_rtime: ::time_t, - #[cfg(target_endian = "little")] - __unused2: ::c_int, - #[cfg(target_endian = "big")] - __unused3: ::c_int, - pub msg_ctime: ::time_t, - #[cfg(target_endian = "little")] - __unused3: ::c_int, - __msg_cbytes: ::c_ulong, + __unused_msg_time: [::c_ulong; 6], + pub msg_cbytes: ::c_ulong, pub msg_qnum: ::msgqnum_t, pub msg_qbytes: ::msglen_t, pub msg_lspid: ::pid_t, pub msg_lrpid: ::pid_t, - __pad1: ::c_ulong, - __pad2: ::c_ulong, + __unused: [::c_ulong; 2], + pub msg_stime: ::time_t, + pub msg_rtime: ::time_t, + pub msg_ctime: ::time_t, } pub struct statfs { @@ -372,7 +345,7 @@ pub const SIGTSTP: ::c_int = 24; pub const SIGURG: ::c_int = 21; pub const SIGIO: ::c_int = 22; pub const SIGSYS: ::c_int = 12; -pub const SIGSTKFLT: ::c_int = 7; +//pub const SIGSTKFLT: ::c_int = 7; pub const SIGPOLL: ::c_int = ::SIGIO; pub const SIGPWR: ::c_int = 19; pub const SIG_SETMASK: ::c_int = 3; diff --git a/src/unix/linux_like/linux/musl/b32/powerpc.rs b/src/unix/linux_like/linux/musl/b32/powerpc.rs index 834a442802b27..24c0d0a88c29c 100644 --- a/src/unix/linux_like/linux/musl/b32/powerpc.rs +++ b/src/unix/linux_like/linux/musl/b32/powerpc.rs @@ -1,5 +1,6 @@ pub type c_char = u8; pub type wchar_t = i32; +pub type stat64 = ::stat; s! { pub struct stat { @@ -14,34 +15,22 @@ s! { pub st_size: ::off_t, pub st_blksize: ::blksize_t, pub st_blocks: ::blkcnt_t, - pub st_atime: ::time_t, - pub st_atime_nsec: ::c_long, - pub st_mtime: ::time_t, - pub st_mtime_nsec: ::c_long, - pub st_ctime: ::time_t, - pub st_ctime_nsec: ::c_long, + __st_atime32: ::c_long, + __st_atime32_nsec: ::c_long, + __st_mtime32: ::c_long, + __st_mtime32_nsec: ::c_long, + __st_ctime32: ::c_long, + __st_ctime32_nsec: ::c_long, __unused: [::c_long; 2], - } - - pub struct stat64 { - pub st_dev: ::dev_t, - pub st_ino: ::ino_t, - pub st_mode: ::mode_t, - pub st_nlink: ::nlink_t, - pub st_uid: ::uid_t, - pub st_gid: ::gid_t, - pub st_rdev: ::dev_t, - __st_rdev_padding: ::c_short, - pub st_size: ::off_t, - pub st_blksize: ::blksize_t, - pub st_blocks: ::blkcnt_t, pub st_atime: ::time_t, pub st_atime_nsec: ::c_long, + __st_atime_nsec_padding: ::c_long, pub st_mtime: ::time_t, pub st_mtime_nsec: ::c_long, + __st_mtime_nsec_padding: ::c_long, pub st_ctime: ::time_t, pub st_ctime_nsec: ::c_long, - __unused: [::c_long; 2], + __st_ctime_nsec_padding: ::c_long, } pub struct stack_t { diff --git a/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs b/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs index 8568f2f338094..2840869cbc074 100644 --- a/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs @@ -2,6 +2,7 @@ pub type c_char = u8; pub type wchar_t = ::c_int; +pub type stat64 = ::stat; s! { pub struct pthread_attr_t { @@ -30,28 +31,6 @@ s! { __unused: [::c_int; 2usize], } - pub struct stat64 { - pub st_dev: ::dev_t, - pub st_ino: ::ino64_t, - pub st_mode: ::mode_t, - pub st_nlink: ::nlink_t, - pub st_uid: ::uid_t, - pub st_gid: ::gid_t, - pub st_rdev: ::dev_t, - pub __pad1: ::dev_t, - pub st_size: ::off64_t, - pub st_blksize: ::blksize_t, - pub __pad2: ::c_int, - pub st_blocks: ::blkcnt64_t, - pub st_atime: ::time_t, - pub st_atime_nsec: ::c_long, - pub st_mtime: ::time_t, - pub st_mtime_nsec: ::c_long, - pub st_ctime: ::time_t, - pub st_ctime_nsec: ::c_long, - __unused: [::c_int; 2], - } - pub struct statfs { pub f_type: ::c_long, pub f_bsize: ::c_long, diff --git a/src/unix/linux_like/linux/musl/b32/x86/mod.rs b/src/unix/linux_like/linux/musl/b32/x86/mod.rs index f43c7ea60f8c7..87c842555e2df 100644 --- a/src/unix/linux_like/linux/musl/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/x86/mod.rs @@ -1,5 +1,6 @@ pub type c_char = i8; pub type wchar_t = i32; +pub type stat64 = ::stat; s! { pub struct stat { @@ -15,35 +16,22 @@ s! { pub st_size: ::off_t, pub st_blksize: ::blksize_t, pub st_blocks: ::blkcnt_t, - pub st_atime: ::time_t, - pub st_atime_nsec: ::c_long, - pub st_mtime: ::time_t, - pub st_mtime_nsec: ::c_long, - pub st_ctime: ::time_t, - pub st_ctime_nsec: ::c_long, + __st_atime32: ::c_long, + __st_atime32_nsec: ::c_long, + __st_mtime32: ::c_long, + __st_mtime32_nsec: ::c_long, + __st_ctime32: ::c_long, + __st_ctime32_nsec: ::c_long, pub st_ino: ::ino_t, - } - - pub struct stat64 { - pub st_dev: ::dev_t, - __st_dev_padding: ::c_int, - __st_ino_truncated: ::c_long, - pub st_mode: ::mode_t, - pub st_nlink: ::nlink_t, - pub st_uid: ::uid_t, - pub st_gid: ::gid_t, - pub st_rdev: ::dev_t, - __st_rdev_padding: ::c_int, - pub st_size: ::off_t, - pub st_blksize: ::blksize_t, - pub st_blocks: ::blkcnt_t, pub st_atime: ::time_t, pub st_atime_nsec: ::c_long, + __st_atime_nsec_padding: ::c_long, pub st_mtime: ::time_t, pub st_mtime_nsec: ::c_long, + __st_mtime_nsec_padding: ::c_long, pub st_ctime: ::time_t, pub st_ctime_nsec: ::c_long, - pub st_ino: ::ino_t, + __st_ctime_nsec_padding: ::c_long, } pub struct stack_t { @@ -67,34 +55,40 @@ s! { pub struct shmid_ds { pub shm_perm: ::ipc_perm, pub shm_segsz: ::size_t, - pub shm_atime: ::time_t, - __unused1: ::c_int, - pub shm_dtime: ::time_t, - __unused2: ::c_int, - pub shm_ctime: ::time_t, - __unused3: ::c_int, + __shm_atime_lo: ::c_ulong, + __shm_atime_hi: ::c_ulong, + __shm_dtime_lo: ::c_ulong, + __shm_dtime_hi: ::c_ulong, + __shm_ctime_lo: ::c_ulong, + __shm_ctime_hi: ::c_ulong, pub shm_cpid: ::pid_t, pub shm_lpid: ::pid_t, pub shm_nattch: ::c_ulong, __pad1: ::c_ulong, __pad2: ::c_ulong, + __pad3: ::c_ulong, + pub shm_atime: ::time_t, + pub shm_dtime: ::time_t, + pub shm_ctime: ::time_t, } pub struct msqid_ds { pub msg_perm: ::ipc_perm, - pub msg_stime: ::time_t, - __unused1: ::c_int, - pub msg_rtime: ::time_t, - __unused2: ::c_int, - pub msg_ctime: ::time_t, - __unused3: ::c_int, - __msg_cbytes: ::c_ulong, + __msg_stime_lo: ::c_ulong, + __msg_stime_hi: ::c_ulong, + __msg_rtime_lo: ::c_ulong, + __msg_rtime_hi: ::c_ulong, + __msg_ctime_lo: ::c_ulong, + __msg_ctime_hi: ::c_ulong, + pub msg_cbytes: ::c_ulong, pub msg_qnum: ::msgqnum_t, pub msg_qbytes: ::msglen_t, pub msg_lspid: ::pid_t, pub msg_lrpid: ::pid_t, - __pad1: ::c_ulong, - __pad2: ::c_ulong, + __unused: [::c_ulong; 2], + pub msg_stime: ::time_t, + pub msg_rtime: ::time_t, + pub msg_ctime: ::time_t, } pub struct statfs { diff --git a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs index 1d84a15790cbc..173d6a95198d0 100644 --- a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs @@ -4,6 +4,7 @@ pub type __s64 = ::c_longlong; pub type wchar_t = u32; pub type nlink_t = u32; pub type blksize_t = ::c_int; +pub type stat64 = ::stat; s! { pub struct stat { @@ -28,28 +29,6 @@ s! { __unused: [::c_uint; 2], } - pub struct stat64 { - pub st_dev: ::dev_t, - pub st_ino: ::ino_t, - pub st_mode: ::mode_t, - pub st_nlink: ::nlink_t, - pub st_uid: ::uid_t, - pub st_gid: ::gid_t, - pub st_rdev: ::dev_t, - __pad0: ::c_ulong, - pub st_size: ::off_t, - pub st_blksize: ::blksize_t, - __pad1: ::c_int, - pub st_blocks: ::blkcnt_t, - pub st_atime: ::time_t, - pub st_atime_nsec: ::c_long, - pub st_mtime: ::time_t, - pub st_mtime_nsec: ::c_long, - pub st_ctime: ::time_t, - pub st_ctime_nsec: ::c_long, - __unused: [::c_uint; 2], - } - pub struct user_regs_struct { pub regs: [::c_ulonglong; 31], pub sp: ::c_ulonglong, diff --git a/src/unix/linux_like/linux/musl/b64/mips64.rs b/src/unix/linux_like/linux/musl/b64/mips64.rs index 18fa6c664c81d..4a3cbdde11f4c 100644 --- a/src/unix/linux_like/linux/musl/b64/mips64.rs +++ b/src/unix/linux_like/linux/musl/b64/mips64.rs @@ -4,6 +4,7 @@ pub type __u64 = ::c_ulong; pub type __s64 = ::c_long; pub type nlink_t = u64; pub type blksize_t = i64; +pub type stat64 = ::stat; s! { pub struct stat { @@ -30,30 +31,6 @@ s! { __pad5: [::c_int; 14], } - pub struct stat64 { - pub st_dev: ::dev_t, - __pad1: [::c_int; 3], - pub st_ino: ::ino_t, - pub st_mode: ::mode_t, - pub st_nlink: ::nlink_t, - pub st_uid: ::uid_t, - pub st_gid: ::gid_t, - pub st_rdev: ::dev_t, - __pad2: [::c_uint; 2], - pub st_size: ::off_t, - __pad3: ::c_int, - pub st_atime: ::time_t, - pub st_atime_nsec: ::c_long, - pub st_mtime: ::time_t, - pub st_mtime_nsec: ::c_long, - pub st_ctime: ::time_t, - pub st_ctime_nsec: ::c_long, - pub st_blksize: ::blksize_t, - __pad4: ::c_uint, - pub st_blocks: ::blkcnt_t, - __pad5: [::c_int; 14], - } - pub struct statfs { pub f_type: ::c_ulong, pub f_bsize: ::c_ulong, diff --git a/src/unix/linux_like/linux/musl/b64/powerpc64.rs b/src/unix/linux_like/linux/musl/b64/powerpc64.rs index 202abe8796b13..830a8b0945e26 100644 --- a/src/unix/linux_like/linux/musl/b64/powerpc64.rs +++ b/src/unix/linux_like/linux/musl/b64/powerpc64.rs @@ -4,6 +4,7 @@ pub type __u64 = ::c_ulong; pub type __s64 = ::c_long; pub type nlink_t = u64; pub type blksize_t = ::c_long; +pub type stat64 = ::stat; s! { pub struct stat { @@ -27,27 +28,6 @@ s! { __unused: [::c_long; 3], } - pub struct stat64 { - pub st_dev: ::dev_t, - pub st_ino: ::ino64_t, - pub st_nlink: ::nlink_t, - pub st_mode: ::mode_t, - pub st_uid: ::uid_t, - pub st_gid: ::gid_t, - __pad0: ::c_int, - pub st_rdev: ::dev_t, - pub st_size: ::off_t, - pub st_blksize: ::blksize_t, - pub st_blocks: ::blkcnt64_t, - pub st_atime: ::time_t, - pub st_atime_nsec: ::c_long, - pub st_mtime: ::time_t, - pub st_mtime_nsec: ::c_long, - pub st_ctime: ::time_t, - pub st_ctime_nsec: ::c_long, - __reserved: [::c_long; 3], - } - pub struct ipc_perm { pub __ipc_perm_key: ::key_t, pub uid: ::uid_t, diff --git a/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs b/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs index 2a37bd976bc7c..4cbdc08108a03 100644 --- a/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs @@ -9,6 +9,7 @@ pub type fsblkcnt64_t = ::c_ulong; pub type fsfilcnt64_t = ::c_ulong; pub type __u64 = ::c_ulonglong; pub type __s64 = ::c_longlong; +pub type stat64 = ::stat; s! { pub struct pthread_attr_t { @@ -37,28 +38,6 @@ s! { __unused: [::c_int; 2usize], } - pub struct stat64 { - pub st_dev: ::dev_t, - pub st_ino: ::ino64_t, - pub st_mode: ::mode_t, - pub st_nlink: ::nlink_t, - pub st_uid: ::uid_t, - pub st_gid: ::gid_t, - pub st_rdev: ::dev_t, - pub __pad1: ::dev_t, - pub st_size: ::off64_t, - pub st_blksize: ::blksize_t, - pub __pad2: ::c_int, - pub st_blocks: ::blkcnt_t, - pub st_atime: ::time_t, - pub st_atime_nsec: ::c_long, - pub st_mtime: ::time_t, - pub st_mtime_nsec: ::c_long, - pub st_ctime: ::time_t, - pub st_ctime_nsec: ::c_long, - __unused: [::c_int; 2], - } - pub struct statfs { pub f_type: ::c_long, pub f_bsize: ::c_long, diff --git a/src/unix/linux_like/linux/musl/b64/s390x.rs b/src/unix/linux_like/linux/musl/b64/s390x.rs index 567914f7b8cd5..0db28945a0197 100644 --- a/src/unix/linux_like/linux/musl/b64/s390x.rs +++ b/src/unix/linux_like/linux/musl/b64/s390x.rs @@ -5,6 +5,7 @@ pub type wchar_t = i32; pub type greg_t = u64; pub type __u64 = u64; pub type __s64 = i64; +pub type stat64 = ::stat; s! { pub struct ipc_perm { @@ -39,26 +40,6 @@ s! { __unused: [::c_long; 3], } - pub struct stat64 { - pub st_dev: ::dev_t, - pub st_ino: ::ino64_t, - pub st_nlink: ::nlink_t, - pub st_mode: ::mode_t, - pub st_uid: ::uid_t, - pub st_gid: ::gid_t, - pub st_rdev: ::dev_t, - pub st_size: ::off_t, - pub st_atime: ::time_t, - pub st_atime_nsec: ::c_long, - pub st_mtime: ::time_t, - pub st_mtime_nsec: ::c_long, - pub st_ctime: ::time_t, - pub st_ctime_nsec: ::c_long, - pub st_blksize: ::blksize_t, - pub st_blocks: ::blkcnt64_t, - __unused: [::c_long; 3], - } - pub struct statfs { pub f_type: ::c_uint, pub f_bsize: ::c_uint, diff --git a/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs b/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs index b1ede42064f97..3c18dc48a0e55 100644 --- a/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs @@ -5,6 +5,7 @@ pub type blksize_t = ::c_long; pub type __u64 = ::c_ulonglong; pub type __s64 = ::c_longlong; pub type greg_t = i64; +pub type stat64 = ::stat; s! { pub struct stat { @@ -28,27 +29,6 @@ s! { __unused: [::c_long; 3], } - pub struct stat64 { - pub st_dev: ::dev_t, - pub st_ino: ::ino64_t, - pub st_nlink: ::nlink_t, - pub st_mode: ::mode_t, - pub st_uid: ::uid_t, - pub st_gid: ::gid_t, - __pad0: ::c_int, - pub st_rdev: ::dev_t, - pub st_size: ::off_t, - pub st_blksize: ::blksize_t, - pub st_blocks: ::blkcnt64_t, - pub st_atime: ::time_t, - pub st_atime_nsec: ::c_long, - pub st_mtime: ::time_t, - pub st_mtime_nsec: ::c_long, - pub st_ctime: ::time_t, - pub st_ctime_nsec: ::c_long, - __reserved: [::c_long; 3], - } - pub struct user_regs_struct { pub r15: ::c_ulong, pub r14: ::c_ulong, @@ -673,7 +653,7 @@ pub const MAP_32BIT: ::c_int = 0x0040; pub const O_APPEND: ::c_int = 1024; pub const O_DIRECT: ::c_int = 0x4000; pub const O_DIRECTORY: ::c_int = 0x10000; -pub const O_LARGEFILE: ::c_int = 0; +pub const O_LARGEFILE: ::c_int = 0x8000; pub const O_NOFOLLOW: ::c_int = 0x20000; pub const O_CREAT: ::c_int = 64; pub const O_EXCL: ::c_int = 128; diff --git a/src/unix/linux_like/linux/musl/lfs64.rs b/src/unix/linux_like/linux/musl/lfs64.rs index 27c1d25836d68..fdc80a72813ff 100644 --- a/src/unix/linux_like/linux/musl/lfs64.rs +++ b/src/unix/linux_like/linux/musl/lfs64.rs @@ -114,7 +114,12 @@ pub unsafe extern "C" fn mmap64( // // These aliases are mostly fine though, neither function takes a LFS64-namespaced type as an // argument, nor do their names clash with any declared types. +// +// Targets i686-unknown-linux-musl and arm-unknown-linux-musleabihf in CI recognize them as unused imports. +// Since `dead_code` is already allowed at the crate level, here they are also allowed. +#[allow(unused_imports)] pub use open as open64; +#[allow(unused_imports)] pub use openat as openat64; #[inline] diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 1a93c39fd3a0a..5a0b3d9dfec08 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -1,16 +1,7 @@ pub type pthread_t = *mut ::c_void; pub type clock_t = c_long; -#[cfg_attr( - not(feature = "rustc-dep-of-std"), - deprecated( - since = "0.2.80", - note = "This type is changed to 64-bit in musl 1.2.0, \ - we'll follow that change in the future release. \ - See #1848 for more info." - ) -)] -pub type time_t = c_long; -pub type suseconds_t = c_long; +pub type time_t = i64; +pub type suseconds_t = i64; pub type ino_t = u64; pub type off_t = i64; pub type blkcnt_t = i64; @@ -364,13 +355,6 @@ s_no_extra_traits! { pub __reserved: [::c_char; 256], } - // FIXME: musl added paddings and adjusted - // layout in 1.2.0 but our CI is still 1.1.24. - // So, I'm leaving some fields as cfg for now. - // ref. https://github.com/bminor/musl/commit/ - // 1e7f0fcd7ff2096904fd93a2ee6d12a2392be392 - // - // OpenHarmony uses the musl 1.2 layout. pub struct utmpx { pub ut_type: ::c_short, __ut_pad1: ::c_short, @@ -381,20 +365,13 @@ s_no_extra_traits! { pub ut_host: [::c_char; 256], pub ut_exit: __exit_status, - #[cfg(target_env = "musl")] - pub ut_session: ::c_long, - - #[cfg(target_env = "ohos")] #[cfg(target_endian = "little")] pub ut_session: ::c_int, - #[cfg(target_env = "ohos")] #[cfg(target_endian = "little")] __ut_pad2: ::c_int, - #[cfg(target_env = "ohos")] #[cfg(not(target_endian = "little"))] __ut_pad2: ::c_int, - #[cfg(target_env = "ohos")] #[cfg(not(target_endian = "little"))] pub ut_session: ::c_int, @@ -827,6 +804,7 @@ extern "C" { vlen: ::c_uint, flags: ::c_uint, ) -> ::c_int; + #[cfg_attr(musl_time64_abi, link_name = "__recvmmsg_time64")] pub fn recvmmsg( sockfd: ::c_int, msgvec: *mut ::mmsghdr, @@ -843,6 +821,7 @@ extern "C" { new_limit: *const ::rlimit, old_limit: *mut ::rlimit, ) -> ::c_int; + #[cfg_attr(musl_time64_abi, link_name = "__gettimeofday_time64")] pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int; pub fn ptrace(request: ::c_int, ...) -> ::c_long; pub fn getpriority(which: ::c_int, who: ::id_t) -> ::c_int; @@ -864,7 +843,9 @@ extern "C" { // Added in `musl` 1.2.2 pub fn reallocarray(ptr: *mut ::c_void, nmemb: ::size_t, size: ::size_t) -> *mut ::c_void; + #[cfg_attr(musl_time64_abi, link_name = "__adjtimex_time64")] pub fn adjtimex(buf: *mut ::timex) -> ::c_int; + #[cfg_attr(musl_time64_abi, link_name = "__clock_adjtime64")] pub fn clock_adjtime(clk_id: ::clockid_t, buf: *mut ::timex) -> ::c_int; pub fn ctermid(s: *mut ::c_char) -> *mut ::c_char; diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index bdbec9c651fc5..defe7dab4bb4f 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -104,14 +104,28 @@ s! { pub struct sched_param { pub sched_priority: ::c_int, - #[cfg(any(target_env = "musl", target_os = "emscripten", target_env = "ohos"))] + #[cfg(target_env = "musl")] + __reserved1: ::c_int, + #[cfg(target_os = "emscripten")] pub sched_ss_low_priority: ::c_int, - #[cfg(any(target_env = "musl", target_os = "emscripten", target_env = "ohos"))] + #[cfg(target_os = "emscripten")] pub sched_ss_repl_period: ::timespec, - #[cfg(any(target_env = "musl", target_os = "emscripten", target_env = "ohos"))] + #[cfg(target_os = "emscripten")] pub sched_ss_init_budget: ::timespec, - #[cfg(any(target_env = "musl", target_os = "emscripten", target_env = "ohos"))] + #[cfg(target_os = "emscripten")] pub sched_ss_max_repl: ::c_int, + #[cfg(musl_time64_abi)] + __reserved2: [::c_long; 4], + #[cfg(all(target_env = "musl", not(musl_time64_abi)))] + __reserved2_1: time_t, + #[cfg(all(target_env = "musl", not(musl_time64_abi)))] + __reserved2_2: ::c_long, + #[cfg(all(target_env = "musl", not(musl_time64_abi)))] + __reserved2_3: time_t, + #[cfg(all(target_env = "musl", not(musl_time64_abi)))] + __reserved2_4: ::c_long, + #[cfg(target_env = "musl")] + __reserved3: ::c_int, } pub struct Dl_info { @@ -1675,8 +1689,11 @@ extern "C" { pub fn fdatasync(fd: ::c_int) -> ::c_int; pub fn mincore(addr: *mut ::c_void, len: ::size_t, vec: *mut ::c_uchar) -> ::c_int; + #[cfg_attr(musl_time64_abi, link_name = "__clock_getres_time64")] pub fn clock_getres(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; + #[cfg_attr(musl_time64_abi, link_name = "__clock_gettime64")] pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; + #[cfg_attr(musl_time64_abi, link_name = "__clock_settime64")] pub fn clock_settime(clk_id: ::clockid_t, tp: *const ::timespec) -> ::c_int; pub fn clock_getcpuclockid(pid: ::pid_t, clk_id: *mut ::clockid_t) -> ::c_int; @@ -1695,7 +1712,15 @@ extern "C" { pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int; pub fn memrchr(cx: *const ::c_void, c: ::c_int, n: ::size_t) -> *mut ::c_void; pub fn posix_fadvise(fd: ::c_int, offset: ::off_t, len: ::off_t, advise: ::c_int) -> ::c_int; + pub fn posix_fadvise64( + fd: ::c_int, + offset: ::off64_t, + len: ::off64_t, + advise: ::c_int, + ) -> ::c_int; + #[cfg_attr(musl_time64_abi, link_name = "__futimens_time64")] pub fn futimens(fd: ::c_int, times: *const ::timespec) -> ::c_int; + #[cfg_attr(musl_time64_abi, link_name = "__utimensat_time64")] pub fn utimensat( dirfd: ::c_int, path: *const ::c_char, @@ -1706,6 +1731,47 @@ extern "C" { pub fn freelocale(loc: ::locale_t); pub fn newlocale(mask: ::c_int, locale: *const ::c_char, base: ::locale_t) -> ::locale_t; pub fn uselocale(loc: ::locale_t) -> ::locale_t; + pub fn creat64(path: *const c_char, mode: mode_t) -> ::c_int; + #[cfg_attr(musl_time64_abi, link_name = "__fstat_time64")] + pub fn fstat64(fildes: ::c_int, buf: *mut stat64) -> ::c_int; + #[cfg_attr(musl_time64_abi, link_name = "__fstatat_time64")] + pub fn fstatat64( + dirfd: ::c_int, + pathname: *const c_char, + buf: *mut stat64, + flags: ::c_int, + ) -> ::c_int; + pub fn ftruncate64(fd: ::c_int, length: off64_t) -> ::c_int; + pub fn lseek64(fd: ::c_int, offset: off64_t, whence: ::c_int) -> off64_t; + #[cfg_attr(musl_time64_abi, link_name = "__lstat_time64")] + pub fn lstat64(path: *const c_char, buf: *mut stat64) -> ::c_int; + pub fn mmap64( + addr: *mut ::c_void, + len: ::size_t, + prot: ::c_int, + flags: ::c_int, + fd: ::c_int, + offset: off64_t, + ) -> *mut ::c_void; + pub fn open64(path: *const c_char, oflag: ::c_int, ...) -> ::c_int; + pub fn openat64(fd: ::c_int, path: *const c_char, oflag: ::c_int, ...) -> ::c_int; + pub fn pread64(fd: ::c_int, buf: *mut ::c_void, count: ::size_t, offset: off64_t) -> ::ssize_t; + pub fn pwrite64( + fd: ::c_int, + buf: *const ::c_void, + count: ::size_t, + offset: off64_t, + ) -> ::ssize_t; + pub fn readdir64(dirp: *mut ::DIR) -> *mut ::dirent64; + pub fn readdir64_r( + dirp: *mut ::DIR, + entry: *mut ::dirent64, + result: *mut *mut ::dirent64, + ) -> ::c_int; + #[cfg_attr(musl_time64_abi, link_name = "__stat_time64")] + pub fn stat64(path: *const c_char, buf: *mut stat64) -> ::c_int; + pub fn truncate64(path: *const c_char, length: off64_t) -> ::c_int; + pub fn mknodat( dirfd: ::c_int, pathname: *const ::c_char, @@ -1741,6 +1807,7 @@ extern "C" { pub fn sbrk(increment: ::intptr_t) -> *mut ::c_void; pub fn setresgid(rgid: ::gid_t, egid: ::gid_t, sgid: ::gid_t) -> ::c_int; pub fn setresuid(ruid: ::uid_t, euid: ::uid_t, suid: ::uid_t) -> ::c_int; + #[cfg_attr(musl_time64_abi, link_name = "__wait4_time64")] pub fn wait4( pid: ::pid_t, status: *mut ::c_int, @@ -1779,53 +1846,6 @@ cfg_if! { pub fn statvfs64(path: *const ::c_char, buf: *mut statvfs64) -> ::c_int; pub fn fstatvfs64(fd: ::c_int, buf: *mut statvfs64) -> ::c_int; pub fn statfs64(path: *const ::c_char, buf: *mut statfs64) -> ::c_int; - pub fn creat64(path: *const c_char, mode: mode_t) -> ::c_int; - pub fn fstat64(fildes: ::c_int, buf: *mut stat64) -> ::c_int; - pub fn fstatat64( - dirfd: ::c_int, - pathname: *const c_char, - buf: *mut stat64, - flags: ::c_int, - ) -> ::c_int; - pub fn ftruncate64(fd: ::c_int, length: off64_t) -> ::c_int; - pub fn lseek64(fd: ::c_int, offset: off64_t, whence: ::c_int) -> off64_t; - pub fn lstat64(path: *const c_char, buf: *mut stat64) -> ::c_int; - pub fn mmap64( - addr: *mut ::c_void, - len: ::size_t, - prot: ::c_int, - flags: ::c_int, - fd: ::c_int, - offset: off64_t, - ) -> *mut ::c_void; - pub fn open64(path: *const c_char, oflag: ::c_int, ...) -> ::c_int; - pub fn openat64(fd: ::c_int, path: *const c_char, oflag: ::c_int, ...) -> ::c_int; - pub fn posix_fadvise64( - fd: ::c_int, - offset: ::off64_t, - len: ::off64_t, - advise: ::c_int, - ) -> ::c_int; - pub fn pread64( - fd: ::c_int, - buf: *mut ::c_void, - count: ::size_t, - offset: off64_t - ) -> ::ssize_t; - pub fn pwrite64( - fd: ::c_int, - buf: *const ::c_void, - count: ::size_t, - offset: off64_t, - ) -> ::ssize_t; - pub fn readdir64(dirp: *mut ::DIR) -> *mut ::dirent64; - pub fn readdir64_r( - dirp: *mut ::DIR, - entry: *mut ::dirent64, - result: *mut *mut ::dirent64, - ) -> ::c_int; - pub fn stat64(path: *const c_char, buf: *mut stat64) -> ::c_int; - pub fn truncate64(path: *const c_char, length: off64_t) -> ::c_int; } } } diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 8984e097b968c..6c36d3540c831 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -69,10 +69,14 @@ s! { // See https://sourceware.org/bugzilla/show_bug.cgi?id=16437 pub struct timespec { pub tv_sec: time_t, + #[cfg(all(musl_time64_abi, target_endian = "big"))] + __pad0: u32, #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] pub tv_nsec: i64, #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] pub tv_nsec: ::c_long, + #[cfg(all(musl_time64_abi, target_endian = "little"))] + __pad0: u32 } pub struct rlimit { @@ -717,6 +721,7 @@ extern "C" { all(target_os = "freebsd", any(freebsd11, freebsd10)), link_name = "fstat@FBSD_1.0" )] + #[cfg_attr(musl_time64_abi, link_name = "__fstat_time64")] pub fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int; pub fn mkdir(path: *const c_char, mode: mode_t) -> ::c_int; @@ -730,6 +735,7 @@ extern "C" { all(target_os = "freebsd", any(freebsd11, freebsd10)), link_name = "stat@FBSD_1.0" )] + #[cfg_attr(musl_time64_abi, link_name = "__stat_time64")] pub fn stat(path: *const c_char, buf: *mut stat) -> ::c_int; pub fn pclose(stream: *mut ::FILE) -> ::c_int; @@ -814,6 +820,7 @@ extern "C" { all(target_os = "freebsd", any(freebsd11, freebsd10)), link_name = "fstatat@FBSD_1.1" )] + #[cfg_attr(musl_time64_abi, link_name = "__fstatat_time64")] pub fn fstatat( dirfd: ::c_int, pathname: *const ::c_char, @@ -920,6 +927,7 @@ extern "C" { link_name = "nanosleep$UNIX2003" )] #[cfg_attr(target_os = "netbsd", link_name = "__nanosleep50")] + #[cfg_attr(musl_time64_abi, link_name = "__nanosleep_time64")] pub fn nanosleep(rqtp: *const timespec, rmtp: *mut timespec) -> ::c_int; pub fn tcgetpgrp(fd: ::c_int) -> pid_t; pub fn tcsetpgrp(fd: ::c_int, pgrp: ::pid_t) -> ::c_int; @@ -959,6 +967,7 @@ extern "C" { pub fn umask(mask: mode_t) -> mode_t; #[cfg_attr(target_os = "netbsd", link_name = "__utime50")] + #[cfg_attr(musl_time64_abi, link_name = "__utime64")] pub fn utime(file: *const c_char, buf: *const utimbuf) -> ::c_int; #[cfg_attr( @@ -1007,6 +1016,7 @@ extern "C" { all(target_os = "freebsd", any(freebsd11, freebsd10)), link_name = "lstat@FBSD_1.0" )] + #[cfg_attr(musl_time64_abi, link_name = "__lstat_time64")] pub fn lstat(path: *const c_char, buf: *mut stat) -> ::c_int; #[cfg_attr( @@ -1035,6 +1045,7 @@ extern "C" { pub fn signal(signum: ::c_int, handler: sighandler_t) -> sighandler_t; #[cfg_attr(target_os = "netbsd", link_name = "__getrusage50")] + #[cfg_attr(musl_time64_abi, link_name = "__getrusage_time64")] pub fn getrusage(resource: ::c_int, usage: *mut rusage) -> ::c_int; #[cfg_attr( @@ -1111,6 +1122,7 @@ extern "C" { all(target_os = "macos", target_arch = "x86"), link_name = "pthread_cond_timedwait$UNIX2003" )] + #[cfg_attr(musl_time64_abi, link_name = "__pthread_cond_timedwait_time64")] pub fn pthread_cond_timedwait( cond: *mut pthread_cond_t, lock: *mut pthread_mutex_t, @@ -1177,9 +1189,11 @@ extern "C" { pub fn raise(signum: ::c_int) -> ::c_int; #[cfg_attr(target_os = "netbsd", link_name = "__utimes50")] + #[cfg_attr(musl_time64_abi, link_name = "__utimes_time64")] pub fn utimes(filename: *const ::c_char, times: *const ::timeval) -> ::c_int; pub fn dlopen(filename: *const ::c_char, flag: ::c_int) -> *mut ::c_void; pub fn dlerror() -> *mut ::c_char; + #[cfg_attr(musl_time64_abi, link_name = "__dlsym_time64")] pub fn dlsym(handle: *mut ::c_void, symbol: *const ::c_char) -> *mut ::c_void; pub fn dlclose(handle: *mut ::c_void) -> ::c_int; @@ -1224,40 +1238,32 @@ extern "C" { pub fn res_init() -> ::c_int; #[cfg_attr(target_os = "netbsd", link_name = "__gmtime_r50")] - #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))] - // FIXME: for `time_t` + #[cfg_attr(musl_time64_abi, link_name = "__gmtime64_r")] pub fn gmtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm; #[cfg_attr(target_os = "netbsd", link_name = "__localtime_r50")] - #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))] - // FIXME: for `time_t` + #[cfg_attr(musl_time64_abi, link_name = "__localtime64_r")] pub fn localtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm; #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "mktime$UNIX2003" )] #[cfg_attr(target_os = "netbsd", link_name = "__mktime50")] - #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))] - // FIXME: for `time_t` + #[cfg_attr(musl_time64_abi, link_name = "__mktime64")] pub fn mktime(tm: *mut tm) -> time_t; #[cfg_attr(target_os = "netbsd", link_name = "__time50")] - #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))] - // FIXME: for `time_t` + #[cfg_attr(musl_time64_abi, link_name = "__time64")] pub fn time(time: *mut time_t) -> time_t; #[cfg_attr(target_os = "netbsd", link_name = "__gmtime50")] - #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))] - // FIXME: for `time_t` + #[cfg_attr(musl_time64_abi, link_name = "__gmtime64")] pub fn gmtime(time_p: *const time_t) -> *mut tm; #[cfg_attr(target_os = "netbsd", link_name = "__locatime50")] - #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))] - // FIXME: for `time_t` + #[cfg_attr(musl_time64_abi, link_name = "__localtime64")] pub fn localtime(time_p: *const time_t) -> *mut tm; #[cfg_attr(target_os = "netbsd", link_name = "__difftime50")] - #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))] - // FIXME: for `time_t` + #[cfg_attr(musl_time64_abi, link_name = "__difftime64")] pub fn difftime(time1: time_t, time0: time_t) -> ::c_double; #[cfg_attr(target_os = "netbsd", link_name = "__timegm50")] - #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))] - // FIXME: for `time_t` + #[cfg_attr(musl_time64_abi, link_name = "__timegm_time64")] pub fn timegm(tm: *mut ::tm) -> time_t; #[cfg_attr(target_os = "netbsd", link_name = "__mknod50")] @@ -1312,6 +1318,7 @@ extern "C" { link_name = "select$UNIX2003" )] #[cfg_attr(target_os = "netbsd", link_name = "__select50")] + #[cfg_attr(musl_time64_abi, link_name = "__select_time64")] pub fn select( nfds: ::c_int, readfds: *mut fd_set, @@ -1421,6 +1428,7 @@ cfg_if! { target_os = "haiku", target_os = "nto")))] { extern "C" { + #[cfg_attr(musl_time64_abi, link_name = "__adjtime64")] pub fn adjtime(delta: *const timeval, olddelta: *mut timeval) -> ::c_int; } } @@ -1541,6 +1549,7 @@ cfg_if! { link_name = "pselect$UNIX2003" )] #[cfg_attr(target_os = "netbsd", link_name = "__pselect50")] + #[cfg_attr(musl_time64_abi, link_name = "__pselect_time64")] pub fn pselect( nfds: ::c_int, readfds: *mut fd_set,