Skip to content

Commit d0527ab

Browse files
authored
[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.
1 parent 1918369 commit d0527ab

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

libc/src/stdlib/rand.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313

1414
namespace LIBC_NAMESPACE {
1515

16+
// Silence warnings on targets with slow atomics.
17+
#pragma GCC diagnostic push
18+
#pragma GCC diagnostic ignored "-Watomic-alignment"
19+
1620
// An implementation of the xorshift64star pseudo random number generator. This
1721
// is a good general purpose generator for most non-cryptographics applications.
1822
LLVM_LIBC_FUNCTION(int, rand, (void)) {
@@ -29,4 +33,6 @@ LLVM_LIBC_FUNCTION(int, rand, (void)) {
2933
}
3034
}
3135

36+
#pragma GCC diagnostic pop
37+
3238
} // namespace LIBC_NAMESPACE

libc/src/stdlib/srand.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,14 @@
1212

1313
namespace LIBC_NAMESPACE {
1414

15+
// Silence warnings on targets with slow atomics.
16+
#pragma GCC diagnostic push
17+
#pragma GCC diagnostic ignored "-Watomic-alignment"
18+
1519
LLVM_LIBC_FUNCTION(void, srand, (unsigned int seed)) {
1620
rand_next.store(seed, cpp::MemoryOrder::RELAXED);
1721
}
1822

23+
#pragma GCC diagnostic pop
24+
1925
} // namespace LIBC_NAMESPACE

0 commit comments

Comments
 (0)