[libc-commits] [libc] [libc] List `rand` and `srand` as supported on the GPU (PR #96757)

Joseph Huber via libc-commits libc-commits at lists.llvm.org
Wed Jun 26 05:06:29 PDT 2024


https://github.com/jhuber6 created https://github.com/llvm/llvm-project/pull/96757

Summary:
I initially didn't report these as supported because they didn't provide
expected behavior and were very wasteful. The recent patch moved them to
a lock-free atomic implementation so they can now actually be used.


>From 406297838912b834acabd6e91c73aa7eb9ff9902 Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Wed, 26 Jun 2024 07:04:30 -0500
Subject: [PATCH] [libc] List `rand` and `srand` as supported on the GPU

Summary:
I initially didn't report these as supported because they didn't provide
expected behavior and were very wasteful. The recent patch moved them to
a lock-free atomic implementation so they can now actually be used.
---
 libc/docs/gpu/support.rst     | 2 ++
 libc/src/stdlib/rand_util.cpp | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/libc/docs/gpu/support.rst b/libc/docs/gpu/support.rst
index 31bbdc41090be..1044b005de0ee 100644
--- a/libc/docs/gpu/support.rst
+++ b/libc/docs/gpu/support.rst
@@ -190,6 +190,8 @@ strtold        |check|
 strtoll        |check|
 strtoul        |check|
 strtoull       |check|
+srand          |check|
+rand           |check|
 =============  =========  ============
 
 inttypes.h
diff --git a/libc/src/stdlib/rand_util.cpp b/libc/src/stdlib/rand_util.cpp
index 81ee358935716..ff3478db70003 100644
--- a/libc/src/stdlib/rand_util.cpp
+++ b/libc/src/stdlib/rand_util.cpp
@@ -12,7 +12,7 @@
 
 namespace LIBC_NAMESPACE {
 
-//  C standard 7.10p2: If 'rand' is called before 'srand' it is to
+// C standard 7.10p2: If 'rand' is called before 'srand' it is to
 // proceed as if the 'srand' function was called with a value of '1'.
 cpp::Atomic<unsigned long> rand_next = 1;
 



More information about the libc-commits mailing list