[flang-commits] [PATCH] D105969: [flang] Add default implementation for SYSTEM_CLOCK

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Fri Jul 16 11:32:14 PDT 2021


klausler added inline comments.


================
Comment at: flang/runtime/time-intrinsic.cpp:80
+template <typename Unused = void>
+count_t getSystemClockCount(fallback_implementation) {
+  std::clock_t timestamp{std::clock()};
----------------
We capitalize function names in the runtime.


================
Comment at: flang/runtime/time-intrinsic.cpp:89
+  // std::clock, our work is done. Otherwise, we have to wrap around.
+  if (std::numeric_limits<std::clock_t>::max() <=
+      std::numeric_limits<count_t>::max()) {
----------------
This could be `if constexpr`, with the rest of the function residing in its `else` part.


================
Comment at: flang/runtime/time-intrinsic.cpp:96
+  // % operator, so we have to wrap around manually.
+  auto max = std::numeric_limits<count_t>::max();
+  return static_cast<count_t>(timestamp - max * std::floor(timestamp / max));
----------------
This could be `static constexpr` and used in the expression of the previous if statement.

We prefer modern braced initialization in runtime.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105969/new/

https://reviews.llvm.org/D105969



More information about the flang-commits mailing list