about summary refs log tree commit diff
path: root/src/libstd/sys/redox/time.rs
AgeCommit message (Collapse)AuthorLines
2019-08-06redox: convert to target_family unixJeremy Soller-207/+0
2019-03-31libstd: deny(elided_lifetimes_in_paths)Mazdak Farrokhzad-2/+2
2019-03-22Update sys::time impls to have checked_sub_instantLinus Färnstrand-4/+2
2019-02-28libstd => 2018Taiki Endo-5/+6
2019-01-07std: Force `Instant::now()` to be monotonicAlex Crichton-0/+8
This commit is an attempt to force `Instant::now` to be monotonic through any means possible. We tried relying on OS/hardware/clock implementations, but those seem buggy enough that we can't rely on them in practice. This commit implements the same hammer Firefox recently implemented (noted in #56612) which is to just keep whatever the lastest `Instant::now()` return value was in memory, returning that instead of the OS looks like it's moving backwards. Closes #48514 Closes #49281 cc #51648 cc #56560 Closes #56612 Closes #56940
2018-12-25Remove licensesMark Rousskov-10/+0
2018-12-13Add checked_sub for Instant and SystemTimeLinus Färnstrand-13/+11
2018-12-13Add checked_add method to Instant time typeLinus Färnstrand-10/+2
2018-11-25Auto merge of #55527 - sgeisler:time-checked-add, r=sfacklerbors-6/+12
Implement checked_add_duration for SystemTime [Original discussion on the rust user forum](https://users.rust-lang.org/t/std-systemtime-misses-a-checked-add-function/21785) Since `SystemTime` is opaque there is no way to check if the result of an addition will be in bounds. That makes the `Add<Duration>` trait completely unusable with untrusted data. This is a big problem because adding a `Duration` to `UNIX_EPOCH` is the standard way of constructing a `SystemTime` from a unix timestamp. This PR implements `checked_add_duration(&self, &Duration) -> Option<SystemTime>` for `std::time::SystemTime` and as a prerequisite also for all platform specific time structs. This also led to the refactoring of many `add_duration(&self, &Duration) -> SystemTime` functions to avoid redundancy (they now unwrap the result of `checked_add_duration`). Some basic unit tests for the newly introduced function were added too. I wasn't sure which stabilization attribute to add to the newly introduced function, so I just chose `#[stable(feature = "time_checked_add", since = "1.32.0")]` for now to make it compile. Please let me know how I should change it or if I violated any other conventions. P.S.: I could only test on Linux so far, so I don't necessarily expect it to compile for all platforms.
2018-11-15use ? operator instead of matchSebastian Geisler-10/+3
2018-11-15Implement checked_add_duration for SystemTimeSebastian Geisler-6/+19
Since SystemTime is opaque there is no way to check if the result of an addition will be in bounds. That makes the Add<Duration> trait completely unusable with untrusted data. This is a big problem because adding a Duration to UNIX_EPOCH is the standard way of constructing a SystemTime from a unix timestamp. This commit implements checked_add_duration(&self, &Duration) -> Option<SystemTime> for std::time::SystemTime and as a prerequisite also for all platform specific time structs. This also led to the refactoring of many add_duration(&self, &Duration) -> SystemTime functions to avoid redundancy (they now unwrap the result of checked_add_duration). Some basic unit tests for the newly introduced function were added too.
2018-11-06refactor: use shorthand fieldsteresy-1/+1
2018-06-04Clarify error phrase in `sub_instant` functionClaudio Bley-1/+1
Uses the same wording as [`src/libstd/sys/windows/time.rs`][1]. 1: https://github.com/avdv/rust/blob/95e2bf253d864c5e14ad000ffa2040ce85916056/src/libstd/sys/windows/time.rs#L65
2017-12-19Add Hash impl for SystemTime and InstantVitaly _Vi Shukela-2/+10
Closes #46670.
2017-09-07Properly detect overflow in Instance +/- Duration.kennytm-7/+15
Avoid unchecked cast from `u64` to `i64`. Use `try_into()` for checked cast. (On Unix, cast to `time_t` instead of `i64`.)
2016-11-28Commit to fix make tidyJeremy Soller-1/+1
2016-11-28Switch to using syscall crate directly - without importJeremy Soller-14/+13
2016-10-28Remove unsafe libc layerJeremy Soller-219/+67
2016-10-27Add redox systemJeremy Soller-0/+351