[libc-commits] [libc] [libc] Add an extension macro to get numerical thread id (PR #195202)

Alexey Samsonov via libc-commits libc-commits at lists.llvm.org
Thu Apr 30 20:47:12 PDT 2026


vonosmas wrote:

> This approach sounds good to me.
> 
> However, I was wondering if we can just promise that thread id is semiregular object with unique object representation such that libc++ can simply use bytewise comparison instead of extending libc?

Well, libc++ needs to implement strong total ordering for [std::thread::id](https://en.cppreference.com/cpp/thread/thread/id) , and there's fair amount of assumptions in their code to assume that implementation-specific `__libcpp_thread_id` behaves like an integer (see [implementation](https://github.com/llvm/llvm-project/blob/70b2f06ab493e29bb5dcc627bd016714dd21405f/libcxx/include/__thread/id.h#L41)). Changing all that to bytewise lexicographical comparison (which I think is what you propose?) on all platforms would be painful...

https://github.com/llvm/llvm-project/pull/195202


More information about the libc-commits mailing list