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

Schrodinger ZHU Yifan via libc-commits libc-commits at lists.llvm.org
Fri May 1 08:47:28 PDT 2026


SchrodingerZhu 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...

I was thinking of dispatching with `is_pointer/is_integral`. But maybe that will require too many changes inside libcxx. 

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


More information about the libc-commits mailing list