Skip to content

Commit 8e35b3d

Browse files
[libc][POSIX][poll.h] implement poll (#125118)
Simple syscall. Fixes: #124647
1 parent b4d547a commit 8e35b3d

27 files changed

+402
-22
lines changed

libc/config/linux/aarch64/entrypoints.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ set(TARGET_LIBC_ENTRYPOINTS
3232
libc.src.fcntl.open
3333
libc.src.fcntl.openat
3434

35+
# poll.h entrypoints
36+
libc.src.poll.poll
37+
3538
# sched.h entrypoints
3639
libc.src.sched.sched_get_priority_max
3740
libc.src.sched.sched_get_priority_min

libc/config/linux/aarch64/headers.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,31 @@ set(TARGET_PUBLIC_HEADERS
88
libc.include.features
99
libc.include.fenv
1010
libc.include.float
11-
libc.include.stdint
1211
libc.include.inttypes
1312
libc.include.limits
1413
libc.include.link
1514
libc.include.malloc
1615
libc.include.math
16+
libc.include.poll
1717
libc.include.pthread
18+
libc.include.search
1819
libc.include.signal
19-
libc.include.stdckdint
2020
libc.include.stdbit
21+
libc.include.stdckdint
22+
libc.include.stdint
2123
libc.include.stdio
2224
libc.include.stdlib
2325
libc.include.string
2426
libc.include.strings
25-
libc.include.search
2627
libc.include.sys_mman
2728
libc.include.sys_socket
2829
libc.include.sys_syscall
2930
libc.include.sys_time
3031
libc.include.threads
3132
libc.include.time
33+
libc.include.uchar
3234
libc.include.unistd
3335
libc.include.wchar
34-
libc.include.uchar
3536

3637
libc.include.sys_ioctl
3738
# Disabled due to epoll_wait syscalls not being available on this platform.

libc/config/linux/arm/entrypoints.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ set(TARGET_LIBC_ENTRYPOINTS
2020
# errno.h entrypoints
2121
libc.src.errno.errno
2222

23+
# poll.h entrypoints
24+
libc.src.poll.poll
25+
2326
# string.h entrypoints
2427
libc.src.string.memccpy
2528
libc.src.string.memchr

libc/config/linux/riscv/entrypoints.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ set(TARGET_LIBC_ENTRYPOINTS
3232
libc.src.fcntl.open
3333
libc.src.fcntl.openat
3434

35+
# poll.h entrypoints
36+
libc.src.poll.poll
37+
3538
# sched.h entrypoints
3639
libc.src.sched.sched_get_priority_max
3740
libc.src.sched.sched_get_priority_min

libc/config/linux/x86_64/entrypoints.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ set(TARGET_LIBC_ENTRYPOINTS
3232
libc.src.fcntl.open
3333
libc.src.fcntl.openat
3434

35+
# poll.h entrypoints
36+
libc.src.poll.poll
37+
3538
# sched.h entrypoints
3639
libc.src.sched.sched_get_priority_max
3740
libc.src.sched.sched_get_priority_min
Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
set(TARGET_PUBLIC_HEADERS
2+
libc.include.arpa_inet
23
libc.include.assert
34
libc.include.complex
45
libc.include.ctype
@@ -10,35 +11,27 @@ set(TARGET_PUBLIC_HEADERS
1011
libc.include.features
1112
libc.include.fenv
1213
libc.include.float
13-
libc.include.stdint
1414
libc.include.inttypes
1515
libc.include.limits
1616
libc.include.link
17+
libc.include.locale
1718
libc.include.malloc
1819
libc.include.math
20+
libc.include.poll
1921
libc.include.pthread
2022
libc.include.sched
23+
libc.include.search
24+
libc.include.setjmp
2125
libc.include.signal
2226
libc.include.spawn
23-
libc.include.setjmp
24-
libc.include.stdckdint
2527
libc.include.stdbit
28+
libc.include.stdckdint
2629
libc.include.stdfix
30+
libc.include.stdint
2731
libc.include.stdio
2832
libc.include.stdlib
2933
libc.include.string
3034
libc.include.strings
31-
libc.include.search
32-
libc.include.termios
33-
libc.include.threads
34-
libc.include.time
35-
libc.include.unistd
36-
libc.include.wchar
37-
libc.include.uchar
38-
libc.include.locale
39-
40-
libc.include.arpa_inet
41-
4235
libc.include.sys_auxv
4336
libc.include.sys_epoll
4437
libc.include.sys_ioctl
@@ -56,4 +49,10 @@ set(TARGET_PUBLIC_HEADERS
5649
libc.include.sys_types
5750
libc.include.sys_utsname
5851
libc.include.sys_wait
52+
libc.include.termios
53+
libc.include.threads
54+
libc.include.time
55+
libc.include.uchar
56+
libc.include.unistd
57+
libc.include.wchar
5958
)

libc/hdr/types/CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,3 +342,19 @@ add_proxy_header_library(
342342
libc.include.llvm-libc-types.struct_iovec
343343
libc.include.sys_uio
344344
)
345+
346+
add_proxy_header_library(
347+
nfds_t
348+
HDRS
349+
nfds_t.h
350+
FULL_BUILD_DEPENDS
351+
libc.include.llvm-libc-types.nfds_t
352+
)
353+
354+
add_proxy_header_library(
355+
struct_pollfd
356+
HDRS
357+
struct_pollfd.h
358+
FULL_BUILD_DEPENDS
359+
libc.include.llvm-libc-types.struct_pollfd
360+
)

libc/hdr/types/nfds_t.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//===-- Definition of nfds_t ----------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//
8+
//===----------------------------------------------------------------------===//
9+
10+
#ifndef LLVM_LIBC_HDR_TYPES_NFDS_T_H
11+
#define LLVM_LIBC_HDR_TYPES_NFDS_T_H
12+
13+
#ifdef LIBC_FULL_BUILD
14+
15+
#include "include/llvm-libc-types/nfds_t.h"
16+
17+
#else // overlay mode
18+
19+
#include <poll.h>
20+
21+
#endif // LLVM_LIBC_FULL_BUILD
22+
23+
#endif // LLVM_LIBC_HDR_TYPES_NFDS_T_H

libc/hdr/types/struct_pollfd.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//===-- Definition of struct pollfd ---------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//
8+
//===----------------------------------------------------------------------===//
9+
10+
#ifndef LLVM_LIBC_HDR_TYPES_STRUCT_POLLFD_H
11+
#define LLVM_LIBC_HDR_TYPES_STRUCT_POLLFD_H
12+
13+
#ifdef LIBC_FULL_BUILD
14+
15+
#include "include/llvm-libc-types/struct_pollfd.h"
16+
17+
#else // overlay mode
18+
19+
#include <poll.h>
20+
21+
#endif // LLVM_LIBC_FULL_BUILD
22+
23+
#endif // LLVM_LIBC_HDR_TYPES_STRUCT_POLLFD_H

libc/include/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,16 @@ add_header_macro(
704704
.llvm-libc-types.struct_lconv
705705
)
706706

707+
add_header_macro(
708+
poll
709+
../libc/include/poll.yaml
710+
poll.h
711+
DEPENDS
712+
.llvm-libc-types.struct_pollfd
713+
.llvm-libc-types.nfds_t
714+
.llvm-libc-macros.poll-macros
715+
)
716+
707717
if(NOT LLVM_LIBC_FULL_BUILD)
708718
# We don't install headers in non-fullbuild mode.
709719
return()

0 commit comments

Comments
 (0)