From nobody Fri Dec 19 21:17:25 2025 X-Original-To: dev-commits-src-main@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 4dY0jf1Gf8z6KJhr for ; Fri, 19 Dec 2025 21:17:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (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 "mxrelay.nyi.freebsd.org", Issuer "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4dY0jd6BFpz3RQF for ; Fri, 19 Dec 2025 21:17:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1766179045; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=acvOcDxtFAeg/ki+FRt97W9nx/RSKsqazs68use/cNU=; b=HAguqOPuHCfPKRU7jdl9fqLHLjl1y4lvNHy+Sm2nxbUyvV+d5zP/i+ri0xE8ejT7Zwljfl r70EkqK1TQB+ffJEJl8gWaHJifPcNCmpHoN3MRvUFVaiGbPIMz7Yjj1bzVoeW4l4nd0nmO iJKvTdkYEmGHbZVyPuUUpFwgxNTBD3+tFbiq1nb8C2KlaRDgZN/xU6m1qGCMJaAQxR8hLO KSt9TfyHVis210cQ31pDksyiWL1d7gmnDPjEBVB7kg5Msgx5jvedGM1gkIGB6N4hwl6hj5 sxBaGi/QHoBG2UEPXNAaKG0paZUKYgWt/LaUJpjpk9KC+KdEjP1eu9ondNg8NQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1766179045; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=acvOcDxtFAeg/ki+FRt97W9nx/RSKsqazs68use/cNU=; b=t4NEEh4OT9AEqKnMoZR3W9tzOPHGPHCai13kfRHXtfi6dgs/lE61I33OE1TXVy12/gAQDm KxOLRPYVxAW390u3FZESLJFp+8w05DmGFz1corcEPjpZrx+FnTWgr5Kw2V0uw7LEnUn1DL CaqDEIkFWZiW/kd8tLv4vgTHtTjefCRUzudqIGOiZNoifZKHcTZH+5OHZkZGWEEqKlSi4s U1ZijWsbEecC2rsofpq1hOc1sRkAPJwn9BYjhrkJgyE2rp3PpUK3OFI3jqdX/AL5EmBM0x Ilsmaqyxuol6RQvW87YShmmacyU6noPl0qXRcEagVw04db7oDBHLVls5YG6lCw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1766179045; a=rsa-sha256; cv=none; b=i7z1hbmNjPm42RTQlvBWTJ7pN4VndTzQ4vC7rRCpYr54Sf6PYwKLkANq9KQ6QoN/LFKuX+ xFy46IxRQd/AUrb1N8PGwIdfRcpth+LsWULqK9GnKwAyy1K1pK8BXnY2Rt2IexS0Q8qyVW aVqWWJ/v/tp+YLUkdSljKkX4eakFh+LPzeWi4no7rR5KFdWp1qZT2fDfBJDMYiMWv3rLSx NiJxPhwfEHjuf6Q1jc08UGJJ6ohDM3EWZxt7NVED5FJ5+6UdHYai2ZGWfxpH1G0Yj9Aq4o yZ856k6Y3vKAxInppkuyUBW24HYvHj3a4EIwwK6I5nTKCQd9ufZE6hC4ZCcGTw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4dY0jd5c4Cz83Y for ; Fri, 19 Dec 2025 21:17:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3cec0 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 19 Dec 2025 21:17:25 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Bjoern A. Zeeb Subject: git: 27aa23cee810 - main - sys/bitcount.h: add __const_bitcount List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 27aa23cee81088b0ffa974eec9f03c654c36438e Auto-Submitted: auto-generated Date: Fri, 19 Dec 2025 21:17:25 +0000 Message-Id: <6945c0e5.3cec0.254dfc3e@gitrepo.freebsd.org> The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=27aa23cee81088b0ffa974eec9f03c654c36438e commit 27aa23cee81088b0ffa974eec9f03c654c36438e Author: Bjoern A. Zeeb AuthorDate: 2025-09-15 23:54:57 +0000 Commit: Bjoern A. Zeeb CommitDate: 2025-12-19 21:16:20 +0000 sys/bitcount.h: add __const_bitcount Add a version of __const_bitcount which can be used to get the numbers at compile-time when __builtin_popcountg() is not available (see sys/compat/linuxkpi/common/include/linux/bitops.h for LLVM before 19 and gcc before 14). Obtained from: https://reviews.freebsd.org/D50995#1174884 by obiwac Sponsored by: The FreeBSD Foundation Reviewed by: brooks, emaste Differential Revision: https://reviews.freebsd.org/D54301 --- sys/sys/bitcount.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/sys/sys/bitcount.h b/sys/sys/bitcount.h index 171425032680..919dc4be06fc 100644 --- a/sys/sys/bitcount.h +++ b/sys/sys/bitcount.h @@ -39,6 +39,28 @@ #include +#define __const_bitcount8(x) ( \ + !!((x) & (1 << 0)) + \ + !!((x) & (1 << 1)) + \ + !!((x) & (1 << 2)) + \ + !!((x) & (1 << 3)) + \ + !!((x) & (1 << 4)) + \ + !!((x) & (1 << 5)) + \ + !!((x) & (1 << 6)) + \ + !!((x) & (1 << 7))) + +#define __const_bitcount16(x) ( \ + __const_bitcount8(x) + \ + __const_bitcount8((x) >> 8)) + +#define __const_bitcount32(x) ( \ + __const_bitcount16(x) + \ + __const_bitcount16((x) >> 16)) + +#define __const_bitcount64(x) ( \ + __const_bitcount32(x) + \ + __const_bitcount32((x) >> 32)) + #ifdef __POPCNT__ #define __bitcount64(x) __builtin_popcountll((__uint64_t)(x)) #define __bitcount32(x) __builtin_popcount((__uint32_t)(x))