* [PATCH 0/2] tools/nolibc: introduce poll.h
@ 2025-04-30 9:35 Thomas Weißschuh
2025-04-30 9:35 ` [PATCH 1/2] tools/nolibc: move poll() to poll.h Thomas Weißschuh
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Thomas Weißschuh @ 2025-04-30 9:35 UTC (permalink / raw)
To: Willy Tarreau, Thomas Weißschuh; +Cc: linux-kernel, Thomas Weißschuh
Move poll() to the standard poll.h and drop the custom related definitions.
This also allows to drop an iffy workaround from the nolibc next branch:
e1896bb9e079 ("selftests: harness: Guard includes on nolibc")
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
Thomas Weißschuh (2):
tools/nolibc: move poll() to poll.h
tools/nolibc: use poll-related definitions from UAPI headers
tools/include/nolibc/Makefile | 1 +
tools/include/nolibc/nolibc.h | 1 +
tools/include/nolibc/poll.h | 55 +++++++++++++++++++++++++++++++++++++++++++
tools/include/nolibc/sys.h | 37 -----------------------------
tools/include/nolibc/types.h | 14 -----------
5 files changed, 57 insertions(+), 51 deletions(-)
---
base-commit: e1896bb9e07948b4825883cbc3ca37cf59e17578
change-id: 20250430-poll-75dc16e95639
Best regards,
--
Thomas Weißschuh <thomas.weissschuh@linutronix.de>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] tools/nolibc: move poll() to poll.h
2025-04-30 9:35 [PATCH 0/2] tools/nolibc: introduce poll.h Thomas Weißschuh
@ 2025-04-30 9:35 ` Thomas Weißschuh
2025-04-30 9:35 ` [PATCH 2/2] tools/nolibc: use poll-related definitions from UAPI headers Thomas Weißschuh
2025-05-11 18:43 ` [PATCH 0/2] tools/nolibc: introduce poll.h Willy Tarreau
2 siblings, 0 replies; 4+ messages in thread
From: Thomas Weißschuh @ 2025-04-30 9:35 UTC (permalink / raw)
To: Willy Tarreau, Thomas Weißschuh; +Cc: linux-kernel, Thomas Weißschuh
This is the location regular userspace expects the definition.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
tools/include/nolibc/Makefile | 1 +
tools/include/nolibc/nolibc.h | 1 +
tools/include/nolibc/poll.h | 55 +++++++++++++++++++++++++++++++++++++++++++
tools/include/nolibc/sys.h | 37 -----------------------------
4 files changed, 57 insertions(+), 37 deletions(-)
diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile
index 41ef18872a7e9435a5efec9c0b32b9e29fcd4ce8..3ad6ac3fde0aed8eac12ed944c06015bbccde6f1 100644
--- a/tools/include/nolibc/Makefile
+++ b/tools/include/nolibc/Makefile
@@ -36,6 +36,7 @@ all_files := \
getopt.h \
limits.h \
nolibc.h \
+ poll.h \
signal.h \
stackprotector.h \
std.h \
diff --git a/tools/include/nolibc/nolibc.h b/tools/include/nolibc/nolibc.h
index d1b949e094eeb7cc0fe875deeafa4c972ecf35b2..05a4bd5fba8bab9b6f896e617f73c49e30a1242e 100644
--- a/tools/include/nolibc/nolibc.h
+++ b/tools/include/nolibc/nolibc.h
@@ -114,6 +114,7 @@
#include "dirent.h"
#include "fcntl.h"
#include "getopt.h"
+#include "poll.h"
/* Used by programs to avoid std includes */
#define NOLIBC
diff --git a/tools/include/nolibc/poll.h b/tools/include/nolibc/poll.h
new file mode 100644
index 0000000000000000000000000000000000000000..be6e44fe022d9e8f196821c6c5eb6d0a56e8aacb
--- /dev/null
+++ b/tools/include/nolibc/poll.h
@@ -0,0 +1,55 @@
+/* SPDX-License-Identifier: LGPL-2.1 OR MIT */
+/*
+ * poll definitions for NOLIBC
+ * Copyright (C) 2017-2021 Willy Tarreau <w@1wt.eu>
+ */
+
+/* make sure to include all global symbols */
+#include "nolibc.h"
+
+#ifndef _NOLIBC_POLL_H
+#define _NOLIBC_POLL_H
+
+#include "arch.h"
+#include "types.h"
+#include "sys.h"
+
+#include <linux/time.h>
+
+/*
+ * int poll(struct pollfd *fds, int nfds, int timeout);
+ */
+
+static __attribute__((unused))
+int sys_poll(struct pollfd *fds, int nfds, int timeout)
+{
+#if defined(__NR_ppoll)
+ struct timespec t;
+
+ if (timeout >= 0) {
+ t.tv_sec = timeout / 1000;
+ t.tv_nsec = (timeout % 1000) * 1000000;
+ }
+ return my_syscall5(__NR_ppoll, fds, nfds, (timeout >= 0) ? &t : NULL, NULL, 0);
+#elif defined(__NR_ppoll_time64)
+ struct __kernel_timespec t;
+
+ if (timeout >= 0) {
+ t.tv_sec = timeout / 1000;
+ t.tv_nsec = (timeout % 1000) * 1000000;
+ }
+ return my_syscall5(__NR_ppoll_time64, fds, nfds, (timeout >= 0) ? &t : NULL, NULL, 0);
+#elif defined(__NR_poll)
+ return my_syscall3(__NR_poll, fds, nfds, timeout);
+#else
+ return __nolibc_enosys(__func__, fds, nfds, timeout);
+#endif
+}
+
+static __attribute__((unused))
+int poll(struct pollfd *fds, int nfds, int timeout)
+{
+ return __sysret(sys_poll(fds, nfds, timeout));
+}
+
+#endif /* _NOLIBC_POLL_H */
diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h
index 68e60e6742114a5422c8afef56a67415ed652c2f..5733fe54911dca44c7423951ff85fb166d95c06f 100644
--- a/tools/include/nolibc/sys.h
+++ b/tools/include/nolibc/sys.h
@@ -766,43 +766,6 @@ int pivot_root(const char *new, const char *old)
}
-/*
- * int poll(struct pollfd *fds, int nfds, int timeout);
- */
-
-static __attribute__((unused))
-int sys_poll(struct pollfd *fds, int nfds, int timeout)
-{
-#if defined(__NR_ppoll)
- struct timespec t;
-
- if (timeout >= 0) {
- t.tv_sec = timeout / 1000;
- t.tv_nsec = (timeout % 1000) * 1000000;
- }
- return my_syscall5(__NR_ppoll, fds, nfds, (timeout >= 0) ? &t : NULL, NULL, 0);
-#elif defined(__NR_ppoll_time64)
- struct __kernel_timespec t;
-
- if (timeout >= 0) {
- t.tv_sec = timeout / 1000;
- t.tv_nsec = (timeout % 1000) * 1000000;
- }
- return my_syscall5(__NR_ppoll_time64, fds, nfds, (timeout >= 0) ? &t : NULL, NULL, 0);
-#elif defined(__NR_poll)
- return my_syscall3(__NR_poll, fds, nfds, timeout);
-#else
- return __nolibc_enosys(__func__, fds, nfds, timeout);
-#endif
-}
-
-static __attribute__((unused))
-int poll(struct pollfd *fds, int nfds, int timeout)
-{
- return __sysret(sys_poll(fds, nfds, timeout));
-}
-
-
/*
* ssize_t read(int fd, void *buf, size_t count);
*/
--
2.49.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] tools/nolibc: use poll-related definitions from UAPI headers
2025-04-30 9:35 [PATCH 0/2] tools/nolibc: introduce poll.h Thomas Weißschuh
2025-04-30 9:35 ` [PATCH 1/2] tools/nolibc: move poll() to poll.h Thomas Weißschuh
@ 2025-04-30 9:35 ` Thomas Weißschuh
2025-05-11 18:43 ` [PATCH 0/2] tools/nolibc: introduce poll.h Willy Tarreau
2 siblings, 0 replies; 4+ messages in thread
From: Thomas Weißschuh @ 2025-04-30 9:35 UTC (permalink / raw)
To: Willy Tarreau, Thomas Weißschuh; +Cc: linux-kernel, Thomas Weißschuh
The UAPI headers already provide definitions for these symbols.
Using them makes the code shorter, more robust and compatible with
applications using linux/poll.h directly.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
tools/include/nolibc/poll.h | 2 +-
tools/include/nolibc/types.h | 14 --------------
2 files changed, 1 insertion(+), 15 deletions(-)
diff --git a/tools/include/nolibc/poll.h b/tools/include/nolibc/poll.h
index be6e44fe022d9e8f196821c6c5eb6d0a56e8aacb..1765acb17ea01ff53cbad0b4750e4938446b6a45 100644
--- a/tools/include/nolibc/poll.h
+++ b/tools/include/nolibc/poll.h
@@ -11,9 +11,9 @@
#define _NOLIBC_POLL_H
#include "arch.h"
-#include "types.h"
#include "sys.h"
+#include <linux/poll.h>
#include <linux/time.h>
/*
diff --git a/tools/include/nolibc/types.h b/tools/include/nolibc/types.h
index fe97953d16572db3e4c18cdc8921c6a991d64f94..70f20519ebf908b90c242b5ff71d05364fa89f2f 100644
--- a/tools/include/nolibc/types.h
+++ b/tools/include/nolibc/types.h
@@ -159,20 +159,6 @@ typedef struct {
__set->fds[__idx] = 0; \
} while (0)
-/* for poll() */
-#define POLLIN 0x0001
-#define POLLPRI 0x0002
-#define POLLOUT 0x0004
-#define POLLERR 0x0008
-#define POLLHUP 0x0010
-#define POLLNVAL 0x0020
-
-struct pollfd {
- int fd;
- short int events;
- short int revents;
-};
-
/* for getdents64() */
struct linux_dirent64 {
uint64_t d_ino;
--
2.49.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] tools/nolibc: introduce poll.h
2025-04-30 9:35 [PATCH 0/2] tools/nolibc: introduce poll.h Thomas Weißschuh
2025-04-30 9:35 ` [PATCH 1/2] tools/nolibc: move poll() to poll.h Thomas Weißschuh
2025-04-30 9:35 ` [PATCH 2/2] tools/nolibc: use poll-related definitions from UAPI headers Thomas Weißschuh
@ 2025-05-11 18:43 ` Willy Tarreau
2 siblings, 0 replies; 4+ messages in thread
From: Willy Tarreau @ 2025-05-11 18:43 UTC (permalink / raw)
To: Thomas Weißschuh; +Cc: Thomas Weißschuh, linux-kernel
Hi Thomas,
sorry for the delay!
On Wed, Apr 30, 2025 at 11:35:31AM +0200, Thomas Weißschuh wrote:
> Move poll() to the standard poll.h and drop the custom related definitions.
> This also allows to drop an iffy workaround from the nolibc next branch:
> e1896bb9e079 ("selftests: harness: Guard includes on nolibc")
This one will be pretty useful for a number of small programs which
try to be a bit interactive, that's nice.
Acked-by: Willy Tarreau <w@1wt.eu>
Thanks!
Willy
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-05-11 18:46 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-30 9:35 [PATCH 0/2] tools/nolibc: introduce poll.h Thomas Weißschuh
2025-04-30 9:35 ` [PATCH 1/2] tools/nolibc: move poll() to poll.h Thomas Weißschuh
2025-04-30 9:35 ` [PATCH 2/2] tools/nolibc: use poll-related definitions from UAPI headers Thomas Weißschuh
2025-05-11 18:43 ` [PATCH 0/2] tools/nolibc: introduce poll.h Willy Tarreau
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®