11 #ifndef __SYS_UniqueThreadIndex__
12 #define __SYS_UniqueThreadIndex__
19 #if defined(LINUX) || defined(MBSD)
29 enum { FIRST_INDEX = 1 };
34 static inline int get();
38 static inline int next();
43 static int myTlsIndex;
44 #elif defined(LINUX) || defined(MBSD)
45 static pthread_key_t myTlsKey;
72 __declspec(dllimport)
void *__stdcall TlsGetValue(
unsigned long);
73 __declspec(dllimport)
int __stdcall TlsSetValue(
unsigned long,
void *);
81 tid =
reinterpret_cast<ptrdiff_t
>(::TlsGetValue(myTlsIndex));
82 if (tid < FIRST_INDEX)
84 tid = myNextIndex.exchangeAdd(1) + FIRST_INDEX;
85 ::TlsSetValue(myTlsIndex, reinterpret_cast<void *>(tid));
88 return static_cast<int>(tid);
93 #elif defined(LINUX) || defined(MBSD)
113 tid =
reinterpret_cast<ptrdiff_t
>(::pthread_getspecific(myTlsKey));
117 ::pthread_setspecific(myTlsKey, reinterpret_cast<void *>(tid));
120 return static_cast<int>(tid);
126 #endif // __SYS_UniqueThreadIndex__
__attribute__((visibility("default")))
T load(SYS_MemoryOrder order=SYS_MEMORY_ORDER_SEQ_CST) const
auto get(const UT_ARTIterator< T > &it) -> decltype(it.key())