| author | |
| committer | |
| log | 8bb6bf681813893c74d0d67c8862a2fc25ee3124 |
| tree | cccc0ad14351eddaba0519ff38aaec4bc803b187 |
| parent | 37a06f4dcf27c6bb5759656d6abc0d8b290f093f |
| signature | Commit is signed but in an unrecognized format. |
upstream commit 67a4a12d61bfb10b2410b53c5a43ef9b4a03de7d3 files changed, 89 insertions(+), 72 deletions(-)
lib/libcxx/include/__threading_support+81| ... | ... | @@ -12,6 +12,7 @@ |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | 14 | #include <chrono> |
| 15 | #include <iosfwd> | |
| 15 | 16 | #include <errno.h> |
| 16 | 17 | |
| 17 | 18 | #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER |
| ... | ... | @@ -394,6 +395,86 @@ int __libcpp_tls_set(__libcpp_tls_key __key, void *__p) |
| 394 | 395 | |
| 395 | 396 | #endif // !_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL || _LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL |
| 396 | 397 | |
| 398 | class _LIBCPP_TYPE_VIS thread; | |
| 399 | class _LIBCPP_TYPE_VIS __thread_id; | |
| 400 | ||
| 401 | namespace this_thread | |
| 402 | { | |
| 403 | ||
| 404 | _LIBCPP_INLINE_VISIBILITY __thread_id get_id() _NOEXCEPT; | |
| 405 | ||
| 406 | } // this_thread | |
| 407 | ||
| 408 | template<> struct hash<__thread_id>; | |
| 409 | ||
| 410 | class _LIBCPP_TEMPLATE_VIS __thread_id | |
| 411 | { | |
| 412 | // FIXME: pthread_t is a pointer on Darwin but a long on Linux. | |
| 413 | // NULL is the no-thread value on Darwin. Someone needs to check | |
| 414 | // on other platforms. We assume 0 works everywhere for now. | |
| 415 | __libcpp_thread_id __id_; | |
| 416 | ||
| 417 | public: | |
| 418 | _LIBCPP_INLINE_VISIBILITY | |
| 419 | __thread_id() _NOEXCEPT : __id_(0) {} | |
| 420 | ||
| 421 | friend _LIBCPP_INLINE_VISIBILITY | |
| 422 | bool operator==(__thread_id __x, __thread_id __y) _NOEXCEPT | |
| 423 | { // don't pass id==0 to underlying routines | |
| 424 | if (__x.__id_ == 0) return __y.__id_ == 0; | |
| 425 | if (__y.__id_ == 0) return false; | |
| 426 | return __libcpp_thread_id_equal(__x.__id_, __y.__id_); | |
| 427 | } | |
| 428 | friend _LIBCPP_INLINE_VISIBILITY | |
| 429 | bool operator!=(__thread_id __x, __thread_id __y) _NOEXCEPT | |
| 430 | {return !(__x == __y);} | |
| 431 | friend _LIBCPP_INLINE_VISIBILITY | |
| 432 | bool operator< (__thread_id __x, __thread_id __y) _NOEXCEPT | |
| 433 | { // id==0 is always less than any other thread_id | |
| 434 | if (__x.__id_ == 0) return __y.__id_ != 0; | |
| 435 | if (__y.__id_ == 0) return false; | |
| 436 | return __libcpp_thread_id_less(__x.__id_, __y.__id_); | |
| 437 | } | |
| 438 | friend _LIBCPP_INLINE_VISIBILITY | |
| 439 | bool operator<=(__thread_id __x, __thread_id __y) _NOEXCEPT | |
| 440 | {return !(__y < __x);} | |
| 441 | friend _LIBCPP_INLINE_VISIBILITY | |
| 442 | bool operator> (__thread_id __x, __thread_id __y) _NOEXCEPT | |
| 443 | {return __y < __x ;} | |
| 444 | friend _LIBCPP_INLINE_VISIBILITY | |
| 445 | bool operator>=(__thread_id __x, __thread_id __y) _NOEXCEPT | |
| 446 | {return !(__x < __y);} | |
| 447 | ||
| 448 | _LIBCPP_INLINE_VISIBILITY | |
| 449 | void __reset() { __id_ = 0; } | |
| 450 | ||
| 451 | template<class _CharT, class _Traits> | |
| 452 | friend | |
| 453 | _LIBCPP_INLINE_VISIBILITY | |
| 454 | basic_ostream<_CharT, _Traits>& | |
| 455 | operator<<(basic_ostream<_CharT, _Traits>& __os, __thread_id __id); | |
| 456 | ||
| 457 | private: | |
| 458 | _LIBCPP_INLINE_VISIBILITY | |
| 459 | __thread_id(__libcpp_thread_id __id) : __id_(__id) {} | |
| 460 | ||
| 461 | friend __thread_id this_thread::get_id() _NOEXCEPT; | |
| 462 | friend class _LIBCPP_TYPE_VIS thread; | |
| 463 | friend struct _LIBCPP_TEMPLATE_VIS hash<__thread_id>; | |
| 464 | }; | |
| 465 | ||
| 466 | namespace this_thread | |
| 467 | { | |
| 468 | ||
| 469 | inline _LIBCPP_INLINE_VISIBILITY | |
| 470 | __thread_id | |
| 471 | get_id() _NOEXCEPT | |
| 472 | { | |
| 473 | return __libcpp_thread_get_current_id(); | |
| 474 | } | |
| 475 | ||
| 476 | } // this_thread | |
| 477 | ||
| 397 | 478 | _LIBCPP_END_NAMESPACE_STD |
| 398 | 479 | |
| 399 | 480 | _LIBCPP_POP_MACROS |
lib/libcxx/include/mutex+3-3| ... | ... | @@ -280,7 +280,7 @@ class _LIBCPP_TYPE_VIS recursive_timed_mutex |
| 280 | 280 | mutex __m_; |
| 281 | 281 | condition_variable __cv_; |
| 282 | 282 | size_t __count_; |
| 283 | __libcpp_thread_id __id_; | |
| 283 | __thread_id __id_; | |
| 284 | 284 | public: |
| 285 | 285 | recursive_timed_mutex(); |
| 286 | 286 | ~recursive_timed_mutex(); |
| ... | ... | @@ -307,9 +307,9 @@ bool |
| 307 | 307 | recursive_timed_mutex::try_lock_until(const chrono::time_point<_Clock, _Duration>& __t) |
| 308 | 308 | { |
| 309 | 309 | using namespace chrono; |
| 310 | __libcpp_thread_id __id = __libcpp_thread_get_current_id(); | |
| 310 | __thread_id __id = this_thread::get_id(); | |
| 311 | 311 | unique_lock<mutex> lk(__m_); |
| 312 | if (__libcpp_thread_id_equal(__id, __id_)) | |
| 312 | if (__id == __id_) | |
| 313 | 313 | { |
| 314 | 314 | if (__count_ == numeric_limits<size_t>::max()) |
| 315 | 315 | return false; |
lib/libcxx/include/thread+5-69| ... | ... | @@ -200,64 +200,6 @@ __thread_specific_ptr<_Tp>::set_pointer(pointer __p) |
| 200 | 200 | __libcpp_tls_set(__key_, __p); |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | class _LIBCPP_TYPE_VIS thread; | |
| 204 | class _LIBCPP_TYPE_VIS __thread_id; | |
| 205 | ||
| 206 | namespace this_thread | |
| 207 | { | |
| 208 | ||
| 209 | _LIBCPP_INLINE_VISIBILITY __thread_id get_id() _NOEXCEPT; | |
| 210 | ||
| 211 | } // this_thread | |
| 212 | ||
| 213 | template<> struct hash<__thread_id>; | |
| 214 | ||
| 215 | class _LIBCPP_TEMPLATE_VIS __thread_id | |
| 216 | { | |
| 217 | // FIXME: pthread_t is a pointer on Darwin but a long on Linux. | |
| 218 | // NULL is the no-thread value on Darwin. Someone needs to check | |
| 219 | // on other platforms. We assume 0 works everywhere for now. | |
| 220 | __libcpp_thread_id __id_; | |
| 221 | ||
| 222 | public: | |
| 223 | _LIBCPP_INLINE_VISIBILITY | |
| 224 | __thread_id() _NOEXCEPT : __id_(0) {} | |
| 225 | ||
| 226 | friend _LIBCPP_INLINE_VISIBILITY | |
| 227 | bool operator==(__thread_id __x, __thread_id __y) _NOEXCEPT | |
| 228 | {return __libcpp_thread_id_equal(__x.__id_, __y.__id_);} | |
| 229 | friend _LIBCPP_INLINE_VISIBILITY | |
| 230 | bool operator!=(__thread_id __x, __thread_id __y) _NOEXCEPT | |
| 231 | {return !(__x == __y);} | |
| 232 | friend _LIBCPP_INLINE_VISIBILITY | |
| 233 | bool operator< (__thread_id __x, __thread_id __y) _NOEXCEPT | |
| 234 | {return __libcpp_thread_id_less(__x.__id_, __y.__id_);} | |
| 235 | friend _LIBCPP_INLINE_VISIBILITY | |
| 236 | bool operator<=(__thread_id __x, __thread_id __y) _NOEXCEPT | |
| 237 | {return !(__y < __x);} | |
| 238 | friend _LIBCPP_INLINE_VISIBILITY | |
| 239 | bool operator> (__thread_id __x, __thread_id __y) _NOEXCEPT | |
| 240 | {return __y < __x ;} | |
| 241 | friend _LIBCPP_INLINE_VISIBILITY | |
| 242 | bool operator>=(__thread_id __x, __thread_id __y) _NOEXCEPT | |
| 243 | {return !(__x < __y);} | |
| 244 | ||
| 245 | template<class _CharT, class _Traits> | |
| 246 | friend | |
| 247 | _LIBCPP_INLINE_VISIBILITY | |
| 248 | basic_ostream<_CharT, _Traits>& | |
| 249 | operator<<(basic_ostream<_CharT, _Traits>& __os, __thread_id __id) | |
| 250 | {return __os << __id.__id_;} | |
| 251 | ||
| 252 | private: | |
| 253 | _LIBCPP_INLINE_VISIBILITY | |
| 254 | __thread_id(__libcpp_thread_id __id) : __id_(__id) {} | |
| 255 | ||
| 256 | friend __thread_id this_thread::get_id() _NOEXCEPT; | |
| 257 | friend class _LIBCPP_TYPE_VIS thread; | |
| 258 | friend struct _LIBCPP_TEMPLATE_VIS hash<__thread_id>; | |
| 259 | }; | |
| 260 | ||
| 261 | 203 | template<> |
| 262 | 204 | struct _LIBCPP_TEMPLATE_VIS hash<__thread_id> |
| 263 | 205 | : public unary_function<__thread_id, size_t> |
| ... | ... | @@ -269,17 +211,11 @@ struct _LIBCPP_TEMPLATE_VIS hash<__thread_id> |
| 269 | 211 | } |
| 270 | 212 | }; |
| 271 | 213 | |
| 272 | namespace this_thread | |
| 273 | { | |
| 274 | ||
| 275 | inline _LIBCPP_INLINE_VISIBILITY | |
| 276 | __thread_id | |
| 277 | get_id() _NOEXCEPT | |
| 278 | { | |
| 279 | return __libcpp_thread_get_current_id(); | |
| 280 | } | |
| 281 | ||
| 282 | } // this_thread | |
| 214 | template<class _CharT, class _Traits> | |
| 215 | _LIBCPP_INLINE_VISIBILITY | |
| 216 | basic_ostream<_CharT, _Traits>& | |
| 217 | operator<<(basic_ostream<_CharT, _Traits>& __os, __thread_id __id) | |
| 218 | {return __os << __id.__id_;} | |
| 283 | 219 | |
| 284 | 220 | class _LIBCPP_TYPE_VIS thread |
| 285 | 221 | { |