| 1 |
// -*- C++ -*- |
| 2 |
//===----------------------------------------------------------------------===// |
| 3 |
// |
| 4 |
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 |
// See https://llvm.org/LICENSE.txt for license information. |
| 6 |
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 7 |
// |
| 8 |
//===----------------------------------------------------------------------===// |
| 9 |
|
| 10 |
#ifndef _LIBCPP___CXX03___THREAD_SUPPORT_WINDOWS_H |
| 11 |
#define _LIBCPP___CXX03___THREAD_SUPPORT_WINDOWS_H |
| 12 |
|
| 13 |
#include <__cxx03/__chrono/duration.h> |
| 14 |
#include <__cxx03/__config> |
| 15 |
#include <__cxx03/ctime> |
| 16 |
|
| 17 |
#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER |
| 18 |
# pragma GCC system_header |
| 19 |
#endif |
| 20 |
|
| 21 |
_LIBCPP_BEGIN_NAMESPACE_STD |
| 22 |
|
| 23 |
using __libcpp_timespec_t = ::timespec; |
| 24 |
|
| 25 |
// |
| 26 |
// Mutex |
| 27 |
// |
| 28 |
typedef void* __libcpp_mutex_t; |
| 29 |
#define _LIBCPP_MUTEX_INITIALIZER 0 |
| 30 |
|
| 31 |
#if defined(_WIN64) |
| 32 |
typedef void* __libcpp_recursive_mutex_t[5]; |
| 33 |
#else |
| 34 |
typedef void* __libcpp_recursive_mutex_t[6]; |
| 35 |
#endif |
| 36 |
|
| 37 |
_LIBCPP_EXPORTED_FROM_ABI int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t* __m); |
| 38 |
|
| 39 |
_LIBCPP_EXPORTED_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int |
| 40 |
__libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t* __m); |
| 41 |
|
| 42 |
_LIBCPP_EXPORTED_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS bool |
| 43 |
__libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t* __m); |
| 44 |
|
| 45 |
_LIBCPP_EXPORTED_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int |
| 46 |
__libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t* __m); |
| 47 |
|
| 48 |
_LIBCPP_EXPORTED_FROM_ABI int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t* __m); |
| 49 |
|
| 50 |
_LIBCPP_EXPORTED_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_mutex_lock(__libcpp_mutex_t* __m); |
| 51 |
|
| 52 |
_LIBCPP_EXPORTED_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS bool __libcpp_mutex_trylock(__libcpp_mutex_t* __m); |
| 53 |
|
| 54 |
_LIBCPP_EXPORTED_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_mutex_unlock(__libcpp_mutex_t* __m); |
| 55 |
|
| 56 |
_LIBCPP_EXPORTED_FROM_ABI int __libcpp_mutex_destroy(__libcpp_mutex_t* __m); |
| 57 |
|
| 58 |
// |
| 59 |
// Condition variable |
| 60 |
// |
| 61 |
typedef void* __libcpp_condvar_t; |
| 62 |
#define _LIBCPP_CONDVAR_INITIALIZER 0 |
| 63 |
|
| 64 |
_LIBCPP_EXPORTED_FROM_ABI int __libcpp_condvar_signal(__libcpp_condvar_t* __cv); |
| 65 |
|
| 66 |
_LIBCPP_EXPORTED_FROM_ABI int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv); |
| 67 |
|
| 68 |
_LIBCPP_EXPORTED_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int |
| 69 |
__libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m); |
| 70 |
|
| 71 |
_LIBCPP_EXPORTED_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int |
| 72 |
__libcpp_condvar_timedwait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m, __libcpp_timespec_t* __ts); |
| 73 |
|
| 74 |
_LIBCPP_EXPORTED_FROM_ABI int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv); |
| 75 |
|
| 76 |
// |
| 77 |
// Execute once |
| 78 |
// |
| 79 |
typedef void* __libcpp_exec_once_flag; |
| 80 |
#define _LIBCPP_EXEC_ONCE_INITIALIZER 0 |
| 81 |
|
| 82 |
_LIBCPP_EXPORTED_FROM_ABI int __libcpp_execute_once(__libcpp_exec_once_flag* __flag, void (*__init_routine)()); |
| 83 |
|
| 84 |
// |
| 85 |
// Thread id |
| 86 |
// |
| 87 |
typedef long __libcpp_thread_id; |
| 88 |
|
| 89 |
_LIBCPP_EXPORTED_FROM_ABI bool __libcpp_thread_id_equal(__libcpp_thread_id __t1, __libcpp_thread_id __t2); |
| 90 |
|
| 91 |
_LIBCPP_EXPORTED_FROM_ABI bool __libcpp_thread_id_less(__libcpp_thread_id __t1, __libcpp_thread_id __t2); |
| 92 |
|
| 93 |
// |
| 94 |
// Thread |
| 95 |
// |
| 96 |
#define _LIBCPP_NULL_THREAD 0U |
| 97 |
typedef void* __libcpp_thread_t; |
| 98 |
|
| 99 |
_LIBCPP_EXPORTED_FROM_ABI bool __libcpp_thread_isnull(const __libcpp_thread_t* __t); |
| 100 |
|
| 101 |
_LIBCPP_EXPORTED_FROM_ABI int __libcpp_thread_create(__libcpp_thread_t* __t, void* (*__func)(void*), void* __arg); |
| 102 |
|
| 103 |
_LIBCPP_EXPORTED_FROM_ABI __libcpp_thread_id __libcpp_thread_get_current_id(); |
| 104 |
|
| 105 |
_LIBCPP_EXPORTED_FROM_ABI __libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t* __t); |
| 106 |
|
| 107 |
_LIBCPP_EXPORTED_FROM_ABI int __libcpp_thread_join(__libcpp_thread_t* __t); |
| 108 |
|
| 109 |
_LIBCPP_EXPORTED_FROM_ABI int __libcpp_thread_detach(__libcpp_thread_t* __t); |
| 110 |
|
| 111 |
_LIBCPP_EXPORTED_FROM_ABI void __libcpp_thread_yield(); |
| 112 |
|
| 113 |
_LIBCPP_EXPORTED_FROM_ABI void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns); |
| 114 |
|
| 115 |
// |
| 116 |
// Thread local storage |
| 117 |
// |
| 118 |
typedef long __libcpp_tls_key; |
| 119 |
|
| 120 |
#define _LIBCPP_TLS_DESTRUCTOR_CC __stdcall |
| 121 |
|
| 122 |
_LIBCPP_EXPORTED_FROM_ABI int |
| 123 |
__libcpp_tls_create(__libcpp_tls_key* __key, void(_LIBCPP_TLS_DESTRUCTOR_CC* __at_exit)(void*)); |
| 124 |
|
| 125 |
_LIBCPP_EXPORTED_FROM_ABI void* __libcpp_tls_get(__libcpp_tls_key __key); |
| 126 |
|
| 127 |
_LIBCPP_EXPORTED_FROM_ABI int __libcpp_tls_set(__libcpp_tls_key __key, void* __p); |
| 128 |
|
| 129 |
_LIBCPP_END_NAMESPACE_STD |
| 130 |
|
| 131 |
#endif // _LIBCPP___CXX03___THREAD_SUPPORT_WINDOWS_H |