windows/time: avoid being too close to 0#156177
windows/time: avoid being too close to 0#156177rust-bors[bot] merged 1 commit intorust-lang:mainfrom
Conversation
|
r? @jhpratt rustbot has assigned @jhpratt. Use Why was this reviewer chosen?The reviewer was selected based on:
|
99d0aef to
a07a3b1
Compare
| // We can add an arbitrary offset to shift the epoch of this clock. We do that to avoid | ||
| // being too close to 0 which would lead to underflow when computing times in the past. Also | ||
| // see <https://github.com/rust-lang/rust/issues/156142>. | ||
| let instant_nsec = instant_nsec + (u64::MAX / 4); |
There was a problem hiding this comment.
Would be nicer to use a signed type for storing the nanoseconds, otherwise we have this useless addition on every Instant::now.
Using a signed type would make this essentially free.
There was a problem hiding this comment.
We use Duration so using anything singed would be a major refactor.
There was a problem hiding this comment.
We would need to make something more or less equivalent to a SignedDuration type if we want to share it between different implementations of Instant. It's a shame we can't just wrap the value of perf_counter::now() but Instant is required to have nanosecond permissions so that's right out.
|
I'll admit I don't exactly love this but it addresses the issue for now so... @bors r+ |
…isDenton windows/time: avoid being too close to 0 Fixes rust-lang#156142 (but only for Windows -- should we still track it for non-tier-1-platforms?)
Rollup of 14 pull requests Successful merges: - #146273 (lint ImproperCTypes: refactor linting architecture (part 2)) - #149509 (Lint unused pub items in binary crates) - #156173 (Fewer global node_id_to_def_id lookups) - #156177 (windows/time: avoid being too close to 0) - #155961 (Deny warnings in the test for crates that are available on stable) - #155981 (Use special DefIds for aliases) - #156109 (Migrate libraries from ptr::slice_from_raw_parts to .cast_slice) - #156130 (Fold/visit tweaks) - #156131 (Metadata macro/query cleanups) - #156202 (llvm: Use correct type for splat mask) - #156227 (Add Trusty OS to the generic error implementation.) - #156237 (compiletest: prevent directives from having multiple revisions) - #156241 (Move tests coercion) - #156258 (Document wasi-sdk minimum versions for WASI targets)
Rollup of 12 pull requests Successful merges: - #156173 (Fewer global node_id_to_def_id lookups) - #156177 (windows/time: avoid being too close to 0) - #155961 (Deny warnings in the test for crates that are available on stable) - #155981 (Use special DefIds for aliases) - #156130 (Fold/visit tweaks) - #156131 (Metadata macro/query cleanups) - #156202 (llvm: Use correct type for splat mask) - #156223 (Refactor `Type::size` field to `TypeId::size` method for `type_info`) - #156227 (Add Trusty OS to the generic error implementation.) - #156237 (compiletest: prevent directives from having multiple revisions) - #156241 (Move tests coercion) - #156258 (Document wasi-sdk minimum versions for WASI targets)
Rollup of 12 pull requests Successful merges: - #156173 (Fewer global node_id_to_def_id lookups) - #156177 (windows/time: avoid being too close to 0) - #155961 (Deny warnings in the test for crates that are available on stable) - #155981 (Use special DefIds for aliases) - #156130 (Fold/visit tweaks) - #156131 (Metadata macro/query cleanups) - #156202 (llvm: Use correct type for splat mask) - #156223 (Refactor `Type::size` field to `TypeId::size` method for `type_info`) - #156227 (Add Trusty OS to the generic error implementation.) - #156237 (compiletest: prevent directives from having multiple revisions) - #156241 (Move tests coercion) - #156258 (Document wasi-sdk minimum versions for WASI targets)
Fixes #156142 (but only for Windows -- should we still track it for non-tier-1-platforms?)