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

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


Author: Joseph Huber
Date: 2024-06-26T11:24:48-05:00
New Revision: d0527ab69765740c1747695bbfe72a3db1781b16

URL: https://github.com/llvm/llvm-project/commit/d0527ab69765740c1747695bbfe72a3db1781b16
DIFF: https://github.com/llvm/llvm-project/commit/d0527ab69765740c1747695bbfe72a3db1781b16.diff

LOG: [libc] Fix Fuscia builder failing on atomic warnings (#96791)

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.

Added: 
    

Modified: 
    libc/src/stdlib/rand.cpp
    libc/src/stdlib/srand.cpp

Removed: 
    


################################################################################
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


        


More information about the libc-commits mailing list