diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2024-04-26 15:33:29 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2024-05-08 19:37:29 -0700 |
| commit | 06ee65af9ed6aa5ee4d1d7f4fab9d7acecf66e76 (patch) | |
| tree | 1316711b92a43dd5c599e425b8693fa8e1e0c0b7 /lib/libcxx/include/__thread/this_thread.h | |
| parent | bc6ebc6f2597fda1f98842c6f545751fef2a5334 (diff) | |
| download | zig-06ee65af9ed6aa5ee4d1d7f4fab9d7acecf66e76.tar.gz zig-06ee65af9ed6aa5ee4d1d7f4fab9d7acecf66e76.zip | |
libcxx: update to LLVM 18
release/18.x branch, commit 78b99c73ee4b96fe9ce0e294d4632326afb2db42
This adds the flag `-D_LIBCPP_HARDENING_MODE` which is determined based
on the Zig optimization mode.
This commit also fixes libunwind, libcxx, and libcxxabi to properly
report sub compilation errors.
Diffstat (limited to 'lib/libcxx/include/__thread/this_thread.h')
| -rw-r--r-- | lib/libcxx/include/__thread/this_thread.h | 63 |
1 files changed, 25 insertions, 38 deletions
diff --git a/lib/libcxx/include/__thread/this_thread.h b/lib/libcxx/include/__thread/this_thread.h index b79065eeed..6fb42533aa 100644 --- a/lib/libcxx/include/__thread/this_thread.h +++ b/lib/libcxx/include/__thread/this_thread.h @@ -27,56 +27,43 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD -namespace this_thread -{ +namespace this_thread { _LIBCPP_EXPORTED_FROM_ABI void sleep_for(const chrono::nanoseconds& __ns); template <class _Rep, class _Period> -_LIBCPP_HIDE_FROM_ABI void -sleep_for(const chrono::duration<_Rep, _Period>& __d) -{ - if (__d > chrono::duration<_Rep, _Period>::zero()) - { - // The standard guarantees a 64bit signed integer resolution for nanoseconds, - // so use INT64_MAX / 1e9 as cut-off point. Use a constant to avoid <climits> - // and issues with long double folding on PowerPC with GCC. - _LIBCPP_CONSTEXPR chrono::duration<long double> __max = - chrono::duration<long double>(9223372036.0L); - chrono::nanoseconds __ns; - if (__d < __max) - { - __ns = chrono::duration_cast<chrono::nanoseconds>(__d); - if (__ns < __d) - ++__ns; - } - else - __ns = chrono::nanoseconds::max(); - this_thread::sleep_for(__ns); - } +_LIBCPP_HIDE_FROM_ABI void sleep_for(const chrono::duration<_Rep, _Period>& __d) { + if (__d > chrono::duration<_Rep, _Period>::zero()) { + // The standard guarantees a 64bit signed integer resolution for nanoseconds, + // so use INT64_MAX / 1e9 as cut-off point. Use a constant to avoid <climits> + // and issues with long double folding on PowerPC with GCC. + _LIBCPP_CONSTEXPR chrono::duration<long double> __max = chrono::duration<long double>(9223372036.0L); + chrono::nanoseconds __ns; + if (__d < __max) { + __ns = chrono::duration_cast<chrono::nanoseconds>(__d); + if (__ns < __d) + ++__ns; + } else + __ns = chrono::nanoseconds::max(); + this_thread::sleep_for(__ns); + } } template <class _Clock, class _Duration> -_LIBCPP_HIDE_FROM_ABI void -sleep_until(const chrono::time_point<_Clock, _Duration>& __t) -{ - mutex __mut; - condition_variable __cv; - unique_lock<mutex> __lk(__mut); - while (_Clock::now() < __t) - __cv.wait_until(__lk, __t); +_LIBCPP_HIDE_FROM_ABI void sleep_until(const chrono::time_point<_Clock, _Duration>& __t) { + mutex __mut; + condition_variable __cv; + unique_lock<mutex> __lk(__mut); + while (_Clock::now() < __t) + __cv.wait_until(__lk, __t); } template <class _Duration> -inline _LIBCPP_INLINE_VISIBILITY -void -sleep_until(const chrono::time_point<chrono::steady_clock, _Duration>& __t) -{ - this_thread::sleep_for(__t - chrono::steady_clock::now()); +inline _LIBCPP_HIDE_FROM_ABI void sleep_until(const chrono::time_point<chrono::steady_clock, _Duration>& __t) { + this_thread::sleep_for(__t - chrono::steady_clock::now()); } -inline _LIBCPP_INLINE_VISIBILITY -void yield() _NOEXCEPT {__libcpp_thread_yield();} +inline _LIBCPP_HIDE_FROM_ABI void yield() _NOEXCEPT { __libcpp_thread_yield(); } } // namespace this_thread |
