[llvm] [libc][bazel] Add Bazel rules for rand/srand functions. (PR #159617)

Joseph Huber via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 18 14:04:27 PDT 2025


jhuber6 wrote:

>
> Do you think we should just move the current `rand()` implementation to somewhere like `libc/src/__support/random.h` , so that we can use it both in `rand()` implementation and in unit tests that need randomness?

That's what I would assume, we already have a bunch of these floating around so we could consolidate. I have used both 32-bit and 64-bit versions of xorshift for most of my PRNG needs. You could extract those to a common header and replace the uses there. Off the top of my head, the GPU benchmarks, allocator, and allocator test. Potentially you could replace the implementation of `rand` and just make it pass in the global state as a reference.

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


More information about the llvm-commits mailing list