xref: /aosp_15_r20/external/llvm-libc/src/errno/libc_errno.h (revision 71db0c75aadcf003ffe3238005f61d7618a3fead)
1 //===-- Implementation header for libc_errno --------------------*- C++ -*-===//
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 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_LIBC_SRC_ERRNO_LIBC_ERRNO_H
10 #define LLVM_LIBC_SRC_ERRNO_LIBC_ERRNO_H
11 
12 #include "src/__support/macros/attributes.h"
13 #include "src/__support/macros/config.h"
14 #include "src/__support/macros/properties/architectures.h"
15 
16 #include "hdr/errno_macros.h"
17 
18 // This header is to be consumed by internal implementations, in which all of
19 // them should refer to `libc_errno` instead of using `errno` directly from
20 // <errno.h> header.
21 
22 // Unit and hermetic tests should:
23 // - #include "src/errno/libc_errno.h"
24 // - NOT #include <errno.h>
25 // - Only use `libc_errno` in the code
26 // - Depend on libc.src.errno.errno
27 
28 // Integration tests should:
29 // - NOT #include "src/errno/libc_errno.h"
30 // - #include <errno.h>
31 // - Use regular `errno` in the code
32 // - Still depend on libc.src.errno.errno
33 
34 namespace LIBC_NAMESPACE_DECL {
35 
36 extern "C" int *__llvm_libc_errno() noexcept;
37 
38 struct Errno {
39   void operator=(int);
40   operator int();
41 };
42 
43 extern Errno libc_errno;
44 
45 } // namespace LIBC_NAMESPACE_DECL
46 
47 #endif // LLVM_LIBC_SRC_ERRNO_LIBC_ERRNO_H
48