[libc-commits] [libc] [libc][annex_k] Add rsize_t. (PR #163238)

Muhammad Bassiouni via libc-commits libc-commits at lists.llvm.org
Wed Mar 18 16:58:48 PDT 2026


https://github.com/bassiounix updated https://github.com/llvm/llvm-project/pull/163238

>From ab3cb836e3a8a458d13033ae4b32ace7b3a28acf Mon Sep 17 00:00:00 2001
From: bassiounix <muhammad.m.bassiouni at gmail.com>
Date: Mon, 13 Oct 2025 21:14:40 +0300
Subject: [PATCH 1/5] [libc][annex_k] Add rsize_t.

---
 libc/hdr/types/CMakeLists.txt               |  8 +++++++
 libc/hdr/types/rsize_t.h                    | 23 +++++++++++++++++++++
 libc/include/llvm-libc-types/CMakeLists.txt |  1 +
 libc/include/llvm-libc-types/rsize_t.h      | 18 ++++++++++++++++
 4 files changed, 50 insertions(+)
 create mode 100644 libc/hdr/types/rsize_t.h
 create mode 100644 libc/include/llvm-libc-types/rsize_t.h

diff --git a/libc/hdr/types/CMakeLists.txt b/libc/hdr/types/CMakeLists.txt
index ba99a02a10118..84a26ecf8fb5e 100644
--- a/libc/hdr/types/CMakeLists.txt
+++ b/libc/hdr/types/CMakeLists.txt
@@ -135,6 +135,14 @@ add_proxy_header_library(
     libc.include.llvm-libc-types.struct_tm
 )
 
+add_proxy_header_library(
+  rsize_t
+  HDRS
+    rsize_t.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-types.rsize_t
+)
+
 add_proxy_header_library(
   size_t
   HDRS
diff --git a/libc/hdr/types/rsize_t.h b/libc/hdr/types/rsize_t.h
new file mode 100644
index 0000000000000..130e6c308e264
--- /dev/null
+++ b/libc/hdr/types/rsize_t.h
@@ -0,0 +1,23 @@
+//===-- Proxy for 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.
+// 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
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/rsize_t.h"
+
+#else
+
+#define __need_rsize_t
+#include <stddef.h>
+#undef __need_rsize_t
+
+#endif // LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_SIZE_T_H
diff --git a/libc/include/llvm-libc-types/CMakeLists.txt b/libc/include/llvm-libc-types/CMakeLists.txt
index 09f9d759f0dd8..d3a3c109aacc0 100644
--- a/libc/include/llvm-libc-types/CMakeLists.txt
+++ b/libc/include/llvm-libc-types/CMakeLists.txt
@@ -1,4 +1,5 @@
 add_header(off64_t HDR off64_t.h)
+add_header(rsize_t HDR rsize_t.h)
 add_header(size_t HDR size_t.h)
 add_header(ssize_t HDR ssize_t.h)
 add_header(__atfork_callback_t HDR __atfork_callback_t.h)
diff --git a/libc/include/llvm-libc-types/rsize_t.h b/libc/include/llvm-libc-types/rsize_t.h
new file mode 100644
index 0000000000000..dc8be02bee592
--- /dev/null
+++ b/libc/include/llvm-libc-types/rsize_t.h
@@ -0,0 +1,18 @@
+//===-- Definition of size_t types ----------------------------------------===//
+//
+// 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_TYPES_RSIZE_T_H
+#define LLVM_LIBC_TYPES_RSIZE_T_H
+
+#ifdef LIBC_HAS_ANNEX_K
+
+typedef __SIZE_TYPE__ rsize_t;
+
+#endif // LIBC_HAS_ANNEX_K
+
+#endif // LLVM_LIBC_TYPES_RSIZE_T_H

>From 9eec75bbe7c61b7f16f961237c470284f1d770f7 Mon Sep 17 00:00:00 2001
From: bassiounix <muhammad.m.bassiouni at gmail.com>
Date: Thu, 19 Mar 2026 00:08:08 +0200
Subject: [PATCH 2/5] redefine rsize_t with size_t

---
 libc/include/llvm-libc-types/CMakeLists.txt | 2 +-
 libc/include/llvm-libc-types/rsize_t.h      | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/libc/include/llvm-libc-types/CMakeLists.txt b/libc/include/llvm-libc-types/CMakeLists.txt
index d3a3c109aacc0..70582517562a5 100644
--- a/libc/include/llvm-libc-types/CMakeLists.txt
+++ b/libc/include/llvm-libc-types/CMakeLists.txt
@@ -1,5 +1,5 @@
 add_header(off64_t HDR off64_t.h)
-add_header(rsize_t HDR rsize_t.h)
+add_header(rsize_t HDR rsize_t.h DEPENDS .size_t)
 add_header(size_t HDR size_t.h)
 add_header(ssize_t HDR ssize_t.h)
 add_header(__atfork_callback_t HDR __atfork_callback_t.h)
diff --git a/libc/include/llvm-libc-types/rsize_t.h b/libc/include/llvm-libc-types/rsize_t.h
index dc8be02bee592..2f17200cbf265 100644
--- a/libc/include/llvm-libc-types/rsize_t.h
+++ b/libc/include/llvm-libc-types/rsize_t.h
@@ -11,7 +11,9 @@
 
 #ifdef LIBC_HAS_ANNEX_K
 
-typedef __SIZE_TYPE__ rsize_t;
+#include "./size_t.h"
+
+typedef size_t rsize_t;
 
 #endif // LIBC_HAS_ANNEX_K
 

>From cc3c286567ab650ee50e2c5ba12a3f3a6b9b4246 Mon Sep 17 00:00:00 2001
From: bassiounix <muhammad.m.bassiouni at gmail.com>
Date: Thu, 19 Mar 2026 00:28:51 +0200
Subject: [PATCH 3/5] reorder

---
 libc/include/llvm-libc-types/CMakeLists.txt | 9 ++++++++-
 libc/include/llvm-libc-types/rsize_t.h      | 2 ++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/libc/include/llvm-libc-types/CMakeLists.txt b/libc/include/llvm-libc-types/CMakeLists.txt
index 70582517562a5..b03e4fa830b05 100644
--- a/libc/include/llvm-libc-types/CMakeLists.txt
+++ b/libc/include/llvm-libc-types/CMakeLists.txt
@@ -1,6 +1,13 @@
 add_header(off64_t HDR off64_t.h)
-add_header(rsize_t HDR rsize_t.h DEPENDS .size_t)
 add_header(size_t HDR size_t.h)
+add_header(
+  rsize_t
+  HDR
+    rsize_t.h
+  DEPENDS
+    .size_t
+    libc.include.llvm-libc-macros.annex_k_macros
+)
 add_header(ssize_t HDR ssize_t.h)
 add_header(__atfork_callback_t HDR __atfork_callback_t.h)
 add_header(__search_compare_t HDR __search_compare_t.h)
diff --git a/libc/include/llvm-libc-types/rsize_t.h b/libc/include/llvm-libc-types/rsize_t.h
index 2f17200cbf265..a32a7b5ee2c3b 100644
--- a/libc/include/llvm-libc-types/rsize_t.h
+++ b/libc/include/llvm-libc-types/rsize_t.h
@@ -9,6 +9,8 @@
 #ifndef LLVM_LIBC_TYPES_RSIZE_T_H
 #define LLVM_LIBC_TYPES_RSIZE_T_H
 
+#include "../llvm-libc-macros/annex-k-macros.h"
+
 #ifdef LIBC_HAS_ANNEX_K
 
 #include "./size_t.h"

>From 29a9d42446b3abb8192d547c713e982c656387b5 Mon Sep 17 00:00:00 2001
From: bassiounix <muhammad.m.bassiouni at gmail.com>
Date: Thu, 19 Mar 2026 00:30:52 +0200
Subject: [PATCH 4/5] rename comment

---
 libc/include/llvm-libc-types/rsize_t.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libc/include/llvm-libc-types/rsize_t.h b/libc/include/llvm-libc-types/rsize_t.h
index a32a7b5ee2c3b..06e3c24af43fa 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 size_t types ----------------------------------------===//
+//===-- Definition of rsize_t types ---------------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.

>From 4bdb98dbdc219064bf886fa51dd2dd0cce297a09 Mon Sep 17 00:00:00 2001
From: bassiounix <muhammad.m.bassiouni at gmail.com>
Date: Thu, 19 Mar 2026 01:58:32 +0200
Subject: [PATCH 5/5] misc

---
 libc/include/llvm-libc-types/rsize_t.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libc/include/llvm-libc-types/rsize_t.h b/libc/include/llvm-libc-types/rsize_t.h
index 06e3c24af43fa..c03d00043bc3e 100644
--- a/libc/include/llvm-libc-types/rsize_t.h
+++ b/libc/include/llvm-libc-types/rsize_t.h
@@ -13,7 +13,7 @@
 
 #ifdef LIBC_HAS_ANNEX_K
 
-#include "./size_t.h"
+#include "size_t.h"
 
 typedef size_t rsize_t;
 



More information about the libc-commits mailing list