[libc-commits] [libc] [libc] C11 threads: Add cnd_timedwait and mtx_trylock. (PR #195966)

Schrodinger ZHU Yifan via libc-commits libc-commits at lists.llvm.org
Wed May 6 07:54:14 PDT 2026


================
@@ -31,6 +31,11 @@ LIBC_INLINE void ensure_monotonicity(AbsTimeout &timeout) {
         convert_clock(timeout.get_timespec(), CLOCK_REALTIME, CLOCK_MONOTONIC),
         false);
 
+    // Clamp the timeout to epoch if becomes negative after the conversion.
+    if (!res.has_value() && res.error() == AbsTimeout::Error::BeforeEpoch) {
+      res = AbsTimeout::from_timespec(timespec{0, 0}, false);
----------------
SchrodingerZhu wrote:

Good catch. Elide the braces?

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


More information about the libc-commits mailing list