[libc-commits] [libc] [llvm] [libc] Have sys/time.h carry sys/select.h (PR #241696)

Mike Lothian via libc-commits libc-commits at lists.llvm.org
Fri Nov 13 02:57:48 PST 2026


https://github.com/FireBurn updated https://github.com/llvm/llvm-project/pull/241696

>From 2d14f7550780cb1c7e9e6dca743345479e8525a7 Mon Sep 17 00:00:00 2001
From: Mike Lothian <mike at fireburn.co.uk>
Date: Sun, 6 Sep 2026 11:19:40 +0100
Subject: [PATCH] [libc] Have sys/time.h carry sys/select.h

POSIX allows `<sys/time.h>` to make `select` and `fd_set` visible, and procps relies on it

AI disclosure: this patch was written with Claude Code. I reviewed the change and built it in a full build, and the include and header tests pass

Assisted-by: Claude
---
 libc/include/CMakeLists.txt                   |  4 +++
 libc/include/sys/select-time.yaml             | 28 +++++++++++++++++++
 libc/include/sys/select.yaml                  | 17 ++---------
 libc/include/sys/time.yaml                    |  5 +++-
 .../llvm-project-overlay/libc/BUILD.bazel     | 10 +++++--
 5 files changed, 46 insertions(+), 18 deletions(-)
 create mode 100644 libc/include/sys/select-time.yaml

diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt
index 7010d6998b5fe..b8660f1ba611e 100644
--- a/libc/include/CMakeLists.txt
+++ b/libc/include/CMakeLists.txt
@@ -1027,9 +1027,13 @@ add_header_macro(
   sys/time.h
   DEPENDS
     .llvm_libc_common_h
+    .llvm-libc-macros.sys_select_macros
     .llvm-libc-macros.sys_time_macros
+    .llvm-libc-types.fd_set
     .llvm-libc-types.struct_itimerval
     .llvm-libc-types.struct_timeval
+    .llvm-libc-types.suseconds_t
+    .llvm-libc-types.time_t
 )
 
 add_header_macro(
diff --git a/libc/include/sys/select-time.yaml b/libc/include/sys/select-time.yaml
new file mode 100644
index 0000000000000..e37bfd632c669
--- /dev/null
+++ b/libc/include/sys/select-time.yaml
@@ -0,0 +1,28 @@
+# This file has the declarations of <sys/select.h> that POSIX also requires
+# <sys/time.h> to provide.
+
+macros:
+  - macro_name: FD_CLR
+    macro_header: sys-select-macros.h
+  - macro_name: FD_ISSET
+    macro_header: sys-select-macros.h
+  - macro_name: FD_SET
+    macro_header: sys-select-macros.h
+  - macro_name: FD_ZERO
+    macro_header: sys-select-macros.h
+  - macro_name: FD_SETSIZE
+    macro_header: sys-select-macros.h
+types:
+  - type_name: fd_set
+  - type_name: struct_timeval
+functions:
+  - name: select
+    standards:
+      - posix
+    return_type: int
+    arguments:
+      - type: int
+      - type: fd_set *__restrict
+      - type: fd_set *__restrict
+      - type: fd_set *__restrict
+      - type: struct timeval *__restrict
diff --git a/libc/include/sys/select.yaml b/libc/include/sys/select.yaml
index 017ce0b4ca4a0..f3b4e9a81cd85 100644
--- a/libc/include/sys/select.yaml
+++ b/libc/include/sys/select.yaml
@@ -1,29 +1,16 @@
 header: sys/select.h
 standards:
   - posix
-macros:
-  - macro_name: FD_SETSIZE
-    macro_header: sys-select-macros.h
+merge_yaml_files:
+  - select-time.yaml
 types:
-  - type_name: struct_timeval
   - type_name: struct_timespec
   - type_name: suseconds_t
   - type_name: sigset_t
   - type_name: time_t
-  - type_name: fd_set
 enums: []
 objects: []
 functions:
-  - name: select
-    standards:
-      - posix
-    return_type: int
-    arguments:
-      - type: int
-      - type: fd_set *__restrict
-      - type: fd_set *__restrict
-      - type: fd_set *__restrict
-      - type: struct timeval *__restrict
   - name: pselect
     standards:
       - posix
diff --git a/libc/include/sys/time.yaml b/libc/include/sys/time.yaml
index 2a80ee334f8f9..6aeb75fcece68 100644
--- a/libc/include/sys/time.yaml
+++ b/libc/include/sys/time.yaml
@@ -1,6 +1,8 @@
 header: sys/time.h
 standards:
   - posix
+merge_yaml_files:
+  - select-time.yaml
 macros:
   - macro_name: ITIMER_REAL
     macro_header: sys-time-macros.h
@@ -11,8 +13,9 @@ macros:
   - macro_name: timeradd
     macro_header: sys-time-macros.h
 types:
-  - type_name: struct_timeval
   - type_name: struct_itimerval
+  - type_name: suseconds_t
+  - type_name: time_t
 enums: []
 objects: []
 functions:
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index c346902359aec..778f3f67eceee 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -233,11 +233,17 @@ LLVM_LIBC_HEADERS = [
     libc_header_info("sys/mman"),
     libc_header_info("sys/random"),
     libc_header_info("sys/resource"),
-    libc_header_info("sys/select"),
+    libc_header_info(
+        "sys/select",
+        other_srcs = ["include/sys/select-time.yaml"],
+    ),
     libc_header_info("sys/socket"),
     libc_header_info("sys/stat"),
     libc_header_info("sys/statvfs"),
-    libc_header_info("sys/time"),
+    libc_header_info(
+        "sys/time",
+        other_srcs = ["include/sys/select-time.yaml"],
+    ),
     libc_header_info("sys/types"),
     libc_header_info("sys/utsname"),
     libc_header_info("sys/wait"),



More information about the libc-commits mailing list