File: mkcapflags.pl

package info (click to toggle)
linux 3.2.68-1%2Bdeb7u2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 692,400 kB
  • sloc: ansic: 9,718,050; asm: 244,082; xml: 40,377; makefile: 23,842; perl: 16,079; python: 4,929; sh: 4,425; cpp: 3,596; yacc: 2,979; lex: 1,726; awk: 708; pascal: 231; lisp: 218; sed: 30
file content (32 lines) | stat: -rw-r--r-- 700 bytes parent folder | download | duplicates (5)
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
#!/usr/bin/perl
#
# Generate the x86_cap_flags[] array from include/asm-x86/cpufeature.h
#

($in, $out) = @ARGV;

open(IN, "< $in\0")   or die "$0: cannot open: $in: $!\n";
open(OUT, "> $out\0") or die "$0: cannot create: $out: $!\n";

print OUT "#include <asm/cpufeature.h>\n\n";
print OUT "const char * const x86_cap_flags[NCAPINTS*32] = {\n";

while (defined($line = <IN>)) {
	if ($line =~ /^\s*\#\s*define\s+(X86_FEATURE_(\S+))\s+(.*)$/) {
		$macro = $1;
		$feature = $2;
		$tail = $3;
		if ($tail =~ /\/\*\s*\"([^"]*)\".*\*\//) {
			$feature = $1;
		}

		if ($feature ne '') {
			printf OUT "\t%-32s = \"%s\",\n",
				"[$macro]", "\L$feature";
		}
	}
}
print OUT "};\n";

close(IN);
close(OUT);