Linux 3.8-rc7
[cris-mirror.git] / arch / x86 / kernel / cpu / mkcapflags.pl
blob091972ef49de830c32f7547753d9ad5f5ec01f01
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 "#ifndef _ASM_X86_CPUFEATURE_H\n";
12 print OUT "#include <asm/cpufeature.h>\n";
13 print OUT "#endif\n";
14 print OUT "\n";
15 print OUT "const char * const x86_cap_flags[NCAPINTS*32] = {\n";
17 %features = ();
18 $err = 0;
20 while (defined($line = <IN>)) {
21 if ($line =~ /^\s*\#\s*define\s+(X86_FEATURE_(\S+))\s+(.*)$/) {
22 $macro = $1;
23 $feature = "\L$2";
24 $tail = $3;
25 if ($tail =~ /\/\*\s*\"([^"]*)\".*\*\//) {
26 $feature = "\L$1";
29 next if ($feature eq '');
31 if ($features{$feature}++) {
32 print STDERR "$in: duplicate feature name: $feature\n";
33 $err++;
35 printf OUT "\t%-32s = \"%s\",\n", "[$macro]", $feature;
38 print OUT "};\n";
40 close(IN);
41 close(OUT);
43 if ($err) {
44 unlink($out);
45 exit(1);
48 exit(0);