Skip to content

Commit 9f3854a

Browse files
[reland][libc] add epoll_wait functions (#79635)
The epoll_wait functions are syscall wrappers that were requested by upstream users. This patch adds them, as well as their header and types. The tests are currently incomplete since they require epoll_create to properly test epoll_wait. That will be added in a followup patch since this one is already very large.
1 parent 69cb99f commit 9f3854a

34 files changed

+631
-5
lines changed

libc/config/linux/aarch64/entrypoints.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,12 @@ set(TARGET_LIBC_ENTRYPOINTS
179179
# sys/auxv.h entrypoints
180180
libc.src.sys.auxv.getauxval
181181

182+
# sys/epoll.h entrypoints
183+
# Disabled due to epoll_wait syscalls not being available on this platform.
184+
# libc.src.sys.epoll.epoll_wait
185+
# libc.src.sys.epoll.epoll_pwait
186+
# libc.src.sys.epoll.epoll_pwait2
187+
182188
# termios.h entrypoints
183189
libc.src.termios.cfgetispeed
184190
libc.src.termios.cfgetospeed

libc/config/linux/aarch64/headers.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,6 @@ set(TARGET_PUBLIC_HEADERS
2525
libc.include.unistd
2626

2727
libc.include.sys_ioctl
28+
# Disabled due to epoll_wait syscalls not being available on this platform.
29+
# libc.include.sys_epoll
2830
)

libc/config/linux/api.td

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
include "config/public_api.td"
22

3-
include "spec/bsd_ext.td"
4-
include "spec/gnu_ext.td"
3+
include "spec/stdc.td"
4+
include "spec/posix.td"
55
include "spec/linux.td"
6+
include "spec/gnu_ext.td"
7+
include "spec/bsd_ext.td"
68
include "spec/llvm_libc_ext.td"
7-
include "spec/posix.td"
8-
include "spec/stdc.td"
99

1010
def AssertMacro : MacroDef<"assert"> {
1111
let Defn = [{
@@ -242,6 +242,10 @@ def SysUtsNameAPI : PublicAPI<"sys/utsname.h"> {
242242
let Types = ["struct utsname"];
243243
}
244244

245+
def SysEpollAPI : PublicAPI<"sys/epoll.h"> {
246+
let Types = ["struct epoll_event", "struct epoll_data", "sigset_t", "struct timespec"];
247+
}
248+
245249
def SpawnAPI : PublicAPI<"spawn.h"> {
246250
let Types = ["mode_t", "pid_t", "posix_spawnattr_t", "posix_spawn_file_actions_t"];
247251
}

libc/config/linux/arm/entrypoints.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,13 @@ set(TARGET_LIBC_ENTRYPOINTS
102102

103103
# sys/prctl.h entrypoints
104104
libc.src.sys.prctl.prctl
105+
106+
# sys/epoll.h entrypoints
107+
# Disabled due to epoll_wait syscalls not being available on this platform.
108+
# libc.src.sys.epoll.epoll_wait
109+
# libc.src.sys.epoll.epoll_pwait
110+
# libc.src.sys.epoll.epoll_pwait2
111+
105112
)
106113

107114
set(TARGET_LIBM_ENTRYPOINTS

libc/config/linux/arm/headers.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,7 @@ set(TARGET_PUBLIC_HEADERS
1010
libc.include.string
1111
libc.include.strings
1212
libc.include.search
13+
14+
# Disabled due to epoll_wait syscalls not being available on this platform.
15+
# libc.include.sys_epoll
1316
)

libc/config/linux/riscv/entrypoints.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,12 @@ set(TARGET_LIBC_ENTRYPOINTS
185185
# sys/auxv.h entrypoints
186186
libc.src.sys.auxv.getauxval
187187

188+
# sys/epoll.h entrypoints
189+
# Disabled due to epoll_wait syscalls not being available on this platform.
190+
# libc.src.sys.epoll.epoll_wait
191+
# libc.src.sys.epoll.epoll_pwait
192+
# libc.src.sys.epoll.epoll_pwait2
193+
188194
# termios.h entrypoints
189195
libc.src.termios.cfgetispeed
190196
libc.src.termios.cfgetospeed

libc/config/linux/riscv/headers.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ set(TARGET_PUBLIC_HEADERS
3030
libc.include.arpa_inet
3131

3232
libc.include.sys_auxv
33+
# Disabled due to epoll_wait syscalls not being available on this platform.
34+
# libc.include.sys_epoll
3335
libc.include.sys_ioctl
3436
libc.include.sys_mman
3537
libc.include.sys_prctl

libc/config/linux/syscall_numbers.h.inc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,10 @@
258258
#define SYS_epoll_pwait __NR_epoll_pwait
259259
#endif
260260

261+
#ifdef __NR_epoll_pwait2
262+
#define SYS_epoll_pwait2 __NR_epoll_pwait2
263+
#endif
264+
261265
#ifdef __NR_epoll_wait
262266
#define SYS_epoll_wait __NR_epoll_wait
263267
#endif

libc/config/linux/x86_64/entrypoints.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@ set(TARGET_LIBC_ENTRYPOINTS
143143
libc.src.stdio.scanf
144144
libc.src.stdio.fscanf
145145

146+
# sys/epoll.h entrypoints
147+
libc.src.sys.epoll.epoll_wait
148+
libc.src.sys.epoll.epoll_pwait
149+
libc.src.sys.epoll.epoll_pwait2
150+
146151
# sys/mman.h entrypoints
147152
libc.src.sys.mman.madvise
148153
libc.src.sys.mman.mmap

libc/config/linux/x86_64/headers.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ set(TARGET_PUBLIC_HEADERS
3030
libc.include.arpa_inet
3131

3232
libc.include.sys_auxv
33+
libc.include.sys_epoll
3334
libc.include.sys_ioctl
3435
libc.include.sys_mman
3536
libc.include.sys_prctl

0 commit comments

Comments
 (0)