lntue | 28699e3 | 2024-02-01 17:16:28 | [diff] [blame] | 1 | //===-- Implementation header for libc_errno --------------------*- C++ -*-===// |
Siva Chandra Reddy | 110ee16 | 2023-02-27 22:27:35 | [diff] [blame] | 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 | |
Guillaume Chatelet | 270547f | 2023-09-21 09:14:47 | [diff] [blame] | 9 | #ifndef LLVM_LIBC_SRC_ERRNO_LIBC_ERRNO_H |
| 10 | #define LLVM_LIBC_SRC_ERRNO_LIBC_ERRNO_H |
Siva Chandra Reddy | 110ee16 | 2023-02-27 22:27:35 | [diff] [blame] | 11 | |
Siva Chandra Reddy | daeee56 | 2023-05-25 19:29:19 | [diff] [blame] | 12 | #include "src/__support/macros/attributes.h" |
Joseph Huber | d9f0331 | 2023-04-24 23:28:54 | [diff] [blame] | 13 | #include "src/__support/macros/properties/architectures.h" |
| 14 | |
lntue | 28699e3 | 2024-02-01 17:16:28 | [diff] [blame] | 15 | // TODO: https://github.com/llvm/llvm-project/issues/80172 |
| 16 | // Separate just the definition of errno numbers in |
| 17 | // include/llvm-libc-macros/* and only include that instead of the system |
| 18 | // <errno.h>. |
Siva Chandra Reddy | 110ee16 | 2023-02-27 22:27:35 | [diff] [blame] | 19 | #include <errno.h> |
| 20 | |
lntue | 28699e3 | 2024-02-01 17:16:28 | [diff] [blame] | 21 | // This header is to be consumed by internal implementations, in which all of |
| 22 | // them should refer to `libc_errno` instead of using `errno` directly from |
| 23 | // <errno.h> header. |
| 24 | |
| 25 | // Unit and hermetic tests should: |
| 26 | // - #include "src/errno/libc_errno.h" |
| 27 | // - NOT #include <errno.h> |
| 28 | // - Only use `libc_errno` in the code |
| 29 | // - Depend on libc.src.errno.errno |
| 30 | |
| 31 | // Integration tests should: |
| 32 | // - NOT #include "src/errno/libc_errno.h" |
| 33 | // - #include <errno.h> |
| 34 | // - Use regular `errno` in the code |
| 35 | // - Still depend on libc.src.errno.errno |
| 36 | |
Guillaume Chatelet | b6bc9d7 | 2023-09-26 09:45:04 | [diff] [blame] | 37 | namespace LIBC_NAMESPACE { |
lntue | 28699e3 | 2024-02-01 17:16:28 | [diff] [blame] | 38 | struct Errno { |
| 39 | void operator=(int); |
| 40 | operator int(); |
Joseph Huber | d9f0331 | 2023-04-24 23:28:54 | [diff] [blame] | 41 | }; |
Joseph Huber | d9f0331 | 2023-04-24 23:28:54 | [diff] [blame] | 42 | |
michaelrj-google | 5ac2320 | 2024-02-06 18:48:25 | [diff] [blame] | 43 | extern Errno libc_errno; |
Siva Chandra Reddy | 110ee16 | 2023-02-27 22:27:35 | [diff] [blame] | 44 | |
michaelrj-google | 3eb1e6d | 2024-02-06 09:36:05 | [diff] [blame] | 45 | } // namespace LIBC_NAMESPACE |
| 46 | |
Guillaume Chatelet | 270547f | 2023-09-21 09:14:47 | [diff] [blame] | 47 | #endif // LLVM_LIBC_SRC_ERRNO_LIBC_ERRNO_H |