From nobody Fri Jan 16 08:49:46 2026 X-Original-To: dev-commits-src-all@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 4dstp23lYjz6P03L for ; Fri, 16 Jan 2026 08:49:46 +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 "R13" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4dstp239Pgz3W02 for ; Fri, 16 Jan 2026 08:49:46 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1768553386; 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=5Ev6k4AXZs554pPRcoEMZG9UOpZEzWN4m9zv8LcuqFY=; b=tYo8Dx/PC+ND+mKruaIFx1ZxnEZECMDrHOTFB5uw4iXpu+OQe5UINP192FCn/7LM77q5+X TEgEuBwQ8B0QPvxTtf+7H3ewxrSlz9r3+TI/oQieN3+QcZgTSYQVPse/zPdHcFWFNNiDMv LVG9CgI3lprGZSyZh0fW4r3Qp69hExlUK/j0M6rMil2eIJx+7Zh+j02tddshSMK9RCjj4m BNBsYgUnSzfdK00qHuJr65u8F1lIOisj1h+DZ10JSnfvdIOpmlBZFPJAWz8kXonMrA2AXW h00BW8Age+mS5rOj1Dixb9mZ0yTc+cApw5cn+kWEdEVqWOIrUfqzgh/29KmwDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1768553386; 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=5Ev6k4AXZs554pPRcoEMZG9UOpZEzWN4m9zv8LcuqFY=; b=dpPkqlIZIoctCq8PZQKEbS0PgbQPQ68Tati947Ug2lvwpR34Q1wMK5nLOMEow9rIEaU4g7 B30tE1DvhXcRLlB+hXhSuH9jTE85DdD8T2hX6XGgsdSNhNYRJ774icqw/OG56/fTLvhNWS X3vmsv0cwcys9oIqBEOyJ8uJm2IdL3WvjbeC+gf04qUys74wnXpysTLOWu0neUPy5DapbS pbWN+oKiA8QWO8wGFQMOw+W/kGtW0NK3eH82LAt0z0O6DV0wxV6hwlBtjdgxfI1y8zVzaP AYSTFB8Ky/it+8ohYu+aqYsJPsusA4UQsvchLJ/+cpHAMfwoRK2UPv3kNGQqpA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1768553386; a=rsa-sha256; cv=none; b=oPv2KtGxi5sPDNBKtn7/vyqCMKN0h9SF56srY8TO2xiykQrzwEEwz5zM5ykk/16bX5cqPv +CxhOU+xH1mvWIKbTQzGHRmo5yk2/scb3G+3t8RBXVMZT59yOP0nwAX6hvIaJbwkCzHAK0 a8JVOfXgWPPLx6NnBmiFapsmVHEommaEDQaTd+ja+BX+9jGBbyi+vfZCBZP69MxTxV2MQr dEVKQy5sZsYX9y4oWHPuBH6OliBfW8T/DLprzRZeVA6+cb4cHXmMaBbTeFzPMXL9HbtbNs U+bLZbftZGkBx5bwBpuuhIWyN57FqtKjAcXeG35rxtkXJgJN//Z9vcbqHS3Ivg== 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 4dstp22lcZz169g for ; Fri, 16 Jan 2026 08:49:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id c525 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 16 Jan 2026 08:49:46 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Bjoern A. Zeeb Subject: git: 605389e40b93 - stable/15 - sys/bitcount.h: add __const_bitcount List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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/stable/15 X-Git-Reftype: branch X-Git-Commit: 605389e40b938088718bd8aa75f4919884789927 Auto-Submitted: auto-generated Date: Fri, 16 Jan 2026 08:49:46 +0000 Message-Id: <6969fbaa.c525.2765b555@gitrepo.freebsd.org> The branch stable/15 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=605389e40b938088718bd8aa75f4919884789927 commit 605389e40b938088718bd8aa75f4919884789927 Author: Bjoern A. Zeeb AuthorDate: 2025-09-15 23:54:57 +0000 Commit: Bjoern A. Zeeb CommitDate: 2026-01-16 08:48:47 +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 (cherry picked from commit 27aa23cee81088b0ffa974eec9f03c654c36438e) --- 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))