lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250320015551.2157511-7-changyuanl@google.com>
Date: Wed, 19 Mar 2025 18:55:41 -0700
From: Changyuan Lyu <changyuanl@...gle.com>
To: linux-kernel@...r.kernel.org
Cc: graf@...zon.com, akpm@...ux-foundation.org, luto@...nel.org, 
	anthony.yznaga@...cle.com, arnd@...db.de, ashish.kalra@....com, 
	benh@...nel.crashing.org, bp@...en8.de, catalin.marinas@....com, 
	dave.hansen@...ux.intel.com, dwmw2@...radead.org, ebiederm@...ssion.com, 
	mingo@...hat.com, jgowans@...zon.com, corbet@....net, krzk@...nel.org, 
	rppt@...nel.org, mark.rutland@....com, pbonzini@...hat.com, 
	pasha.tatashin@...een.com, hpa@...or.com, peterz@...radead.org, 
	ptyadav@...zon.de, robh+dt@...nel.org, robh@...nel.org, saravanak@...gle.com, 
	skinsburskii@...ux.microsoft.com, rostedt@...dmis.org, tglx@...utronix.de, 
	thomas.lendacky@....com, usama.arif@...edance.com, will@...nel.org, 
	devicetree@...r.kernel.org, kexec@...ts.infradead.org, 
	linux-arm-kernel@...ts.infradead.org, linux-doc@...r.kernel.org, 
	linux-mm@...ck.org, x86@...nel.org, Changyuan Lyu <changyuanl@...gle.com>
Subject: [PATCH v5 06/16] hashtable: add macro HASHTABLE_INIT

Similar to HLIST_HEAD_INIT, HASHTABLE_INIT allows a hashtable embedded
in another structure to be initialized at compile time.

Example,

struct tree_node {
    DECLARE_HASHTABLE(properties, 4);
    DECLARE_HASHTABLE(sub_nodes, 4);
};

static struct tree_node root_node = {
    .properties = HASHTABLE_INIT(4),
    .sub_nodes = HASHTABLE_INIT(4),
};

Signed-off-by: Changyuan Lyu <changyuanl@...gle.com>
---
 include/linux/hashtable.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/include/linux/hashtable.h b/include/linux/hashtable.h
index f6c666730b8c..27e07a436e2a 100644
--- a/include/linux/hashtable.h
+++ b/include/linux/hashtable.h
@@ -13,13 +13,14 @@
 #include <linux/hash.h>
 #include <linux/rculist.h>
 
+#define HASHTABLE_INIT(bits) { [0 ... ((1 << (bits)) - 1)] = HLIST_HEAD_INIT }
+
 #define DEFINE_HASHTABLE(name, bits)						\
-	struct hlist_head name[1 << (bits)] =					\
-			{ [0 ... ((1 << (bits)) - 1)] = HLIST_HEAD_INIT }
+	struct hlist_head name[1 << (bits)] =	HASHTABLE_INIT(bits)	\
 
 #define DEFINE_READ_MOSTLY_HASHTABLE(name, bits)				\
 	struct hlist_head name[1 << (bits)] __read_mostly =			\
-			{ [0 ... ((1 << (bits)) - 1)] = HLIST_HEAD_INIT }
+		HASHTABLE_INIT(bits)
 
 #define DECLARE_HASHTABLE(name, bits)                                   	\
 	struct hlist_head name[1 << (bits)]
-- 
2.48.1.711.g2feabab25a-goog


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ