From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from cygnus.enyo.de (cygnus.enyo.de [79.140.189.114]) by sourceware.org (Postfix) with ESMTPS id 844A03858414 for ; Sat, 24 Feb 2024 11:40:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 844A03858414 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=deneb.enyo.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=deneb.enyo.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 844A03858414 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=79.140.189.114 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708774827; cv=none; b=eoh3fH65QYyhlzJH182D2PAZv9ZzYtxIibbhtdu//hO2zsODrqREXV/eayyCshpLN/bF1hmoiEeIhO2+NMPVk2DSiYdx2GeQsdJ+GpntNP/4KfdHt6ASbmcGhS1neVoApKsk6sb3TXmzIYhF/Cx261lxTzwkYSOETlWcoW6w8wA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708774827; c=relaxed/simple; bh=+XDWIcDK5WtGN8P1TkRQaKKxMa70851seyfbzwRm+Qo=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=NB9YCgnByS03tn5FwbgyeSe4TZGOqmPtHK4rB+OgTsRS22SvqlEKkzaPElyrm7sGmxnfpykuPFny7VkCjHLp0D09MR0COAta1hfn0TWyf7qoxB1PEi+NE5lhCQrOJt4kq/V6ZROqEQZOMogJEP2ylEUy9JWvQm5V+TDeqgJm8RQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from [172.17.203.2] (port=37277 helo=deneb.enyo.de) by albireo.enyo.de ([172.17.140.2]) with esmtps (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) id 1rdqOC-0053bY-2Y; Sat, 24 Feb 2024 11:40:21 +0000 Received: from fw by deneb.enyo.de with local (Exim 4.96) (envelope-from ) id 1rdqOD-000AlM-0U; Sat, 24 Feb 2024 12:40:21 +0100 From: Florian Weimer To: Evan Green Cc: Florian Weimer , libc-alpha@sourceware.org, vineetg@rivosinc.com, slewis@rivosinc.com, palmer@rivosinc.com Subject: Re: [PATCH v12 2/7] linux: Introduce INTERNAL_VSYSCALL References: <20240214143159.2951158-1-evan@rivosinc.com> <20240214143159.2951158-3-evan@rivosinc.com> <877cj47t0f.fsf@oldenburg.str.redhat.com> Date: Sat, 24 Feb 2024 12:40:21 +0100 In-Reply-To: (Evan Green's message of "Fri, 23 Feb 2024 15:12:31 -0800") Message-ID: <87sf1iw0nu.fsf@mid.deneb.enyo.de> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00,KAM_DMARC_STATUS,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: * Evan Green: > It's kinda awkward without the label because the regular syscall is > made either if vdsop is NULL or returns ENOSYS (which is two checks on > the return value, so doesn't lend itself to inlining in the if > statement). The best I could come up with without the label is to > duplicate the syscall_call: > > #define INTERNAL_VSYSCALL(name, nr, args...) \ > ({ \ > long int sc_ret; \ > \ > __typeof (GLRO(dl_vdso_##name)) vdsop = GLRO(dl_vdso_##name); \ > if (vdsop != NULL) \ > { \ > sc_ret = INTERNAL_VSYSCALL_CALL (vdsop, nr, ##args); \ > if ((INTERNAL_SYSCALL_ERROR_P (sc_ret)) && \ > (INTERNAL_SYSCALL_ERRNO (sc_ret) == ENOSYS)) \ > sc_ret = INTERNAL_SYSCALL_CALL (name, ##args); \ > } \ > else \ > { \ > sc_ret = INTERNAL_SYSCALL_CALL (name, ##args); \ > } \ > sc_ret; \ > }) Indentation is off for me, for clarification: #define INTERNAL_VSYSCALL(name, nr, args...) \ ({ \ long int sc_ret; \ \ __typeof (GLRO(dl_vdso_##name)) vdsop = GLRO(dl_vdso_##name); \ if (vdsop != NULL) \ { \ sc_ret = INTERNAL_VSYSCALL_CALL (vdsop, nr, ##args); \ if ((INTERNAL_SYSCALL_ERROR_P (sc_ret)) && \ (INTERNAL_SYSCALL_ERRNO (sc_ret) == ENOSYS)) \ sc_ret = INTERNAL_SYSCALL_CALL (name, ##args); \ } \ else \ { \ sc_ret = INTERNAL_SYSCALL_CALL (name, ##args); \ } \ sc_ret; \ }) ?: does not work because the comparison with -ENOSYS discards the return value. Does this look correct? #define INTERNAL_VSYSCALL(name, nr, args...) \ ({ \ long int sc_ret = -ENOSYS; \ __typeof (GLRO(dl_vdso_##name)) vdsop = GLRO(dl_vdso_##name); \ if (vdsop != NULL) \ sc_ret = INTERNAL_VSYSCALL_CALL (vdsop, nr, ##args); \ if (sc_ret == -ENOSYS) \ sc_ret = INTERNAL_SYSCALL_CALL (name, ##args); \ sc_ret; \ }) I expect GCC to generate decent code for it.