[libc-commits] [libc] [libc] Change LIBC_THREAD_LOCAL to be dependent on LIBC_THREAD_MODE (PR #151527)

William Huynh via libc-commits libc-commits at lists.llvm.org
Tue Aug 5 08:03:41 PDT 2025


https://github.com/saturn691 updated https://github.com/llvm/llvm-project/pull/151527

>From 44fc15556e0149811b8df44619c6c609543cc50c Mon Sep 17 00:00:00 2001
From: William Huynh <William.Huynh at arm.com>
Date: Tue, 5 Aug 2025 16:03:31 +0100
Subject: [PATCH] Try and get CI to pass

---
 libc/src/__support/macros/attributes.h | 11 ++++++++++-
 libc/src/__support/threads/mutex.h     |  9 ---------
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/libc/src/__support/macros/attributes.h b/libc/src/__support/macros/attributes.h
index c6474673de85a..08594a34840b0 100644
--- a/libc/src/__support/macros/attributes.h
+++ b/libc/src/__support/macros/attributes.h
@@ -28,7 +28,16 @@
 #define LIBC_INLINE_ASM __asm__ __volatile__
 #define LIBC_UNUSED __attribute__((unused))
 
-#ifdef LIBC_TARGET_ARCH_IS_GPU
+// Uses the platform specific specialization
+#define LIBC_THREAD_MODE_PLATFORM 0
+
+// Mutex guards nothing, used in single-threaded implementations
+#define LIBC_THREAD_MODE_SINGLE 1
+
+// Vendor provides implementation
+#define LIBC_THREAD_MODE_EXTERNAL 2
+
+#ifdef LIBC_THREAD_MODE == LIBC_THREAD_MODE_SINGLE
 #define LIBC_THREAD_LOCAL
 #else
 #define LIBC_THREAD_LOCAL thread_local
diff --git a/libc/src/__support/threads/mutex.h b/libc/src/__support/threads/mutex.h
index cbef0d00009b2..9f3489cf99836 100644
--- a/libc/src/__support/threads/mutex.h
+++ b/libc/src/__support/threads/mutex.h
@@ -12,15 +12,6 @@
 #include "src/__support/macros/attributes.h"
 #include "src/__support/macros/config.h"
 
-// Uses the platform specific specialization
-#define LIBC_THREAD_MODE_PLATFORM 0
-
-// Mutex guards nothing, used in single-threaded implementations
-#define LIBC_THREAD_MODE_SINGLE 1
-
-// Vendor provides implementation
-#define LIBC_THREAD_MODE_EXTERNAL 2
-
 #if !defined(LIBC_THREAD_MODE)
 #error LIBC_THREAD_MODE is undefined
 #endif // LIBC_THREAD_MODE



More information about the libc-commits mailing list