[PATCH] D105970: [flang] Add POSIX implementation for SYSTEM_CLOCK

Diana Picus via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 26 10:04:21 PDT 2021


rovka 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;
----------------
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?


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