diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4bb28e25dfb81..5a971be3eae18 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -218,6 +218,14 @@ jobs: - target: loongarch64-unknown-linux-musl env: RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 + - target: arm-unknown-linux-musleabihf + env: + RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 + RUST_LIBC_UNSTABLE_MUSL_TIME64: 1 + - target: i686-unknown-linux-musl + env: + RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 + RUST_LIBC_UNSTABLE_MUSL_TIME64: 1 # FIXME(ppc): SIGILL running tests, see # https://github.com/rust-lang/libc/pull/4254#issuecomment-2636288713 # - target: powerpc-unknown-linux-gnu diff --git a/build.rs b/build.rs index 3cd797e2c56de..787ca93ff12c2 100644 --- a/build.rs +++ b/build.rs @@ -24,6 +24,7 @@ const ALLOWED_CFGS: &[&str] = &[ // Corresponds to `__USE_TIME_BITS64` in UAPI "linux_time_bits64", "musl_v1_2_3", + "musl32_time64", ]; // Extra values to allow for check-cfg. @@ -44,6 +45,8 @@ const CHECK_CFG_EXTRA: &[(&str, &[&str])] = &[ ), ]; +const MUSL_TIME64_ARCHS: &[&str] = &["arm", "mips", "powerpc", "x86"]; + fn main() { // Avoid unnecessary re-building. println!("cargo:rerun-if-changed=build.rs"); @@ -90,10 +93,16 @@ fn main() { let musl_v1_2_3 = env::var("RUST_LIBC_UNSTABLE_MUSL_V1_2_3").is_ok(); println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_MUSL_V1_2_3"); + let musl32_time64 = env::var("RUST_LIBC_UNSTABLE_MUSL_TIME64").is_ok(); + println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_MUSL_TIME64"); // loongarch64 and ohos have already updated - if musl_v1_2_3 || target_os == "loongarch64" || target_env == "ohos" { - // FIXME(musl): enable time64 api as well + if ((musl_v1_2_3 || target_os == "loongarch64") && target_env == "musl") || target_env == "ohos" + { set_cfg("musl_v1_2_3"); + if musl32_time64 && MUSL_TIME64_ARCHS.contains(&target_arch.as_str()) { + set_cfg("musl32_time64"); + set_cfg("linux_time_bits64"); + } } let linux_time_bits64 = env::var("RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64").is_ok(); println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64"); diff --git a/ci/run-docker.sh b/ci/run-docker.sh index 9411d39e5f670..24ee73eb13fd5 100755 --- a/ci/run-docker.sh +++ b/ci/run-docker.sh @@ -45,6 +45,8 @@ run() { --env LIBC_CI_ZBUILD_STD \ --env RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS \ --env RUST_LIBC_UNSTABLE_GNU_TIME_BITS \ + --env RUST_LIBC_UNSTABLE_MUSL_V1_2_3 \ + --env RUST_LIBC_UNSTABLE_MUSL_TIME64 \ --env CARGO_HOME=/cargo \ --env CARGO_TARGET_DIR=/checkout/target \ --volume "$CARGO_HOME":/cargo \ diff --git a/ci/verify-build.sh b/ci/verify-build.sh index eab203df3129a..aa19e4df3c1c0 100755 --- a/ci/verify-build.sh +++ b/ci/verify-build.sh @@ -81,6 +81,15 @@ test_target() { # Test with the equivalent of _TIME_BITS=64 RUST_LIBC_UNSTABLE_GNU_TIME_BITS=64 $cmd ;; + arm*-musl*|i*86-musl|powerpc-*-musl*|mips*-musl) + # Test with new musl changes and the equivalent of _REDIR_TIME64 + RUST_LIBC_UNSTABLE_MUSL_V1_2_3=1 \ + RUST_LIBC_UNSTABLE_MUSL_TIME64=1 $cmd + ;; + *musl*) + # Test with the new musl changes. + RUST_LIBC_UNSTABLE_MUSL_V1_2_3=1 $cmd + ;; esac fi diff --git a/libc-test/build.rs b/libc-test/build.rs index 23eef46d3e617..a1e15a2d75cbd 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -3683,14 +3683,22 @@ fn test_linux(target: &str) { let loongarch64 = target.contains("loongarch64"); let wasm32 = target.contains("wasm32"); let uclibc = target.contains("uclibc"); + let mips64 = target.contains("mips64"); + let mips32 = target.contains("mips") && !mips64; let musl_v1_2_3 = env::var("RUST_LIBC_UNSTABLE_MUSL_V1_2_3").is_ok(); + let musl32_time64 = env::var("RUST_LIBC_UNSTABLE_MUSL_TIME64").is_ok(); let old_musl = musl && !musl_v1_2_3; let mut cfg = ctest_cfg(); - if musl_v1_2_3 { + if (musl_v1_2_3 || loongarch64) && musl { cfg.cfg("musl_v1_2_3", None); + if musl32_time64 && (arm || ppc || x86_32 || mips32) { + cfg.cfg("musl32_time64", None); + cfg.cfg("linux_time_bits64", None); + } } + cfg.define("_GNU_SOURCE", None); // This macro re-defines fscanf,scanf,sscanf to link to the symbols that are // deprecated since glibc >= 2.29. This allows Rust binaries to link against @@ -4299,6 +4307,10 @@ fn test_linux(target: &str) { if old_musl && name == "RLIM_NLIMITS" { return true; } + // Incorrectly named and renamed upstream: + if old_musl && name == "SIGSTKFLT" { + return true; + } } match name { // These constants are not available if gnu headers have been included @@ -4872,7 +4884,9 @@ fn test_linux(target: &str) { // the `xsk_tx_metadata_union` field is an anonymous union (struct_ == "xsk_tx_metadata" && field == "xsk_tx_metadata_union") || // After musl 1.2.0, the type becomes `int` instead of `long`. - (old_musl && struct_ == "utmpx" && field == "ut_session") + (old_musl && struct_ == "utmpx" && field == "ut_session") || + // FIXME(linux): this is changed to separate sec/usec fields when time64 is enabled + (struct_ == "input_event" && field == "time") }); cfg.skip_roundtrip(move |s| match s { diff --git a/libc-test/semver/linux-powerpc-gnu.txt b/libc-test/semver/linux-powerpc-gnu.txt new file mode 100644 index 0000000000000..d63be666e789f --- /dev/null +++ b/libc-test/semver/linux-powerpc-gnu.txt @@ -0,0 +1,16 @@ +KEYCTL_CAPABILITIES +KEYCTL_CAPS0_BIG_KEY +KEYCTL_CAPS0_CAPABILITIES +KEYCTL_CAPS0_DIFFIE_HELLMAN +KEYCTL_CAPS0_INVALIDATE +KEYCTL_CAPS0_MOVE +KEYCTL_CAPS0_PERSISTENT_KEYRINGS +KEYCTL_CAPS0_PUBLIC_KEY +KEYCTL_CAPS0_RESTRICT_KEYRING +KEYCTL_CAPS1_NS_KEYRING_NAME +KEYCTL_CAPS1_NS_KEY_TAG +KEYCTL_MOVE +PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP +PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP +PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP +sysctl diff --git a/libc-test/semver/linux-powerpc.txt b/libc-test/semver/linux-powerpc.txt index 2826bb98d20e3..a559c891a4f95 100644 --- a/libc-test/semver/linux-powerpc.txt +++ b/libc-test/semver/linux-powerpc.txt @@ -2,27 +2,12 @@ B2500000 B3000000 B3500000 B4000000 -KEYCTL_CAPABILITIES -KEYCTL_CAPS0_BIG_KEY -KEYCTL_CAPS0_CAPABILITIES -KEYCTL_CAPS0_DIFFIE_HELLMAN -KEYCTL_CAPS0_INVALIDATE -KEYCTL_CAPS0_MOVE -KEYCTL_CAPS0_PERSISTENT_KEYRINGS -KEYCTL_CAPS0_PUBLIC_KEY -KEYCTL_CAPS0_RESTRICT_KEYRING -KEYCTL_CAPS1_NS_KEYRING_NAME -KEYCTL_CAPS1_NS_KEY_TAG -KEYCTL_MOVE MADV_SOFT_OFFLINE MAP_SYNC NFT_MSG_DELOBJ NFT_MSG_GETOBJ NFT_MSG_GETOBJ_RESET NFT_MSG_NEWOBJ -PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP -PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP -PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP PTRACE_GETFPREGS PTRACE_GETREGS PTRACE_SETFPREGS @@ -158,4 +143,3 @@ TIOCSRS485 flock64 fsblkcnt64_t fsfilcnt64_t -sysctl diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 0d0e971d1646f..8ac6a1797192b 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -1,5 +1,6 @@ //! Linux-specific definitions for linux-like values +use core::cfg; use core::mem::size_of; use crate::prelude::*; @@ -2851,9 +2852,17 @@ pub const IPC_NOWAIT: c_int = 0o4000; pub const IPC_RMID: c_int = 0; pub const IPC_SET: c_int = 1; -pub const IPC_STAT: c_int = 2; +pub const IPC_STAT: c_int = if cfg!(musl32_time64) { + 0x102 +} else { + 2 +}; pub const IPC_INFO: c_int = 3; -pub const MSG_STAT: c_int = 11; +pub const MSG_STAT: c_int = if cfg!(musl32_time64) { + 0x10b +} else { + 11 +}; pub const MSG_INFO: c_int = 12; pub const MSG_NOTIFICATION: c_int = 0x8000; @@ -2870,9 +2879,17 @@ pub const GETNCNT: c_int = 14; pub const GETZCNT: c_int = 15; pub const SETVAL: c_int = 16; pub const SETALL: c_int = 17; -pub const SEM_STAT: c_int = 18; +pub const SEM_STAT: c_int = if cfg!(musl32_time64) { + 0x112 +} else { + 18 +}; pub const SEM_INFO: c_int = 19; -pub const SEM_STAT_ANY: c_int = 20; +pub const SEM_STAT_ANY: c_int = if cfg!(musl32_time64) { + 0x114 +} else { + 20 +}; pub const SHM_R: c_int = 0o400; pub const SHM_W: c_int = 0o200; @@ -6108,7 +6125,7 @@ cfg_if! { pub fn aio_error(aiocbp: *const aiocb) -> c_int; #[cfg_attr(gnu_file_offset_bits64, link_name = "aio_return64")] pub fn aio_return(aiocbp: *mut aiocb) -> ssize_t; - #[cfg_attr(gnu_time_bits64, link_name = "__aio_suspend_time64")] + #[cfg_attr(any(musl32_time64, gnu_time_bits64), link_name = "__aio_suspend_time64")] pub fn aio_suspend( aiocb_list: *const *const aiocb, nitems: c_int, @@ -6171,6 +6188,7 @@ cfg_if! { flags: c_ulong, ) -> isize; #[cfg_attr(gnu_time_bits64, link_name = "__futimes64")] + #[cfg_attr(musl32_time64, link_name = "__futimes_time64")] pub fn futimes(fd: c_int, times: *const crate::timeval) -> c_int; } } @@ -6200,7 +6218,7 @@ cfg_if! { msg_len: size_t, msg_prio: *mut c_uint, ) -> ssize_t; - #[cfg_attr(gnu_time_bits64, link_name = "__mq_timedreceive_time64")] + #[cfg_attr(any(gnu_time_bits64, musl32_time64), link_name = "__mq_timedreceive_time64")] pub fn mq_timedreceive( mqd: crate::mqd_t, msg_ptr: *mut c_char, @@ -6214,7 +6232,7 @@ cfg_if! { msg_len: size_t, msg_prio: c_uint, ) -> c_int; - #[cfg_attr(gnu_time_bits64, link_name = "__mq_timedsend_time64")] + #[cfg_attr(any(gnu_time_bits64, musl32_time64), link_name = "__mq_timedsend_time64")] pub fn mq_timedsend( mqd: crate::mqd_t, msg_ptr: *const c_char, @@ -6266,6 +6284,7 @@ extern "C" { pub fn lcong48(p: *mut c_ushort); #[cfg_attr(gnu_time_bits64, link_name = "__lutimes64")] + #[cfg_attr(musl32_time64, link_name = "__lutimes_time64")] pub fn lutimes(file: *const c_char, times: *const crate::timeval) -> c_int; pub fn setpwent(); @@ -6361,9 +6380,9 @@ extern "C" { pub fn fremovexattr(filedes: c_int, name: *const c_char) -> c_int; pub fn signalfd(fd: c_int, mask: *const crate::sigset_t, flags: c_int) -> c_int; pub fn timerfd_create(clockid: crate::clockid_t, flags: c_int) -> c_int; - #[cfg_attr(gnu_time_bits64, link_name = "__timerfd_gettime64")] + #[cfg_attr(any(gnu_time_bits64, musl32_time64), link_name = "__timerfd_gettime64")] pub fn timerfd_gettime(fd: c_int, curr_value: *mut itimerspec) -> c_int; - #[cfg_attr(gnu_time_bits64, link_name = "__timerfd_settime64")] + #[cfg_attr(any(gnu_time_bits64, musl32_time64), link_name = "__timerfd_settime64")] pub fn timerfd_settime( fd: c_int, flags: c_int, @@ -6380,6 +6399,7 @@ extern "C" { ) -> c_int; pub fn dup3(oldfd: c_int, newfd: c_int, flags: c_int) -> c_int; #[cfg_attr(gnu_time_bits64, link_name = "__sigtimedwait64")] + #[cfg_attr(musl32_time64, link_name = "__sigtimedwait_time64")] pub fn sigtimedwait( set: *const sigset_t, info: *mut siginfo_t, @@ -6500,6 +6520,7 @@ extern "C" { 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(gnu_time_bits64, link_name = "__settimeofday64")] + #[cfg_attr(musl32_time64, link_name = "__settimeofday_time64")] pub fn settimeofday(tv: *const crate::timeval, tz: *const crate::timezone) -> c_int; pub fn splice( fd_in: c_int, @@ -6514,8 +6535,10 @@ extern "C" { pub fn eventfd_write(fd: c_int, value: eventfd_t) -> c_int; #[cfg_attr(gnu_time_bits64, link_name = "__sched_rr_get_interval64")] + #[cfg_attr(musl32_time64, link_name = "__sched_rr_get_interval_time64")] pub fn sched_rr_get_interval(pid: crate::pid_t, tp: *mut crate::timespec) -> c_int; #[cfg_attr(gnu_time_bits64, link_name = "__sem_timedwait64")] + #[cfg_attr(musl32_time64, link_name = "__sem_timedwait_time64")] pub fn sem_timedwait(sem: *mut sem_t, abstime: *const crate::timespec) -> c_int; pub fn sem_getvalue(sem: *mut sem_t, sval: *mut c_int) -> c_int; pub fn sched_setparam(pid: crate::pid_t, param: *const crate::sched_param) -> c_int; @@ -6535,6 +6558,7 @@ extern "C" { pub fn prctl(option: c_int, ...) -> c_int; pub fn sched_getparam(pid: crate::pid_t, param: *mut crate::sched_param) -> c_int; #[cfg_attr(gnu_time_bits64, link_name = "__ppoll64")] + #[cfg_attr(musl32_time64, link_name = "__ppoll_time64")] pub fn ppoll( fds: *mut crate::pollfd, nfds: nfds_t, @@ -6548,6 +6572,7 @@ extern "C" { pub fn pthread_mutexattr_setprotocol(attr: *mut pthread_mutexattr_t, protocol: c_int) -> c_int; #[cfg_attr(gnu_time_bits64, link_name = "__pthread_mutex_timedlock64")] + #[cfg_attr(musl32_time64, link_name = "__pthread_mutex_timedlock_time64")] pub fn pthread_mutex_timedlock( lock: *mut pthread_mutex_t, abstime: *const crate::timespec, @@ -6582,7 +6607,10 @@ extern "C" { ... ) -> c_int; pub fn sched_getscheduler(pid: crate::pid_t) -> c_int; - #[cfg_attr(gnu_time_bits64, link_name = "__clock_nanosleep_time64")] + #[cfg_attr( + any(gnu_time_bits64, musl32_time64), + link_name = "__clock_nanosleep_time64" + )] pub fn clock_nanosleep( clk_id: crate::clockid_t, flags: c_int, @@ -6840,9 +6868,9 @@ extern "C" { ) -> c_int; pub fn timer_delete(timerid: crate::timer_t) -> c_int; pub fn timer_getoverrun(timerid: crate::timer_t) -> c_int; - #[cfg_attr(gnu_time_bits64, link_name = "__timer_gettime64")] + #[cfg_attr(any(gnu_time_bits64, musl32_time64), link_name = "__timer_gettime64")] pub fn timer_gettime(timerid: crate::timer_t, curr_value: *mut crate::itimerspec) -> c_int; - #[cfg_attr(gnu_time_bits64, link_name = "__timer_settime64")] + #[cfg_attr(any(gnu_time_bits64, musl32_time64), link_name = "__timer_settime64")] pub fn timer_settime( timerid: crate::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 b9be033a2c2c4..d2bd9738bdbe5 100644 --- a/src/unix/linux_like/linux/musl/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/arm/mod.rs @@ -4,6 +4,11 @@ use crate::prelude::*; pub type wchar_t = u32; s! { + pub struct __c_anonymous_timespec32 { + __tv_sec: c_long, + __tv_nsec: c_long, + } + pub struct stat { pub st_dev: crate::dev_t, __st_dev_padding: c_int, @@ -17,12 +22,27 @@ s! { pub st_size: off_t, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt_t, + #[cfg(musl32_time64)] + __st_atim32: __c_anonymous_timespec32, + #[cfg(musl32_time64)] + __st_mtim32: __c_anonymous_timespec32, + #[cfg(musl32_time64)] + __st_ctim32: __c_anonymous_timespec32, + #[cfg(musl32_time64)] + pub st_ino: crate::ino_t, pub st_atime: crate::time_t, pub st_atime_nsec: c_long, + #[cfg(musl32_time64)] + __st_atim_pad: u32, pub st_mtime: crate::time_t, pub st_mtime_nsec: c_long, + #[cfg(musl32_time64)] + __st_mtim_pad: u32, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, + #[cfg(musl32_time64)] + __st_ctim_pad: u32, + #[cfg(not(musl32_time64))] pub st_ino: crate::ino_t, } @@ -39,12 +59,27 @@ s! { pub st_size: off_t, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt_t, + #[cfg(musl32_time64)] + __st_atim32: __c_anonymous_timespec32, + #[cfg(musl32_time64)] + __st_mtim32: __c_anonymous_timespec32, + #[cfg(musl32_time64)] + __st_ctim32: __c_anonymous_timespec32, + #[cfg(musl32_time64)] + pub st_ino: crate::ino_t, pub st_atime: crate::time_t, pub st_atime_nsec: c_long, + #[cfg(musl32_time64)] + __st_atim_pad: u32, pub st_mtime: crate::time_t, pub st_mtime_nsec: c_long, + #[cfg(musl32_time64)] + __st_mtim_pad: u32, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, + #[cfg(musl32_time64)] + __st_ctim_pad: u32, + #[cfg(not(musl32_time64))] pub st_ino: crate::ino_t, } @@ -77,27 +112,78 @@ s! { pub struct shmid_ds { pub shm_perm: crate::ipc_perm, pub shm_segsz: size_t, + + #[cfg(musl32_time64)] + __shm_atime_lo: c_ulong, + #[cfg(musl32_time64)] + __shm_atime_hi: c_ulong, + #[cfg(musl32_time64)] + __shm_dtime_lo: c_ulong, + #[cfg(musl32_time64)] + __shm_dtime_hi: c_ulong, + #[cfg(musl32_time64)] + __msg_ctime_lo: c_ulong, + #[cfg(musl32_time64)] + __msg_ctime_hi: c_ulong, + + #[cfg(not(musl32_time64))] pub shm_atime: crate::time_t, + #[cfg(not(musl32_time64))] __unused1: c_int, + #[cfg(not(musl32_time64))] pub shm_dtime: crate::time_t, + #[cfg(not(musl32_time64))] __unused2: c_int, + #[cfg(not(musl32_time64))] pub shm_ctime: crate::time_t, + #[cfg(not(musl32_time64))] __unused3: c_int, + pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, pub shm_nattch: c_ulong, __pad1: c_ulong, __pad2: c_ulong, + + #[cfg(musl32_time64)] + __pad3: c_ulong, + #[cfg(musl32_time64)] + shm_atime: crate::time_t, + #[cfg(musl32_time64)] + shm_dtime: crate::time_t, + #[cfg(musl32_time64)] + shm_ctime: crate::time_t, } pub struct msqid_ds { pub msg_perm: crate::ipc_perm, + + #[cfg(musl32_time64)] + __msg_stime_lo: c_ulong, + #[cfg(musl32_time64)] + __msg_stime_hi: c_ulong, + #[cfg(musl32_time64)] + __msg_rtime_lo: c_ulong, + #[cfg(musl32_time64)] + __msg_rtime_hi: c_ulong, + #[cfg(musl32_time64)] + __msg_ctime_lo: c_ulong, + #[cfg(musl32_time64)] + __msg_ctime_hi: c_ulong, + + #[cfg(not(musl32_time64))] pub msg_stime: crate::time_t, + #[cfg(not(musl32_time64))] __unused1: c_int, + #[cfg(not(musl32_time64))] pub msg_rtime: crate::time_t, + #[cfg(not(musl32_time64))] __unused2: c_int, + #[cfg(not(musl32_time64))] pub msg_ctime: crate::time_t, + #[cfg(not(musl32_time64))] __unused3: c_int, + pub __msg_cbytes: c_ulong, pub msg_qnum: crate::msgqnum_t, pub msg_qbytes: crate::msglen_t, @@ -105,6 +191,13 @@ s! { pub msg_lrpid: crate::pid_t, __pad1: c_ulong, __pad2: c_ulong, + + #[cfg(musl32_time64)] + pub msg_stime: crate::time_t, + #[cfg(musl32_time64)] + pub msg_rtime: crate::time_t, + #[cfg(musl32_time64)] + pub msg_ctime: crate::time_t, } pub struct mcontext_t { 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 3f2b73decbec6..37e000c2b1fe2 100644 --- a/src/unix/linux_like/linux/musl/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/mips/mod.rs @@ -3,7 +3,110 @@ use crate::prelude::*; pub type wchar_t = c_int; +cfg_if! { + if #[cfg(target_endian = "big")] { + s! { + pub struct msqid_ds { + pub msg_perm: crate::ipc_perm, + + #[cfg(musl32_time64)] + __msg_stime_hi: c_ulong, + #[cfg(musl32_time64)] + __msg_stime_lo: c_ulong, + #[cfg(musl32_time64)] + __msg_rtime_hi: c_ulong, + #[cfg(musl32_time64)] + __msg_rtime_lo: c_ulong, + #[cfg(musl32_time64)] + __msg_ctime_hi: c_ulong, + #[cfg(musl32_time64)] + __msg_ctime_lo: c_ulong, + + #[cfg(not(musl32_time64))] + __unused1: c_int, + #[cfg(not(musl32_time64))] + pub msg_stime: crate::time_t, + #[cfg(not(musl32_time64))] + __unused2: c_int, + #[cfg(not(musl32_time64))] + pub msg_rtime: crate::time_t, + #[cfg(not(musl32_time64))] + __unused3: c_int, + #[cfg(not(musl32_time64))] + pub msg_ctime: crate::time_t, + + pub __msg_cbytes: c_ulong, + pub msg_qnum: crate::msgqnum_t, + pub msg_qbytes: crate::msglen_t, + pub msg_lspid: crate::pid_t, + pub msg_lrpid: crate::pid_t, + __pad1: c_ulong, + __pad2: c_ulong, + + #[cfg(musl32_time64)] + pub msg_stime: crate::time_t, + #[cfg(musl32_time64)] + pub msg_rtime: crate::time_t, + #[cfg(musl32_time64)] + pub msg_ctime: crate::time_t, + } + } + } else { + s! { + pub struct msqid_ds { + pub msg_perm: crate::ipc_perm, + + #[cfg(musl32_time64)] + __msg_stime_lo: c_ulong, + #[cfg(musl32_time64)] + __msg_stime_hi: c_ulong, + #[cfg(musl32_time64)] + __msg_rtime_lo: c_ulong, + #[cfg(musl32_time64)] + __msg_rtime_hi: c_ulong, + #[cfg(musl32_time64)] + __msg_ctime_lo: c_ulong, + #[cfg(musl32_time64)] + __msg_ctime_hi: c_ulong, + + #[cfg(not(musl32_time64))] + pub msg_stime: crate::time_t, + #[cfg(not(musl32_time64))] + __unused1: c_int, + #[cfg(not(musl32_time64))] + pub msg_rtime: crate::time_t, + #[cfg(not(musl32_time64))] + __unused2: c_int, + #[cfg(not(musl32_time64))] + pub msg_ctime: crate::time_t, + #[cfg(not(musl32_time64))] + __unused3: c_int, + + pub __msg_cbytes: c_ulong, + pub msg_qnum: crate::msgqnum_t, + pub msg_qbytes: crate::msglen_t, + pub msg_lspid: crate::pid_t, + pub msg_lrpid: crate::pid_t, + __pad1: c_ulong, + __pad2: c_ulong, + + #[cfg(musl32_time64)] + pub msg_stime: crate::time_t, + #[cfg(musl32_time64)] + pub msg_rtime: crate::time_t, + #[cfg(musl32_time64)] + pub msg_ctime: crate::time_t, + } + } + } +} + s! { + pub struct __c_anonymous_timespec32 { + __tv_sec: c_long, + __tv_nsec: c_long, + } + pub struct stat { pub st_dev: crate::dev_t, __st_padding1: [c_long; 2], @@ -15,22 +118,70 @@ s! { pub st_rdev: crate::dev_t, __st_padding2: [c_long; 2], pub st_size: off_t, + + #[cfg(musl32_time64)] + __st_atim32: __c_anonymous_timespec32, + #[cfg(musl32_time64)] + __st_mtim32: __c_anonymous_timespec32, + #[cfg(musl32_time64)] + __st_ctim32: __c_anonymous_timespec32, + + #[cfg(not(musl32_time64))] pub st_atime: crate::time_t, + #[cfg(not(musl32_time64))] pub st_atime_nsec: c_long, + #[cfg(not(musl32_time64))] pub st_mtime: crate::time_t, + #[cfg(not(musl32_time64))] pub st_mtime_nsec: c_long, + #[cfg(not(musl32_time64))] pub st_ctime: crate::time_t, + #[cfg(not(musl32_time64))] pub st_ctime_nsec: c_long, + pub st_blksize: crate::blksize_t, __st_padding3: c_long, pub st_blocks: crate::blkcnt_t, + #[cfg(not(musl32_time64))] __st_padding4: [c_long; 14], + + + #[cfg(musl32_time64)] + pub st_atime: crate::time_t, + #[cfg(all(musl32_time64, target_endian = "big"))] + __st_atim__pad: u32, + #[cfg(musl32_time64)] + pub st_atime_nsec: c_long, + #[cfg(all(musl32_time64, target_endian = "little"))] + __st_atim__pad: u32, + + #[cfg(musl32_time64)] + pub st_mtime: crate::time_t, + #[cfg(all(musl32_time64, target_endian = "big"))] + __st_mtim__pad: u32, + #[cfg(musl32_time64)] + pub st_mtime_nsec: c_long, + #[cfg(all(musl32_time64, target_endian = "little"))] + __st_mtim__pad: u32, + + + #[cfg(musl32_time64)] + pub st_ctime: crate::time_t, + #[cfg(all(musl32_time64, target_endian = "big"))] + __st_ctim__pad: u32, + #[cfg(musl32_time64)] + pub st_ctime_nsec: c_long, + #[cfg(all(musl32_time64, target_endian = "little"))] + __st_ctim__pad: u32, + + #[cfg(musl32_time64)] + __st_padding4: [c_long; 2], } pub struct stat64 { pub st_dev: crate::dev_t, __st_padding1: [c_long; 2], - pub st_ino: crate::ino64_t, + pub st_ino: crate::ino_t, pub st_mode: crate::mode_t, pub st_nlink: crate::nlink_t, pub st_uid: crate::uid_t, @@ -38,18 +189,67 @@ s! { pub st_rdev: crate::dev_t, __st_padding2: [c_long; 2], pub st_size: off_t, + + #[cfg(musl32_time64)] + __st_atim32: __c_anonymous_timespec32, + #[cfg(musl32_time64)] + __st_mtim32: __c_anonymous_timespec32, + #[cfg(musl32_time64)] + __st_ctim32: __c_anonymous_timespec32, + + #[cfg(not(musl32_time64))] pub st_atime: crate::time_t, + #[cfg(not(musl32_time64))] pub st_atime_nsec: c_long, + #[cfg(not(musl32_time64))] pub st_mtime: crate::time_t, + #[cfg(not(musl32_time64))] pub st_mtime_nsec: c_long, + #[cfg(not(musl32_time64))] pub st_ctime: crate::time_t, + #[cfg(not(musl32_time64))] pub st_ctime_nsec: c_long, + pub st_blksize: crate::blksize_t, __st_padding3: c_long, - pub st_blocks: crate::blkcnt64_t, + pub st_blocks: crate::blkcnt_t, + #[cfg(not(musl32_time64))] __st_padding4: [c_long; 14], + + + #[cfg(musl32_time64)] + pub st_atime: crate::time_t, + #[cfg(all(musl32_time64, target_endian = "big"))] + __st_atim__pad: u32, + #[cfg(musl32_time64)] + pub st_atime_nsec: c_long, + #[cfg(all(musl32_time64, target_endian = "little"))] + __st_atim__pad: u32, + + #[cfg(musl32_time64)] + pub st_mtime: crate::time_t, + #[cfg(all(musl32_time64, target_endian = "big"))] + __st_mtim__pad: u32, + #[cfg(musl32_time64)] + pub st_mtime_nsec: c_long, + #[cfg(all(musl32_time64, target_endian = "little"))] + __st_mtim__pad: u32, + + + #[cfg(musl32_time64)] + pub st_ctime: crate::time_t, + #[cfg(all(musl32_time64, target_endian = "big"))] + __st_ctim__pad: u32, + #[cfg(musl32_time64)] + pub st_ctime_nsec: c_long, + #[cfg(all(musl32_time64, target_endian = "little"))] + __st_ctim__pad: u32, + + #[cfg(musl32_time64)] + __st_padding4: [c_long; 2], } + pub struct stack_t { pub ss_sp: *mut c_void, pub ss_size: size_t, @@ -79,40 +279,40 @@ s! { pub struct shmid_ds { pub shm_perm: crate::ipc_perm, pub shm_segsz: size_t, + #[cfg(not(musl32_time64))] pub shm_atime: crate::time_t, + #[cfg(not(musl32_time64))] pub shm_dtime: crate::time_t, + #[cfg(not(musl32_time64))] pub shm_ctime: crate::time_t, + #[cfg(musl32_time64)] + __shm_atime_lo: c_long, + #[cfg(musl32_time64)] + __shm_dtime_lo: c_long, + #[cfg(musl32_time64)] + __shm_ctime_lo: c_long, pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, pub shm_nattch: c_ulong, + #[cfg(not(musl32_time64))] __pad1: c_ulong, + #[cfg(not(musl32_time64))] __pad2: c_ulong, - } - pub struct msqid_ds { - pub msg_perm: crate::ipc_perm, - #[cfg(target_endian = "big")] - __unused1: c_int, - pub msg_stime: crate::time_t, - #[cfg(target_endian = "little")] - __unused1: c_int, - #[cfg(target_endian = "big")] - __unused2: c_int, - pub msg_rtime: crate::time_t, - #[cfg(target_endian = "little")] - __unused2: c_int, - #[cfg(target_endian = "big")] - __unused3: c_int, - pub msg_ctime: crate::time_t, - #[cfg(target_endian = "little")] - __unused3: c_int, - pub __msg_cbytes: c_ulong, - pub msg_qnum: crate::msgqnum_t, - pub msg_qbytes: crate::msglen_t, - pub msg_lspid: crate::pid_t, - pub msg_lrpid: crate::pid_t, - __pad1: c_ulong, - __pad2: c_ulong, + #[cfg(musl32_time64)] + __shm_atime_hi: c_ushort, + #[cfg(musl32_time64)] + __shm_dtime_hi: c_ushort, + #[cfg(musl32_time64)] + __shm_ctime_hi: c_ushort, + #[cfg(musl32_time64)] + __pad1: c_ushort, + #[cfg(musl32_time64)] + pub shm_atime: crate::time_t, + #[cfg(musl32_time64)] + pub shm_dtime: crate::time_t, + #[cfg(musl32_time64)] + pub shm_ctime: crate::time_t, } pub struct statfs { @@ -363,6 +563,13 @@ 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 SIGEMT: c_int = 7; +#[cfg(not(musl_v1_2_3))] +#[deprecated( + since = "0.2.173", + note = "This signal actually corresponds to SIGEMT was incorrectly named in musl. + As it does not exist on mips it will be dropped entirely in a future release" +)] pub const SIGSTKFLT: c_int = 7; pub const SIGPOLL: c_int = crate::SIGIO; pub const SIGPWR: c_int = 19; diff --git a/src/unix/linux_like/linux/musl/b32/powerpc.rs b/src/unix/linux_like/linux/musl/b32/powerpc.rs index 460b2d8fcf0ee..d6681aabebc67 100644 --- a/src/unix/linux_like/linux/musl/b32/powerpc.rs +++ b/src/unix/linux_like/linux/musl/b32/powerpc.rs @@ -4,6 +4,11 @@ use crate::prelude::*; pub type wchar_t = i32; s! { + pub struct __c_anonymous_timespec32 { + __tv_sec: c_long, + __tv_nsec: c_long, + } + pub struct stat { pub st_dev: crate::dev_t, pub st_ino: crate::ino_t, @@ -16,12 +21,27 @@ s! { pub st_size: off_t, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt_t, + #[cfg(musl32_time64)] + __st_atim32: __c_anonymous_timespec32, + #[cfg(musl32_time64)] + __st_mtim32: __c_anonymous_timespec32, + #[cfg(musl32_time64)] + __st_ctim32: __c_anonymous_timespec32, + #[cfg(musl32_time64)] + __unused: [c_long; 2], pub st_atime: crate::time_t, + #[cfg(musl32_time64)] + __st_atim__pad: u32, pub st_atime_nsec: c_long, pub st_mtime: crate::time_t, + #[cfg(musl32_time64)] + __st_mtim__pad: u32, pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, + #[cfg(musl32_time64)] + __st_ctim__pad: u32, pub st_ctime_nsec: c_long, + #[cfg(not(musl32_time64))] __unused: [c_long; 2], } @@ -37,12 +57,27 @@ s! { pub st_size: off_t, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt_t, + #[cfg(musl32_time64)] + __st_atim32: __c_anonymous_timespec32, + #[cfg(musl32_time64)] + __st_mtim32: __c_anonymous_timespec32, + #[cfg(musl32_time64)] + __st_ctim32: __c_anonymous_timespec32, + #[cfg(musl32_time64)] + __unused: [c_long; 2], pub st_atime: crate::time_t, + #[cfg(musl32_time64)] + __st_atim__pad: u32, pub st_atime_nsec: c_long, pub st_mtime: crate::time_t, + #[cfg(musl32_time64)] + __st_mtim__pad: u32, pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, + #[cfg(musl32_time64)] + __st_ctim__pad: u32, pub st_ctime_nsec: c_long, + #[cfg(not(musl32_time64))] __unused: [c_long; 2], } @@ -75,29 +110,83 @@ s! { pub struct shmid_ds { pub shm_perm: crate::ipc_perm, + + #[cfg(musl32_time64)] + __shm_atime_hi: c_ulong, + #[cfg(musl32_time64)] + __shm_atime_lo: c_ulong, + #[cfg(musl32_time64)] + __shm_dtime_hi: c_ulong, + #[cfg(musl32_time64)] + __shm_dtime_lo: c_ulong, + #[cfg(musl32_time64)] + __shm_ctime_hi: c_ulong, + #[cfg(musl32_time64)] + __shm_ctime_lo: c_ulong, + + #[cfg(not(musl32_time64))] __unused1: c_int, + #[cfg(not(musl32_time64))] pub shm_atime: crate::time_t, + #[cfg(not(musl32_time64))] __unused2: c_int, + #[cfg(not(musl32_time64))] pub shm_dtime: crate::time_t, + #[cfg(not(musl32_time64))] __unused3: c_int, + #[cfg(not(musl32_time64))] pub shm_ctime: crate::time_t, + #[cfg(not(musl32_time64))] __unused4: c_int, + + #[cfg(musl32_time64)] + __pad1: c_ulong, + pub shm_segsz: size_t, pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, pub shm_nattch: c_ulong, + #[cfg(not(musl32_time64))] __pad1: c_ulong, __pad2: c_ulong, + + #[cfg(musl32_time64)] + pub shm_atime: crate::time_t, + #[cfg(musl32_time64)] + pub shm_dtime: crate::time_t, + #[cfg(musl32_time64)] + pub shm_ctime: crate::time_t, } pub struct msqid_ds { pub msg_perm: crate::ipc_perm, + + #[cfg(musl32_time64)] + __msg_stime_hi: c_ulong, + #[cfg(musl32_time64)] + __msg_stime_lo: c_ulong, + #[cfg(musl32_time64)] + __msg_rtime_hi: c_ulong, + #[cfg(musl32_time64)] + __msg_rtime_lo: c_ulong, + #[cfg(musl32_time64)] + __msg_ctime_hi: c_ulong, + #[cfg(musl32_time64)] + __msg_ctime_lo: c_ulong, + + #[cfg(not(musl32_time64))] __unused1: c_int, + #[cfg(not(musl32_time64))] pub msg_stime: crate::time_t, + #[cfg(not(musl32_time64))] __unused2: c_int, + #[cfg(not(musl32_time64))] pub msg_rtime: crate::time_t, + #[cfg(not(musl32_time64))] __unused3: c_int, + #[cfg(not(musl32_time64))] pub msg_ctime: crate::time_t, + pub __msg_cbytes: c_ulong, pub msg_qnum: crate::msgqnum_t, pub msg_qbytes: crate::msglen_t, @@ -105,6 +194,13 @@ s! { pub msg_lrpid: crate::pid_t, __pad1: c_ulong, __pad2: c_ulong, + + #[cfg(musl32_time64)] + pub msg_stime: crate::time_t, + #[cfg(musl32_time64)] + pub msg_rtime: crate::time_t, + #[cfg(musl32_time64)] + pub msg_ctime: crate::time_t, } } 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 583e0a51eacb0..21bdceda8ab9a 100644 --- a/src/unix/linux_like/linux/musl/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/x86/mod.rs @@ -4,6 +4,11 @@ use crate::prelude::*; pub type wchar_t = i32; s! { + pub struct __c_anonymous_timespec32 { + __tv_sec: c_long, + __tv_nsec: c_long, + } + pub struct stat { pub st_dev: crate::dev_t, __st_dev_padding: c_int, @@ -17,12 +22,27 @@ s! { pub st_size: off_t, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt_t, + #[cfg(musl32_time64)] + __st_atim32: __c_anonymous_timespec32, + #[cfg(musl32_time64)] + __st_mtim32: __c_anonymous_timespec32, + #[cfg(musl32_time64)] + __st_ctim32: __c_anonymous_timespec32, + #[cfg(musl32_time64)] + pub st_ino: crate::ino_t, pub st_atime: crate::time_t, pub st_atime_nsec: c_long, + #[cfg(musl32_time64)] + __st_atim_pad: u32, pub st_mtime: crate::time_t, pub st_mtime_nsec: c_long, + #[cfg(musl32_time64)] + __st_mtim_pad: u32, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, + #[cfg(musl32_time64)] + __st_ctim_pad: u32, + #[cfg(not(musl32_time64))] pub st_ino: crate::ino_t, } @@ -39,12 +59,27 @@ s! { pub st_size: off_t, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt_t, + #[cfg(musl32_time64)] + __st_atim32: __c_anonymous_timespec32, + #[cfg(musl32_time64)] + __st_mtim32: __c_anonymous_timespec32, + #[cfg(musl32_time64)] + __st_ctim32: __c_anonymous_timespec32, + #[cfg(musl32_time64)] + pub st_ino: crate::ino_t, pub st_atime: crate::time_t, pub st_atime_nsec: c_long, + #[cfg(musl32_time64)] + __st_atim_pad: u32, pub st_mtime: crate::time_t, pub st_mtime_nsec: c_long, + #[cfg(musl32_time64)] + __st_mtim_pad: u32, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, + #[cfg(musl32_time64)] + __st_ctim_pad: u32, + #[cfg(not(musl32_time64))] pub st_ino: crate::ino_t, } @@ -81,27 +116,79 @@ s! { pub struct shmid_ds { pub shm_perm: crate::ipc_perm, pub shm_segsz: size_t, + + #[cfg(musl32_time64)] + __shm_atime_lo: c_ulong, + #[cfg(musl32_time64)] + __shm_atime_hi: c_ulong, + #[cfg(musl32_time64)] + __shm_dtime_lo: c_ulong, + #[cfg(musl32_time64)] + __shm_dtime_hi: c_ulong, + #[cfg(musl32_time64)] + __msg_ctime_lo: c_ulong, + #[cfg(musl32_time64)] + __msg_ctime_hi: c_ulong, + + #[cfg(not(musl32_time64))] pub shm_atime: crate::time_t, + #[cfg(not(musl32_time64))] __unused1: c_int, + #[cfg(not(musl32_time64))] pub shm_dtime: crate::time_t, + #[cfg(not(musl32_time64))] __unused2: c_int, + #[cfg(not(musl32_time64))] pub shm_ctime: crate::time_t, + #[cfg(not(musl32_time64))] __unused3: c_int, + pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, pub shm_nattch: c_ulong, __pad1: c_ulong, __pad2: c_ulong, + + #[cfg(musl32_time64)] + __pad3: c_ulong, + #[cfg(musl32_time64)] + shm_atime: crate::time_t, + #[cfg(musl32_time64)] + shm_dtime: crate::time_t, + #[cfg(musl32_time64)] + shm_ctime: crate::time_t, } pub struct msqid_ds { pub msg_perm: crate::ipc_perm, + + #[cfg(musl32_time64)] + __msg_stime_lo: c_ulong, + #[cfg(musl32_time64)] + __msg_stime_hi: c_ulong, + #[cfg(musl32_time64)] + __msg_rtime_lo: c_ulong, + #[cfg(musl32_time64)] + __msg_rtime_hi: c_ulong, + #[cfg(musl32_time64)] + __msg_ctime_lo: c_ulong, + #[cfg(musl32_time64)] + __msg_ctime_hi: c_ulong, + + + #[cfg(not(musl32_time64))] pub msg_stime: crate::time_t, + #[cfg(not(musl32_time64))] __unused1: c_int, + #[cfg(not(musl32_time64))] pub msg_rtime: crate::time_t, + #[cfg(not(musl32_time64))] __unused2: c_int, + #[cfg(not(musl32_time64))] pub msg_ctime: crate::time_t, + #[cfg(not(musl32_time64))] __unused3: c_int, + pub __msg_cbytes: c_ulong, pub msg_qnum: crate::msgqnum_t, pub msg_qbytes: crate::msglen_t, @@ -109,6 +196,13 @@ s! { pub msg_lrpid: crate::pid_t, __pad1: c_ulong, __pad2: c_ulong, + + #[cfg(musl32_time64)] + pub msg_stime: crate::time_t, + #[cfg(musl32_time64)] + pub msg_rtime: crate::time_t, + #[cfg(musl32_time64)] + pub msg_ctime: crate::time_t, } } diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 69d1dc24c940e..9f5ea5d967a99 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -3,6 +3,9 @@ use crate::prelude::*; pub type pthread_t = *mut c_void; pub type clock_t = c_long; +#[cfg(musl32_time64)] +pub type time_t = i64; +#[cfg(not(musl32_time64))] #[cfg_attr( not(feature = "rustc-dep-of-std"), deprecated( @@ -13,6 +16,18 @@ pub type clock_t = c_long; ) )] pub type time_t = c_long; +#[cfg(musl32_time64)] +pub type suseconds_t = i64; +#[cfg(not(musl32_time64))] +#[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 suseconds_t = c_long; pub type ino_t = u64; pub type off_t = i64; @@ -841,6 +856,7 @@ extern "C" { vlen: c_uint, flags: c_uint, ) -> c_int; + #[cfg_attr(musl32_time64, link_name = "__recvmmsg_time64")] pub fn recvmmsg( sockfd: c_int, msgvec: *mut crate::mmsghdr, @@ -857,6 +873,7 @@ extern "C" { new_limit: *const crate::rlimit, old_limit: *mut crate::rlimit, ) -> c_int; + #[cfg_attr(musl32_time64, link_name = "__gettimeofday_time64")] pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut c_void) -> c_int; pub fn ptrace(request: c_int, ...) -> c_long; pub fn getpriority(which: c_int, who: crate::id_t) -> c_int; @@ -892,7 +909,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(musl32_time64, link_name = "__adjtimex_time64")] pub fn adjtimex(buf: *mut crate::timex) -> c_int; + #[cfg_attr(musl32_time64, link_name = "__clock_adjtime64")] pub fn clock_adjtime(clk_id: crate::clockid_t, buf: *mut crate::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 0c68006f56c01..879b5c1a6f6b1 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -13,6 +13,46 @@ missing! { pub enum timezone {} } +// FIXME(musl): these changes are not strictly part of time64 but the fact musl_v1_2_3 is enabled +// on ohos makes it awkward. +cfg_if! { + if #[cfg(not(any(target_env = "musl", target_os = "emscripten", target_env = "ohos")))] { + s! { + pub struct sched_param { + pub sched_priority: c_int, + } + } + } else if #[cfg(musl32_time64)] { + s! { + pub struct sched_param { + pub sched_priority: c_int, + + __reserved1: c_int, + //#[cfg(musl32_time64)] + __reserved2: [c_long; 4], + //#[cfg(not(musl32_time64))] + //__reserved2: [crate::timespec; 2], + __reserved3: c_int, + } + } + } else { + s! { + pub struct sched_param { + pub sched_priority: c_int, + + #[deprecated(since = "0.2.173", note = "This field has been removed upstream and we'll follow that change in a future release.")] + pub sched_ss_low_priority: c_int, + #[deprecated(since = "0.2.173", note = "This field has been removed upstream and we'll follow that change in a future release.")] + pub sched_ss_repl_period: crate::timespec, + #[deprecated(since = "0.2.173", note = "This field has been removed upstream and we'll follow that change in a future release.")] + pub sched_ss_init_budget: crate::timespec, + #[deprecated(since = "0.2.173", note = "This field has been removed upstream and we'll follow that change in a future release.")] + pub sched_ss_max_repl: c_int, + } + } + } +} + s! { // FIXME(1.0): This should not implement `PartialEq` #[allow(unpredictable_function_pointer_comparisons)] @@ -110,18 +150,6 @@ s! { pub tm_zone: *const c_char, } - pub struct sched_param { - pub sched_priority: c_int, - #[cfg(any(target_env = "musl", target_os = "emscripten", target_env = "ohos"))] - pub sched_ss_low_priority: c_int, - #[cfg(any(target_env = "musl", target_os = "emscripten", target_env = "ohos"))] - pub sched_ss_repl_period: crate::timespec, - #[cfg(any(target_env = "musl", target_os = "emscripten", target_env = "ohos"))] - pub sched_ss_init_budget: crate::timespec, - #[cfg(any(target_env = "musl", target_os = "emscripten", target_env = "ohos"))] - pub sched_ss_max_repl: c_int, - } - pub struct Dl_info { pub dli_fname: *const c_char, pub dli_fbase: *mut c_void, @@ -1921,10 +1949,11 @@ extern "C" { pub fn mincore(addr: *mut c_void, len: size_t, vec: *mut c_uchar) -> c_int; #[cfg_attr(gnu_time_bits64, link_name = "__clock_getres64")] + #[cfg_attr(musl32_time64, link_name = "__clock_getres_time64")] pub fn clock_getres(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; - #[cfg_attr(gnu_time_bits64, link_name = "__clock_gettime64")] + #[cfg_attr(any(gnu_time_bits64, musl32_time64), link_name = "__clock_gettime64")] pub fn clock_gettime(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; - #[cfg_attr(gnu_time_bits64, link_name = "__clock_settime64")] + #[cfg_attr(any(gnu_time_bits64, musl32_time64), link_name = "__clock_settime64")] pub fn clock_settime(clk_id: crate::clockid_t, tp: *const crate::timespec) -> c_int; pub fn clock_getcpuclockid(pid: crate::pid_t, clk_id: *mut crate::clockid_t) -> c_int; @@ -1952,8 +1981,10 @@ extern "C" { #[cfg_attr(gnu_file_offset_bits64, link_name = "posix_fadvise64")] pub fn posix_fadvise(fd: c_int, offset: off_t, len: off_t, advise: c_int) -> c_int; #[cfg_attr(gnu_time_bits64, link_name = "__futimens64")] + #[cfg_attr(musl32_time64, link_name = "__futimens_time64")] pub fn futimens(fd: c_int, times: *const crate::timespec) -> c_int; #[cfg_attr(gnu_time_bits64, link_name = "__utimensat64")] + #[cfg_attr(musl32_time64, link_name = "__utimensat_time64")] pub fn utimensat( dirfd: c_int, path: *const c_char, @@ -2003,7 +2034,7 @@ extern "C" { pub fn sbrk(increment: intptr_t) -> *mut c_void; pub fn setresgid(rgid: crate::gid_t, egid: crate::gid_t, sgid: crate::gid_t) -> c_int; pub fn setresuid(ruid: crate::uid_t, euid: crate::uid_t, suid: crate::uid_t) -> c_int; - #[cfg_attr(gnu_time_bits64, link_name = "__wait4_time64")] + #[cfg_attr(any(gnu_time_bits64, musl32_time64), link_name = "__wait4_time64")] pub fn wait4( pid: crate::pid_t, status: *mut c_int, diff --git a/src/unix/mod.rs b/src/unix/mod.rs index c9415554b2c1b..e03b3c21dace2 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -71,10 +71,14 @@ s! { #[cfg(not(target_env = "gnu"))] pub struct timespec { pub tv_sec: time_t, + #[cfg(all(musl32_time64, 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(musl32_time64, target_endian = "little"))] + __pad0: u32, } pub struct rlimit { @@ -877,6 +881,7 @@ extern "C" { all(not(gnu_time_bits64), gnu_file_offset_bits64), link_name = "fstat64" )] + #[cfg_attr(musl32_time64, 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; @@ -895,6 +900,7 @@ extern "C" { all(not(gnu_time_bits64), gnu_file_offset_bits64), link_name = "stat64" )] + #[cfg_attr(musl32_time64, link_name = "__stat_time64")] pub fn stat(path: *const c_char, buf: *mut stat) -> c_int; pub fn pclose(stream: *mut crate::FILE) -> c_int; @@ -987,6 +993,7 @@ extern "C" { all(not(gnu_time_bits64), gnu_file_offset_bits64), link_name = "fstatat64" )] + #[cfg_attr(musl32_time64, link_name = "__fstatat_time64")] pub fn fstatat(dirfd: c_int, pathname: *const c_char, buf: *mut stat, flags: c_int) -> c_int; pub fn linkat( olddirfd: c_int, @@ -1087,6 +1094,7 @@ extern "C" { )] #[cfg_attr(target_os = "netbsd", link_name = "__nanosleep50")] #[cfg_attr(gnu_time_bits64, link_name = "__nanosleep64")] + #[cfg_attr(musl32_time64, 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: crate::pid_t) -> c_int; @@ -1131,7 +1139,7 @@ extern "C" { pub fn umask(mask: mode_t) -> mode_t; #[cfg_attr(target_os = "netbsd", link_name = "__utime50")] - #[cfg_attr(gnu_time_bits64, link_name = "__utime64")] + #[cfg_attr(any(gnu_time_bits64, musl32_time64), link_name = "__utime64")] pub fn utime(file: *const c_char, buf: *const utimbuf) -> c_int; #[cfg_attr( @@ -1186,6 +1194,7 @@ extern "C" { all(not(gnu_time_bits64), gnu_file_offset_bits64), link_name = "lstat64" )] + #[cfg_attr(musl32_time64, link_name = "__lstat_time64")] pub fn lstat(path: *const c_char, buf: *mut stat) -> c_int; #[cfg_attr( @@ -1217,6 +1226,7 @@ extern "C" { #[cfg_attr(target_os = "netbsd", link_name = "__getrusage50")] #[cfg_attr(gnu_time_bits64, link_name = "__getrusage64")] + #[cfg_attr(musl32_time64, link_name = "__getrusage_time64")] pub fn getrusage(resource: c_int, usage: *mut rusage) -> c_int; #[cfg_attr( @@ -1293,6 +1303,7 @@ extern "C" { link_name = "pthread_cond_timedwait$UNIX2003" )] #[cfg_attr(gnu_time_bits64, link_name = "__pthread_cond_timedwait64")] + #[cfg_attr(musl32_time64, link_name = "__pthread_cond_timedwait_time64")] pub fn pthread_cond_timedwait( cond: *mut pthread_cond_t, lock: *mut pthread_mutex_t, @@ -1361,9 +1372,11 @@ extern "C" { #[cfg_attr(target_os = "netbsd", link_name = "__utimes50")] #[cfg_attr(gnu_time_bits64, link_name = "__utimes64")] + #[cfg_attr(musl32_time64, link_name = "__utimes_time64")] pub fn utimes(filename: *const c_char, times: *const crate::timeval) -> c_int; pub fn dlopen(filename: *const c_char, flag: c_int) -> *mut c_void; pub fn dlerror() -> *mut c_char; + #[cfg_attr(musl32_time64, 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; @@ -1411,49 +1424,44 @@ 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(time): for `time_t` #[cfg_attr(gnu_time_bits64, link_name = "__gmtime64_r")] + #[cfg_attr(not(musl32_time64), allow(deprecated))] + #[cfg_attr(musl32_time64, 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(time): for `time_t` #[cfg_attr(gnu_time_bits64, link_name = "__localtime64_r")] + #[cfg_attr(not(musl32_time64), allow(deprecated))] + #[cfg_attr(musl32_time64, 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(gnu_time_bits64, link_name = "__mktime64")] + #[cfg_attr(any(gnu_time_bits64, musl32_time64), link_name = "__mktime64")] + #[cfg_attr(not(musl32_time64), allow(deprecated))] 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(gnu_time_bits64, link_name = "__time64")] + #[cfg_attr(any(gnu_time_bits64, musl32_time64), link_name = "__time64")] + #[cfg_attr(not(musl32_time64), allow(deprecated))] 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(time): for `time_t` - #[cfg_attr(gnu_time_bits64, link_name = "__gmtime64")] + #[cfg_attr(any(gnu_time_bits64, musl32_time64), link_name = "__gmtime64")] + #[cfg_attr(not(musl32_time64), allow(deprecated))] 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(time): for `time_t` - #[cfg_attr(gnu_time_bits64, link_name = "__localtime64")] + #[cfg_attr(any(gnu_time_bits64, musl32_time64), link_name = "__localtime64")] + #[cfg_attr(not(musl32_time64), allow(deprecated))] 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(time): for `time_t` - #[cfg_attr(gnu_time_bits64, link_name = "__difftime64")] + #[cfg_attr(any(gnu_time_bits64, musl32_time64), link_name = "__difftime64")] + #[cfg_attr(not(musl32_time64), allow(deprecated))] pub fn difftime(time1: time_t, time0: time_t) -> c_double; #[cfg(not(target_os = "aix"))] #[cfg_attr(target_os = "netbsd", link_name = "__timegm50")] - #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))] - // FIXME(time): for `time_t` #[cfg_attr(gnu_time_bits64, link_name = "__timegm64")] + #[cfg_attr(not(musl32_time64), allow(deprecated))] + #[cfg_attr(musl32_time64, link_name = "__timegm_time64")] pub fn timegm(tm: *mut crate::tm) -> time_t; #[cfg_attr(target_os = "netbsd", link_name = "__mknod50")] @@ -1513,6 +1521,7 @@ extern "C" { #[cfg_attr(target_os = "netbsd", link_name = "__select50")] #[cfg_attr(target_os = "aix", link_name = "__fd_select")] #[cfg_attr(gnu_time_bits64, link_name = "__select64")] + #[cfg_attr(musl32_time64, link_name = "__select_time64")] pub fn select( nfds: c_int, readfds: *mut fd_set, @@ -1635,7 +1644,7 @@ cfg_if! { target_os = "aix", )))] { extern "C" { - #[cfg_attr(gnu_time_bits64, link_name = "__adjtime64")] + #[cfg_attr(any(gnu_time_bits64, musl32_time64), link_name = "__adjtime64")] pub fn adjtime(delta: *const timeval, olddelta: *mut timeval) -> c_int; } } else if #[cfg(target_os = "solaris")] { @@ -1790,6 +1799,7 @@ cfg_if! { )] #[cfg_attr(target_os = "netbsd", link_name = "__pselect50")] #[cfg_attr(gnu_time_bits64, link_name = "__pselect64")] + #[cfg_attr(musl32_time64, link_name = "__pselect_time64")] pub fn pselect( nfds: c_int, readfds: *mut fd_set,