-
Notifications
You must be signed in to change notification settings - Fork 1.1k
musl: 64-bit time support #4463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
4c60787
9d24137
8df6f13
615407f
1c715f2
11cc752
ac1ae09
f3afea0
2a54692
172d85b
e91f182
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,8 @@ const ALLOWED_CFGS: &[&str] = &[ | |
// Corresponds to `__USE_TIME_BITS64` in UAPI | ||
"linux_time_bits64", | ||
"musl_v1_2_3", | ||
"musl_time64", | ||
"musl_not_time64", | ||
]; | ||
|
||
// Extra values to allow for check-cfg. | ||
|
@@ -44,6 +46,8 @@ const CHECK_CFG_EXTRA: &[(&str, &[&str])] = &[ | |
), | ||
]; | ||
|
||
const MUSL_TIME64_ARCHS: &[&str] = &["arm", "mips", "powerpc", "x86"]; | ||
|
||
fn main() { | ||
// Avoid unnecessary re-building. | ||
println!("cargo:rerun-if-changed=build.rs"); | ||
|
@@ -90,10 +94,20 @@ fn main() { | |
|
||
let musl_v1_2_3 = env::var("RUST_LIBC_UNSTABLE_MUSL_V1_2_3").is_ok(); | ||
println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_MUSL_V1_2_3"); | ||
let musl_time64 = env::var("RUST_LIBC_UNSTABLE_MUSL_TIME64").is_ok(); | ||
println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_MUSL_TIME64"); | ||
// loongarch64 and ohos have already updated | ||
if musl_v1_2_3 || target_os == "loongarch64" || target_env == "ohos" { | ||
// FIXME(musl): enable time64 api as well | ||
if ((musl_v1_2_3 || target_os == "loongarch64") && target_env == "musl") || target_env == "ohos" | ||
{ | ||
set_cfg("musl_v1_2_3"); | ||
if musl_time64 && MUSL_TIME64_ARCHS.contains(&target_arch.as_str()) { | ||
set_cfg("musl_time64"); | ||
set_cfg("linux_time_bits64"); | ||
} else { | ||
set_cfg("musl_not_time64"); | ||
} | ||
} else if target_env == "musl" || target_env == "ohos" { | ||
set_cfg("musl_not_time64"); | ||
Comment on lines
+100
to
+110
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, this is kind of a hack to ignore the deprecation warning for musl but not time64. I'll get rid of it by allowing deprecation for any |
||
} | ||
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"); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,8 @@ run() { | |
--env LIBC_CI_ZBUILD_STD \ | ||
--env RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS \ | ||
--env RUST_LIBC_UNSTABLE_GNU_TIME_BITS \ | ||
--env RUST_LIBC_UNSTABLE_MUSL_V1_2_3 \ | ||
--env RUST_LIBC_UNSTABLE_MUSL_TIME64 \ | ||
--env CARGO_HOME=/cargo \ | ||
--env CARGO_TARGET_DIR=/checkout/target \ | ||
Comment on lines
46
to
51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: this should match the indentation |
||
--volume "$CARGO_HOME":/cargo \ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2850,8 +2850,14 @@ pub const IPC_NOWAIT: c_int = 0o4000; | |
|
||
pub const IPC_RMID: c_int = 0; | ||
pub const IPC_SET: c_int = 1; | ||
#[cfg(musl_time64)] | ||
pub const IPC_STAT: c_int = 0x102; | ||
#[cfg(not(musl_time64))] | ||
pub const IPC_STAT: c_int = 2; | ||
Comment on lines
+2853
to
2856
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style nit: these should be writeable as |
||
pub const IPC_INFO: c_int = 3; | ||
#[cfg(musl_time64)] | ||
pub const MSG_STAT: c_int = 0x10b; | ||
#[cfg(not(musl_time64))] | ||
pub const MSG_STAT: c_int = 11; | ||
pub const MSG_INFO: c_int = 12; | ||
pub const MSG_NOTIFICATION: c_int = 0x8000; | ||
|
@@ -2869,8 +2875,14 @@ pub const GETNCNT: c_int = 14; | |
pub const GETZCNT: c_int = 15; | ||
pub const SETVAL: c_int = 16; | ||
pub const SETALL: c_int = 17; | ||
#[cfg(musl_time64)] | ||
pub const SEM_STAT: c_int = 0x112; | ||
#[cfg(not(musl_time64))] | ||
pub const SEM_STAT: c_int = 18; | ||
pub const SEM_INFO: c_int = 19; | ||
#[cfg(musl_time64)] | ||
pub const SEM_STAT_ANY: c_int = 0x114; | ||
#[cfg(not(musl_time64))] | ||
pub const SEM_STAT_ANY: c_int = 20; | ||
|
||
pub const SHM_R: c_int = 0o400; | ||
|
@@ -6107,7 +6119,7 @@ cfg_if! { | |
pub fn aio_error(aiocbp: *const aiocb) -> c_int; | ||
#[cfg_attr(gnu_file_offset_bits64, link_name = "aio_return64")] | ||
pub fn aio_return(aiocbp: *mut aiocb) -> ssize_t; | ||
#[cfg_attr(gnu_time_bits64, link_name = "__aio_suspend_time64")] | ||
#[cfg_attr(any(musl_time64, gnu_time_bits64), link_name = "__aio_suspend_time64")] | ||
pub fn aio_suspend( | ||
aiocb_list: *const *const aiocb, | ||
nitems: c_int, | ||
|
@@ -6170,6 +6182,7 @@ cfg_if! { | |
flags: c_ulong, | ||
) -> isize; | ||
#[cfg_attr(gnu_time_bits64, link_name = "__futimes64")] | ||
#[cfg_attr(musl_time64, link_name = "__futimes_time64")] | ||
pub fn futimes(fd: c_int, times: *const crate::timeval) -> c_int; | ||
} | ||
} | ||
|
@@ -6199,7 +6212,7 @@ cfg_if! { | |
msg_len: size_t, | ||
msg_prio: *mut c_uint, | ||
) -> ssize_t; | ||
#[cfg_attr(gnu_time_bits64, link_name = "__mq_timedreceive_time64")] | ||
#[cfg_attr(any(gnu_time_bits64, musl_time64), link_name = "__mq_timedreceive_time64")] | ||
pub fn mq_timedreceive( | ||
mqd: crate::mqd_t, | ||
msg_ptr: *mut c_char, | ||
|
@@ -6213,7 +6226,7 @@ cfg_if! { | |
msg_len: size_t, | ||
msg_prio: c_uint, | ||
) -> c_int; | ||
#[cfg_attr(gnu_time_bits64, link_name = "__mq_timedsend_time64")] | ||
#[cfg_attr(any(gnu_time_bits64, musl_time64), link_name = "__mq_timedsend_time64")] | ||
pub fn mq_timedsend( | ||
mqd: crate::mqd_t, | ||
msg_ptr: *const c_char, | ||
|
@@ -6265,6 +6278,7 @@ extern "C" { | |
pub fn lcong48(p: *mut c_ushort); | ||
|
||
#[cfg_attr(gnu_time_bits64, link_name = "__lutimes64")] | ||
#[cfg_attr(musl_time64, link_name = "__lutimes_time64")] | ||
pub fn lutimes(file: *const c_char, times: *const crate::timeval) -> c_int; | ||
|
||
pub fn setpwent(); | ||
|
@@ -6360,9 +6374,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, musl_time64), link_name = "__timerfd_gettime64")] | ||
pub fn timerfd_gettime(fd: c_int, curr_value: *mut itimerspec) -> c_int; | ||
#[cfg_attr(gnu_time_bits64, link_name = "__timerfd_settime64")] | ||
#[cfg_attr(any(gnu_time_bits64, musl_time64), link_name = "__timerfd_settime64")] | ||
pub fn timerfd_settime( | ||
fd: c_int, | ||
flags: c_int, | ||
|
@@ -6379,6 +6393,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(musl_time64, link_name = "__sigtimedwait_time64")] | ||
pub fn sigtimedwait( | ||
set: *const sigset_t, | ||
info: *mut siginfo_t, | ||
|
@@ -6499,6 +6514,7 @@ extern "C" { | |
pub fn sched_get_priority_max(policy: c_int) -> c_int; | ||
pub fn tee(fd_in: c_int, fd_out: c_int, len: size_t, flags: c_uint) -> ssize_t; | ||
#[cfg_attr(gnu_time_bits64, link_name = "__settimeofday64")] | ||
#[cfg_attr(musl_time64, link_name = "__settimeofday_time64")] | ||
pub fn settimeofday(tv: *const crate::timeval, tz: *const crate::timezone) -> c_int; | ||
pub fn splice( | ||
fd_in: c_int, | ||
|
@@ -6513,8 +6529,10 @@ extern "C" { | |
pub fn eventfd_write(fd: c_int, value: eventfd_t) -> c_int; | ||
|
||
#[cfg_attr(gnu_time_bits64, link_name = "__sched_rr_get_interval64")] | ||
#[cfg_attr(musl_time64, link_name = "__sched_rr_get_interval_time64")] | ||
pub fn sched_rr_get_interval(pid: crate::pid_t, tp: *mut crate::timespec) -> c_int; | ||
#[cfg_attr(gnu_time_bits64, link_name = "__sem_timedwait64")] | ||
#[cfg_attr(musl_time64, link_name = "__sem_timedwait_time64")] | ||
pub fn sem_timedwait(sem: *mut sem_t, abstime: *const crate::timespec) -> c_int; | ||
pub fn sem_getvalue(sem: *mut sem_t, sval: *mut c_int) -> c_int; | ||
pub fn sched_setparam(pid: crate::pid_t, param: *const crate::sched_param) -> c_int; | ||
|
@@ -6534,6 +6552,7 @@ extern "C" { | |
pub fn prctl(option: c_int, ...) -> c_int; | ||
pub fn sched_getparam(pid: crate::pid_t, param: *mut crate::sched_param) -> c_int; | ||
#[cfg_attr(gnu_time_bits64, link_name = "__ppoll64")] | ||
#[cfg_attr(musl_time64, link_name = "__ppoll_time64")] | ||
pub fn ppoll( | ||
fds: *mut crate::pollfd, | ||
nfds: nfds_t, | ||
|
@@ -6547,6 +6566,7 @@ extern "C" { | |
pub fn pthread_mutexattr_setprotocol(attr: *mut pthread_mutexattr_t, protocol: c_int) -> c_int; | ||
|
||
#[cfg_attr(gnu_time_bits64, link_name = "__pthread_mutex_timedlock64")] | ||
#[cfg_attr(musl_time64, link_name = "__pthread_mutex_timedlock_time64")] | ||
pub fn pthread_mutex_timedlock( | ||
lock: *mut pthread_mutex_t, | ||
abstime: *const crate::timespec, | ||
|
@@ -6581,7 +6601,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, musl_time64), | ||
link_name = "__clock_nanosleep_time64" | ||
)] | ||
pub fn clock_nanosleep( | ||
clk_id: crate::clockid_t, | ||
flags: c_int, | ||
|
@@ -6839,9 +6862,9 @@ extern "C" { | |
) -> c_int; | ||
pub fn timer_delete(timerid: crate::timer_t) -> c_int; | ||
pub fn timer_getoverrun(timerid: crate::timer_t) -> c_int; | ||
#[cfg_attr(gnu_time_bits64, link_name = "__timer_gettime64")] | ||
#[cfg_attr(any(gnu_time_bits64, musl_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, musl_time64), link_name = "__timer_settime64")] | ||
pub fn timer_settime( | ||
timerid: crate::timer_t, | ||
flags: c_int, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think
musl_time64
as it is used should be named something likemusl_time64_on_32
. We probably don't need an env to set this independently,build.rs
should just set it whenmusl_time64
is set andtarget_ptr_width
is 32.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I think I will rename it to something like
musl_time64_on_32
,musl32_time64
or maybemusl_redir_time64
as you suggested in the previous PR. I don't think there is a practical use for a separatemusl_time64
variable.