[flang-commits] [PATCH] D105970: [flang] Add POSIX implementation for SYSTEM_CLOCK
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Mon Jul 26 10:12:00 PDT 2021
klausler added inline comments.
================
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;
----------------
rovka wrote:
> klausler wrote:
> > 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.
> Well, the POSIX epoch ought to be set to 1970, and most code survives longer than people expect it to, so I'm sure it will be relevant :P
> Anyway, on a serious note, are you saying we should skip the wrapping altogether and just return tv_nsec + tv_sec * NSECS_PER_SEC?
No, I was pointing out that the overflow path isn't tested. Not a big deal.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D105970/new/
https://reviews.llvm.org/D105970
More information about the flang-commits
mailing list