[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / libc / src / errno / libc_errno.cpp
blobc8f0bffd0962e9b4ec7449b956ba09b0a82a26ed
1 //===-- Implementation of errno -------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "src/__support/macros/attributes.h"
10 #include "src/__support/macros/properties/architectures.h"
12 namespace LIBC_NAMESPACE {
14 #ifdef LIBC_TARGET_ARCH_IS_GPU
15 struct ErrnoConsumer {
16 void operator=(int) {}
18 #endif
20 extern "C" {
21 #ifdef LIBC_COPT_PUBLIC_PACKAGING
22 // TODO: Declare __llvmlibc_errno only under LIBC_COPT_PUBLIC_PACKAGING and
23 // __llvmlibc_internal_errno otherwise.
24 // In overlay mode, this will be an unused thread local variable as libc_errno
25 // will resolve to errno from the system libc's errno.h. In full build mode
26 // however, libc_errno will resolve to this thread local variable via the errno
27 // macro defined in LLVM libc's public errno.h header file.
28 // TODO: Use a macro to distinguish full build and overlay build which can be
29 // used to exclude __llvmlibc_errno under overlay build.
30 #ifdef LIBC_TARGET_ARCH_IS_GPU
31 ErrnoConsumer __llvmlibc_errno;
32 #else
33 LIBC_THREAD_LOCAL int __llvmlibc_errno;
34 #endif // LIBC_TARGET_ARCH_IS_GPU
35 #else
36 LIBC_THREAD_LOCAL int __llvmlibc_internal_errno;
37 #endif
38 } // extern "C"
40 } // namespace LIBC_NAMESPACE