[libc-commits] [libc] [libc] make rand() wait-free (PR #99406)

via libc-commits libc-commits at lists.llvm.org
Wed Jul 17 16:51:54 PDT 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 83251a22f623df8d27b6184d19b24c18d314f2bd 8a1379beffa8cb552da01c28e27c928d0718d2da --extensions cpp -- libc/src/stdlib/rand.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/libc/src/stdlib/rand.cpp b/libc/src/stdlib/rand.cpp
index 48b63ca7a5..c889d477c1 100644
--- a/libc/src/stdlib/rand.cpp
+++ b/libc/src/stdlib/rand.cpp
@@ -26,9 +26,9 @@ LLVM_LIBC_FUNCTION(int, rand, (void)) {
   x = x * x + y;
   x = (x >> 32) | (x << 32);
   x = x * x + z;
-  x = (x >> 32) | (x << 32); 
+  x = (x >> 32) | (x << 32);
   x = x * x + y;
-  x = (x >> 32) | (x << 32); 
+  x = (x >> 32) | (x << 32);
   uint64_t result = (x * x + z) >> 32;
   // project into range
   return static_cast<int>(((result) % RAND_MAX + RAND_MAX) % RAND_MAX);

``````````

</details>


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


More information about the libc-commits mailing list