Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp7509338rwd; Tue, 6 Jun 2023 11:45:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4eUEBZkegpGBE26e3PqUbjx8d0TTuscktKY/Ejh+UcV0YUtsx98cvU2CMrCGOiq1Esdgxk X-Received: by 2002:ac8:7d94:0:b0:3f2:a58:7a7a with SMTP id c20-20020ac87d94000000b003f20a587a7amr657874qtd.58.1686077150018; Tue, 06 Jun 2023 11:45:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686077150; cv=none; d=google.com; s=arc-20160816; b=BUDoHpzrkiqbMhyKQCwpWZPGgvMJJMLaoqIuSI6lSMMHa4cbjVwBwA1d2UKDQr01LT lxzzhIVfwb/6XV+reDYrEwxKH5V1JPePtvRbr9hGoH9N50XkWQBlzbXudymb7YIbqXHk UTEb5Bx3Fw8oKUXwSsKOnNVtsBxrcTqpj/NSAhK0qqAdEuAA4srwdmeHDnhB4rek3dBp 4tLx3CFwhwK2vswUFGxDWy2YeetFVPSEu66J1Ev4Rj7LoZiKoQ67tzcu7E4bJevW0cbw jXk1qfDGRgZ1dZAOCZWAP2x+Dq2VkyHjAfx5leMKN/TE6yon7YsfwZUq5m61giEcB9oh mKZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:dkim-signature:date; bh=2aVcHO5NypIMlRBSm7bihfosbJYkhRqAtaR27121V9c=; b=hsiZEzMfNTQZtYCm62hLFSERjm9Ag+WZFLtW/dCIdZRm0Y57kZlTdcGpgsN4ae6pAI mT+WQOvXlIm8/IjFrdlt2IiwpuRRlYR87RNDEZ6GsCFyGh3K1091W9/0ysqkI38Ovatv IQJBoE5abHDPGReD/WZr0GDJPqgGvZNtL5CHATscZlhElTKkFaULcFXu3RbrthaogJdC QDEPVJhAYCCXCimRIBjo2dCV5KdpITL6H0Uv3dwj8KhG0UXX6x7+uK1HHlDKIMh+fjEf ESIAvgasF21dqarn9Go2TfqZTaqa3xJrg5ygMcslUiIMr7zXBO8NfjO0FgEKxP7QFG/B Jv5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@t-8ch.de header.s=mail header.b=jUN+GWho; 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 g9-20020ac87f49000000b003f3875db680si1233809qtk.610.2023.06.06.11.45.35; Tue, 06 Jun 2023 11:45:50 -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; dkim=pass header.i=@t-8ch.de header.s=mail header.b=jUN+GWho; 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 S238782AbjFFShD (ORCPT + 99 others); Tue, 6 Jun 2023 14:37:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238346AbjFFShC (ORCPT ); Tue, 6 Jun 2023 14:37:02 -0400 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE88D11B; Tue, 6 Jun 2023 11:36:57 -0700 (PDT) Date: Tue, 6 Jun 2023 20:36:53 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=t-8ch.de; s=mail; t=1686076615; bh=OjRLqwrxR3FBsWW4XS2Cc09XFAFldwpVvvt9U+Wh0WI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=jUN+GWhoyrtMbFAKRDwmRGykG90E96Ekg0Tfu8T7zUUwutFn9MeQJuZ2SLG3d6UDe +LU5lzDLMfsmeBrCSWiGWbK7znlbqv0VHMFVPcppLKCCZ7dUOSXSU4kyKVpwZro48S 5oCiYmxg1TZDtAe01th4fdo17Nc0/TM9939V4HoQ= From: Thomas =?utf-8?Q?Wei=C3=9Fschuh?= To: Zhangjin Wu , w@1wt.eu Cc: arnd@arndb.de, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org Subject: Re: [PATCH v2 4/4] tools/nolibc: sys.h: apply __syscall() helper Message-ID: <7e76f099-4198-421c-8157-430201970c4c@t-8ch.de> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham 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 Zhangjin, On 2023-06-06 16:17:38+0800, Zhangjin Wu wrote: > Use __syscall() helper to shrink 252 lines of code. > > $ git show HEAD^:tools/include/nolibc/sys.h | wc -l > 1425 > $ git show HEAD:tools/include/nolibc/sys.h | wc -l > 1173 > $ echo "1425-1173" | bc -l > 252 > > Signed-off-by: Zhangjin Wu > --- > tools/include/nolibc/sys.h | 336 +++++-------------------------------- > 1 file changed, 42 insertions(+), 294 deletions(-) > > diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h > index f6e3168b3e50..0cfc5157845a 100644 > --- a/tools/include/nolibc/sys.h > +++ b/tools/include/nolibc/sys.h > @@ -108,13 +108,7 @@ int sys_chdir(const char *path) > static __attribute__((unused)) > int chdir(const char *path) > { > - int ret = sys_chdir(path); > - > - if (ret < 0) { > - SET_ERRNO(-ret); > - ret = -1; > - } > - return ret; > + return __syscall(chdir, path); To be honest I'm still not a big fan of the __syscall macro. It's a bit too magic for too little gain. The commit message argues that the patches make the code shorter. However doing __sysret(sys_chdir(path)); instead of __syscall(chdir, path); is only three characters longer and the same amout of lines. Otherwise we would have syscall() _syscall() and __syscall() each doing different things. And __syscall does not behave like a regular function. The rest of the patchset looks great. Maybe Willy can break the tie? Thomas Note: If we figure out a way to build syscall() without macros I would like that also :-)