[libcxx-commits] [PATCH] D152382: [libc++] Expand the contents of LIBCXX_ENABLE_FILESYSTEM

Michael Platings via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jul 4 08:39:24 PDT 2023


michaelplatings added a comment.

> Does that mean the platform doesn't provide a way to check the time, or is it that the API it provides is just different? How is e.g. `std::system_clock` implemented on that platform?

>From `chrono.cpp`:

  #if !defined(__APPLE__) && defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0
  # define _LIBCPP_USE_CLOCK_GETTIME
  #endif
  
  ...
  
  #elif defined(CLOCK_REALTIME) && defined(_LIBCPP_USE_CLOCK_GETTIME)
  
  ...
  
  #else
  
  static system_clock::time_point __libcpp_system_clock_now() {
      timeval tv;
      gettimeofday(&tv, 0);
      return system_clock::time_point(seconds(tv.tv_sec) + microseconds(tv.tv_usec));
  }
  
  #endif

Picolibc does not define `_POSIX_TIMERS` so it looks like `gettimeofday` is used, which is part of standard C, not a POSIX extension. Perhaps the same could be done in `filesystem_clock.cpp`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152382



More information about the libcxx-commits mailing list