From nobody Wed Oct 27 01:52:21 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 5FDE91834CE8 for ; Wed, 27 Oct 2021 01:52:24 +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 4HfBX762kWz4bZg; Wed, 27 Oct 2021 01:52:23 +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 19R1qLdU012607 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Tue, 26 Oct 2021 18:52:22 -0700 (PDT) (envelope-from glebius@freebsd.org) Received: (from glebius@localhost) by cell.glebi.us (8.16.1/8.16.1/Submit) id 19R1qLhn012606; Tue, 26 Oct 2021 18:52:21 -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 18:52:21 -0700 From: Gleb Smirnoff To: kib@freebsd.org, mjg@freebsd.org, jhb@freebsd.org, jeff@freebsd.org Cc: arch@freebsd.org Subject: rwlock(9) and mutex(9) definitions Message-ID: 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 X-Rspamd-Queue-Id: 4HfBX762kWz4bZg X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [0.00 / 15.00]; local_wl_from(0.00)[freebsd.org]; ASN(0.00)[asn:27348, ipnet:162.251.186.0/24, country:US] X-ThisMailContainsUnwantedMimeParts: N Hi, [To: list constructed with help of git blame] despite manual pages describe locking functions as voids in reality some of them (not all) are preprocessor defines wrapped in "do {} while (0)". Such wraps don't really behave as a true void. For example you can not tail call them: void smartass_lock(lock, clue) { if (clue) return (rw_rlock(lock)); else return (rw_wlock(lock)); } This will fail on rw_wlock, but not on rw_rlock. However, if you have WITNESS it will compile correctly :) So, we need either make these function "static inline void" in mtx.h and rwlock.h, or wrap them in __extension__ ({ }). Btw, the latter is already done for mtx_trylock_spin() by kib in 90b581f2cc327. Of course for try-lock functions inability of tail call is a bigger issue then for voids. However, voids should be fixed as well, I believe. Your call? "static inline" or "__extension__ ({ })"? -- Gleb Smirnoff