llvm-project
493ebf71 - [libc++] Add support for thread-id handling for llvm-libc. (#198595)

Commit
6 days ago
[libc++] Add support for thread-id handling for llvm-libc. (#198595) This change adds support for properly defining and obtaining `__libcpp_thread_id` when llvm-libc is used. It defines the integral thread-id (which satisfies necessary restrictions of having total order, being hashable and formattable) as `pthread_id_np_t` type and uses `pthread_getthreadid_np` and `pthread_getunique_np` functions to obtain it (added in https://github.com/llvm/llvm-project/pull/197027, following the discussions in https://github.com/llvm/llvm-project/pull/195139 and https://github.com/llvm/llvm-project/pull/195202). We also let `_LIBCPP_NULL_THREAD` macro use a more portable `PTHREAD_NULL` (defined in the latest POSIX) when this macro is available, so that it would work as expected for opaque `pthread_t` implementations, where default constructor might not necessarily zero-initialize all the members. This is the last remaining change to allow building libc++ against llvm-libc with threads enabled (test-suite results TBD).
Author
Parents
Loading