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/properties/architectures.h"
14
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>.
19#include <errno.h>
20
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
37namespace LIBC_NAMESPACE {
38struct Errno {
39 void operator=(int);
40 operator int();
41};
42
43extern Errno libc_errno;
44
45} // namespace LIBC_NAMESPACE
46
47#endif // LLVM_LIBC_SRC_ERRNO_LIBC_ERRNO_H
48

source code of libc/src/errno/libc_errno.h