From nobody Wed Oct 27 04:17:27 2021 X-Original-To: arch@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 9399D182644E for ; Wed, 27 Oct 2021 04:17:29 +0000 (UTC) (envelope-from glebius@freebsd.org) Received: from cell.glebi.us (glebi.us [162.251.186.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "cell.glebi.us", Issuer "cell.glebi.us" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HfFlY15SGz3DH1; Wed, 27 Oct 2021 04:17:29 +0000 (UTC) (envelope-from glebius@freebsd.org) Received: from cell.glebi.us (localhost [127.0.0.1]) by cell.glebi.us (8.16.1/8.16.1) with ESMTPS id 19R4HRm7013172 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Tue, 26 Oct 2021 21:17:27 -0700 (PDT) (envelope-from glebius@freebsd.org) Received: (from glebius@localhost) by cell.glebi.us (8.16.1/8.16.1/Submit) id 19R4HRii013171; Tue, 26 Oct 2021 21:17:27 -0700 (PDT) (envelope-from glebius@freebsd.org) X-Authentication-Warning: cell.glebi.us: glebius set sender to glebius@freebsd.org using -f Date: Tue, 26 Oct 2021 21:17:27 -0700 From: Gleb Smirnoff To: Konstantin Belousov Cc: mjg@freebsd.org, jhb@freebsd.org, jeff@freebsd.org, arch@freebsd.org Subject: Re: rwlock(9) and mutex(9) definitions Message-ID: References: List-Id: Discussion related to FreeBSD architecture List-Archive: https://lists.freebsd.org/archives/freebsd-arch List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-arch@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 4HfFlY15SGz3DH1 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: N On Wed, Oct 27, 2021 at 05:06:52AM +0300, Konstantin Belousov wrote: K> > counters. K> K> That said, you seems to use wrong syntax for your example. Might be, it K> is enough to fix that, and not change the definition? K> K> void K> something(bool clue) K> { K> if (clue) { K> rw_rlock(lock); K> else K> rw_wlock(lock); K> } K> Both rw_rlock and rw_wlock are in tail context. You cannot _return_ void. You actually can return void to hint compiler for a tail call optimization. It is not a wrong syntax. Other code that is working with true void functions (e.g. with WITNESS) and doesn't work with "do {} while" is: void something(bool clue) { return (clue ? rw_rlock(lock) : rw_wlock(lock)); } This is explicitly allowed in 6.5.15 of the C11 standard. Of course all this code can be written in some other way, so constraint of KPI not being true functions can be worked around, but I believe better it be fixed. -- Gleb Smirnoff