aboutsummaryrefslogtreecommitdiff
path: root/stdlib/random.c
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/random.c')
-rw-r--r--stdlib/random.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/stdlib/random.c b/stdlib/random.c
index 6da39d4..5d482a8 100644
--- a/stdlib/random.c
+++ b/stdlib/random.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995-2024 Free Software Foundation, Inc.
+/* Copyright (C) 1995-2025 Free Software Foundation, Inc.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -51,6 +51,7 @@
SUCH DAMAGE.*/
#include <libc-lock.h>
+#include <sys/single_threaded.h>
#include <limits.h>
#include <stddef.h>
#include <stdlib.h>
@@ -288,6 +289,12 @@ __random (void)
{
int32_t retval;
+ if (SINGLE_THREAD_P)
+ {
+ (void) __random_r (&unsafe_state, &retval);
+ return retval;
+ }
+
__libc_lock_lock (lock);
(void) __random_r (&unsafe_state, &retval);