UAPI: Partition the header include path sets and add uapi/ header directories
[linux-block.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 "#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";
16
17 %features = ();
18 $err = 0;
19
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";
27                 }
28
29                 next if ($feature eq '');
30
31                 if ($features{$feature}++) {
32                         print STDERR "$in: duplicate feature name: $feature\n";
33                         $err++;
34                 }
35                 printf OUT "\t%-32s = \"%s\",\n", "[$macro]", $feature;
36         }
37 }
38 print OUT "};\n";
39
40 close(IN);
41 close(OUT);
42
43 if ($err) {
44         unlink($out);
45         exit(1);
46 }
47
48 exit(0);