[PATCH 7/9] arm64: sysreg: Reject a macro name defined twice

Fuad Tabba fuad.tabba at linux.dev
Sun Nov 22 23:52:17 PST 2026


The generator rejects a duplicate register, SysregFields block, prefix
or enum value, but not two definitions of the same macro. Two fields
called F in REG make it emit REG_F twice with different masks, which the
compiler reports only as a redefinition warning against the generated
header, in every file that includes it. Two values of one enum sharing a
name do the same, and so do names that collide only once the generator
joins them: a field A_B beside value B of field A, a field F_MASK beside
F, or a field B_C in FOO beside a field C in FOO_B.

Record every macro name the generator defines, and fail on the second
definition. This covers a duplicate block or prefix too, but their own
checks stay, since they report the duplicate at the block's own line, by
block name.

Signed-off-by: Fuad Tabba <fuad.tabba at linux.dev>
---
 arch/arm64/tools/gen-sysreg.awk | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm64/tools/gen-sysreg.awk b/arch/arm64/tools/gen-sysreg.awk
index cde526896ed96..0bd6aab8aae0f 100755
--- a/arch/arm64/tools/gen-sysreg.awk
+++ b/arch/arm64/tools/gen-sysreg.awk
@@ -46,6 +46,10 @@ function expect_fields(nf) {
 # Print a CPP macro definition, padded with spaces so that the macro bodies
 # line up in a column
 function define(prefix, name, val) {
+	if ((prefix name) in defined_macros)
+		fatal("Duplicate macro " prefix name)
+	defined_macros[prefix name] = 1
+
 	printf "%-56s%s\n", "#define " prefix name, val
 }
 
-- 
2.47.3




More information about the linux-arm-kernel mailing list