From nobody Sun Feb 8 08:48:02 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BC038219314 for ; Wed, 30 Apr 2025 09:35:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746005746; cv=none; b=Ojv7whEeOPsQO6IA2/D40YqF5HOoBTmkBW9+AZAZj1LhXKbDFa56ftaO2Z1awflD7Li9/9yqNxoP86HTvVOfj1JpGVKd4w8RIh8fU/jrBOtCQCLpGcKZLPoiSPogliNKsXz15D/MLjyOcs3uhZjz2CqnKgMrt7gW1XGo95MD+AA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746005746; c=relaxed/simple; bh=Pq9BfiOdZyNySS6Oc6INFzMRWWtutsa2WXTAkUDipEo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QzxBuf/3bzeuVD8apSzk3eScmgO/F1Od/3Lftnl1GhoYd7bIM+iUxCA7AHNhgun2Plr+wtDkX2Sx0Pe4tw3ffXeaAT8uxK2tgyp+rbMJxtepUE8Jqf15nsiqAGIOleafiqfQL4gmIfH93B5OrLGRWQT5yy/KRouD05ewPStNDkY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=l4jjMu3h; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=tSVGAcA5; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="l4jjMu3h"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="tSVGAcA5" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1746005743; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QnbDKBvSHAjsGRlqJ73b13EXZeHz5vL3RyuYlFhM1I8=; b=l4jjMu3h8Fe8nf+pg38dt2BItmcqP0E/mDMGlRPAzgq9/vVmDMjBuW4fMPxR791z1rf3tw HSjmq8aBbeZHOYcGJbsW6c+s9gv6XiEJ2uKBMEYj9siSwgczRxgS+Vao6AwbHBzgqsU7xE mwDjjjnzj0fqljsyD0HiCfIt4cKhCdFcH/5Id6fsBhkuEr1914YVNqtmc8vMDz9uPjn+2D u1NnbbEmyS+KTF/dCdws16F9O3DZScTL1t727IvbsZETfvQ2ePxG1u6S7U2EkUmvb09ckT 67wOVqp/a19cQ78JThQMvd6lriO9hitDKNrif74HQEtHbnqRkpt+5IvlNRUR/g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1746005743; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QnbDKBvSHAjsGRlqJ73b13EXZeHz5vL3RyuYlFhM1I8=; b=tSVGAcA5PvXLVKU5UNAhqgMwgIT9JsGiCATADG5WjFkEJ94t3YsHl7WuFPCdMX87ZA1JX5 JIjq4XGaSz6XD6Bw== Date: Wed, 30 Apr 2025 11:35:32 +0200 Subject: [PATCH 1/2] tools/nolibc: move poll() to poll.h Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250430-poll-v1-1-44b5ceabdeee@linutronix.de> References: <20250430-poll-v1-0-44b5ceabdeee@linutronix.de> In-Reply-To: <20250430-poll-v1-0-44b5ceabdeee@linutronix.de> To: Willy Tarreau , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Cc: linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1746005742; l=4232; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=Pq9BfiOdZyNySS6Oc6INFzMRWWtutsa2WXTAkUDipEo=; b=FHOBwQNWFN7D8wHxMvYoJpYcle5xCksoDabtNSs9mmFibjrEG4S8FkC1laXRuCXivnH+MZSYA 2NTj5QSheMhCncFvWcbnw/OOU+z2PxfcOPOJJynWFFGJ4FmUu2TIjbJ X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= This is the location regular userspace expects the definition. Signed-off-by: Thomas Wei=C3=9Fschuh Acked-by: Willy Tarreau --- 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..3ad6ac3fde0aed8eac12ed944c0= 6015bbccde6f1 100644 --- a/tools/include/nolibc/Makefile +++ b/tools/include/nolibc/Makefile @@ -36,6 +36,7 @@ all_files :=3D \ 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..05a4bd5fba8bab9b6f896e617f7= 3c49e30a1242e 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" =20 /* 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..be6e44fe022d9e8f196821c6c5e= b6d0a56e8aacb --- /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 + */ + +/* 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 + +/* + * 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 >=3D 0) { + t.tv_sec =3D timeout / 1000; + t.tv_nsec =3D (timeout % 1000) * 1000000; + } + return my_syscall5(__NR_ppoll, fds, nfds, (timeout >=3D 0) ? &t : NULL, N= ULL, 0); +#elif defined(__NR_ppoll_time64) + struct __kernel_timespec t; + + if (timeout >=3D 0) { + t.tv_sec =3D timeout / 1000; + t.tv_nsec =3D (timeout % 1000) * 1000000; + } + return my_syscall5(__NR_ppoll_time64, fds, nfds, (timeout >=3D 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..5733fe54911dca44c7423951ff8= 5fb166d95c06f 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) } =20 =20 -/* - * 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 >=3D 0) { - t.tv_sec =3D timeout / 1000; - t.tv_nsec =3D (timeout % 1000) * 1000000; - } - return my_syscall5(__NR_ppoll, fds, nfds, (timeout >=3D 0) ? &t : NULL, N= ULL, 0); -#elif defined(__NR_ppoll_time64) - struct __kernel_timespec t; - - if (timeout >=3D 0) { - t.tv_sec =3D timeout / 1000; - t.tv_nsec =3D (timeout % 1000) * 1000000; - } - return my_syscall5(__NR_ppoll_time64, fds, nfds, (timeout >=3D 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); */ --=20 2.49.0 From nobody Sun Feb 8 08:48:02 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 00711231847 for ; Wed, 30 Apr 2025 09:35:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746005748; cv=none; b=nCVTneGNmkROucXw6mrPjzojrjJCdJqY3UxNpHSR0wb0doh714/avMuomNWRe+tuiX/+cgd7sJ032Hc/wpiJ3O4Hofacb0LjYD4AASqagyzfbLHvLxwD/9duF339vCQpbt0bTTNKsUH8Dge5vxo6/RtgyL1/0YjTg5fTviyKrEo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746005748; c=relaxed/simple; bh=Hsifuij714dAEdgIZ+9nKlKj8m9fKrLfKEnFbFVJ9cI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hPoz6meC4UVADF6Y8JDEGQAEVInG6GG4eWd31IRrYc0a8CvKqESK8v1p7BV7+W61G6O4yJt4Bgn2MpaRYj7b3D6d+iP+P0+9vb9/AJFhXQ2o19jAnY30QxNJG3KZcA/k26hX77dVe07Tm9JM4RIgjM05tBrYV734ytafjnNEYHU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=3p5GskwU; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=5mq4+KD1; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="3p5GskwU"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="5mq4+KD1" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1746005743; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UJNip2zXDm80B7tAkghMaJlFm8y4M4Dt4sSg4eOjKbg=; b=3p5GskwUZJvMKuPLBgoNW/xrDZaNhDPR2n5RXR6KQKDvlk9529a5AD17qzKRAMUDX/hnmB Y/JK+uoIF34h2uf8dp9II6ywFl/oXixiqbZJ/+l5B+Ty3F67PxBjd9LCgBzrseXIYCpztr qzoajifD3B3NAahyGtY85tl+XuwFYM47d9f/ycJ82kxsGZTskeHELZMi/hGKuWNFC1eaNu HB4PnHz8xC6N7l2bPUhCdcAApWy8EdXHxZ1WC9QZoz/xy2U5W9vdw1DKv5hzcoVtTrxlWK AnNPBV1ha/X26tgsknXOippclSy/zPfx2Ogkbbv3KPnIDsf8DumEJjipdzEyxg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1746005743; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UJNip2zXDm80B7tAkghMaJlFm8y4M4Dt4sSg4eOjKbg=; b=5mq4+KD1a23JEuPfm/hRiD8eILaJILMq1B7kS15L6KURnB2Z1YywQ75oP8i91IZyPN8Frv lOC80XtnnRZptPAA== Date: Wed, 30 Apr 2025 11:35:33 +0200 Subject: [PATCH 2/2] tools/nolibc: use poll-related definitions from UAPI headers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250430-poll-v1-2-44b5ceabdeee@linutronix.de> References: <20250430-poll-v1-0-44b5ceabdeee@linutronix.de> In-Reply-To: <20250430-poll-v1-0-44b5ceabdeee@linutronix.de> To: Willy Tarreau , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Cc: linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1746005742; l=1527; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=Hsifuij714dAEdgIZ+9nKlKj8m9fKrLfKEnFbFVJ9cI=; b=rVIPNb6CshHPMzMPl2oLqG9i9i2G6Dx6RX559JGeLAafjKAgbugKAw8qDSF7u1bJUxNeUkHE/ WM/fO79xzBVDTEiY/c6/EYKj+AT3HmT8IL9AqqDxG93q7HspZeV7DRH X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= 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=C3=9Fschuh Acked-by: Willy Tarreau --- 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..1765acb17ea01ff53cbad0b4750= e4938446b6a45 100644 --- a/tools/include/nolibc/poll.h +++ b/tools/include/nolibc/poll.h @@ -11,9 +11,9 @@ #define _NOLIBC_POLL_H =20 #include "arch.h" -#include "types.h" #include "sys.h" =20 +#include #include =20 /* diff --git a/tools/include/nolibc/types.h b/tools/include/nolibc/types.h index fe97953d16572db3e4c18cdc8921c6a991d64f94..70f20519ebf908b90c242b5ff71= d05364fa89f2f 100644 --- a/tools/include/nolibc/types.h +++ b/tools/include/nolibc/types.h @@ -159,20 +159,6 @@ typedef struct { __set->fds[__idx] =3D 0; \ } while (0) =20 -/* 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; --=20 2.49.0