[libcxx-commits] [libcxx] [libc++] Use clock_gettime in filesystem_clock on OpenBSD (PR #235292)

via libcxx-commits libcxx-commits at lists.llvm.org
Sat Oct 24 05:38:20 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libcxx

Author: Brad Smith (brad0)

<details>
<summary>Changes</summary>

OpenBSD does not define _POSIX_TIMERS > 0 because its POSIX timers
support is incomplete, but it does provide clock_gettime() and
CLOCK_MONOTONIC. chrono.cpp already special-cases OpenBSD for this;
filesystem_clock.cpp did not, so on OpenBSD it fell back to
gettimeofday() for file_time_type::clock::now().

Add __OpenBSD__ to the _LIBCPP_HAS_CLOCK_GETTIME check in
filesystem_clock.cpp so it matches chrono.cpp, and copy over the
comment explaining why.

---
Full diff: https://github.com/llvm/llvm-project/pull/235292.diff


1 Files Affected:

- (modified) libcxx/src/filesystem/filesystem_clock.cpp (+4-2) 


``````````diff
diff --git a/libcxx/src/filesystem/filesystem_clock.cpp b/libcxx/src/filesystem/filesystem_clock.cpp
index 0d360c51a7a37e..cb9af6a9b440be 100644
--- a/libcxx/src/filesystem/filesystem_clock.cpp
+++ b/libcxx/src/filesystem/filesystem_clock.cpp
@@ -36,8 +36,10 @@
 #  define _LIBCPP_HAS_TIMESPEC_GET
 #endif
 
-#if defined(__APPLE__) || defined(__gnu_hurd__) || defined(__AMDGPU__) || defined(__NVPTX__) ||                        \
-    (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0)
+// OpenBSD and GPU do not have a fully conformant suite of POSIX timers, but
+// it does have clock_gettime and CLOCK_MONOTONIC which is all we need.
+#if defined(__APPLE__) || defined(__gnu_hurd__) || defined(__OpenBSD__) || defined(__AMDGPU__) ||                      \
+    defined(__NVPTX__) || (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0)
 #  define _LIBCPP_HAS_CLOCK_GETTIME
 #endif
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/235292


More information about the libcxx-commits mailing list