File: gen-cpucaps.awk

package info (click to toggle)
linux 6.1.159-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,495,620 kB
  • sloc: ansic: 23,458,997; asm: 266,680; sh: 110,635; makefile: 49,889; python: 36,941; perl: 36,837; cpp: 6,055; yacc: 4,908; lex: 2,725; awk: 1,440; ruby: 25; sed: 5
file content (40 lines) | stat: -rwxr-xr-x 759 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/awk -f
# SPDX-License-Identifier: GPL-2.0
# gen-cpucaps.awk: arm64 cpucaps header generator
#
# Usage: awk -f gen-cpucaps.awk cpucaps.txt

# Log an error and terminate
function fatal(msg) {
	print "Error at line " NR ": " msg > "/dev/stderr"
	exit 1
}

# skip blank lines and comment lines
/^$/ { next }
/^#/ { next }

BEGIN {
	print "#ifndef __ASM_CPUCAPS_H"
	print "#define __ASM_CPUCAPS_H"
	print ""
	print "/* Generated file - do not edit */"
	cap_num = 0
	print ""
}

/^[vA-Z0-9_]+$/ {
	printf("#define ARM64_%-30s\t%d\n", $0, cap_num++)
	next
}

END {
	printf("#define ARM64_NCAPS\t\t\t\t%d\n", cap_num)
	print ""
	print "#endif /* __ASM_CPUCAPS_H */"
}

# Any lines not handled by previous rules are unexpected
{
	fatal("unhandled statement")
}