128699e38Slntue //===-- Implementation header for libc_errno --------------------*- C++ -*-===// 2110ee164SSiva Chandra Reddy // 3110ee164SSiva Chandra Reddy // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4110ee164SSiva Chandra Reddy // See https://llvm.org/LICENSE.txt for license information. 5110ee164SSiva Chandra Reddy // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6110ee164SSiva Chandra Reddy // 7110ee164SSiva Chandra Reddy //===----------------------------------------------------------------------===// 8110ee164SSiva Chandra Reddy 9270547f3SGuillaume Chatelet #ifndef LLVM_LIBC_SRC_ERRNO_LIBC_ERRNO_H 10270547f3SGuillaume Chatelet #define LLVM_LIBC_SRC_ERRNO_LIBC_ERRNO_H 11110ee164SSiva Chandra Reddy 12daeee567SSiva Chandra Reddy #include "src/__support/macros/attributes.h" 135ff3ff33SPetr Hosek #include "src/__support/macros/config.h" 14d9f03314SJoseph Huber #include "src/__support/macros/properties/architectures.h" 15d9f03314SJoseph Huber 16561c42dfSRobin Caloudis #include "hdr/errno_macros.h" 17110ee164SSiva Chandra Reddy 1828699e38Slntue // This header is to be consumed by internal implementations, in which all of 1928699e38Slntue // them should refer to `libc_errno` instead of using `errno` directly from 2028699e38Slntue // <errno.h> header. 2128699e38Slntue 2228699e38Slntue // Unit and hermetic tests should: 2328699e38Slntue // - #include "src/errno/libc_errno.h" 2428699e38Slntue // - NOT #include <errno.h> 2528699e38Slntue // - Only use `libc_errno` in the code 2628699e38Slntue // - Depend on libc.src.errno.errno 2728699e38Slntue 2828699e38Slntue // Integration tests should: 2928699e38Slntue // - NOT #include "src/errno/libc_errno.h" 3028699e38Slntue // - #include <errno.h> 3128699e38Slntue // - Use regular `errno` in the code 3228699e38Slntue // - Still depend on libc.src.errno.errno 3328699e38Slntue 345ff3ff33SPetr Hosek namespace LIBC_NAMESPACE_DECL { 3569258491SPetr Hosek 36*8802c9fdSPetr Hosek extern "C" int *__llvm_libc_errno() noexcept; 374a68654aSPetr Hosek 3828699e38Slntue struct Errno { 3928699e38Slntue void operator=(int); 4028699e38Slntue operator int(); 41d9f03314SJoseph Huber }; 42d9f03314SJoseph Huber 435ac23208Smichaelrj-google extern Errno libc_errno; 44110ee164SSiva Chandra Reddy 455ff3ff33SPetr Hosek } // namespace LIBC_NAMESPACE_DECL 463eb1e6d8Smichaelrj-google 47270547f3SGuillaume Chatelet #endif // LLVM_LIBC_SRC_ERRNO_LIBC_ERRNO_H 48