1 //===-- Implementation of errno -------------------------------------------===//
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
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) {}
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
;
33 LIBC_THREAD_LOCAL
int __llvmlibc_errno
;
34 #endif // LIBC_TARGET_ARCH_IS_GPU
36 LIBC_THREAD_LOCAL
int __llvmlibc_internal_errno
;
40 } // namespace LIBC_NAMESPACE