Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2256938rwd; Fri, 26 May 2023 04:14:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ51qrLyoWteLRDl0p3sEMkAdAH79wIDZZBlV10OZFg7F4j9ygHNvOdreTk5wgQNPHkdB6SQ X-Received: by 2002:a05:6a20:3caa:b0:101:e4f3:5336 with SMTP id b42-20020a056a203caa00b00101e4f35336mr2009916pzj.27.1685099654715; Fri, 26 May 2023 04:14:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685099654; cv=none; d=google.com; s=arc-20160816; b=ImqzuI5x9Q15twl3PWwTaoscAgiE3rYvGfIUDMjDrLpUr1Am64WC0Tp4vo33nPsE3F AaxoZien6hPkiIlA8Xg/JwX3rbmeCJTie1qLwWbo92vXBVK/4j0GswE0JYHU7mC8QSR0 +2e0h5nSNYbsl2Z/kEUNyalaikSPsdtzbLwAqADeb1UF+3HITmJeztCVpndYk3E7+Lrl p9OhUAVHPAKapBc3S3Gt0bkXiEEHI7trr3rQ2I7/6vLe95wBHbeRhqjJz68C7v+pRf/E gU2iRbL1Kf4UH6b/fb58lh+vkuSncGItScqHVrSc2jNVzBjO7mQjaIPLuU7zfno0quIt 0/ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=XYaER4WTHqDz1pMbqYYUHG7ukKp/3rrX7l0g4VruQH4=; b=wZf1RDgIyKIY+aDRfU2VwQnCXHZaYuxFLl7FXOp8Ql5w05eJsgEpNzPQdIikdXHD8t ERpeqQ6VSPCnfELlJNzUPsEvErYOMWtF/COqEBT/2hDmButmtCLKVzm/nfkO30L6uapp sDFlG7Gqeg1pCwem8zNATNvYRWG+Jm1x/2LYGY+/ZsSqSS587nfWKl7Zc1f3ciezwpMH JCydqREmVOp0AceFqaPSKkIiqJAkmCNNnmO2CmqPemDUlHAeEHKGGBevQ0pkrbRFYXoT b/JdRhdEjJJC5b6eH08LHMs4mFQ+RPo0b9pLt8STDqjWy1L8dr1nuhAg92xPrRmLWZ/g 2UiA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b16-20020a637150000000b005346be4ead7si1325841pgn.766.2023.05.26.04.14.00; Fri, 26 May 2023 04:14:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242720AbjEZLAV (ORCPT + 99 others); Fri, 26 May 2023 07:00:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236264AbjEZLAT (ORCPT ); Fri, 26 May 2023 07:00:19 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.67.158]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3483E101; Fri, 26 May 2023 04:00:17 -0700 (PDT) X-QQ-mid: bizesmtp73t1685098803tuh3o3nn Received: from linux-lab-host.localdomain ( [119.123.130.80]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 26 May 2023 19:00:02 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: UMQM+3VOEYubwFG4eTf0xraKgpRd5gWS2yEiy7v3gdEJXjTVfMxvBDdt0o0aW 1MynBUjeWTGOOWpwfoHYEsUSf+xKPkA8TDsfcf0ZksxHbLMy1tZtGdGz3AnUOAPZzNmsIwH Pd5MxhuYRwOgOueKlRBcpnGzeOQeM+4LiFIM+NLXOsv1F4T5T8sCPnCqIT99yNWDSwt7qFh stJKJknwKPMHOePk0uTLVgAedqcqgQ6lmWDJKJkjDKohGvMYHoJEUsi8A15+fM3D5/7dmbH TfKPnKjCmO9Ge3phYQi4v6PvvbJpUJxAShi8n5IDd0lxB6s4xHOukhq+d4YO1jr3UFzwLYA XAa1E/0DiGdVqtStxOwkb43pskkqtTVoqOAXkkWTp22wG5vqQg6/iOx1ZLkYw== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 8105341843970772384 From: Zhangjin Wu To: arnd@arndb.de Cc: falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, palmer@dabbelt.com, paul.walmsley@sifive.com, thomas@t-8ch.de, w@1wt.eu Subject: Re: [PATCH 00/13] tools/nolibc: riscv: Add full rv32 support Date: Fri, 26 May 2023 19:00:01 +0800 Message-Id: <20230526110001.150368-1-falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz3a-3 X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SORTED_RECIPS,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Arnd > On Wed, May 24, 2023, at 19:59, Zhangjin Wu wrote: > > diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h > > index c0335a84f880..00c7197dcd50 100644 > > --- a/tools/include/nolibc/sys.h > > +++ b/tools/include/nolibc/sys.h > > @@ -1041,8 +1041,13 @@ int sys_select(int nfds, fd_set *rfds, fd_set > > *wfds, fd_set *efds, struct timeva > > 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) > > +#elif defined(__ARCH_WANT_SYS_PSELECT6) && (defined(__NR_pselect6) || > > defined(__NR_pselect6_time64)) > > +#ifdef __NR_pselect6 > > struct timespec t; > > +#else > > + struct timespec64 t; > > +#define __NR_pselect6 __NR_pselect6_time64 > > +#endif > > Overriding the __NR_pselect6 constant seems wrong here, this can > easily lead to more bugs, as pselect6 and pselect6_time64 are > not compatible because of the different arguments, so anything > using the constant after including sys.h will be broken. > Yes, thanks, Thomas also pointed out this issue in another reply of this message thread, it has been fixed locally with his suggestion, it looks like this: #ifdef __NR_pselect6 struct timespec t; const long nr_pselect = __NR_pselect6; #else struct timespec64 t; const long nr_pselect = __NR_pselect6_time64; #endif if (timeout) { t.tv_sec = timeout->tv_sec; t.tv_nsec = timeout->tv_usec * 1000; } return my_syscall6(nr_pselect, nfds, rfds, wfds, efds, timeout ? &t : NULL, NULL); I have applied this method for ppoll_time64 and clock_gettime64 too, this method can save several duplicated lines for us, I have prepared v2 patches locally for them. > I would just use __kernel_timespec64 unconditionally and then > use __NR_pselect6_time64 on all 32-bit architectures here, > but use __NR_pselect6 on 32-bit architectures. > The 2nd 32-bit you mean is 64-bit? This is related to the timespec64/time64_t definitions as you commented in another reply. I will learn how to use the one from , it may require to clean up the existing files in tools/include/nolibc/ at first. > I think we can also kill off the oldselect and newselect > cases, using pselect6/pselect6_time64 unconditionally here, > and no longer care about building against pre-5.1 kernel > headers, at least for the copy of nolibc that ships with the > kernel. As Willy commented in another reply, users may want to copy the recent one and use them with an old kernel, even if want to drop them, a standalone patch may be preferable. Thanks very much, Zhangjin > > Arnd