[libc-commits] [libc] [libc] Add BSD/SysV compatibility types to sys/types.h (PR #201314)
via libc-commits
libc-commits at lists.llvm.org
Wed Jun 3 04:27:11 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: Jeff Bailey (kaladron)
<details>
<summary>Changes</summary>
Added u_char, u_int32_t, and uint to sys/types.h. These types are commonly used by legacy and compatibility-reliant libraries like libedit and libcap.
Assisted-by: Automated tooling, human reviewed.
---
Full diff: https://github.com/llvm/llvm-project/pull/201314.diff
6 Files Affected:
- (modified) libc/include/CMakeLists.txt (+3)
- (modified) libc/include/llvm-libc-types/CMakeLists.txt (+3)
- (added) libc/include/llvm-libc-types/u_char.h (+19)
- (added) libc/include/llvm-libc-types/u_int32_t.h (+19)
- (added) libc/include/llvm-libc-types/uint.h (+19)
- (modified) libc/include/sys/types.yaml (+3)
``````````diff
diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt
index a83c6bfc79537..f7b889fedf804 100644
--- a/libc/include/CMakeLists.txt
+++ b/libc/include/CMakeLists.txt
@@ -876,7 +876,10 @@ add_header_macro(
.llvm-libc-types.ssize_t
.llvm-libc-types.suseconds_t
.llvm-libc-types.time_t
+ .llvm-libc-types.u_char
+ .llvm-libc-types.u_int32_t
.llvm-libc-types.uid_t
+ .llvm-libc-types.uint
)
add_header_macro(
diff --git a/libc/include/llvm-libc-types/CMakeLists.txt b/libc/include/llvm-libc-types/CMakeLists.txt
index c1b35fce166a7..096e326c01511 100644
--- a/libc/include/llvm-libc-types/CMakeLists.txt
+++ b/libc/include/llvm-libc-types/CMakeLists.txt
@@ -154,6 +154,9 @@ endif()
add_header(mcontext_t HDR mcontext_t.h DEPENDS ${mcontext_deps})
add_header(ucontext_t HDR ucontext_t.h DEPENDS .mcontext_t ${ucontext_deps})
+add_header(u_char HDR u_char.h)
+add_header(u_int32_t HDR u_int32_t.h)
+add_header(uint HDR uint.h)
add_header(__jmp_buf HDR __jmp_buf.h DEPENDS .sigset_t)
add_header(jmp_buf HDR jmp_buf.h DEPENDS .__jmp_buf)
add_header(sigjmp_buf HDR sigjmp_buf.h DEPENDS .__jmp_buf)
diff --git a/libc/include/llvm-libc-types/u_char.h b/libc/include/llvm-libc-types/u_char.h
new file mode 100644
index 0000000000000..876fb46d52267
--- /dev/null
+++ b/libc/include/llvm-libc-types/u_char.h
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Definition of u_char type.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_U_CHAR_H
+#define LLVM_LIBC_TYPES_U_CHAR_H
+
+typedef unsigned char u_char;
+
+#endif // LLVM_LIBC_TYPES_U_CHAR_H
diff --git a/libc/include/llvm-libc-types/u_int32_t.h b/libc/include/llvm-libc-types/u_int32_t.h
new file mode 100644
index 0000000000000..459ac29f4a464
--- /dev/null
+++ b/libc/include/llvm-libc-types/u_int32_t.h
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Definition of u_int32_t type.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_U_INT32_T_H
+#define LLVM_LIBC_TYPES_U_INT32_T_H
+
+typedef __UINT32_TYPE__ u_int32_t;
+
+#endif // LLVM_LIBC_TYPES_U_INT32_T_H
diff --git a/libc/include/llvm-libc-types/uint.h b/libc/include/llvm-libc-types/uint.h
new file mode 100644
index 0000000000000..281a0adc3e436
--- /dev/null
+++ b/libc/include/llvm-libc-types/uint.h
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Definition of uint type.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_UINT_H
+#define LLVM_LIBC_TYPES_UINT_H
+
+typedef unsigned int uint;
+
+#endif // LLVM_LIBC_TYPES_UINT_H
diff --git a/libc/include/sys/types.yaml b/libc/include/sys/types.yaml
index cdc9602520a0b..605b0c9258841 100644
--- a/libc/include/sys/types.yaml
+++ b/libc/include/sys/types.yaml
@@ -27,4 +27,7 @@ types:
- type_name: ssize_t
- type_name: suseconds_t
- type_name: time_t
+ - type_name: u_char
+ - type_name: u_int32_t
- type_name: uid_t
+ - type_name: uint
``````````
</details>
https://github.com/llvm/llvm-project/pull/201314
More information about the libc-commits
mailing list