Format
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
use super::{fseek_locked, ftell_locked, FILE, SEEK_SET};
|
||||
use crate::{
|
||||
core_io::Read,
|
||||
platform::types::off_t,
|
||||
};
|
||||
use crate::{core_io::Read, platform::types::off_t};
|
||||
struct LookAheadBuffer {
|
||||
buf: *const u8,
|
||||
pos: isize,
|
||||
|
||||
+7
-10
@@ -163,8 +163,8 @@ pub extern "C" fn clock() -> clock_t {
|
||||
}
|
||||
let ts = unsafe { ts.assume_init() };
|
||||
|
||||
let clocks = ts.tv_sec * CLOCKS_PER_SEC as i64
|
||||
+ (ts.tv_nsec / (1_000_000_000 / CLOCKS_PER_SEC)) as i64;
|
||||
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,
|
||||
@@ -368,10 +368,9 @@ pub unsafe extern "C" fn mktime(t: *mut tm) -> time_t {
|
||||
day += MONTH_DAYS[leap][month as usize] as i64;
|
||||
}
|
||||
|
||||
(
|
||||
-(day * (60 * 60 * 24)
|
||||
- (((*t).tm_hour as i64) * (60 * 60) + ((*t).tm_min as i64) * 60 + (*t).tm_sec as i64))
|
||||
) as time_t
|
||||
(-(day * (60 * 60 * 24)
|
||||
- (((*t).tm_hour as i64) * (60 * 60) + ((*t).tm_min as i64) * 60 + (*t).tm_sec as i64)))
|
||||
as time_t
|
||||
} else {
|
||||
while year > 1970 {
|
||||
year -= 1;
|
||||
@@ -383,12 +382,10 @@ pub unsafe extern "C" fn mktime(t: *mut tm) -> time_t {
|
||||
day += MONTH_DAYS[leap][month as usize] as i64;
|
||||
}
|
||||
|
||||
(
|
||||
day * (60 * 60 * 24)
|
||||
(day * (60 * 60 * 24)
|
||||
+ ((*t).tm_hour as i64) * (60 * 60)
|
||||
+ ((*t).tm_min as i64) * 60
|
||||
+ (*t).tm_sec as i64
|
||||
) as time_t
|
||||
+ (*t).tm_sec as i64) as time_t
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
-2
@@ -8,13 +8,16 @@ use core::{
|
||||
};
|
||||
|
||||
use crate::{
|
||||
header::{sys_mman, time::{CLOCK_MONOTONIC, clock_gettime, timespec}},
|
||||
header::{
|
||||
sys_mman,
|
||||
time::{clock_gettime, timespec, CLOCK_MONOTONIC},
|
||||
},
|
||||
ld_so::{
|
||||
linker::Linker,
|
||||
tcb::{Master, Tcb},
|
||||
},
|
||||
platform::{
|
||||
types::{c_int, c_uint, c_long, c_void, pid_t, size_t, time_t},
|
||||
types::{c_int, c_long, c_uint, c_void, pid_t, size_t, time_t},
|
||||
Pal, Sys,
|
||||
},
|
||||
sync::{Mutex, Semaphore},
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
use super::AtomicLock;
|
||||
use crate::{
|
||||
header::time::{CLOCK_MONOTONIC, clock_gettime, timespec},
|
||||
header::time::{clock_gettime, timespec, CLOCK_MONOTONIC},
|
||||
platform::{types::*, Pal, Sys},
|
||||
};
|
||||
|
||||
@@ -33,13 +33,13 @@ impl Semaphore {
|
||||
value,
|
||||
value - 1,
|
||||
Ordering::SeqCst,
|
||||
Ordering::SeqCst
|
||||
Ordering::SeqCst,
|
||||
) {
|
||||
Ok(_) => {
|
||||
// Acquired
|
||||
return Ok(());
|
||||
}
|
||||
Err(_) => ()
|
||||
Err(_) => (),
|
||||
}
|
||||
// Try again (as long as value > 0)
|
||||
continue;
|
||||
@@ -47,11 +47,11 @@ impl Semaphore {
|
||||
if let Some(timeout) = timeout_opt {
|
||||
let mut time = timespec::default();
|
||||
clock_gettime(CLOCK_MONOTONIC, &mut time);
|
||||
if (time.tv_sec > timeout.tv_sec) ||
|
||||
(time.tv_sec == timeout.tv_sec && time.tv_nsec >= timeout.tv_nsec)
|
||||
if (time.tv_sec > timeout.tv_sec)
|
||||
|| (time.tv_sec == timeout.tv_sec && time.tv_nsec >= timeout.tv_nsec)
|
||||
{
|
||||
//Timeout happened, return error
|
||||
return Err(())
|
||||
return Err(());
|
||||
} else {
|
||||
// Use futex to wait for the next change, with a relative timeout
|
||||
let mut relative = timespec {
|
||||
|
||||
Reference in New Issue
Block a user