diff --git a/build.rs b/build.rs index bbee2d28a1789..2ff4149960fc5 100644 --- a/build.rs +++ b/build.rs @@ -35,6 +35,12 @@ fn main() { Some(_) | None => println!("cargo:rustc-cfg=freebsd11"), } + // Some ABIs need to redirect time related symbols to their time64 + // equivalents. See #2088 and #1848 for more information. + if is_musl_time64_abi() { + println!("cargo:rustc-cfg=musl_time64_abi"); + } + // On CI: deny all warnings if libc_ci { println!("cargo:rustc-cfg=libc_deny_warnings"); @@ -176,3 +182,22 @@ fn which_freebsd() -> Option { _ => None, } } + +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/docker/mips-unknown-linux-musl/Dockerfile b/ci/docker/mips-unknown-linux-musl/Dockerfile index 6fbd284fb9ba3..c01d9b597df0f 100644 --- a/ci/docker/mips-unknown-linux-musl/Dockerfile +++ b/ci/docker/mips-unknown-linux-musl/Dockerfile @@ -10,16 +10,16 @@ RUN mkdir /toolchain # See build_dir/target-mips_24kc_musl/linux-ath79_generic/linux-5.4.154 # Musl version: 1.1.24 # See staging_dir/toolchain-mips_24kc_gcc-8.4.0_musl/info.mk -RUN curl --retry 5 -L https://downloads.openwrt.org/releases/21.02.1/targets/ath79/generic/openwrt-sdk-21.02.1-ath79-generic_gcc-8.4.0_musl.Linux-x86_64.tar.xz | \ +RUN curl --retry 5 -L https://downloads.openwrt.org/releases/22.03.0-rc6/targets/ath79/generic/openwrt-sdk-22.03.0-rc6-ath79-generic_gcc-11.2.0_musl.Linux-x86_64.tar.xz | \ tar xJf - -C /toolchain --strip-components=1 # See https://lkml.org/lkml/2014/3/14/269 COPY sysinfo_guard.patch /toolchain -RUN patch /toolchain/staging_dir/toolchain-mips_24kc_gcc-8.4.0_musl/include/linux/kernel.h = 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", @@ -3255,8 +3272,8 @@ fn test_linux(target: &str) { t if t.ends_with("_t") => t.to_string(), - // In MUSL `flock64` is a typedef to `flock`. - "flock64" if musl => format!("struct {}", ty), + // 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), @@ -3475,6 +3492,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/linux/arch/generic/mod.rs b/src/unix/linux_like/linux/arch/generic/mod.rs index 40bc30a4f336b..64fc8f58468f6 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; @@ -119,7 +133,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 @@ -270,7 +283,7 @@ cfg_if! { pub const RLIMIT_NICE: ::c_int = 13; pub const RLIMIT_RTPRIO: ::c_int = 14; pub const RLIMIT_RTTIME: ::c_int = 15; - pub const RLIM_NLIMITS: ::c_int = 15; + 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 077417de52faf..7027d159b9637 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; @@ -254,7 +269,7 @@ cfg_if! { pub const RLIMIT_NICE: ::c_int = 13; pub const RLIMIT_RTPRIO: ::c_int = 14; pub const RLIMIT_RTTIME: ::c_int = 15; - pub const RLIM_NLIMITS: ::c_int = 15; + 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 d3d627234ceea..04f58fe8f270a 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -184,6 +184,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, @@ -3752,6 +3757,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, @@ -3805,6 +3811,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 @@ -3832,6 +3839,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(); @@ -3949,7 +3957,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, @@ -3971,6 +3981,7 @@ extern "C" { 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, @@ -3984,6 +3995,7 @@ extern "C" { 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, @@ -4003,6 +4015,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, @@ -4118,6 +4131,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, @@ -4128,7 +4142,9 @@ extern "C" { flags: ::c_uint, ) -> ::ssize_t; pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::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; @@ -4150,6 +4166,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, @@ -4165,6 +4182,7 @@ extern "C" { 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, @@ -4182,6 +4200,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, @@ -4444,7 +4463,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 c47fa2c4cfda9..a9cd5f50e6ccf 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 40b507bcd0633..9606c90d261fb 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 { @@ -373,7 +346,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 5b1bf17ed8c22..3a4ee89cc5412 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 573624620728a..d662af943c312 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 c319b91b61434..722e007617d6c 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 14b4bc6d68b87..96f2e289f43e6 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 22ac916909346..a5252f785b983 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 0bb4cf837d268..8596770a51240 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 f354293e0d05c..bb67418dbd7d5 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 60bfc8d3e0b24..55e8094f98f68 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_ulong, pub f_bsize: ::c_ulong, 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 8198dc2f35168..dc91f0797b3db 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, @@ -671,7 +651,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/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 2a894a602502e..4db01269f5838 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; @@ -285,14 +276,9 @@ 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 comments for now. - // ref. https://github.com/bminor/musl/commit/ - // 1e7f0fcd7ff2096904fd93a2ee6d12a2392be392 pub struct utmpx { pub ut_type: ::c_short, - //__ut_pad1: ::c_short, + __ut_pad1: ::c_short, pub ut_pid: ::pid_t, pub ut_line: [::c_char; 32], pub ut_id: [::c_char; 4], @@ -300,15 +286,15 @@ s_no_extra_traits! { pub ut_host: [::c_char; 256], pub ut_exit: __exit_status, - //#[cfg(target_endian = "little")] - pub ut_session: ::c_long, - //#[cfg(target_endian = "little")] - //__ut_pad2: ::c_long, + #[cfg(target_endian = "little")] + pub ut_session: ::c_int, + #[cfg(target_endian = "little")] + __ut_pad2: ::c_int, - //#[cfg(not(target_endian = "little"))] - //__ut_pad2: ::c_int, - //#[cfg(not(target_endian = "little"))] - //pub ut_session: ::c_int, + #[cfg(not(target_endian = "little"))] + __ut_pad2: ::c_int, + #[cfg(not(target_endian = "little"))] + pub ut_session: ::c_int, pub ut_tv: ::timeval, pub ut_addr_v6: [::c_uint; 4], @@ -701,6 +687,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, @@ -727,6 +714,7 @@ extern "C" { ) -> ::c_int; pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::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; @@ -748,7 +736,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 45a1dee554b4c..3974488e07f8f 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -108,14 +108,28 @@ s! { pub struct sched_param { pub sched_priority: ::c_int, - #[cfg(any(target_env = "musl", target_os = "emscripten"))] + #[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"))] + #[cfg(target_os = "emscripten")] pub sched_ss_repl_period: ::timespec, - #[cfg(any(target_env = "musl", target_os = "emscripten"))] + #[cfg(target_os = "emscripten")] pub sched_ss_init_budget: ::timespec, - #[cfg(any(target_env = "musl", target_os = "emscripten"))] + #[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 { @@ -1637,8 +1651,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; @@ -1668,7 +1685,9 @@ extern "C" { 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, @@ -1680,7 +1699,9 @@ extern "C" { 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, @@ -1689,6 +1710,7 @@ extern "C" { ) -> ::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, @@ -1713,6 +1735,7 @@ extern "C" { 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; @@ -1756,6 +1779,7 @@ extern "C" { pub fn vfork() -> ::pid_t; 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, diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 826b835182a82..c5c172b5257a3 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -73,10 +73,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 { @@ -730,6 +734,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; @@ -743,6 +748,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; @@ -827,6 +833,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, @@ -933,6 +940,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; @@ -972,6 +980,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( @@ -1020,6 +1029,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( @@ -1047,6 +1057,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( @@ -1118,6 +1129,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, @@ -1181,9 +1193,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; pub fn dladdr(addr: *const ::c_void, info: *mut Dl_info) -> ::c_int; @@ -1231,40 +1245,32 @@ extern "C" { pub fn res_init() -> ::c_int; #[cfg_attr(target_os = "netbsd", link_name = "__gmtime_r50")] - #[cfg_attr(target_env = "musl", 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(target_env = "musl", 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(target_env = "musl", 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(target_env = "musl", 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(target_env = "musl", 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(target_env = "musl", 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(target_env = "musl", 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(target_env = "musl", 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")] @@ -1319,6 +1325,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, @@ -1410,6 +1417,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; pub fn stpncpy(dst: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char; } @@ -1509,6 +1517,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,