aboutsummaryrefslogtreecommitdiff
path: root/lldb/packages/Python/lldbsuite/test/configuration.py
diff options
context:
space:
mode:
authorJoseph Huber <huberjn@outlook.com>2024-06-26 07:03:28 -0500
committerGitHub <noreply@github.com>2024-06-26 07:03:28 -0500
commit86860be2886283210083e5e3f20048e559cc059e (patch)
treef826560adbf77be294910d0a884645f2d371423a /lldb/packages/Python/lldbsuite/test/configuration.py
parentd6f906eadbf7a5c2eb484f62740bf3e6a650bc92 (diff)
downloadllvm-86860be2886283210083e5e3f20048e559cc059e.zip
llvm-86860be2886283210083e5e3f20048e559cc059e.tar.gz
llvm-86860be2886283210083e5e3f20048e559cc059e.tar.bz2
[libc] Make 'rand()' thread-safe using atomics instead of TLS (#96692)
Summary: Currently, we implement the `rand` function using thread-local storage. This is somewhat problematic because not every target supports TLS, and even more do not support non-zero initializers on TLS. The C standard states that the `rand()` function need not be thread, safe. However, many implementations provide thread-safety anyway. There's some confusing language in the 'rationale' section of https://pubs.opengroup.org/onlinepubs/9699919799/functions/rand.html, but given that `glibc` uses a lock, I think we should make this thread safe as well. it mentions that threaded behavior is desirable and can be done in the two ways: 1. A single per-process sequence of pseudo-random numbers that is shared by all threads that call rand() 2. A different sequence of pseudo-random numbers for each thread that calls rand() The current implementation is (2.) and this patch moves it to (1.). This is beneficial for the GPU case and more generic support. The downside is that it's slightly slower to do these atomic operations, the fast path will be two atomic reads and an atomic write.
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/configuration.py')
0 files changed, 0 insertions, 0 deletions