[PATCH] D105970: [flang] Add POSIX implementation for SYSTEM_CLOCK
Peter Klausler via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 16 11:39:44 PDT 2021
klausler added inline comments.
================
Comment at: flang/runtime/time-intrinsic.cpp:111
+
+constexpr count_t NSECS_PER_SEC = 1'000'000'000;
+
----------------
Please use modern braced initializers in the runtime; they're safer.
================
Comment at: flang/runtime/time-intrinsic.cpp:136
+ // Wrap around to avoid overflows.
+ count_t max_secs = std::numeric_limits<count_t>::max() / NSECS_PER_SEC;
+ count_t wrapped_secs = tspec.tv_sec % max_secs;
----------------
Can be constexpr.
Since `count_t` is a 64-bit signed integer, max_secs is going to be ca. 8e9, or roughly 300 years. That might make it hard to test your overflow cases.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D105970/new/
https://reviews.llvm.org/D105970
More information about the llvm-commits
mailing list