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

via libc-commits libc-commits at lists.llvm.org
Wed Mar 25 06:16:40 PDT 2026


Author: Victor Campos
Date: 2026-03-25T13:16:34Z
New Revision: 2baa2cdce97eb3b548d193247e1692a95cb694b5

URL: https://github.com/llvm/llvm-project/commit/2baa2cdce97eb3b548d193247e1692a95cb694b5
DIFF: https://github.com/llvm/llvm-project/commit/2baa2cdce97eb3b548d193247e1692a95cb694b5.diff

LOG: [libc] Follow up on Annex K's rsize_t (#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 by Clang, not LLVM libc.

Added: 
    

Modified: 
    libc/hdr/types/rsize_t.h
    libc/include/CMakeLists.txt
    libc/include/llvm-libc-types/rsize_t.h
    libc/include/stdio.yaml
    libc/include/stdlib.yaml
    libc/include/string.yaml
    libc/include/time.yaml
    libc/include/wchar.yaml

Removed: 
    


################################################################################
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 18220de13d268..3f4bbf85160b7 100644
--- a/libc/include/CMakeLists.txt
+++ b/libc/include/CMakeLists.txt
@@ -254,6 +254,7 @@ add_header_macro(
     .llvm_libc_common_h
     .llvm-libc-macros.null_macro
     .llvm-libc-types.errno_t
+    .llvm-libc-types.rsize_t
     .llvm-libc-types.size_t
 )
 
@@ -295,6 +296,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(
@@ -370,6 +372,7 @@ add_header_macro(
     .llvm-libc-types.cookie_io_functions_t
     .llvm-libc-types.errno_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
@@ -392,6 +395,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
 )
@@ -838,6 +842,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 ad556e659f433..cf8675f73495a 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 f7275a51b93db..4ab1f36906b14 100644
--- a/libc/include/stdlib.yaml
+++ b/libc/include/stdlib.yaml
@@ -17,6 +17,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
   - type_name: errno_t

diff  --git a/libc/include/string.yaml b/libc/include/string.yaml
index c781060bb59b6..ec9678f8ab47c 100644
--- a/libc/include/string.yaml
+++ b/libc/include/string.yaml
@@ -7,6 +7,7 @@ macros:
 types:
   - type_name: errno_t
   - 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 26ce829939f64..2311f045d1502 100644
--- a/libc/include/time.yaml
+++ b/libc/include/time.yaml
@@ -11,6 +11,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