initial commit with v3.6.7
[linux-3.6.7-moxart.git] / arch / x86 / kernel / cpu / mkcapflags.pl
blobc7b3fe2d72e0f71b94577fde23622a8797eca941
1 #!/usr/bin/perl -w
3 # Generate the x86_cap_flags[] array from include/asm-x86/cpufeature.h
6 ($in, $out) = @ARGV;
8 open(IN, "< $in\0") or die "$0: cannot open: $in: $!\n";
9 open(OUT, "> $out\0") or die "$0: cannot create: $out: $!\n";
11 print OUT "#include <asm/cpufeature.h>\n\n";
12 print OUT "const char * const x86_cap_flags[NCAPINTS*32] = {\n";
14 %features = ();
15 $err = 0;
17 while (defined($line = <IN>)) {
18 if ($line =~ /^\s*\#\s*define\s+(X86_FEATURE_(\S+))\s+(.*)$/) {
19 $macro = $1;
20 $feature = "\L$2";
21 $tail = $3;
22 if ($tail =~ /\/\*\s*\"([^"]*)\".*\*\//) {
23 $feature = "\L$1";
26 next if ($feature eq '');
28 if ($features{$feature}++) {
29 print STDERR "$in: duplicate feature name: $feature\n";
30 $err++;
32 printf OUT "\t%-32s = \"%s\",\n", "[$macro]", $feature;
35 print OUT "};\n";
37 close(IN);
38 close(OUT);
40 if ($err) {
41 unlink($out);
42 exit(1);
45 exit(0);