From nobody Fri Dec 03 10:03:54 2021 X-Original-To: freebsd-current@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 13957188DD8C for ; Fri, 3 Dec 2021 10:04:00 +0000 (UTC) (envelope-from se@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (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 (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4J57hH5FWjz4YvM; Fri, 3 Dec 2021 10:03:59 +0000 (UTC) (envelope-from se@freebsd.org) Received: from [IPV6:2003:cd:5f26:bf00:2002:64d8:36ae:6cc] (p200300cd5f26bf00200264d836ae06cc.dip0.t-ipconnect.de [IPv6:2003:cd:5f26:bf00:2002:64d8:36ae:6cc]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: se/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id 214D7721C; Fri, 3 Dec 2021 10:03:59 +0000 (UTC) (envelope-from se@freebsd.org) Message-ID: <77845d03-6351-8a8b-2eae-1db98f8a192c@freebsd.org> Date: Fri, 3 Dec 2021 11:03:54 +0100 List-Id: Discussions about the use of FreeBSD-current List-Archive: https://lists.freebsd.org/archives/freebsd-current List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-current@freebsd.org MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: Re: [REVIEW] Hide BIT_* macros from userland code Content-Language: en-US To: Shawn Webb Cc: FreeBSD CURRENT References: <7d97e129-4aa7-aa98-dc91-e332a3da620f@freebsd.org> <20211202164648.276kuh3blin6b2wp@mutt-hbsd> From: Stefan Esser In-Reply-To: <20211202164648.276kuh3blin6b2wp@mutt-hbsd> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------7fJerW2eTavEse5JA9lhZC5g" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638525839; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Zj/+2WsQ8v6E/0iqroTTPXOv+hYyST/Uf2YMMR3OSOc=; b=odf1CHrpsNchF5ugn9RgBrc+91441kYq1A8krwHPkcll1ltdDgSZGJQY8V9uI17IA1htzZ 31w6VqA2ZlSX78aHHQGnaECYMFPHY8IHj9XKaB8ZoFnOvT69HMtPko6TWs/1h3XNCqPtDq /nDe7CtGkXeGWp9KX8ZgGdHPnabhthZVwIiZlyQ7go4sKV2klrbak4+O7MieSbsSz65dZE llTVsqkA+tZNRSEPrPTLp2MdujCszvIHYpkHn0q/RFRzmZCE6xDZm7Gb05q1lutgePTwCn V0pDg9ouxZqzYckJjOBWe4lwmcsJodHtzb8ogzhQViEG3Z+JJm6sN8Fb7YrvzA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638525839; a=rsa-sha256; cv=none; b=MNtrnI3BGfl0yJ3UzyExKuAgJLXPuODgAqTCLQo+EZnqXIocSDoTV2pmIKgpU8T/5HDhxg J6d1c9CiN0SsyFYpWQ3aQ/upOFSctZb4C1WNOP/G43frHuvCMckR1MkvPwvw1GHKloiAm2 tD61VIjsZDyJy1MTczrTu3SEGeNzFV1fSs2ulG/dd9lZCvu/jzLz2Xr2+jijVIekKLCVFN mn2cVRlOspljmvZdGaYgSQM0FAC9i3fuN9Ouwio3ynSC7QllgMq3HwYYSHnxTyhkx1ypZu TXa/OE8s1AOQ6QWUwOFPNB0RiRi19Zu20/PeZq1RjDfCDDo9AC0DzxjQv1SR6Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --------------7fJerW2eTavEse5JA9lhZC5g Content-Type: multipart/mixed; boundary="------------StiE8KZpu6BOYfw0r6NJz1bR"; protected-headers="v1" From: Stefan Esser To: Shawn Webb Cc: FreeBSD CURRENT Message-ID: <77845d03-6351-8a8b-2eae-1db98f8a192c@freebsd.org> Subject: Re: [REVIEW] Hide BIT_* macros from userland code References: <7d97e129-4aa7-aa98-dc91-e332a3da620f@freebsd.org> <20211202164648.276kuh3blin6b2wp@mutt-hbsd> In-Reply-To: <20211202164648.276kuh3blin6b2wp@mutt-hbsd> --------------StiE8KZpu6BOYfw0r6NJz1bR Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Am 02.12.21 um 17:46 schrieb Shawn Webb: > Hey Stefan, >=20 > On Thu, Dec 02, 2021 at 05:26:55PM +0100, Stefan Esser wrote: >> I have created >> >> https://reviews.freebsd.org/D33235 >> >> to remove the BIT_* macros used in the kernel from the userland API. >> >> They conflict with differing definitions in some 3rd party code and >> lead to compile issues in a number of ports (via CPU_* macros based >> on the BIT_* macros). >> >> See PR259787 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D25978= 7 >> for an example of such a problem. >=20 > I recently was in a position to evaluate BIT_* macros for userland > use. It was around the time when the conversation regarding hiding > BIT_* from userland, which conversation caused me to find another > solution. >=20 > I think such an API is incredibly useful, so I wonder if there's a way > to satisfy both. For example, maybe prefix the userland side with a > USERLAND_ or something similar? Kernel would use BIT_* and userland > would use USERLAND_BIT_* (just spitballing, not actually advocating > for "USERLAND_BIT_*" but rather just the idea of it.) Hi Shawn, I have updated the patch set in review D33235 and have added you to the reviewer list. IMHO the approach proposed by Konstantin Belousov is better than the introduction of prefixed macro names for the userland. A simple #define _WANT_FREEBSD_BITSET makes the __BIT* macros available by their traditional names, no other changes are required in the code. This does not solve the potential case of a program that wants to use both the BSD and GLIBC variants of the macros in a single source file. But I think that such a case is constructed and does not occur in actual code. And in any case, the IMHO __BIT* names are as good as the USERLAND_BIT* names you suggest (and I understand that you did not want that specific name - therefore a prefix of __ might be considered to match what you proposed ;-) ). And you are of course free to map __BIT* to any other prefixed name in a header file in your code ... An update of the bitset(9) man page might be a good idea, explaining the visibility rules and _WANT_FREEBSD_BITSET for system utilities that need to work with kernel style bitsets. Regards, STefan --------------StiE8KZpu6BOYfw0r6NJz1bR-- --------------7fJerW2eTavEse5JA9lhZC5g Content-Type: application/pgp-signature; name="OpenPGP_signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="OpenPGP_signature" -----BEGIN PGP SIGNATURE----- wsB5BAABCAAjFiEEo3HqZZwL7MgrcVMTR+u171r99UQFAmGp64sFAwAAAAAACgkQR+u171r99URv wQgApvC3nHQqyAI7klB15zMEcgRyhqc334UCgBcFBg1uJhO5r/7Iw1n+dCaTGtfedhbAzmjNnULy 8MMaDJw96+Ze023dYJy9CcM8n3aBWfV43VlhWXzysJJQl9vz4thNCRajN1n1e6iyFHQhLdi4Yres FY0JwvLCfgye6YrAJYB0zz1M42VCaM1CFFFycR081YvUykFjJnJfG49BWYnBfuHkWdlUNcinNzCV 2XHA8t/4NNjRf6xImvy9LllG6L2GDv9pXI9U8a2nmHnS/6WS/yEtDvhvE6Wxq1GO5iomOlhqc8VP BvxtbgGTuR5lJbYTBC+/ws9I9+SW5WRmLE0Bh8DEFw== =gfdj -----END PGP SIGNATURE----- --------------7fJerW2eTavEse5JA9lhZC5g--