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