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 | ||
abbf1590 DH |
11 | print OUT "#ifndef _ASM_X86_CPUFEATURE_H\n"; |
12 | print OUT "#include <asm/cpufeature.h>\n"; | |
13 | print OUT "#endif\n"; | |
14 | print OUT "\n"; | |
7414aa41 PA |
15 | print OUT "const char * const x86_cap_flags[NCAPINTS*32] = {\n"; |
16 | ||
55f6cb9d PA |
17 | %features = (); |
18 | $err = 0; | |
19 | ||
7414aa41 PA |
20 | while (defined($line = <IN>)) { |
21 | if ($line =~ /^\s*\#\s*define\s+(X86_FEATURE_(\S+))\s+(.*)$/) { | |
22 | $macro = $1; | |
55f6cb9d | 23 | $feature = "\L$2"; |
7414aa41 PA |
24 | $tail = $3; |
25 | if ($tail =~ /\/\*\s*\"([^"]*)\".*\*\//) { | |
55f6cb9d | 26 | $feature = "\L$1"; |
7414aa41 PA |
27 | } |
28 | ||
55f6cb9d PA |
29 | next if ($feature eq ''); |
30 | ||
31 | if ($features{$feature}++) { | |
32 | print STDERR "$in: duplicate feature name: $feature\n"; | |
33 | $err++; | |
7414aa41 | 34 | } |
1b6b7c9f | 35 | printf OUT "\t%-32s = \"%s\",\n", "[$macro]", $feature; |
7414aa41 PA |
36 | } |
37 | } | |
38 | print OUT "};\n"; | |
39 | ||
40 | close(IN); | |
41 | close(OUT); | |
55f6cb9d PA |
42 | |
43 | if ($err) { | |
44 | unlink($out); | |
45 | exit(1); | |
46 | } | |
47 | ||
48 | exit(0); |