blob: 5afc0a41d348ae85179ffb6102f8dede6b8e0b11 [file] [log] [blame]
lntue28699e32024-02-01 17:16:281//===-- Implementation header for libc_errno --------------------*- C++ -*-===//
Siva Chandra Reddy110ee162023-02-27 22:27:352//
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 Chatelet270547f2023-09-21 09:14:479#ifndef LLVM_LIBC_SRC_ERRNO_LIBC_ERRNO_H
10#define LLVM_LIBC_SRC_ERRNO_LIBC_ERRNO_H
Siva Chandra Reddy110ee162023-02-27 22:27:3511
Siva Chandra Reddydaeee562023-05-25 19:29:1912#include "src/__support/macros/attributes.h"
Joseph Huberd9f03312023-04-24 23:28:5413#include "src/__support/macros/properties/architectures.h"
14
lntue28699e32024-02-01 17:16:2815// 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 Reddy110ee162023-02-27 22:27:3519#include <errno.h>
20
lntue28699e32024-02-01 17:16:2821// 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 Chateletb6bc9d72023-09-26 09:45:0437namespace LIBC_NAMESPACE {
lntue28699e32024-02-01 17:16:2838struct Errno {
39 void operator=(int);
40 operator int();
Joseph Huberd9f03312023-04-24 23:28:5441};
Joseph Huberd9f03312023-04-24 23:28:5442
michaelrj-google5ac23202024-02-06 18:48:2543extern Errno libc_errno;
Siva Chandra Reddy110ee162023-02-27 22:27:3544
michaelrj-google3eb1e6d2024-02-06 09:36:0545} // namespace LIBC_NAMESPACE
46
Guillaume Chatelet270547f2023-09-21 09:14:4747#endif // LLVM_LIBC_SRC_ERRNO_LIBC_ERRNO_H