[libc-commits] [libc] [libc] Follow up on Annex K's rsize_t (PR #187707)

Victor Campos via libc-commits libc-commits at lists.llvm.org
Fri Mar 20 07:25:57 PDT 2026


https://github.com/vhscampos created https://github.com/llvm/llvm-project/pull/187707

 - Fix header guard name.
 - Define `__STDC_WANT_LIB_EXT1__` in `hdr/types/rsize_t.h` so that the type is available for internal use.
 - In accordance to the standard, make `stdio.h`, `stdlib.h`, `string.h`, `time.h` and `wchar.h` define the type. It should already be available in `stddef.h` as it's provided in Clang, not LLVM libc.

>From 15a8d38c5dd59e8cef4e44c6c930857646f6bf18 Mon Sep 17 00:00:00 2001
From: Victor Campos <victor.campos at arm.com>
Date: Fri, 20 Mar 2026 14:12:09 +0000
Subject: [PATCH] [libc] Follow up on Annex K's rsize_t

 - Fix header guard name.
 - Define `__STDC_WANT_LIB_EXT1__` in `hdr/types/rsize_t.h` so that the
   type is available for internal use.
 - In accordance to the standard, make `stdio.h`, `stdlib.h`,
   `string.h`, `time.h` and `wchar.h` define the type. It should already
   be available in `stddef.h` as it's provided in Clang, not LLVM libc.
---
 libc/hdr/types/rsize_t.h               | 14 +++++++++++---
 libc/include/CMakeLists.txt            |  5 +++++
 libc/include/llvm-libc-types/rsize_t.h |  2 +-
 libc/include/stdio.yaml                |  1 +
 libc/include/stdlib.yaml               |  1 +
 libc/include/string.yaml               |  1 +
 libc/include/time.yaml                 |  1 +
 libc/include/wchar.yaml                |  1 +
 8 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/libc/hdr/types/rsize_t.h b/libc/hdr/types/rsize_t.h
index 130e6c308e264..ed2571a210793 100644
--- a/libc/hdr/types/rsize_t.h
+++ b/libc/hdr/types/rsize_t.h
@@ -5,8 +5,12 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-#ifndef LLVM_LIBC_HDR_TYPES_SIZE_T_H
-#define LLVM_LIBC_HDR_TYPES_SIZE_T_H
+#ifndef LLVM_LIBC_HDR_TYPES_RSIZE_T_H
+#define LLVM_LIBC_HDR_TYPES_RSIZE_T_H
+
+#ifndef __STDC_WANT_LIB_EXT1__
+#define __STDC_WANT_LIB_EXT1__ 1
+#endif
 
 #ifdef LIBC_FULL_BUILD
 
@@ -20,4 +24,8 @@
 
 #endif // LIBC_FULL_BUILD
 
-#endif // LLVM_LIBC_HDR_TYPES_SIZE_T_H
+#ifdef __STDC_WANT_LIB_EXT1__
+#undef __STDC_WANT_LIB_EXT1__
+#endif
+
+#endif // LLVM_LIBC_HDR_TYPES_RSIZE_T_H
diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt
index cc0b83124d064..b14675d41f357 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.rsize_t
     .llvm-libc-types.size_t
 )
 
@@ -293,6 +294,7 @@ add_header_macro(
     .llvm-libc-types.struct_timespec
     .llvm-libc-types.struct_timeval
     .llvm-libc-types.clockid_t
+    .llvm-libc-types.rsize_t
 )
 
 add_header_macro(
@@ -367,6 +369,7 @@ add_header_macro(
     .llvm-libc-types.FILE
     .llvm-libc-types.cookie_io_functions_t
     .llvm-libc-types.off_t
+    .llvm-libc-types.rsize_t
     .llvm-libc-types.size_t
     .llvm-libc-types.ssize_t
     .llvm_libc_common_h
@@ -387,6 +390,7 @@ add_header_macro(
     .llvm-libc-types.ldiv_t
     .llvm-libc-types.lldiv_t
     .llvm-libc-types.locale_t
+    .llvm-libc-types.rsize_t
     .llvm-libc-types.size_t
     .llvm_libc_common_h
 )
@@ -833,6 +837,7 @@ add_header_macro(
     .llvm-libc-macros.null_macro
     .llvm-libc-macros.wchar_macros
     .llvm-libc-types.mbstate_t
+    .llvm-libc-types.rsize_t
     .llvm-libc-types.size_t
     .llvm-libc-types.wint_t
     .llvm-libc-types.wchar_t
diff --git a/libc/include/llvm-libc-types/rsize_t.h b/libc/include/llvm-libc-types/rsize_t.h
index c03d00043bc3e..6e92bb99025f8 100644
--- a/libc/include/llvm-libc-types/rsize_t.h
+++ b/libc/include/llvm-libc-types/rsize_t.h
@@ -1,4 +1,4 @@
-//===-- Definition of rsize_t types ---------------------------------------===//
+//===-- Definition of type rsize_t -------------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/libc/include/stdio.yaml b/libc/include/stdio.yaml
index 67eeeaf07bdd1..e607b15e35450 100644
--- a/libc/include/stdio.yaml
+++ b/libc/include/stdio.yaml
@@ -10,6 +10,7 @@ macros:
   - macro_name: stderr
     macro_value: stderr
 types:
+  - type_name: rsize_t
   - type_name: size_t
   - type_name: off_t
   - type_name: cookie_io_functions_t
diff --git a/libc/include/stdlib.yaml b/libc/include/stdlib.yaml
index 4752244279243..29fd7d954a78f 100644
--- a/libc/include/stdlib.yaml
+++ b/libc/include/stdlib.yaml
@@ -16,6 +16,7 @@ types:
   - type_name: ldiv_t
   - type_name: lldiv_t
   - type_name: locale_t
+  - type_name: rsize_t
   - type_name: size_t
   - type_name: wchar_t  
 enums: []
diff --git a/libc/include/string.yaml b/libc/include/string.yaml
index 22010f4afa812..a7213d1131d15 100644
--- a/libc/include/string.yaml
+++ b/libc/include/string.yaml
@@ -6,6 +6,7 @@ macros:
     macro_header: null-macro.h
 types:
   - type_name: locale_t
+  - type_name: rsize_t
   - type_name: size_t
 enums: []
 objects: []
diff --git a/libc/include/time.yaml b/libc/include/time.yaml
index bf68da326ccd4..86eefc3ba2ce6 100644
--- a/libc/include/time.yaml
+++ b/libc/include/time.yaml
@@ -10,6 +10,7 @@ types:
   - type_name: struct_tm
   - type_name: time_t
   - type_name: clock_t
+  - type_name: rsize_t
   - type_name: size_t
   - type_name: locale_t
 enums: []
diff --git a/libc/include/wchar.yaml b/libc/include/wchar.yaml
index 7a94f9b542b7f..32e13d040621a 100644
--- a/libc/include/wchar.yaml
+++ b/libc/include/wchar.yaml
@@ -5,6 +5,7 @@ macros:
     macro_header: null-macro.h
 types:
   - type_name: FILE
+  - type_name: rsize_t
   - type_name: size_t
   # TODO: Remove this once we have a function declaration using "struct tm"
   # (wcsftime). We're declaring it here now, since libc++ expects



More information about the libc-commits mailing list