Merge branch 'timespec-noncopy' into 'master'

do not derive Copy for timespec

See merge request redox-os/relibc!1082
This commit is contained in:
Jeremy Soller
2026-03-11 09:41:52 -06:00
5 changed files with 9 additions and 8 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ use crate::{
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/time.h.html>.
#[repr(C)]
#[derive(Clone, Copy, Default, Debug)]
#[derive(Clone, Default, Debug)]
pub struct timespec {
pub tv_sec: time_t,
pub tv_nsec: c_long,
+1 -1
View File
@@ -76,7 +76,7 @@ pub unsafe extern "C" fn pthread_mutex_timedlock(
mutex: *mut pthread_mutex_t,
abstime: &timespec,
) -> c_int {
let relative = match timespec_realtime_to_monotonic(*abstime) {
let relative = match timespec_realtime_to_monotonic(abstime.clone()) {
Ok(relative) => relative,
Err(err) => return e(Err(err)),
};
+3 -2
View File
@@ -96,7 +96,7 @@ pub unsafe extern "C" fn sem_clockwait(
clock_id: clockid_t,
abstime: *const timespec,
) -> c_int {
if let Ok(()) = unsafe { get(sem) }.wait(Some(&unsafe { *abstime }), clock_id) {}; // TODO handle error
if let Ok(()) = unsafe { get(sem) }.wait(Some(&unsafe { (*abstime).clone() }), clock_id) {}; // TODO handle error
0
}
@@ -104,7 +104,8 @@ pub unsafe extern "C" fn sem_clockwait(
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/sem_timedwait.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn sem_timedwait(sem: *mut sem_t, abstime: *const timespec) -> c_int {
if let Ok(()) = unsafe { get(sem) }.wait(Some(&unsafe { *abstime }), CLOCK_REALTIME) {}; // TODO handle error
if let Ok(()) = unsafe { get(sem) }.wait(Some(&unsafe { (*abstime).clone() }), CLOCK_REALTIME) {
}; // TODO handle error
0
}
+3 -3
View File
@@ -1367,7 +1367,7 @@ impl Pal for Sys {
Self::clock_gettime(timer_st.clockid, Out::from_mut(&mut now))?;
if timer_st.evp.sigev_notify == SIGEV_NONE {
if timespec::subtract(timer_st.next_wake_time.it_value, now).is_none() {
if timespec::subtract(timer_st.next_wake_time.it_value.clone(), now.clone()).is_none() {
// error here means the timer is disarmed
let _ = timer_update_wake_time(timer_st);
}
@@ -1378,8 +1378,8 @@ impl Pal for Sys {
itimerspec::default()
} else {
itimerspec {
it_interval: timer_st.next_wake_time.it_interval,
it_value: timespec::subtract(timer_st.next_wake_time.it_value, now)
it_interval: timer_st.next_wake_time.it_interval.clone(),
it_value: timespec::subtract(timer_st.next_wake_time.it_value.clone(), now)
.unwrap_or_default(),
}
});
+1 -1
View File
@@ -86,7 +86,7 @@ pub(crate) fn timer_update_wake_time(timer_st: &mut timer_internal_t) -> Result<
} else {
let mut now = timespec::default();
Sys::clock_gettime(timer_st.clockid, Out::from_mut(&mut now))?;
let next_time = match timespec::add(now, timer_st.next_wake_time.it_interval) {
let next_time = match timespec::add(now, timer_st.next_wake_time.it_interval.clone()) {
Some(a) => a,
None => timespec::default(),
};