[libc-commits] [libc] [libc] Support configurable errno modes (PR #98287)

Michael Jones via libc-commits libc-commits at lists.llvm.org
Fri Jul 12 10:01:11 PDT 2024


================
@@ -7,46 +7,81 @@
 //===----------------------------------------------------------------------===//
 
 #include "libc_errno.h"
-#include "src/__support/CPP/atomic.h"
+#include "src/errno/errno.h"
 
-#ifdef LIBC_TARGET_ARCH_IS_GPU
-// LIBC_THREAD_LOCAL on GPU currently does nothing. So essentially this is just
-// a global errno for gpu to use for now.
-extern "C" {
-LIBC_THREAD_LOCAL LIBC_NAMESPACE::cpp::Atomic<int> __llvmlibc_errno;
-}
+#define LIBC_ERRNO_MODE_UNDEFINED 1
+#define LIBC_ERRNO_MODE_THREAD_LOCAL 2
+#define LIBC_ERRNO_MODE_SHARED 3
+#define LIBC_ERRNO_MODE_EXTERNAL 4
+#define LIBC_ERRNO_MODE_SYSTEM 5
+
+#ifndef LIBC_ERRNO_MODE
+#if defined(LIBC_FULL_BUILD) || !defined(LIBC_COPT_PUBLIC_PACKAGING)
+#define LIBC_ERRNO_MODE LIBC_ERRNO_MODE_THREAD_LOCAL
+#else
+#define LIBC_ERRNO_MODE LIBC_ERRNO_MODE_SYSTEM
+#endif
+#endif // LIBC_ERRNO_MODE
+
+#if LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_UNDEFINED &&                            \
----------------
michaelrj-google wrote:

ah, I misread it then. Nevermind

https://github.com/llvm/llvm-project/pull/98287


More information about the libc-commits mailing list