diff --git a/libc/src/errno/CMakeLists.txt b/libc/src/errno/CMakeLists.txt index 61b56047ce0a4..2fa1381a70cc6 100644 --- a/libc/src/errno/CMakeLists.txt +++ b/libc/src/errno/CMakeLists.txt @@ -4,7 +4,6 @@ add_entrypoint_object( libc_errno.cpp HDRS libc_errno.h # Include this - llvmlibc_errno.h # DEPRECATED: Will be removed soon DEPENDS libc.include.errno ) diff --git a/libc/src/errno/libc_errno.cpp b/libc/src/errno/libc_errno.cpp index 98a76c2cbcf49..b8c276cb853fb 100644 --- a/libc/src/errno/libc_errno.cpp +++ b/libc/src/errno/libc_errno.cpp @@ -9,9 +9,9 @@ namespace __llvm_libc { 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 @@ -19,7 +19,9 @@ extern "C" { // TODO: Use a macro to distinguish full build and overlay build which can be // used to exclude __llvmlibc_errno under overlay build. thread_local int __llvmlibc_errno; +#else thread_local int __llvmlibc_internal_errno; +#endif } // extern "C" } // namespace __llvm_libc diff --git a/libc/src/errno/libc_errno.h b/libc/src/errno/libc_errno.h index 586d88feba906..28f8d0d13e736 100644 --- a/libc/src/errno/libc_errno.h +++ b/libc/src/errno/libc_errno.h @@ -29,7 +29,7 @@ extern thread_local int __llvmlibc_internal_errno; // libc_errno, this header file will be "shipped" via an add_entrypoint_object // target. At which point libc_errno, should point to __llvmlibc_internal_errno // if LIBC_COPT_PUBLIC_PACKAGING is not defined. -#define libc_errno errno +#define libc_errno __llvm_libc::__llvmlibc_internal_errno } // namespace __llvm_libc #endif diff --git a/libc/src/errno/llvmlibc_errno.h b/libc/src/errno/llvmlibc_errno.h deleted file mode 100644 index eb1f66c2e4080..0000000000000 --- a/libc/src/errno/llvmlibc_errno.h +++ /dev/null @@ -1,21 +0,0 @@ -//===-- Implementation header for errno -------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_LIBC_SRC_ERRNO_LLVMLIBC_ERRNO_H -#define LLVM_LIBC_SRC_ERRNO_LLVMLIBC_ERRNO_H - -#include - -// DEPRECATED: Use libc_errno from libc_errno.h instead. This macro is only -// present to facilitate gradual transition (as in, in multiple simple patches) -// to libc_errno. -// TODO: After all of libc/src and libc/test is switched over to use libc_errno, -// remove this macro and header file. -#define llvmlibc_errno errno - -#endif // LLVM_LIBC_SRC_ERRNO_LLVMLIBC_ERRNO_H diff --git a/libc/test/CMakeLists.txt b/libc/test/CMakeLists.txt index fc9df9c670cb7..d325aac68f523 100644 --- a/libc/test/CMakeLists.txt +++ b/libc/test/CMakeLists.txt @@ -9,6 +9,8 @@ add_header_library( errno_setter_matcher HDRS ErrnoSetterMatcher.h + DEPENDS + libc.src.errno.errno ) add_custom_target(check-libc) diff --git a/libc/test/ErrnoSetterMatcher.h b/libc/test/ErrnoSetterMatcher.h index d2dab988dc0de..36ba9323b12d1 100644 --- a/libc/test/ErrnoSetterMatcher.h +++ b/libc/test/ErrnoSetterMatcher.h @@ -9,9 +9,9 @@ #ifndef LLVM_LIBC_TEST_ERRNOSETTERMATCHER_H #define LLVM_LIBC_TEST_ERRNOSETTERMATCHER_H +#include "src/errno/libc_errno.h" #include "test/UnitTest/Test.h" -#include #include namespace __llvm_libc { @@ -42,8 +42,8 @@ template class ErrnoSetterMatcher : public Matcher { bool match(T Got) { ActualReturn = Got; - ActualErrno = errno; - errno = 0; + ActualErrno = libc_errno; + libc_errno = 0; return Got == ExpectedReturn && ActualErrno == ExpectedErrno; } };