libc_errno.cpp
HDRS
libc_errno.h # Include this
- llvmlibc_errno.h # DEPRECATED: Will be removed soon
DEPENDS
libc.include.errno
)
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
// 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
// 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
+++ /dev/null
-//===-- 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 <errno.h>
-
-// 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
errno_setter_matcher
HDRS
ErrnoSetterMatcher.h
+ DEPENDS
+ libc.src.errno.errno
)
add_custom_target(check-libc)
#ifndef LLVM_LIBC_TEST_ERRNOSETTERMATCHER_H
#define LLVM_LIBC_TEST_ERRNOSETTERMATCHER_H
+#include "src/errno/libc_errno.h"
#include "test/UnitTest/Test.h"
-#include <errno.h>
#include <string.h>
namespace __llvm_libc {
bool match(T Got) {
ActualReturn = Got;
- ActualErrno = errno;
- errno = 0;
+ ActualErrno = libc_errno;
+ libc_errno = 0;
return Got == ExpectedReturn && ActualErrno == ExpectedErrno;
}
};