[libc-commits] [libc] [libc] Define Annex K's errno_t in specified headers (PR #187700)
via libc-commits
libc-commits at lists.llvm.org
Fri Mar 20 07:02:34 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: Victor Campos (vhscampos)
<details>
<summary>Changes</summary>
- Change `errno.h.def` to include a placeholder where hdrgen emits the public API, which contains the `errno_t` definition.
- Make headers `stdio.h`, `stdlib.h`, `string.h` and `time.h` also define `errno_t` as specified in the standard.
---
Full diff: https://github.com/llvm/llvm-project/pull/187700.diff
6 Files Affected:
- (modified) libc/include/CMakeLists.txt (+5-1)
- (modified) libc/include/errno.h.def (+2)
- (modified) libc/include/stdio.yaml (+1)
- (modified) libc/include/stdlib.yaml (+2-1)
- (modified) libc/include/string.yaml (+1)
- (modified) libc/include/time.yaml (+1)
``````````diff
diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt
index cc0b83124d064..cc318404a5b84 100644
--- a/libc/include/CMakeLists.txt
+++ b/libc/include/CMakeLists.txt
@@ -253,6 +253,7 @@ add_header_macro(
DEPENDS
.llvm_libc_common_h
.llvm-libc-macros.null_macro
+ .llvm-libc-types.errno_t
.llvm-libc-types.size_t
)
@@ -288,6 +289,7 @@ add_header_macro(
.llvm-libc-macros.null_macro
.llvm-libc-macros.time_macros
.llvm-libc-types.clock_t
+ .llvm-libc-types.errno_t
.llvm-libc-types.time_t
.llvm-libc-types.struct_tm
.llvm-libc-types.struct_timespec
@@ -364,8 +366,9 @@ add_header_macro(
.llvm-libc-macros.file_seek_macros
.llvm-libc-macros.null_macro
.llvm-libc-macros.stdio_macros
- .llvm-libc-types.FILE
.llvm-libc-types.cookie_io_functions_t
+ .llvm-libc-types.errno_t
+ .llvm-libc-types.FILE
.llvm-libc-types.off_t
.llvm-libc-types.size_t
.llvm-libc-types.ssize_t
@@ -384,6 +387,7 @@ add_header_macro(
.llvm-libc-types.__qsortrcompare_t
.llvm-libc-types.__search_compare_t
.llvm-libc-types.div_t
+ .llvm-libc-types.errno_t
.llvm-libc-types.ldiv_t
.llvm-libc-types.lldiv_t
.llvm-libc-types.locale_t
diff --git a/libc/include/errno.h.def b/libc/include/errno.h.def
index 0ac8e57f7a158..f731accc3b24b 100644
--- a/libc/include/errno.h.def
+++ b/libc/include/errno.h.def
@@ -31,6 +31,8 @@
#endif
+%%public_api()
+
__BEGIN_C_DECLS
int *__llvm_libc_errno(void) __NOEXCEPT;
diff --git a/libc/include/stdio.yaml b/libc/include/stdio.yaml
index 67eeeaf07bdd1..ad556e659f433 100644
--- a/libc/include/stdio.yaml
+++ b/libc/include/stdio.yaml
@@ -14,6 +14,7 @@ types:
- type_name: off_t
- type_name: cookie_io_functions_t
- type_name: FILE
+ - type_name: errno_t
enums: []
objects:
- object_name: stdin
diff --git a/libc/include/stdlib.yaml b/libc/include/stdlib.yaml
index 4752244279243..8741b06d1bcd8 100644
--- a/libc/include/stdlib.yaml
+++ b/libc/include/stdlib.yaml
@@ -17,7 +17,8 @@ types:
- type_name: lldiv_t
- type_name: locale_t
- type_name: size_t
- - type_name: wchar_t
+ - type_name: wchar_t
+ - type_name: errno_t
enums: []
objects: []
functions:
diff --git a/libc/include/string.yaml b/libc/include/string.yaml
index 22010f4afa812..c781060bb59b6 100644
--- a/libc/include/string.yaml
+++ b/libc/include/string.yaml
@@ -5,6 +5,7 @@ macros:
- macro_name: "NULL"
macro_header: null-macro.h
types:
+ - type_name: errno_t
- type_name: locale_t
- type_name: size_t
enums: []
diff --git a/libc/include/time.yaml b/libc/include/time.yaml
index bf68da326ccd4..26ce829939f64 100644
--- a/libc/include/time.yaml
+++ b/libc/include/time.yaml
@@ -6,6 +6,7 @@ macros:
types:
- type_name: struct_timeval
- type_name: clockid_t
+ - type_name: errno_t
- type_name: struct_timespec
- type_name: struct_tm
- type_name: time_t
``````````
</details>
https://github.com/llvm/llvm-project/pull/187700
More information about the libc-commits
mailing list