Fix compilation on 32-bit systems

This commit is contained in:
Jeremy Soller
2022-12-02 08:00:36 -07:00
parent 041d1604b5
commit 59b2e32953
6 changed files with 19 additions and 21 deletions
+1 -1
View File
@@ -616,7 +616,7 @@ pub unsafe fn fseek_locked(stream: &mut FILE, mut off: off_t, whence: c_int) ->
/// Seek to a position `pos` in the file from the beginning of the file
#[no_mangle]
pub unsafe extern "C" fn fsetpos(stream: *mut FILE, pos: *const fpos_t) -> c_int {
fseek(stream, *pos, SEEK_SET)
fseeko(stream, *pos, SEEK_SET)
}
/// Get the current position of the cursor in the file
+5 -7
View File
@@ -163,14 +163,12 @@ pub extern "C" fn clock() -> clock_t {
}
let ts = unsafe { ts.assume_init() };
if ts.tv_sec > time_t::max_value() / CLOCKS_PER_SEC
|| ts.tv_nsec / (1_000_000_000 / CLOCKS_PER_SEC)
> time_t::max_value() - CLOCKS_PER_SEC * ts.tv_sec
{
return -1;
let clocks = ts.tv_sec * CLOCKS_PER_SEC as i64
+ (ts.tv_nsec / (1_000_000_000 / CLOCKS_PER_SEC)) as i64;
match clock_t::try_from(clocks) {
Ok(ok) => ok,
Err(_err) => -1,
}
ts.tv_sec * CLOCKS_PER_SEC + ts.tv_nsec / (1_000_000_000 / CLOCKS_PER_SEC)
}
// #[no_mangle]
+2 -2
View File
@@ -603,7 +603,7 @@ pub extern "C" fn setuid(uid: uid_t) -> c_int {
#[no_mangle]
pub extern "C" fn sleep(seconds: c_uint) -> c_uint {
let rqtp = timespec {
tv_sec: seconds as c_long,
tv_sec: seconds as time_t,
tv_nsec: 0,
};
let rmtp = ptr::null_mut();
@@ -731,7 +731,7 @@ pub unsafe extern "C" fn unlink(path: *const c_char) -> c_int {
#[no_mangle]
pub extern "C" fn usleep(useconds: useconds_t) -> c_int {
let rqtp = timespec {
tv_sec: (useconds / 1_000_000) as c_long,
tv_sec: (useconds / 1_000_000) as time_t,
tv_nsec: ((useconds % 1_000_000) * 1000) as c_long,
};
let rmtp = ptr::null_mut();
+5 -5
View File
@@ -14,7 +14,7 @@ use crate::{
tcb::{Master, Tcb},
},
platform::{
types::{c_int, c_uint, c_long, c_void, pid_t, size_t},
types::{c_int, c_uint, c_long, c_void, pid_t, size_t, time_t},
Pal, Sys,
},
sync::{Mutex, Semaphore},
@@ -253,8 +253,8 @@ pub unsafe extern "C" fn pte_osThreadSleep(msecs: c_uint) {
Sys::sched_yield();
} else {
let tm = timespec {
tv_sec: msecs as c_long / 1000,
tv_nsec: (msecs % 1000) as c_long * 1000000,
tv_sec: msecs as time_t / 1000,
tv_nsec: ((msecs as c_long) % 1000) * 1000000,
};
Sys::nanosleep(&tm, ptr::null_mut());
}
@@ -353,9 +353,9 @@ pub unsafe extern "C" fn pte_osSemaphorePend(
clock_gettime(CLOCK_MONOTONIC, &mut time);
// Add timeout to time
let timeout = *pTimeout as c_long;
let timeout = *pTimeout as time_t;
time.tv_sec += timeout / 1000;
time.tv_nsec += (timeout % 1000) * 1_000_000;
time.tv_nsec += ((timeout % 1000) * 1_000_000) as c_long;
while time.tv_nsec >= 1_000_000_000 {
time.tv_sec += 1;
time.tv_nsec -= 1_000_000_000;
+2 -2
View File
@@ -190,7 +190,7 @@ impl Pal for Sys {
-1 => -1,
_ => {
unsafe {
(*tp).tv_sec = redox_tp.tv_sec as c_long;
(*tp).tv_sec = redox_tp.tv_sec as time_t;
(*tp).tv_nsec = redox_tp.tv_nsec as c_long;
};
0
@@ -702,7 +702,7 @@ impl Pal for Sys {
_ => {
unsafe {
if !rmtp.is_null() {
(*rmtp).tv_sec = redox_rmtp.tv_sec as c_long;
(*rmtp).tv_sec = redox_rmtp.tv_sec as time_t;
(*rmtp).tv_nsec = redox_rmtp.tv_nsec as c_long;
}
}
+4 -4
View File
@@ -39,9 +39,9 @@ impl PalSignal for Sys {
}
unsafe {
(*out).it_interval.tv_sec = spec.it_interval.tv_sec as c_long;
(*out).it_interval.tv_sec = spec.it_interval.tv_sec as time_t;
(*out).it_interval.tv_usec = spec.it_interval.tv_nsec / 1000;
(*out).it_value.tv_sec = spec.it_value.tv_sec as c_long;
(*out).it_value.tv_sec = spec.it_value.tv_sec as time_t;
(*out).it_value.tv_usec = spec.it_value.tv_nsec / 1000;
}
@@ -81,9 +81,9 @@ impl PalSignal for Sys {
if count != !0 {
unsafe {
if !old.is_null() {
(*old).it_interval.tv_sec = spec.it_interval.tv_sec as c_long;
(*old).it_interval.tv_sec = spec.it_interval.tv_sec as time_t;
(*old).it_interval.tv_usec = spec.it_interval.tv_nsec / 1000;
(*old).it_value.tv_sec = spec.it_value.tv_sec as c_long;
(*old).it_value.tv_sec = spec.it_value.tv_sec as time_t;
(*old).it_value.tv_usec = spec.it_value.tv_nsec / 1000;
}