diff options
author | hiddenpath <hiddenpath@yandex-team.com> | 2024-02-21 23:16:42 +0300 |
---|---|---|
committer | hiddenpath <hiddenpath@yandex-team.com> | 2024-02-21 23:33:25 +0300 |
commit | 9052eb5cc304b8da8885fc4e3364ebddc16945f3 (patch) | |
tree | 3c252f6161dd0745c7732d74c9304c000645ab47 /contrib/libs/cxxsupp/libcxx/include/__thread/id.h | |
parent | f5eb715f103692e7c7536e13bef3f281fd78e5e7 (diff) | |
download | ydb-9052eb5cc304b8da8885fc4e3364ebddc16945f3.tar.gz |
Update libcxx to llvmorg-17.0.6
Update libcxx to llvmorg-17.0.6
c871ef572c71b4fef22d4a9e65bcebc57e625aea
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/include/__thread/id.h')
-rw-r--r-- | contrib/libs/cxxsupp/libcxx/include/__thread/id.h | 121 |
1 files changed, 121 insertions, 0 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/include/__thread/id.h b/contrib/libs/cxxsupp/libcxx/include/__thread/id.h new file mode 100644 index 0000000000..fd6e6dffaf --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__thread/id.h @@ -0,0 +1,121 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___THREAD_ID_H +#define _LIBCPP___THREAD_ID_H + +#include <__compare/ordering.h> +#include <__config> +#include <__fwd/hash.h> +#include <__threading_support> +#include <iosfwd> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#ifndef _LIBCPP_HAS_NO_THREADS +class _LIBCPP_EXPORTED_FROM_ABI __thread_id; + +namespace this_thread { + +_LIBCPP_HIDE_FROM_ABI __thread_id get_id() _NOEXCEPT; + +} // namespace this_thread + +template <> +struct hash<__thread_id>; + +class _LIBCPP_TEMPLATE_VIS __thread_id { + // FIXME: pthread_t is a pointer on Darwin but a long on Linux. + // NULL is the no-thread value on Darwin. Someone needs to check + // on other platforms. We assume 0 works everywhere for now. + __libcpp_thread_id __id_; + + static _LIBCPP_HIDE_FROM_ABI bool + __lt_impl(__thread_id __x, __thread_id __y) _NOEXCEPT { // id==0 is always less than any other thread_id + if (__x.__id_ == 0) + return __y.__id_ != 0; + if (__y.__id_ == 0) + return false; + return __libcpp_thread_id_less(__x.__id_, __y.__id_); + } + +public: + _LIBCPP_HIDE_FROM_ABI __thread_id() _NOEXCEPT : __id_(0) {} + + _LIBCPP_HIDE_FROM_ABI void __reset() { __id_ = 0; } + + friend _LIBCPP_HIDE_FROM_ABI bool operator==(__thread_id __x, __thread_id __y) _NOEXCEPT; +# if _LIBCPP_STD_VER <= 17 + friend _LIBCPP_HIDE_FROM_ABI bool operator<(__thread_id __x, __thread_id __y) _NOEXCEPT; +# else // _LIBCPP_STD_VER <= 17 + friend _LIBCPP_HIDE_FROM_ABI strong_ordering operator<=>(__thread_id __x, __thread_id __y) noexcept; +# endif // _LIBCPP_STD_VER <= 17 + + template <class _CharT, class _Traits> + friend _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& + operator<<(basic_ostream<_CharT, _Traits>& __os, __thread_id __id); + +private: + _LIBCPP_HIDE_FROM_ABI __thread_id(__libcpp_thread_id __id) : __id_(__id) {} + + _LIBCPP_HIDE_FROM_ABI friend __libcpp_thread_id __get_underlying_id(const __thread_id __id) { return __id.__id_; } + + friend __thread_id this_thread::get_id() _NOEXCEPT; + friend class _LIBCPP_EXPORTED_FROM_ABI thread; + friend struct _LIBCPP_TEMPLATE_VIS hash<__thread_id>; +}; + +inline _LIBCPP_HIDE_FROM_ABI bool operator==(__thread_id __x, __thread_id __y) _NOEXCEPT { + // Don't pass id==0 to underlying routines + if (__x.__id_ == 0) + return __y.__id_ == 0; + if (__y.__id_ == 0) + return false; + return __libcpp_thread_id_equal(__x.__id_, __y.__id_); +} + +# if _LIBCPP_STD_VER <= 17 + +inline _LIBCPP_HIDE_FROM_ABI bool operator!=(__thread_id __x, __thread_id __y) _NOEXCEPT { return !(__x == __y); } + +inline _LIBCPP_HIDE_FROM_ABI bool operator<(__thread_id __x, __thread_id __y) _NOEXCEPT { + return __thread_id::__lt_impl(__x.__id_, __y.__id_); +} + +inline _LIBCPP_HIDE_FROM_ABI bool operator<=(__thread_id __x, __thread_id __y) _NOEXCEPT { return !(__y < __x); } +inline _LIBCPP_HIDE_FROM_ABI bool operator>(__thread_id __x, __thread_id __y) _NOEXCEPT { return __y < __x; } +inline _LIBCPP_HIDE_FROM_ABI bool operator>=(__thread_id __x, __thread_id __y) _NOEXCEPT { return !(__x < __y); } + +# else // _LIBCPP_STD_VER <= 17 + +inline _LIBCPP_HIDE_FROM_ABI strong_ordering operator<=>(__thread_id __x, __thread_id __y) noexcept { + if (__x == __y) + return strong_ordering::equal; + if (__thread_id::__lt_impl(__x, __y)) + return strong_ordering::less; + return strong_ordering::greater; +} + +# endif // _LIBCPP_STD_VER <= 17 + +namespace this_thread { + +inline _LIBCPP_HIDE_FROM_ABI __thread_id get_id() _NOEXCEPT { return __libcpp_thread_get_current_id(); } + +} // namespace this_thread + +#endif // !_LIBCPP_HAS_NO_THREADS + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___THREAD_ID_H |