Merge tag 'firewire-updates' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee139...
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / arch / x86 / kernel / cpu / mkcapflags.pl
1 #!/usr/bin/perl -w
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
14 %features = ();
15 $err = 0;
16
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";
24 }
25
26 next if ($feature eq '');
27
28 if ($features{$feature}++) {
29 print STDERR "$in: duplicate feature name: $feature\n";
30 $err++;
31 }
32 printf OUT "\t%-32s = \"%s\",\n", "[$macro]", $feature;
33 }
34 }
35 print OUT "};\n";
36
37 close(IN);
38 close(OUT);
39
40 if ($err) {
41 unlink($out);
42 exit(1);
43 }
44
45 exit(0);