diff --git a/build.rs b/build.rs index c21a1c642bca3..5a705526e3215 100644 --- a/build.rs +++ b/build.rs @@ -28,6 +28,8 @@ const ALLOWED_CFGS: &[&str] = &[ // Corresponds to `__USE_TIME_BITS64` in UAPI "linux_time_bits64", "musl_v1_2_3", + // Corresponds to `_REDIR_TIME64` in musl + "musl32_time64", "vxworks_lt_25_09", ]; @@ -49,6 +51,9 @@ const CHECK_CFG_EXTRA: &[(&str, &[&str])] = &[ ), ]; +/// Musl architectures that set `#define _REDIR_TIME64 1`. +const MUSL_REDIR_TIME64_ARCHES: &[&str] = &["arm", "mips", "powerpc", "x86"]; + fn main() { // Avoid unnecessary re-building. println!("cargo:rerun-if-changed=build.rs"); @@ -99,12 +104,29 @@ fn main() { _ => (), } - let musl_v1_2_3 = env_flag("RUST_LIBC_UNSTABLE_MUSL_V1_2_3"); + let mut musl_v1_2_3 = env_flag("RUST_LIBC_UNSTABLE_MUSL_V1_2_3"); println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_MUSL_V1_2_3"); - // loongarch64 and ohos have already updated - if musl_v1_2_3 || target_arch == "loongarch64" || target_env == "ohos" { - // FIXME(musl): enable time64 api as well + + // OpenHarmony uses a fork of the musl libc + let musl = target_env == "musl" || target_env == "ohos"; + + // loongarch64 and ohos only exist with recent musl + if target_arch == "loongarch64" || target_env == "ohos" { + musl_v1_2_3 = true; + } + + if musl && musl_v1_2_3 { set_cfg("musl_v1_2_3"); + if MUSL_REDIR_TIME64_ARCHES.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"); + if linux_time_bits64 { + set_cfg("linux_time_bits64"); } println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS"); println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_GNU_TIME_BITS"); diff --git a/libc-test/build.rs b/libc-test/build.rs index 25126877d450d..5cef8be6b5d70 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -3690,6 +3690,7 @@ fn test_linux(target: &str) { let i686 = target.contains("i686"); let ppc = target.contains("powerpc"); let ppc64 = target.contains("powerpc64"); + let ppc32 = ppc && !ppc64; let s390x = target.contains("s390x"); let sparc64 = target.contains("sparc64"); let x32 = target.contains("x32"); @@ -3702,6 +3703,8 @@ fn test_linux(target: &str) { let wasm32 = target.contains("wasm32"); let uclibc = target.contains("uclibc"); let mips = target.contains("mips"); + let mips64 = target.contains("mips64"); + let mips32 = mips && !mips64; let musl_v1_2_3 = env::var("RUST_LIBC_UNSTABLE_MUSL_V1_2_3").is_ok(); if musl_v1_2_3 { @@ -3710,8 +3713,12 @@ fn test_linux(target: &str) { 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 arm || ppc32 || 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 @@ -3965,9 +3972,9 @@ fn test_linux(target: &str) { cfg.rename_struct_field(move |struct_, field| { match (struct_.ident(), field.ident()) { // Our stat *_nsec fields normally don't actually exist but are part - // of a timeval struct + // of a timeval struct - this is fixed in musl_v1_2_3 ("stat" | "statfs" | "statvfs" | "stat64" | "statfs64" | "statvfs64", f) - if f.ends_with("_nsec") => + if !musl_v1_2_3 && f.ends_with("_nsec") => { Some(f.replace("e_nsec", ".tv_nsec")) } @@ -4722,8 +4729,6 @@ fn test_linux(target: &str) { ("xsk_tx_metadata", "xsk_tx_metadata_union") => true, // After musl 1.2.0, the type becomes `int` instead of `long`. ("utmpx", "ut_session") if musl => true, - // FIXME(musl,time): changed with the musl time updates - ("input_event", "time") if musl_v1_2_3 => true, // `frames` is a flexible array member ("bcm_msg_head", "frames") => true, // FAM @@ -4776,83 +4781,6 @@ fn test_linux(target: &str) { _ => false, }); - // FIXME(musl,time): these should be resolved with the time64 updates - if musl_v1_2_3 { - // Time primitives changed, as did structs containing them - cfg.skip_alias(|ty| match ty.ident() { - "time_t" | "suseconds_t" => true, - _ => false, - }); - cfg.skip_struct(|s| match s.ident() { - "utimbuf" | "timeval" | "timespec" | "rusage" | "itimerval" | "itimerspec" - | "timex" | "ntptimeval" | "stat" | "shmid_ds" | "msqid_ds" => true, - _ => false, - }); - - cfg.skip_const(|c| match c.ident() { - // Changed syscall numbers under `linux_time_bits64` - "SO_TIMESTAMP" | "SO_TIMESTAMPNS" | "SO_TIMESTAMPING" | "SO_RCVTIMEO" - | "SO_SNDTIMEO" => true, - // Derived from `SO_` constants - "SCM_TIMESTAMP" | "SCM_TIMESTAMPNS" | "SCM_TIMESTAMPING" => true, - // `IPC_STAT` and derived values - "IPC_STAT" | "SEM_STAT" | "SEM_STAT_ANY" => true, - _ => false, - }); - - // Functions that got a new link name - cfg.skip_fn_ptrcheck(|f| match f { - "pthread_mutex_timedlock" - | "recvmmsg" - | "fstat" - | "stat" - | "fstatat" - | "nanosleep" - | "utime" - | "lstat" - | "getrusage" - | "pthread_cond_timedwait" - | "utimes" - | "dlsym" - | "gmtime_r" - | "localtime_r" - | "mktime" - | "time" - | "gmtime" - | "localtime" - | "difftime" - | "timegm" - | "select" - | "adjtime" - | "pselect" - | "clock_getres" - | "clock_gettime" - | "clock_settime" - | "futimens" - | "utimensat" - | "wait4" - | "aio_suspend" - | "futimes" - | "mq_timedreceive" - | "mq_timedsend" - | "lutimes" - | "timerfd_gettime" - | "timerfd_settime" - | "sigtimedwait" - | "settimeofday" - | "sched_rr_get_interval" - | "sem_timedwait" - | "ppoll" - | "clock_nanosleep" - | "timer_gettime" - | "timer_settime" - | "gettimeofday" - | "adjtimex" - | "clock_adjtime" => true, - _ => false, - }); - } - ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); if !l4re { 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/libc-test/tests/style_lib/mod.rs b/libc-test/tests/style_lib/mod.rs index 04eec91df635d..d436dcaaa2800 100644 --- a/libc-test/tests/style_lib/mod.rs +++ b/libc-test/tests/style_lib/mod.rs @@ -51,6 +51,12 @@ use syn::visit::{ use syn::Token; const ALLOWED_REPEATED_MACROS: &[&str] = &["s", "s_no_extra_traits", "s_paren"]; +const ALLOWED_POSITIVE_S_CFGS: &[&str] = &[ + "gnu_file_offset_bits64", + "gnu_time_bits64", + "musl32_time64", + "musl_v1_2_3", +]; pub type Error = Box; pub type Result = std::result::Result; @@ -236,25 +242,6 @@ impl StyleChecker { self.state = initial_state; } - /// If we see a normal s! macro without any attributes we just need - /// to check if there are any duplicates. - fn handle_s_macro_no_attrs(&mut self, item_macro: &syn::ItemMacro) { - let span = item_macro.span(); - match self.seen_s_macro_cfgs.get("") { - Some(seen_span) => { - self.error( - "duplicate s! macro".to_string(), - span, - format!("other s! macro"), - (Some(*seen_span), "combine the two".to_string()), - ); - } - None => { - self.seen_s_macro_cfgs.insert(String::new(), span); - } - } - } - /// If an s! macro has attributes we check for any duplicates as well /// as if they are standalone positive cfgs that would be better /// in a separate file. @@ -285,6 +272,8 @@ impl StyleChecker { if !meta_str.starts_with("not") && !meta_str.starts_with("any") && !meta_str.starts_with("all") + && !meta_str.starts_with("target_endian") + && !ALLOWED_POSITIVE_S_CFGS.contains(&meta_str.as_str()) { self.error( "positive #[cfg] for s! macro".to_string(), @@ -359,9 +348,7 @@ impl<'ast> Visit<'ast> for StyleChecker { /// instead of [syn::Macro] because it contains the attributes. fn visit_item_macro(&mut self, item_macro: &'ast syn::ItemMacro) { if item_macro.mac.path.is_ident("s") { - if item_macro.attrs.is_empty() { - self.handle_s_macro_no_attrs(item_macro); - } else { + if !item_macro.attrs.is_empty() { self.handle_s_macro_with_attrs(item_macro); } } diff --git a/libc-test/tests/style_tests.rs b/libc-test/tests/style_tests.rs index e136bb66d26a4..c325a51770b6e 100644 --- a/libc-test/tests/style_tests.rs +++ b/libc-test/tests/style_tests.rs @@ -154,19 +154,6 @@ s! { pub struct bar { /* ... */ } } checker.finalize().unwrap(); } -#[test] -fn check_style_reject_duplicated_s_macro() { - let contents = r#" -s! {} -s! {} -"# - .to_string(); - - let mut checker = StyleChecker::new(); - checker.check_string(contents).unwrap(); - assert!(checker.finalize().is_err()); -} - #[test] fn check_style_reject_duplicated_s_macro_cfg() { let contents = r#" diff --git a/src/new/common/posix/pthread.rs b/src/new/common/posix/pthread.rs index 50c6f98131294..146cd6042b0bb 100644 --- a/src/new/common/posix/pthread.rs +++ b/src/new/common/posix/pthread.rs @@ -195,6 +195,7 @@ extern "C" { #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] #[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 crate::pthread_mutex_t, abstime: *const crate::timespec, diff --git a/src/new/emscripten/mod.rs b/src/new/emscripten/mod.rs index f0765d3e06fff..9b74464059bb1 100644 --- a/src/new/emscripten/mod.rs +++ b/src/new/emscripten/mod.rs @@ -3,4 +3,5 @@ //! * Headers: pub(crate) mod pthread; +pub(crate) mod sched; pub(crate) mod unistd; diff --git a/src/new/emscripten/sched.rs b/src/new/emscripten/sched.rs new file mode 100644 index 0000000000000..3bf854ef33c29 --- /dev/null +++ b/src/new/emscripten/sched.rs @@ -0,0 +1,38 @@ +use crate::prelude::*; + +cfg_if! { + if #[cfg(musl_v1_2_3)] { + s! { + struct __c_anon_sched_param__reserved2 { + __reserved1: crate::time_t, + __reserved2: c_long, + } + + pub struct sched_param { + pub sched_priority: c_int, + + __reserved1: Padding, + #[cfg(musl32_time64)] + __reserved2: Padding<[c_long; 4]>, + #[cfg(not(musl32_time64))] + __reserved2: Padding<[__c_anon_sched_param__reserved2; 2]>, + __reserved3: Padding, + } + } + } else { + s! { + pub struct sched_param { + pub sched_priority: c_int, + + #[deprecated(since = "0.2.173", note = "This field has been removed upstream")] + pub sched_ss_low_priority: c_int, + #[deprecated(since = "0.2.173", note = "This field has been removed upstream")] + pub sched_ss_repl_period: crate::timespec, + #[deprecated(since = "0.2.173", note = "This field has been removed upstream")] + pub sched_ss_init_budget: crate::timespec, + #[deprecated(since = "0.2.173", note = "This field has been removed upstream")] + pub sched_ss_max_repl: c_int, + } + } + } +} diff --git a/src/new/mod.rs b/src/new/mod.rs index dd451bb5286bd..3e373ce520d7c 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -58,6 +58,7 @@ cfg_if! { pub(crate) use dragonfly::*; } else if #[cfg(target_os = "emscripten")] { mod emscripten; + pub use emscripten::sched::*; pub(crate) use emscripten::*; } else if #[cfg(target_os = "espidf")] { mod espidf; @@ -150,6 +151,7 @@ cfg_if! { } else if #[cfg(any(target_env = "musl", target_env = "ohos"))] { // OhOS also uses the musl libc mod musl; + pub use musl::sched::*; pub(crate) use musl::*; } else if #[cfg(target_env = "newlib")] { mod newlib; diff --git a/src/new/musl/mod.rs b/src/new/musl/mod.rs index 9fd4d8e96100d..a6551c342da67 100644 --- a/src/new/musl/mod.rs +++ b/src/new/musl/mod.rs @@ -29,4 +29,5 @@ pub(crate) mod sys { pub(crate) mod socket; } +pub(crate) mod sched; pub(crate) mod unistd; diff --git a/src/new/musl/sched.rs b/src/new/musl/sched.rs new file mode 100644 index 0000000000000..3bf854ef33c29 --- /dev/null +++ b/src/new/musl/sched.rs @@ -0,0 +1,38 @@ +use crate::prelude::*; + +cfg_if! { + if #[cfg(musl_v1_2_3)] { + s! { + struct __c_anon_sched_param__reserved2 { + __reserved1: crate::time_t, + __reserved2: c_long, + } + + pub struct sched_param { + pub sched_priority: c_int, + + __reserved1: Padding, + #[cfg(musl32_time64)] + __reserved2: Padding<[c_long; 4]>, + #[cfg(not(musl32_time64))] + __reserved2: Padding<[__c_anon_sched_param__reserved2; 2]>, + __reserved3: Padding, + } + } + } else { + s! { + pub struct sched_param { + pub sched_priority: c_int, + + #[deprecated(since = "0.2.173", note = "This field has been removed upstream")] + pub sched_ss_low_priority: c_int, + #[deprecated(since = "0.2.173", note = "This field has been removed upstream")] + pub sched_ss_repl_period: crate::timespec, + #[deprecated(since = "0.2.173", note = "This field has been removed upstream")] + pub sched_ss_init_budget: crate::timespec, + #[deprecated(since = "0.2.173", note = "This field has been removed upstream")] + pub sched_ss_max_repl: c_int, + } + } + } +} diff --git a/src/new/musl/sys/socket.rs b/src/new/musl/sys/socket.rs index 24731914641cc..e723043dc0a36 100644 --- a/src/new/musl/sys/socket.rs +++ b/src/new/musl/sys/socket.rs @@ -41,6 +41,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, diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index e54dd5ef685b3..44cf2c645f2ed 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -1,5 +1,4 @@ //! Linux-specific definitions for linux-like values - use crate::prelude::*; use crate::{ sock_filter, @@ -1569,7 +1568,7 @@ pub const RENAME_NOREPLACE: c_uint = 1; pub const RENAME_EXCHANGE: c_uint = 2; pub const RENAME_WHITEOUT: c_uint = 4; -pub const MSG_STAT: c_int = 11; +pub const MSG_STAT: c_int = 11 | (crate::IPC_STAT & 0x100); pub const MSG_INFO: c_int = 12; pub const MSG_NOTIFICATION: c_int = 0x8000; @@ -1586,9 +1585,9 @@ 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 = 18 | (crate::IPC_STAT & 0x100); pub const SEM_INFO: c_int = 19; -pub const SEM_STAT_ANY: c_int = 20; +pub const SEM_STAT_ANY: c_int = 20 | (crate::IPC_STAT & 0x100); pub const QFMT_VFS_OLD: c_int = 1; pub const QFMT_VFS_V0: c_int = 2; @@ -4132,7 +4131,10 @@ 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: mqd_t, msg_ptr: *mut c_char, @@ -4146,7 +4148,10 @@ 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: mqd_t, msg_ptr: *const c_char, @@ -4170,6 +4175,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 shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int; @@ -4245,9 +4251,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 crate::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, @@ -4264,6 +4270,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, @@ -4326,6 +4333,7 @@ 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; pub fn sched_setparam(pid: crate::pid_t, param: *const crate::sched_param) -> c_int; pub fn setns(fd: c_int, nstype: c_int) -> c_int; @@ -4342,7 +4350,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, 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 dea804a527026..0f96453fde4f4 100644 --- a/src/unix/linux_like/linux/musl/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/arm/mod.rs @@ -3,6 +3,8 @@ use crate::prelude::*; pub type wchar_t = u32; +pub type stat64 = stat; + s! { pub struct stat { pub st_dev: crate::dev_t, @@ -17,35 +19,34 @@ s! { pub st_size: off_t, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt_t, - pub st_atime: crate::time_t, - pub st_atime_nsec: c_long, - pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_long, + + #[cfg(musl32_time64)] + __st_atim32: Padding<__c_anonymous_timespec32>, + #[cfg(musl32_time64)] + __st_mtim32: Padding<__c_anonymous_timespec32>, + #[cfg(musl32_time64)] + __st_ctim32: Padding<__c_anonymous_timespec32>, + + #[cfg(not(musl32_time64))] + pub st_atim: crate::timespec, + #[cfg(not(musl32_time64))] + pub st_mtim: crate::timespec, + #[cfg(not(musl32_time64))] + pub st_ctim: crate::timespec, + pub st_ino: crate::ino_t, + + #[cfg(musl32_time64)] + pub st_atim: crate::timespec, + #[cfg(musl32_time64)] + pub st_mtim: crate::timespec, + #[cfg(musl32_time64)] + pub st_ctim: crate::timespec, } - pub struct stat64 { - pub st_dev: crate::dev_t, - __st_dev_padding: Padding, - __st_ino_truncated: c_long, - pub st_mode: crate::mode_t, - pub st_nlink: crate::nlink_t, - pub st_uid: crate::uid_t, - pub st_gid: crate::gid_t, - pub st_rdev: crate::dev_t, - __st_rdev_padding: Padding, - pub st_size: off_t, - pub st_blksize: crate::blksize_t, - pub st_blocks: crate::blkcnt_t, - pub st_atime: crate::time_t, - pub st_atime_nsec: c_long, - pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_long, - pub st_ino: crate::ino_t, + struct __c_anonymous_timespec32 { + __tv_sec: c_long, + __tv_nsec: c_long, } pub struct stack_t { @@ -77,27 +78,78 @@ s! { pub struct shmid_ds { pub shm_perm: crate::ipc_perm, pub shm_segsz: size_t, + + #[cfg(musl32_time64)] + __shm_atime_lo: Padding, + #[cfg(musl32_time64)] + __shm_atime_hi: Padding, + #[cfg(musl32_time64)] + __shm_dtime_lo: Padding, + #[cfg(musl32_time64)] + __shm_dtime_hi: Padding, + #[cfg(musl32_time64)] + __msg_ctime_lo: Padding, + #[cfg(musl32_time64)] + __msg_ctime_hi: Padding, + + #[cfg(not(musl32_time64))] pub shm_atime: crate::time_t, + #[cfg(not(musl32_time64))] __unused1: Padding, + #[cfg(not(musl32_time64))] pub shm_dtime: crate::time_t, + #[cfg(not(musl32_time64))] __unused2: Padding, + #[cfg(not(musl32_time64))] pub shm_ctime: crate::time_t, + #[cfg(not(musl32_time64))] __unused3: Padding, + pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, pub shm_nattch: c_ulong, __pad1: Padding, __pad2: Padding, + + #[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: Padding, + #[cfg(musl32_time64)] + __msg_stime_hi: Padding, + #[cfg(musl32_time64)] + __msg_rtime_lo: Padding, + #[cfg(musl32_time64)] + __msg_rtime_hi: Padding, + #[cfg(musl32_time64)] + __msg_ctime_lo: Padding, + #[cfg(musl32_time64)] + __msg_ctime_hi: Padding, + + #[cfg(not(musl32_time64))] pub msg_stime: crate::time_t, + #[cfg(not(musl32_time64))] __unused1: Padding, + #[cfg(not(musl32_time64))] pub msg_rtime: crate::time_t, + #[cfg(not(musl32_time64))] __unused2: Padding, + #[cfg(not(musl32_time64))] pub msg_ctime: crate::time_t, + #[cfg(not(musl32_time64))] __unused3: Padding, + pub __msg_cbytes: c_ulong, pub msg_qnum: crate::msgqnum_t, pub msg_qbytes: crate::msglen_t, @@ -105,6 +157,13 @@ s! { pub msg_lrpid: crate::pid_t, __pad1: Padding, __pad2: Padding, + + #[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/hexagon.rs b/src/unix/linux_like/linux/musl/b32/hexagon.rs index 8ce439cee5bf9..7aa01d625cdcd 100644 --- a/src/unix/linux_like/linux/musl/b32/hexagon.rs +++ b/src/unix/linux_like/linux/musl/b32/hexagon.rs @@ -17,13 +17,27 @@ s! { pub st_blksize: crate::blksize_t, __st_blksize_padding: Padding, pub st_blocks: crate::blkcnt_t, + + #[cfg(not(musl_v1_2_3))] pub st_atime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_atime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_mtime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_mtime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_ctime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_ctime_nsec: c_long, + #[cfg(musl_v1_2_3)] + pub st_atim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_mtim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_ctim: crate::timespec, + __unused: Padding<[c_int; 2]>, } 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 d563c5e420a12..0771a7f67c888 100644 --- a/src/unix/linux_like/linux/musl/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/mips/mod.rs @@ -3,6 +3,8 @@ use crate::prelude::*; pub type wchar_t = c_int; +pub type stat64 = stat; + s! { pub struct stat { pub st_dev: crate::dev_t, @@ -15,39 +17,41 @@ s! { pub st_rdev: crate::dev_t, __st_padding2: Padding<[c_long; 2]>, pub st_size: off_t, - pub st_atime: crate::time_t, - pub st_atime_nsec: c_long, - pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_long, + + #[cfg(musl32_time64)] + __st_atim32: Padding<__c_anonymous_timespec32>, + #[cfg(musl32_time64)] + __st_mtim32: Padding<__c_anonymous_timespec32>, + #[cfg(musl32_time64)] + __st_ctim32: Padding<__c_anonymous_timespec32>, + + #[cfg(not(musl32_time64))] + pub st_atim: crate::timespec, + #[cfg(not(musl32_time64))] + pub st_mtim: crate::timespec, + #[cfg(not(musl32_time64))] + pub st_ctim: crate::timespec, + pub st_blksize: crate::blksize_t, __st_padding3: Padding, pub st_blocks: crate::blkcnt_t, + #[cfg(not(musl32_time64))] __st_padding4: Padding<[c_long; 14]>, + + #[cfg(musl32_time64)] + pub st_atim: crate::timespec, + #[cfg(musl32_time64)] + pub st_mtim: crate::timespec, + #[cfg(musl32_time64)] + pub st_ctim: crate::timespec, + + #[cfg(musl32_time64)] + __st_padding4: Padding<[c_long; 2]>, } - pub struct stat64 { - pub st_dev: crate::dev_t, - __st_padding1: Padding<[c_long; 2]>, - pub st_ino: crate::ino64_t, - pub st_mode: crate::mode_t, - pub st_nlink: crate::nlink_t, - pub st_uid: crate::uid_t, - pub st_gid: crate::gid_t, - pub st_rdev: crate::dev_t, - __st_padding2: Padding<[c_long; 2]>, - pub st_size: off_t, - pub st_atime: crate::time_t, - pub st_atime_nsec: c_long, - pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_long, - pub st_blksize: crate::blksize_t, - __st_padding3: Padding, - pub st_blocks: crate::blkcnt64_t, - __st_padding4: Padding<[c_long; 14]>, + struct __c_anonymous_timespec32 { + __tv_sec: c_long, + __tv_nsec: c_long, } pub struct stack_t { @@ -79,40 +83,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: Padding, + #[cfg(musl32_time64)] + __shm_dtime_lo: Padding, + #[cfg(musl32_time64)] + __shm_ctime_lo: Padding, pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, pub shm_nattch: c_ulong, + #[cfg(not(musl32_time64))] __pad1: Padding, + #[cfg(not(musl32_time64))] __pad2: Padding, - } - pub struct msqid_ds { - pub msg_perm: crate::ipc_perm, - #[cfg(target_endian = "big")] - __unused1: Padding, - pub msg_stime: crate::time_t, - #[cfg(target_endian = "little")] - __unused1: Padding, - #[cfg(target_endian = "big")] - __unused2: Padding, - pub msg_rtime: crate::time_t, - #[cfg(target_endian = "little")] - __unused2: Padding, - #[cfg(target_endian = "big")] - __unused3: Padding, - pub msg_ctime: crate::time_t, - #[cfg(target_endian = "little")] - __unused3: Padding, - 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: Padding, - __pad2: Padding, + #[cfg(musl32_time64)] + __shm_atime_hi: Padding, + #[cfg(musl32_time64)] + __shm_dtime_hi: Padding, + #[cfg(musl32_time64)] + __shm_ctime_hi: Padding, + #[cfg(musl32_time64)] + __pad1: Padding, + #[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 { @@ -146,6 +150,94 @@ s! { } } +cfg_if! { + if #[cfg(musl32_time64)] { + s! { + pub struct msqid_ds { + pub msg_perm: crate::ipc_perm, + + #[cfg(target_endian = "big")] + __msg_stime_hi: Padding, + #[cfg(target_endian = "big")] + __msg_stime_lo: Padding, + #[cfg(target_endian = "big")] + __msg_rtime_hi: Padding, + #[cfg(target_endian = "big")] + __msg_rtime_lo: Padding, + #[cfg(target_endian = "big")] + __msg_ctime_hi: Padding, + #[cfg(target_endian = "big")] + __msg_ctime_lo: Padding, + + #[cfg(target_endian = "little")] + __msg_stime_lo: Padding, + #[cfg(target_endian = "little")] + __msg_stime_hi: Padding, + #[cfg(target_endian = "little")] + __msg_rtime_lo: Padding, + #[cfg(target_endian = "little")] + __msg_rtime_hi: Padding, + #[cfg(target_endian = "little")] + __msg_ctime_lo: Padding, + #[cfg(target_endian = "little")] + __msg_ctime_hi: Padding, + + 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: Padding, + __pad2: Padding, + + pub msg_stime: crate::time_t, + pub msg_rtime: crate::time_t, + pub msg_ctime: crate::time_t, + } + } + } else { + s! { + pub struct msqid_ds { + pub msg_perm: crate::ipc_perm, + + #[cfg(target_endian = "big")] + __unused1: Padding, + #[cfg(target_endian = "big")] + pub msg_stime: crate::time_t, + #[cfg(target_endian = "big")] + __unused2: Padding, + #[cfg(target_endian = "big")] + pub msg_rtime: crate::time_t, + #[cfg(target_endian = "big")] + __unused3: Padding, + #[cfg(target_endian = "big")] + pub msg_ctime: crate::time_t, + + #[cfg(target_endian = "little")] + pub msg_stime: crate::time_t, + #[cfg(target_endian = "little")] + __unused1: Padding, + #[cfg(target_endian = "little")] + pub msg_rtime: crate::time_t, + #[cfg(target_endian = "little")] + __unused2: Padding, + #[cfg(target_endian = "little")] + pub msg_ctime: crate::time_t, + #[cfg(target_endian = "little")] + __unused3: Padding, + + 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: Padding, + __pad2: Padding, + } + } + } +} + s_no_extra_traits! { #[repr(align(8))] pub struct max_align_t { diff --git a/src/unix/linux_like/linux/musl/b32/powerpc.rs b/src/unix/linux_like/linux/musl/b32/powerpc.rs index 4bf82c7b0cac4..64a2719abbc11 100644 --- a/src/unix/linux_like/linux/musl/b32/powerpc.rs +++ b/src/unix/linux_like/linux/musl/b32/powerpc.rs @@ -3,6 +3,8 @@ use crate::prelude::*; pub type wchar_t = i32; +pub type stat64 = stat; + s! { pub struct termios { pub c_iflag: crate::tcflag_t, @@ -27,34 +29,34 @@ s! { pub st_size: off_t, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt_t, - pub st_atime: crate::time_t, - pub st_atime_nsec: c_long, - pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_long, + + #[cfg(musl32_time64)] + __st_atim32: Padding<__c_anonymous_timespec32>, + #[cfg(musl32_time64)] + __st_mtim32: Padding<__c_anonymous_timespec32>, + #[cfg(musl32_time64)] + __st_ctim32: Padding<__c_anonymous_timespec32>, + + #[cfg(not(musl32_time64))] + pub st_atim: crate::timespec, + #[cfg(not(musl32_time64))] + pub st_mtim: crate::timespec, + #[cfg(not(musl32_time64))] + pub st_ctim: crate::timespec, + __unused: Padding<[c_long; 2]>, + + #[cfg(musl32_time64)] + pub st_atim: crate::timespec, + #[cfg(musl32_time64)] + pub st_mtim: crate::timespec, + #[cfg(musl32_time64)] + pub st_ctim: crate::timespec, } - pub struct stat64 { - pub st_dev: crate::dev_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, - pub st_gid: crate::gid_t, - pub st_rdev: crate::dev_t, - __st_rdev_padding: Padding, - pub st_size: off_t, - pub st_blksize: crate::blksize_t, - pub st_blocks: crate::blkcnt_t, - pub st_atime: crate::time_t, - pub st_atime_nsec: c_long, - pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_long, - __unused: Padding<[c_long; 2]>, + struct __c_anonymous_timespec32 { + __tv_sec: c_long, + __tv_nsec: c_long, } pub struct stack_t { @@ -86,29 +88,83 @@ s! { pub struct shmid_ds { pub shm_perm: crate::ipc_perm, + + #[cfg(musl32_time64)] + __shm_atime_hi: Padding, + #[cfg(musl32_time64)] + __shm_atime_lo: Padding, + #[cfg(musl32_time64)] + __shm_dtime_hi: Padding, + #[cfg(musl32_time64)] + __shm_dtime_lo: Padding, + #[cfg(musl32_time64)] + __shm_ctime_hi: Padding, + #[cfg(musl32_time64)] + __shm_ctime_lo: Padding, + + #[cfg(not(musl32_time64))] __unused1: Padding, + #[cfg(not(musl32_time64))] pub shm_atime: crate::time_t, + #[cfg(not(musl32_time64))] __unused2: Padding, + #[cfg(not(musl32_time64))] pub shm_dtime: crate::time_t, + #[cfg(not(musl32_time64))] __unused3: Padding, + #[cfg(not(musl32_time64))] pub shm_ctime: crate::time_t, + #[cfg(not(musl32_time64))] __unused4: Padding, + + #[cfg(musl32_time64)] + __pad1: Padding, + 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: Padding, __pad2: Padding, + + #[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: Padding, + #[cfg(musl32_time64)] + __msg_stime_lo: Padding, + #[cfg(musl32_time64)] + __msg_rtime_hi: Padding, + #[cfg(musl32_time64)] + __msg_rtime_lo: Padding, + #[cfg(musl32_time64)] + __msg_ctime_hi: Padding, + #[cfg(musl32_time64)] + __msg_ctime_lo: Padding, + + #[cfg(not(musl32_time64))] __unused1: Padding, + #[cfg(not(musl32_time64))] pub msg_stime: crate::time_t, + #[cfg(not(musl32_time64))] __unused2: Padding, + #[cfg(not(musl32_time64))] pub msg_rtime: crate::time_t, + #[cfg(not(musl32_time64))] __unused3: Padding, + #[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, @@ -116,6 +172,13 @@ s! { pub msg_lrpid: crate::pid_t, __pad1: Padding, __pad2: Padding, + + #[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/riscv32/mod.rs b/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs index 4237c579a1a7f..5561dcb34d358 100644 --- a/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs @@ -1,13 +1,12 @@ //! RISC-V-specific definitions for 32-bit linux-like values +use crate::off_t; use crate::prelude::*; -use crate::{ - off64_t, - off_t, -}; pub type wchar_t = c_int; +pub type stat64 = stat; + s! { pub struct stat { pub st_dev: crate::dev_t, @@ -22,35 +21,28 @@ s! { pub st_blksize: crate::blksize_t, pub __pad2: c_int, pub st_blocks: crate::blkcnt_t, - pub st_atime: crate::time_t, - pub st_atime_nsec: c_long, - pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_long, - __unused: Padding<[c_int; 2usize]>, - } - pub struct stat64 { - pub st_dev: crate::dev_t, - pub st_ino: crate::ino64_t, - pub st_mode: crate::mode_t, - pub st_nlink: crate::nlink_t, - pub st_uid: crate::uid_t, - pub st_gid: crate::gid_t, - pub st_rdev: crate::dev_t, - pub __pad1: crate::dev_t, - pub st_size: off64_t, - pub st_blksize: crate::blksize_t, - pub __pad2: c_int, - pub st_blocks: crate::blkcnt64_t, + #[cfg(not(musl_v1_2_3))] pub st_atime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_atime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_mtime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_mtime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_ctime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_ctime_nsec: c_long, - __unused: Padding<[c_int; 2]>, + + #[cfg(musl_v1_2_3)] + pub st_atim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_mtim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_ctim: crate::timespec, + + __unused: Padding<[c_int; 2usize]>, } pub struct stack_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 ada436fc99b56..3f2145bc266ef 100644 --- a/src/unix/linux_like/linux/musl/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/x86/mod.rs @@ -3,6 +3,8 @@ use crate::prelude::*; pub type wchar_t = i32; +pub type stat64 = stat; + s! { pub struct stat { pub st_dev: crate::dev_t, @@ -17,35 +19,34 @@ s! { pub st_size: off_t, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt_t, - pub st_atime: crate::time_t, - pub st_atime_nsec: c_long, - pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_long, + + #[cfg(musl32_time64)] + __st_atim32: Padding<__c_anonymous_timespec32>, + #[cfg(musl32_time64)] + __st_mtim32: Padding<__c_anonymous_timespec32>, + #[cfg(musl32_time64)] + __st_ctim32: Padding<__c_anonymous_timespec32>, + + #[cfg(not(musl32_time64))] + pub st_atim: crate::timespec, + #[cfg(not(musl32_time64))] + pub st_mtim: crate::timespec, + #[cfg(not(musl32_time64))] + pub st_ctim: crate::timespec, + pub st_ino: crate::ino_t, + + #[cfg(musl32_time64)] + pub st_atim: crate::timespec, + #[cfg(musl32_time64)] + pub st_mtim: crate::timespec, + #[cfg(musl32_time64)] + pub st_ctim: crate::timespec, } - pub struct stat64 { - pub st_dev: crate::dev_t, - __st_dev_padding: Padding, - __st_ino_truncated: c_long, - pub st_mode: crate::mode_t, - pub st_nlink: crate::nlink_t, - pub st_uid: crate::uid_t, - pub st_gid: crate::gid_t, - pub st_rdev: crate::dev_t, - __st_rdev_padding: Padding, - pub st_size: off_t, - pub st_blksize: crate::blksize_t, - pub st_blocks: crate::blkcnt_t, - pub st_atime: crate::time_t, - pub st_atime_nsec: c_long, - pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_long, - pub st_ino: crate::ino_t, + struct __c_anonymous_timespec32 { + __tv_sec: c_long, + __tv_nsec: c_long, } pub struct mcontext_t { @@ -81,27 +82,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: Padding, + #[cfg(not(musl32_time64))] pub shm_dtime: crate::time_t, + #[cfg(not(musl32_time64))] __unused2: Padding, + #[cfg(not(musl32_time64))] pub shm_ctime: crate::time_t, + #[cfg(not(musl32_time64))] __unused3: Padding, + pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, pub shm_nattch: c_ulong, __pad1: Padding, __pad2: Padding, + + #[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: Padding, + #[cfg(not(musl32_time64))] pub msg_rtime: crate::time_t, + #[cfg(not(musl32_time64))] __unused2: Padding, + #[cfg(not(musl32_time64))] pub msg_ctime: crate::time_t, + #[cfg(not(musl32_time64))] __unused3: Padding, + pub __msg_cbytes: c_ulong, pub msg_qnum: crate::msgqnum_t, pub msg_qbytes: crate::msglen_t, @@ -109,6 +161,13 @@ s! { pub msg_lrpid: crate::pid_t, __pad1: Padding, __pad2: Padding, + + #[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 user_fpxregs_struct { 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 cc52a179e7203..47f29d5e11abf 100644 --- a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs @@ -7,6 +7,8 @@ pub type wchar_t = u32; pub type nlink_t = u32; pub type blksize_t = c_int; +pub type stat64 = stat; + s! { pub struct stat { pub st_dev: crate::dev_t, @@ -21,34 +23,27 @@ s! { pub st_blksize: crate::blksize_t, __pad1: Padding, pub st_blocks: crate::blkcnt_t, - pub st_atime: crate::time_t, - pub st_atime_nsec: c_long, - pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_long, - __unused: Padding<[c_uint; 2]>, - } - pub struct stat64 { - pub st_dev: crate::dev_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, - pub st_gid: crate::gid_t, - pub st_rdev: crate::dev_t, - __pad0: Padding, - pub st_size: off_t, - pub st_blksize: crate::blksize_t, - __pad1: Padding, - pub st_blocks: crate::blkcnt_t, + #[cfg(not(musl_v1_2_3))] pub st_atime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_atime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_mtime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_mtime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_ctime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_ctime_nsec: c_long, + + #[cfg(musl_v1_2_3)] + pub st_atim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_mtim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_ctim: crate::timespec, + __unused: Padding<[c_uint; 2]>, } diff --git a/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs b/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs index f41f61de62bcf..29f7d49cc8320 100644 --- a/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs @@ -1,10 +1,7 @@ //! LoongArch-specific definitions for 64-bit linux-like values +use crate::off_t; use crate::prelude::*; -use crate::{ - off64_t, - off_t, -}; pub type wchar_t = c_int; @@ -13,6 +10,8 @@ pub type blksize_t = c_int; pub type __u64 = c_ulonglong; pub type __s64 = c_longlong; +pub type stat64 = stat; + s! { pub struct stat { pub st_dev: crate::dev_t, @@ -27,35 +26,28 @@ s! { pub st_blksize: crate::blksize_t, __pad2: Padding, pub st_blocks: crate::blkcnt_t, - pub st_atime: crate::time_t, - pub st_atime_nsec: c_long, - pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_long, - __unused: Padding<[c_int; 2usize]>, - } - pub struct stat64 { - pub st_dev: crate::dev_t, - pub st_ino: crate::ino64_t, - pub st_mode: crate::mode_t, - pub st_nlink: crate::nlink_t, - pub st_uid: crate::uid_t, - pub st_gid: crate::gid_t, - pub st_rdev: crate::dev_t, - pub __pad1: crate::dev_t, - pub st_size: off64_t, - pub st_blksize: crate::blksize_t, - pub __pad2: c_int, - pub st_blocks: crate::blkcnt_t, + #[cfg(not(musl_v1_2_3))] pub st_atime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_atime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_mtime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_mtime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_ctime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_ctime_nsec: c_long, - __unused: Padding<[c_int; 2]>, + + #[cfg(musl_v1_2_3)] + pub st_atim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_mtim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_ctim: crate::timespec, + + __unused: Padding<[c_int; 2usize]>, } pub struct ipc_perm { diff --git a/src/unix/linux_like/linux/musl/b64/mips64.rs b/src/unix/linux_like/linux/musl/b64/mips64.rs index 9626e3db78b8e..d05b40bd38a11 100644 --- a/src/unix/linux_like/linux/musl/b64/mips64.rs +++ b/src/unix/linux_like/linux/musl/b64/mips64.rs @@ -7,6 +7,8 @@ pub type __s64 = c_long; pub type nlink_t = c_uint; pub type blksize_t = i64; +pub type stat64 = stat; + s! { pub struct stat { pub st_dev: crate::dev_t, @@ -20,36 +22,27 @@ s! { __pad2: Padding<[c_uint; 2]>, pub st_size: off_t, __pad3: Padding, - pub st_atime: crate::time_t, - pub st_atime_nsec: c_long, - pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_long, - pub st_blksize: crate::blksize_t, - __pad4: Padding, - pub st_blocks: crate::blkcnt_t, - __pad5: Padding<[c_int; 14]>, - } - pub struct stat64 { - pub st_dev: crate::dev_t, - __pad1: Padding<[c_int; 3]>, - pub st_ino: crate::ino_t, - pub st_mode: crate::mode_t, - pub st_nlink: crate::nlink_t, - pub st_uid: crate::uid_t, - pub st_gid: crate::gid_t, - pub st_rdev: crate::dev_t, - __pad2: Padding<[c_uint; 2]>, - pub st_size: off_t, - __pad3: Padding, + #[cfg(not(musl_v1_2_3))] pub st_atime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_atime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_mtime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_mtime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_ctime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_ctime_nsec: c_long, + + #[cfg(musl_v1_2_3)] + pub st_atim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_mtim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_ctim: crate::timespec, + pub st_blksize: crate::blksize_t, __pad4: Padding, pub st_blocks: crate::blkcnt_t, diff --git a/src/unix/linux_like/linux/musl/b64/powerpc64.rs b/src/unix/linux_like/linux/musl/b64/powerpc64.rs index dbf20c565e438..6e0d6db6a1978 100644 --- a/src/unix/linux_like/linux/musl/b64/powerpc64.rs +++ b/src/unix/linux_like/linux/musl/b64/powerpc64.rs @@ -7,6 +7,8 @@ pub type __s64 = c_long; pub type nlink_t = u64; pub type blksize_t = c_long; +pub type stat64 = stat; + s! { pub struct termios { pub c_iflag: crate::tcflag_t, @@ -31,34 +33,28 @@ s! { pub st_size: off_t, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt_t, - pub st_atime: crate::time_t, - pub st_atime_nsec: c_long, - pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_long, - __unused: Padding<[c_long; 3]>, - } - pub struct stat64 { - pub st_dev: crate::dev_t, - pub st_ino: crate::ino64_t, - pub st_nlink: crate::nlink_t, - pub st_mode: crate::mode_t, - pub st_uid: crate::uid_t, - pub st_gid: crate::gid_t, - __pad0: Padding, - pub st_rdev: crate::dev_t, - pub st_size: off_t, - pub st_blksize: crate::blksize_t, - pub st_blocks: crate::blkcnt64_t, + #[cfg(not(musl_v1_2_3))] pub st_atime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_atime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_mtime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_mtime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_ctime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_ctime_nsec: c_long, - __reserved: Padding<[c_long; 3]>, + + #[cfg(musl_v1_2_3)] + pub st_atim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_mtim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_ctim: crate::timespec, + + __unused: Padding<[c_long; 3]>, } pub struct shmid_ds { 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 b987f8358b365..ba9bebd84cc73 100644 --- a/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs @@ -1,10 +1,7 @@ //! RISC-V-specific definitions for 64-bit linux-like values +use crate::off_t; use crate::prelude::*; -use crate::{ - off64_t, - off_t, -}; pub type wchar_t = c_int; @@ -13,6 +10,8 @@ pub type blksize_t = c_int; pub type __u64 = c_ulonglong; pub type __s64 = c_longlong; +pub type stat64 = stat; + s! { pub struct stat { pub st_dev: crate::dev_t, @@ -22,40 +21,33 @@ s! { pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, - pub __pad1: crate::dev_t, + __pad1: Padding, pub st_size: off_t, pub st_blksize: crate::blksize_t, - pub __pad2: c_int, + __pad2: Padding, pub st_blocks: crate::blkcnt_t, - pub st_atime: crate::time_t, - pub st_atime_nsec: c_long, - pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_long, - __unused: Padding<[c_int; 2usize]>, - } - pub struct stat64 { - pub st_dev: crate::dev_t, - pub st_ino: crate::ino64_t, - pub st_mode: crate::mode_t, - pub st_nlink: crate::nlink_t, - pub st_uid: crate::uid_t, - pub st_gid: crate::gid_t, - pub st_rdev: crate::dev_t, - pub __pad1: crate::dev_t, - pub st_size: off64_t, - pub st_blksize: crate::blksize_t, - pub __pad2: c_int, - pub st_blocks: crate::blkcnt_t, + #[cfg(not(musl_v1_2_3))] pub st_atime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_atime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_mtime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_mtime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_ctime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_ctime_nsec: c_long, - __unused: Padding<[c_int; 2]>, + + #[cfg(musl_v1_2_3)] + pub st_atim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_mtim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_ctim: crate::timespec, + + __unused: Padding<[c_int; 2usize]>, } pub struct ipc_perm { diff --git a/src/unix/linux_like/linux/musl/b64/s390x.rs b/src/unix/linux_like/linux/musl/b64/s390x.rs index d8ce68e662089..ce33d514aed3c 100644 --- a/src/unix/linux_like/linux/musl/b64/s390x.rs +++ b/src/unix/linux_like/linux/musl/b64/s390x.rs @@ -8,6 +8,7 @@ pub type greg_t = u64; pub type __u64 = u64; pub type __s64 = i64; pub type statfs64 = statfs; +pub type stat64 = stat; s! { pub struct ipc_perm { @@ -39,34 +40,29 @@ s! { pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, pub st_size: off_t, - pub st_atime: crate::time_t, - pub st_atime_nsec: c_long, - pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_long, - pub st_blksize: crate::blksize_t, - pub st_blocks: crate::blkcnt_t, - __unused: Padding<[c_long; 3]>, - } - pub struct stat64 { - pub st_dev: crate::dev_t, - pub st_ino: crate::ino64_t, - pub st_nlink: crate::nlink_t, - pub st_mode: crate::mode_t, - pub st_uid: crate::uid_t, - pub st_gid: crate::gid_t, - pub st_rdev: crate::dev_t, - pub st_size: off_t, + #[cfg(not(musl_v1_2_3))] pub st_atime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_atime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_mtime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_mtime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_ctime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_ctime_nsec: c_long, + + #[cfg(musl_v1_2_3)] + pub st_atim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_mtim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_ctim: crate::timespec, + pub st_blksize: crate::blksize_t, - pub st_blocks: crate::blkcnt64_t, + pub st_blocks: crate::blkcnt_t, __unused: Padding<[c_long; 3]>, } diff --git a/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs b/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs index d4d0fe69839b3..06b34c25d9238 100644 --- a/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs @@ -9,6 +9,8 @@ pub type blksize_t = c_long; pub type __u64 = c_ulonglong; pub type __s64 = c_longlong; +pub type stat64 = stat; + s! { pub struct stat { pub st_dev: crate::dev_t, @@ -22,34 +24,28 @@ s! { pub st_size: off_t, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt_t, - pub st_atime: crate::time_t, - pub st_atime_nsec: c_long, - pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_long, - __unused: Padding<[c_long; 3]>, - } - pub struct stat64 { - pub st_dev: crate::dev_t, - pub st_ino: crate::ino64_t, - pub st_nlink: crate::nlink_t, - pub st_mode: crate::mode_t, - pub st_uid: crate::uid_t, - pub st_gid: crate::gid_t, - __pad0: Padding, - pub st_rdev: crate::dev_t, - pub st_size: off_t, - pub st_blksize: crate::blksize_t, - pub st_blocks: crate::blkcnt64_t, + #[cfg(not(musl_v1_2_3))] pub st_atime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_atime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_mtime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_mtime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_ctime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_ctime_nsec: c_long, - __reserved: Padding<[c_long; 3]>, + + #[cfg(musl_v1_2_3)] + pub st_atim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_mtim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_ctim: crate::timespec, + + __unused: Padding<[c_long; 3]>, } pub struct ipc_perm { 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 f7f449cbc8936..ec9a31bccf577 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 @@ -8,6 +8,8 @@ pub type __u64 = c_ulonglong; pub type __s64 = c_longlong; pub type greg_t = i64; +pub type stat64 = stat; + s! { pub struct stat { pub st_dev: crate::dev_t, @@ -21,34 +23,28 @@ s! { pub st_size: off_t, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt_t, - pub st_atime: crate::time_t, - pub st_atime_nsec: c_long, - pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_long, - __unused: Padding<[c_long; 3]>, - } - pub struct stat64 { - pub st_dev: crate::dev_t, - pub st_ino: crate::ino64_t, - pub st_nlink: crate::nlink_t, - pub st_mode: crate::mode_t, - pub st_uid: crate::uid_t, - pub st_gid: crate::gid_t, - __pad0: Padding, - pub st_rdev: crate::dev_t, - pub st_size: off_t, - pub st_blksize: crate::blksize_t, - pub st_blocks: crate::blkcnt64_t, + #[cfg(not(musl_v1_2_3))] pub st_atime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_atime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_mtime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_mtime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_ctime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_ctime_nsec: c_long, - __reserved: Padding<[c_long; 3]>, + + #[cfg(musl_v1_2_3)] + pub st_atim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_mtim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_ctim: crate::timespec, + + __unused: Padding<[c_long; 3]>, } pub struct user_regs_struct { diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index b165e2f3a7d55..2fe0440eb43fe 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; @@ -750,6 +765,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; @@ -785,7 +801,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/linux_l4re_shared.rs b/src/unix/linux_like/linux_l4re_shared.rs index b3d014482cfc7..bd3cfafeb6e72 100644 --- a/src/unix/linux_like/linux_l4re_shared.rs +++ b/src/unix/linux_like/linux_l4re_shared.rs @@ -976,7 +976,7 @@ 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 SHM_R: c_int = 0o400; @@ -1648,7 +1648,10 @@ cfg_if! { pub fn aio_error(aiocbp: *const crate::aiocb) -> c_int; #[cfg_attr(gnu_file_offset_bits64, link_name = "aio_return64")] pub fn aio_return(aiocbp: *mut crate::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 crate::aiocb, nitems: c_int, @@ -1711,6 +1714,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; } } @@ -1812,8 +1816,10 @@ extern "C" { ) -> c_int; pub fn sched_get_priority_max(policy: c_int) -> c_int; #[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; #[cfg_attr(gnu_time_bits64, link_name = "__sem_timedwait64")] + #[cfg_attr(musl32_time64, link_name = "__sem_timedwait_time64")] pub fn sem_timedwait(sem: *mut crate::sem_t, abstime: *const crate::timespec) -> c_int; pub fn sem_getvalue(sem: *mut crate::sem_t, sval: *mut c_int) -> c_int; pub fn mount( @@ -1826,6 +1832,7 @@ extern "C" { #[cfg_attr(gnu_time_bits64, link_name = "__prctl_time64")] pub fn prctl(option: c_int, ...) -> 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: crate::nfds_t, @@ -1916,9 +1923,9 @@ extern "C" { pub fn timer_delete(timerid: crate::timer_t) -> c_int; #[cfg(not(target_os = "l4re"))] 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/mod.rs b/src/unix/linux_like/mod.rs index 5fd99e015a619..0d4d6f2790598 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -110,16 +110,9 @@ s! { pub tm_zone: *const c_char, } + #[cfg(not(any(target_env = "musl", target_os = "emscripten", target_env = "ohos")))] 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 { @@ -1928,10 +1921,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; #[cfg(not(target_os = "l4re"))] pub fn clock_getcpuclockid(pid: crate::pid_t, clk_id: *mut crate::clockid_t) -> c_int; @@ -1950,9 +1944,11 @@ 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")] #[cfg(not(target_os = "l4re"))] 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, @@ -1999,7 +1995,7 @@ extern "C" { pub fn setresgid(rgid: crate::gid_t, egid: crate::gid_t, sgid: crate::gid_t) -> c_int; #[cfg(not(target_os = "l4re"))] 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")] #[cfg(not(target_os = "l4re"))] pub fn wait4( pid: crate::pid_t, diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 01f81833984ea..086f2cfd80958 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -72,10 +72,14 @@ s! { #[cfg(all(not(target_env = "gnu"), not(target_os = "aix")))] pub struct timespec { pub tv_sec: time_t, + #[cfg(all(musl32_time64, target_endian = "big"))] + __pad0: Padding, #[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: Padding, } pub struct rlimit { @@ -901,6 +905,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; @@ -919,6 +924,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; @@ -1013,6 +1019,7 @@ extern "C" { link_name = "fstatat64" )] #[cfg(not(target_os = "l4re"))] + #[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; #[cfg(not(target_os = "l4re"))] pub fn linkat( @@ -1117,6 +1124,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; @@ -1161,7 +1169,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( @@ -1216,6 +1224,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( @@ -1247,6 +1256,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( @@ -1329,6 +1339,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 crate::pthread_cond_t, lock: *mut crate::pthread_mutex_t, @@ -1397,9 +1408,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; @@ -1448,49 +1461,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")] @@ -1551,6 +1559,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, @@ -1679,7 +1688,7 @@ cfg_if! { )))] { extern "C" { #[cfg_attr(target_os = "netbsd", link_name = "__adjtime50")] - #[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")] { @@ -1857,6 +1866,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,