[libc-commits] [libc] [libc] Change rand implementation so all tests pass in both 32- and 64-bit systems (PR #98692)

Joseph Huber via libc-commits libc-commits at lists.llvm.org
Fri Jul 12 17:58:46 PDT 2024


================
@@ -13,20 +13,33 @@
 
 namespace LIBC_NAMESPACE {
 
-// An implementation of the xorshift64star pseudo random number generator. This
+// An implementation of the xorshift* pseudo random number generator. This
 // is a good general purpose generator for most non-cryptographics applications.
-LLVM_LIBC_FUNCTION(int, rand, (void)) {
+static inline unsigned long xorshiftstar(unsigned long a, unsigned long b,
----------------
jhuber6 wrote:

It's more code, but I think it's much clearer if we just call this `xorshift64*` and `xorshift32` and have them be separate functions.

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


More information about the libc-commits mailing list