Commit | Line | Data |
---|---|---|
1b6b7c9f | 1 | #!/usr/bin/perl -w |
7414aa41 PA |
2 | # |
3 | # Generate the x86_cap_flags[] array from include/asm-x86/cpufeature.h | |
4 | # | |
5 | ||
6 | ($in, $out) = @ARGV; | |
7 | ||
8 | open(IN, "< $in\0") or die "$0: cannot open: $in: $!\n"; | |
9 | open(OUT, "> $out\0") or die "$0: cannot create: $out: $!\n"; | |
10 | ||
11 | print OUT "#include <asm/cpufeature.h>\n\n"; | |
12 | print OUT "const char * const x86_cap_flags[NCAPINTS*32] = {\n"; | |
13 | ||
55f6cb9d PA |
14 | %features = (); |
15 | $err = 0; | |
16 | ||
7414aa41 PA |
17 | while (defined($line = <IN>)) { |
18 | if ($line =~ /^\s*\#\s*define\s+(X86_FEATURE_(\S+))\s+(.*)$/) { | |
19 | $macro = $1; | |
55f6cb9d | 20 | $feature = "\L$2"; |
7414aa41 PA |
21 | $tail = $3; |
22 | if ($tail =~ /\/\*\s*\"([^"]*)\".*\*\//) { | |
55f6cb9d | 23 | $feature = "\L$1"; |
7414aa41 PA |
24 | } |
25 | ||
55f6cb9d PA |
26 | next if ($feature eq ''); |
27 | ||
28 | if ($features{$feature}++) { | |
29 | print STDERR "$in: duplicate feature name: $feature\n"; | |
30 | $err++; | |
7414aa41 | 31 | } |
1b6b7c9f | 32 | printf OUT "\t%-32s = \"%s\",\n", "[$macro]", $feature; |
7414aa41 PA |
33 | } |
34 | } | |
35 | print OUT "};\n"; | |
36 | ||
37 | close(IN); | |
38 | close(OUT); | |
55f6cb9d PA |
39 | |
40 | if ($err) { | |
41 | unlink($out); | |
42 | exit(1); | |
43 | } | |
44 | ||
45 | exit(0); |