[libc-commits] [libc] [libc] Fix Fuscia builder failing on atomic warnings (PR #96791)

via libc-commits libc-commits at lists.llvm.org
Wed Jun 26 09:18:59 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Joseph Huber (jhuber6)

<details>
<summary>Changes</summary>

Summary:
This function uses atomics now, which emit warnings on some platforms
that don't support full lock-free atomics. These aren't specifically
wrong, and in the future we could investigate a libc configuration
specialized for single-threaded microprocessors, but for now we should
get the bot running again.


---
Full diff: https://github.com/llvm/llvm-project/pull/96791.diff


2 Files Affected:

- (modified) libc/src/stdlib/rand.cpp (+6) 
- (modified) libc/src/stdlib/srand.cpp (+6) 


``````````diff
diff --git a/libc/src/stdlib/rand.cpp b/libc/src/stdlib/rand.cpp
index ff3875c2f6959..8f2ae90336d51 100644
--- a/libc/src/stdlib/rand.cpp
+++ b/libc/src/stdlib/rand.cpp
@@ -13,6 +13,10 @@
 
 namespace LIBC_NAMESPACE {
 
+// Silence warnings on targets with slow atomics.
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Watomic-alignment"
+
 // An implementation of the xorshift64star pseudo random number generator. This
 // is a good general purpose generator for most non-cryptographics applications.
 LLVM_LIBC_FUNCTION(int, rand, (void)) {
@@ -29,4 +33,6 @@ LLVM_LIBC_FUNCTION(int, rand, (void)) {
   }
 }
 
+#pragma GCC diagnostic pop
+
 } // namespace LIBC_NAMESPACE
diff --git a/libc/src/stdlib/srand.cpp b/libc/src/stdlib/srand.cpp
index 21166c7a6754e..681aad8fac4e8 100644
--- a/libc/src/stdlib/srand.cpp
+++ b/libc/src/stdlib/srand.cpp
@@ -12,8 +12,14 @@
 
 namespace LIBC_NAMESPACE {
 
+// Silence warnings on targets with slow atomics.
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Watomic-alignment"
+
 LLVM_LIBC_FUNCTION(void, srand, (unsigned int seed)) {
   rand_next.store(seed, cpp::MemoryOrder::RELAXED);
 }
 
+#pragma GCC diagnostic pop
+
 } // namespace LIBC_NAMESPACE

``````````

</details>


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


More information about the libc-commits mailing list