Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
1b3fe75
Allow simd_shuffle to accept vectors of any length
calebzulawski Sep 11, 2021
37196e3
Suggest replacing an inexisting field for an unmentioned field
hkmatsumoto Aug 12, 2021
ffdabc8
Check for shadowing issues involving block labels
tmiasko Sep 15, 2021
bd4c967
Fix linting when trailing macro expands to a trailing semi
Aaron1011 Sep 16, 2021
4a4ca94
Fix shuffle index constant not being monomorphized.
calebzulawski Sep 16, 2021
2b512cc
fix potential race in AtomicU64 time monotonizer
the8472 Sep 16, 2021
f84000d
Add a separate error for `dyn Trait` in `const fn`
WaffleLapkin Sep 16, 2021
57465d9
use AtomicU64::fetch_update instead of handrolled RMW-loop
the8472 Sep 17, 2021
ec34aa6
modify std::os docs to be more consistent
schctl Sep 17, 2021
05b01cd
refactor: VecDeques IntoIter fields to private
DeveloperC286 Sep 17, 2021
68147eb
Suggest better place to add call parentheses for method expressions w…
Kobzol Sep 17, 2021
59d5eb2
Resolve issue 85066
Wardenfar Sep 16, 2021
3f75ab3
Fix typo
Sep 18, 2021
2f210be
Rollup merge of #87960 - hkmatsumoto:suggest-inexisting-field-for-unm…
JohnTitor Sep 19, 2021
5bc783b
Rollup merge of #88855 - calebzulawski:feature/simd_shuffle, r=nagisa
JohnTitor Sep 19, 2021
25beabe
Rollup merge of #88966 - tmiasko:block-label-shadowing, r=petrochenkov
JohnTitor Sep 19, 2021
ddf3c53
Rollup merge of #88996 - Aaron1011:trailing-macro-semi, r=petrochenkov
JohnTitor Sep 19, 2021
487101d
Rollup merge of #89017 - the8472:fix-u64-time-monotonizer, r=kennytm
JohnTitor Sep 19, 2021
c58c4b0
Rollup merge of #89021 - WaffleLapkin:separate_error_for_dyn_trait_in…
JohnTitor Sep 19, 2021
833312b
Rollup merge of #89023 - Wardenfar:issue-85066, r=nagisa
JohnTitor Sep 19, 2021
59891cc
Rollup merge of #89051 - schctl:master, r=jyn514
JohnTitor Sep 19, 2021
93bb4a9
Rollup merge of #89053 - DeveloperC286:into_iter_fields_to_private, r…
JohnTitor Sep 19, 2021
64b19fe
Rollup merge of #89055 - Kobzol:wrapped-method-expr-call-parens, r=we…
JohnTitor Sep 19, 2021
265dd84
Rollup merge of #89081 - ondra05:patch-1, r=dtolnay
JohnTitor Sep 19, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@
#![feature(atomic_mut_ptr)]
#![feature(auto_traits)]
#![feature(bench_black_box)]
#![feature(bool_to_option)]
#![feature(box_syntax)]
#![feature(c_unwind)]
#![feature(c_variadic)]
Expand Down
57 changes: 29 additions & 28 deletions library/std/src/time/monotonic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,35 +37,36 @@ pub mod inner {
// This could be a problem for programs that call instants at intervals greater
// than 68 years. Interstellar probes may want to ensure that actually_monotonic() is true.
let packed = (secs << 32) | nanos;
let old = mono.load(Relaxed);

if old == UNINITIALIZED || packed.wrapping_sub(old) < u64::MAX / 2 {
mono.store(packed, Relaxed);
raw
} else {
// Backslide occurred. We reconstruct monotonized time from the upper 32 bit of the
// passed in value and the 64bits loaded from the atomic
let seconds_lower = old >> 32;
let mut seconds_upper = secs & 0xffff_ffff_0000_0000;
if secs & 0xffff_ffff > seconds_lower {
// Backslide caused the lower 32bit of the seconds part to wrap.
// This must be the case because the seconds part is larger even though
// we are in the backslide branch, i.e. the seconds count should be smaller or equal.
//
// We assume that backslides are smaller than 2^32 seconds
// which means we need to add 1 to the upper half to restore it.
//
// Example:
// most recent observed time: 0xA1_0000_0000_0000_0000u128
// bits stored in AtomicU64: 0x0000_0000_0000_0000u64
// backslide by 1s
// caller time is 0xA0_ffff_ffff_0000_0000u128
// -> we can fix up the upper half time by adding 1 << 32
seconds_upper = seconds_upper.wrapping_add(0x1_0000_0000);
let updated = mono.fetch_update(Relaxed, Relaxed, |old| {
(old == UNINITIALIZED || packed.wrapping_sub(old) < u64::MAX / 2).then_some(packed)
});
match updated {
Ok(_) => raw,
Err(newer) => {
// Backslide occurred. We reconstruct monotonized time from the upper 32 bit of the
// passed in value and the 64bits loaded from the atomic
let seconds_lower = newer >> 32;
let mut seconds_upper = secs & 0xffff_ffff_0000_0000;
if secs & 0xffff_ffff > seconds_lower {
// Backslide caused the lower 32bit of the seconds part to wrap.
// This must be the case because the seconds part is larger even though
// we are in the backslide branch, i.e. the seconds count should be smaller or equal.
//
// We assume that backslides are smaller than 2^32 seconds
// which means we need to add 1 to the upper half to restore it.
//
// Example:
// most recent observed time: 0xA1_0000_0000_0000_0000u128
// bits stored in AtomicU64: 0x0000_0000_0000_0000u64
// backslide by 1s
// caller time is 0xA0_ffff_ffff_0000_0000u128
// -> we can fix up the upper half time by adding 1 << 32
seconds_upper = seconds_upper.wrapping_add(0x1_0000_0000);
}
let secs = seconds_upper | seconds_lower;
let nanos = newer as u32;
ZERO.checked_add_duration(&Duration::new(secs, nanos)).unwrap()
}
let secs = seconds_upper | seconds_lower;
let nanos = old as u32;
ZERO.checked_add_duration(&Duration::new(secs, nanos)).unwrap()
}
}
}
Expand Down