From patchwork Mon May 29 19:57:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13258917 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7BB95C77B7E for ; Mon, 29 May 2023 19:57:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=2MVHOqo31vz5qMkS5MTNLTQE9v4DSaQ8nY13sqxv3Xo=; b=WSzsRtMje/9XQv 0FZAEel0Z6T5+965qFYdGAz2lwDbvGpUNYY/TZ/mP4wjcXuUuRsGVJygDAhyISUXZ/4++Rg5r3ZaV C5qSOYUgo/WvSuEoDQAHBPOjQ8pIEhJXRCZoOA88W/LFMJCAvSN7cSyoNfoMJ7oGCUdfp4m3K1lAR 3a4tahp4w0mD5+s7MgkadXVH8JinjP39rg5uL4Z64XhqCmdPDOe7r8Ze7XHfzNhYv9T/wKIY5U+EX p4GhiXq23OyBjX32tndfFOG5WkTrDqFeGryFmXdRzlF/xnoSG4Cz2vBzIvOJECvJ2nBFLGSfK1Uwu d5LT1Bp9pN2bGTjJlN3g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q3j06-00BZcJ-1D; Mon, 29 May 2023 19:57:54 +0000 Received: from bg4.exmail.qq.com ([43.154.54.12]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q3izz-00BZav-33 for linux-riscv@lists.infradead.org; Mon, 29 May 2023 19:57:52 +0000 X-QQ-mid: bizesmtp80t1685390254t729c4zv Received: from linux-lab-host.localdomain ( [119.123.130.80]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 30 May 2023 03:57:32 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: OXH3MF60TyUJojDygxgZs4OMGkp1TUBtXvEWJdTtHAxot7E3XnB+0jWSYs5Qa BpmJ83k0gOTutEc9dsST9cB8jNwauzivhsGGJ+WxNBuD9M9eNdiIZUiSovoSAwtJzVLUqNm 6l1RtQ45rz9J2I3WLQmOeHihNwFnMtTRziVyjB0iz59ARI+qIWT0VVbOhERipkWFJ3lGSgs z31bSq9gRuFfFjPOr/TnPG9HYs05G8i6RHx6VH+8NqisChYzoHDYOtLHXrJQ9UnnJ5xgUiG dFCN5lljhXjqrqsg4PxpyT3yteKfbL1fTzNCP55FIWq10KjWQOyKMweMhP0WyvDzHbgWZJr TFKLrgmQR/8gwTpM43kNKwXTRSuAGZdl+qjEyHibORah4Pf6S3xUE86Z/xwAHoNYlmIeKbK X-QQ-GoodBg: 0 X-BIZMAIL-ID: 9056491278207555835 From: Zhangjin Wu To: w@1wt.eu Cc: arnd@arndb.de, falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, thomas@t-8ch.de, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Subject: [PATCH v2 09/13] tools/nolibc: sys_select: add pure 64bit select Date: Tue, 30 May 2023 03:57:23 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz3a-3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230529_125748_288772_0F25FCC1 X-CRM114-Status: GOOD ( 11.66 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org It's time to provide 64bit time structs for all platforms, for y2038 is near. pselect6_time64 has been added from v4.20 and the last arch support is at least from v5.0.0. Suggested-by: Thomas Weißschuh Link: https://lore.kernel.org/linux-riscv/76a5f9a0-eec4-415a-9c5d-ac3bca4d4b0e@t-8ch.de/ Suggested-by: Arnd Bergmann Link: https://lore.kernel.org/linux-riscv/bf3e07c1-75f5-425b-9124-f3f2b230e63a@app.fastmail.com/ Signed-off-by: Zhangjin Wu --- tools/include/nolibc/arch-aarch64.h | 3 --- tools/include/nolibc/arch-loongarch.h | 3 --- tools/include/nolibc/arch-riscv.h | 3 --- tools/include/nolibc/sys.h | 25 ++++++++++--------------- 4 files changed, 10 insertions(+), 24 deletions(-) diff --git a/tools/include/nolibc/arch-aarch64.h b/tools/include/nolibc/arch-aarch64.h index 11f294a406b7..53255a3a326f 100644 --- a/tools/include/nolibc/arch-aarch64.h +++ b/tools/include/nolibc/arch-aarch64.h @@ -47,10 +47,7 @@ struct sys_stat_struct { * - the arguments are cast to long and assigned into the target registers * which are then simply passed as registers to the asm code, so that we * don't have to experience issues with register constraints. - * - * On aarch64, select() is not implemented so we have to use pselect6(). */ -#define __ARCH_WANT_SYS_PSELECT6 #define my_syscall0(num) \ ({ \ diff --git a/tools/include/nolibc/arch-loongarch.h b/tools/include/nolibc/arch-loongarch.h index ad3f266e7093..973fdca96651 100644 --- a/tools/include/nolibc/arch-loongarch.h +++ b/tools/include/nolibc/arch-loongarch.h @@ -18,10 +18,7 @@ * - the arguments are cast to long and assigned into the target * registers which are then simply passed as registers to the asm code, * so that we don't have to experience issues with register constraints. - * - * On LoongArch, select() is not implemented so we have to use pselect6(). */ -#define __ARCH_WANT_SYS_PSELECT6 #define my_syscall0(num) \ ({ \ diff --git a/tools/include/nolibc/arch-riscv.h b/tools/include/nolibc/arch-riscv.h index a2e8564e66d6..713eb9d2c91d 100644 --- a/tools/include/nolibc/arch-riscv.h +++ b/tools/include/nolibc/arch-riscv.h @@ -53,10 +53,7 @@ struct sys_stat_struct { * - the arguments are cast to long and assigned into the target * registers which are then simply passed as registers to the asm code, * so that we don't have to experience issues with register constraints. - * - * On riscv, select() is not implemented so we have to use pselect6(). */ -#define __ARCH_WANT_SYS_PSELECT6 #define my_syscall0(num) \ ({ \ diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index 1b3675d4c5fc..db648b5b9a1c 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -1046,28 +1046,23 @@ int sched_yield(void) static __attribute__((unused)) int sys_select(int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *timeout) { -#if defined(__ARCH_WANT_SYS_OLD_SELECT) && !defined(__NR__newselect) - struct sel_arg_struct { - unsigned long n; - fd_set *r, *w, *e; - struct timeval *t; - } arg = { .n = nfds, .r = rfds, .w = wfds, .e = efds, .t = timeout }; - return my_syscall1(__NR_select, &arg); -#elif defined(__ARCH_WANT_SYS_PSELECT6) && defined(__NR_pselect6) +#if defined(__NR_pselect6) || defined(__NR_pselect6_time64) +#ifdef __NR_pselect6_time64 + const long nr_pselect = __NR_pselect6_time64; +#elif __SIZEOF_LONG__ == 8 + const long nr_pselect = __NR_pselect6; +#else +#error No __NR_pselect6_time64 defined, cannot implement time64 sys_select() +#endif struct timespec t; if (timeout) { t.tv_sec = timeout->tv_sec; t.tv_nsec = timeout->tv_usec * 1000; } - return my_syscall6(__NR_pselect6, nfds, rfds, wfds, efds, timeout ? &t : NULL, NULL); -#elif defined(__NR__newselect) || defined(__NR_select) -#ifndef __NR__newselect -#define __NR__newselect __NR_select -#endif - return my_syscall5(__NR__newselect, nfds, rfds, wfds, efds, timeout); + return my_syscall6(nr_pselect, nfds, rfds, wfds, efds, timeout ? &t : NULL, NULL); #else -#error None of __NR_select, __NR_pselect6, nor __NR__newselect defined, cannot implement sys_select() +#error Neither __NR_pselect6 nor __NR_pselect6_time64 defined, cannot implement sys_select() #endif }