[libc-commits] [libc] [libc] Use `LIBC_COPT_PUBLIC_PACKAGING` for hermetic and integration tests. (PR #79319)

Guillaume Chatelet via libc-commits libc-commits at lists.llvm.org
Fri Jan 26 00:56:01 PST 2024


================
@@ -11,30 +11,44 @@
 
 namespace LIBC_NAMESPACE {
 
-#ifdef LIBC_TARGET_ARCH_IS_GPU
-struct ErrnoConsumer {
-  void operator=(int) {}
+struct Errno {
+  void operator=(int);
+  operator int();
 };
-#endif
 
-extern "C" {
-#ifdef LIBC_COPT_PUBLIC_PACKAGING
-// TODO: Declare __llvmlibc_errno only under LIBC_COPT_PUBLIC_PACKAGING and
-// __llvmlibc_internal_errno otherwise.
-// In overlay mode, this will be an unused thread local variable as libc_errno
-// will resolve to errno from the system libc's errno.h. In full build mode
-// however, libc_errno will resolve to this thread local variable via the errno
-// macro defined in LLVM libc's public errno.h header file.
-// TODO: Use a macro to distinguish full build and overlay build which can be
-//       used to exclude __llvmlibc_errno under overlay build.
+} // namespace LIBC_NAMESPACE
+
 #ifdef LIBC_TARGET_ARCH_IS_GPU
-ErrnoConsumer __llvmlibc_errno;
-#else
+// If we are targeting the GPU we currently don't support 'errno'. We simply
+// consume it.
+void LIBC_NAMESPACE::Errno::operator=(int) {}
+LIBC_NAMESPACE::Errno::operator int() { return 0; }
+
+#elif !defined(LIBC_COPT_PUBLIC_PACKAGING)
+// This mode is for unit testing.  We just use another internal errno.
----------------
gchatelet wrote:

"We just use ~another~ our internal errno."

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


More information about the libc-commits mailing list