Skip to content

Commit 047964a

Browse files
committed
[libc] Use global errno for baremetal
We want to avoid thread local variables on baremetal since the TLS support may not be universally available in those environments.
1 parent 93869df commit 047964a

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

libc/include/errno.h.def

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
#include "llvm-libc-macros/generic-error-number-macros.h"
2626
#endif
2727

28-
#if defined(__AMDGPU__) || defined(__NVPTX__)
28+
#if defined(__AMDGPU__) || defined(__NVPTX__) || \
29+
(defined(__ELF__) && !defined(__linux__) && defined(__Fuchsia__))
2930
extern int __llvmlibc_errno; // Not thread_local!
3031
#else
3132
#ifdef __cplusplus

libc/src/errno/libc_errno.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
#include "libc_errno.h"
1010
#include "src/__support/CPP/atomic.h"
1111

12-
#ifdef LIBC_TARGET_ARCH_IS_GPU
12+
#if defined(LIBC_TARGET_ARCH_IS_GPU) || \
13+
(defined(__ELF__) && !defined(__linux__) && defined(__Fuchsia__))
1314
// LIBC_THREAD_LOCAL on GPU currently does nothing. So essentially this is just
1415
// a global errno for gpu to use for now.
1516
extern "C" {

0 commit comments

Comments
 (0)