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

Mikhail R. Gadelha via libc-commits libc-commits at lists.llvm.org
Mon Jul 15 08:56:12 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,
----------------
mikhailramalho wrote:

This request introduces a warning when the other function is not selected:
```
/home/mgadelha/tools/llvm-project/libc/src/stdlib/rand.cpp:19:12: warning: function 'xorshift64star' is not needed and will not be emitted [-Wunneeded-internal-declaration]
   19 | static int xorshift64star() {
      |            ^~~~~~~~~~~~~~
1 warning generated.


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


More information about the libc-commits mailing list