Skip to content

Commit 0aef51f

Browse files
committed
[libc][stdlib] Remove LIBC_THREAD_LOCAL from rand_next
srand and rand do not need to be threadsafe, so it should be permissible to remove thise from rand_next whose only users are srand and rand. This is helpful for the baremetal runtimes where we still need to setup the TLS machinery.
1 parent 17af54b commit 0aef51f

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

libc/src/stdlib/rand_util.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ ThreadLocal<unsigned long> rand_next;
1818
#else
1919
// C standard 7.10p2: If 'rand' is called before 'srand' it is to proceed as if
2020
// the 'srand' function was called with a value of '1'.
21-
LIBC_THREAD_LOCAL unsigned long rand_next = 1;
21+
unsigned long rand_next = 1;
2222
#endif
2323

2424
} // namespace LIBC_NAMESPACE

libc/src/stdlib/rand_util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ template <typename T> class ThreadLocal {
3434

3535
extern ThreadLocal<unsigned long> rand_next;
3636
#else
37-
extern LIBC_THREAD_LOCAL unsigned long rand_next;
37+
extern unsigned long rand_next;
3838
#endif
3939

4040
} // namespace LIBC_NAMESPACE

0 commit comments

Comments
 (0)