From b00886eb7e6234635c33238c4a5a88c60379519e Mon Sep 17 00:00:00 2001 From: bassiounix Date: Sun, 12 Oct 2025 22:18:17 +0300 Subject: [PATCH 1/2] [libc][annex_k] Add errno_t. --- libc/hdr/types/CMakeLists.txt | 9 +++++++++ libc/hdr/types/errno_t.h | 18 ++++++++++++++++++ libc/include/CMakeLists.txt | 1 + libc/include/errno.h.def | 2 ++ libc/include/llvm-libc-types/CMakeLists.txt | 2 ++ libc/include/llvm-libc-types/errno_t.h | 18 ++++++++++++++++++ 6 files changed, 50 insertions(+) create mode 100644 libc/hdr/types/errno_t.h create mode 100644 libc/include/llvm-libc-types/errno_t.h diff --git a/libc/hdr/types/CMakeLists.txt b/libc/hdr/types/CMakeLists.txt index 21971a4004760..89414f419a7f0 100644 --- a/libc/hdr/types/CMakeLists.txt +++ b/libc/hdr/types/CMakeLists.txt @@ -162,6 +162,15 @@ add_proxy_header_library( libc.include.fcntl ) +add_proxy_header_library( + errno_t + HDRS + errno_t.h + FULL_BUILD_DEPENDS + libc.include.llvm-libc-types.errno_t + libc.include.errno +) + add_proxy_header_library( fenv_t HDRS diff --git a/libc/hdr/types/errno_t.h b/libc/hdr/types/errno_t.h new file mode 100644 index 0000000000000..91706b05c9155 --- /dev/null +++ b/libc/hdr/types/errno_t.h @@ -0,0 +1,18 @@ +//===-- Proxy for errno_t -------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_HDR_TYPES_ERRNO_T_H +#define LLVM_LIBC_HDR_TYPES_ERRNO_T_H + +#define LIBC_HAS_ANNEX_K + +#include "include/llvm-libc-types/errno_t.h" + +#undef LIBC_HAS_ANNEX_K + +#endif // LLVM_LIBC_HDR_TYPES_ERRNO_T_H diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt index afa90e6c8b655..a6715392fe7a1 100644 --- a/libc/include/CMakeLists.txt +++ b/libc/include/CMakeLists.txt @@ -302,6 +302,7 @@ add_header_macro( DEPENDS .llvm-libc-macros.generic_error_number_macros .llvm-libc-macros.error_number_macros + .llvm-libc-types.errno_t ) add_header_macro( diff --git a/libc/include/errno.h.def b/libc/include/errno.h.def index aa1f6c9e48444..35341c60e38b2 100644 --- a/libc/include/errno.h.def +++ b/libc/include/errno.h.def @@ -33,4 +33,6 @@ __END_C_DECLS #define errno (*__llvm_libc_errno()) +#include "llvm-libc-types/errno_t.h" + #endif // LLVM_LIBC_ERRNO_H diff --git a/libc/include/llvm-libc-types/CMakeLists.txt b/libc/include/llvm-libc-types/CMakeLists.txt index 70da983be9090..670ab71468661 100644 --- a/libc/include/llvm-libc-types/CMakeLists.txt +++ b/libc/include/llvm-libc-types/CMakeLists.txt @@ -296,3 +296,5 @@ add_header(EFI_SYSTEM_TABLE .EFI_TABLE_HEADER .char16_t ) + +add_header(errno_t HDR errno_t.h) diff --git a/libc/include/llvm-libc-types/errno_t.h b/libc/include/llvm-libc-types/errno_t.h new file mode 100644 index 0000000000000..f99fe1266ccd1 --- /dev/null +++ b/libc/include/llvm-libc-types/errno_t.h @@ -0,0 +1,18 @@ +//===-- Definition of type errno_t ----------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_INCLUDE_LLVM_LIBC_TYPES_ERRNO_T_H +#define LLVM_LIBC_INCLUDE_LLVM_LIBC_TYPES_ERRNO_T_H + +#ifdef LIBC_HAS_ANNEX_K + +typedef int errno_t; + +#endif // LIBC_HAS_ANNEX_K + +#endif // LLVM_LIBC_INCLUDE_LLVM_LIBC_TYPES_ERRNO_T_H From b841bdd129de44b674ffd328ef98cf9566a322ca Mon Sep 17 00:00:00 2001 From: bassiounix Date: Tue, 14 Oct 2025 00:44:08 +0300 Subject: [PATCH 2/2] change location of errno_t --- libc/include/llvm-libc-types/CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libc/include/llvm-libc-types/CMakeLists.txt b/libc/include/llvm-libc-types/CMakeLists.txt index 670ab71468661..bbeebbed2790a 100644 --- a/libc/include/llvm-libc-types/CMakeLists.txt +++ b/libc/include/llvm-libc-types/CMakeLists.txt @@ -29,6 +29,7 @@ add_header(double_t HDR double_t.h) add_header(DIR HDR DIR.h) add_header(dev_t HDR dev_t.h) add_header(div_t HDR div_t.h) +add_header(errno_t HDR errno_t.h) add_header(ldiv_t HDR ldiv_t.h) add_header(lldiv_t HDR lldiv_t.h) add_header(FILE HDR FILE.h) @@ -296,5 +297,3 @@ add_header(EFI_SYSTEM_TABLE .EFI_TABLE_HEADER .char16_t ) - -add_header(errno_t HDR errno_t.h)