[libc-commits] [libc] [libc] Make 'rand()' thread-safe using atomics instead of TLS (PR #96692)

Joseph Huber via libc-commits libc-commits at lists.llvm.org
Wed Jun 26 08:48:32 PDT 2024


jhuber6 wrote:

> I think at least for clang, is_lock_free can also be detected using macros directly

Can you give me an example of that? I tried as in https://godbolt.org/z/v9chvGxe9 but it doesn't seem to work within a macro.

And even then, should we really make this MT-unsafe if the atomics aren't fast? It should still work as long as the platform has *some* support. The alternatives are to 1. leave it slow and suppress the diagnostics, or 2. make baremetal submit a new config `COPT_MT_UNSAFE` or similar.

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


More information about the libc-commits mailing list