UAPI: (Scripted) Convert #include "..." to #include <path/...> in kernel system headers
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / arch / x86 / kernel / cpu / mkcapflags.pl
CommitLineData
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
8open(IN, "< $in\0") or die "$0: cannot open: $in: $!\n";
9open(OUT, "> $out\0") or die "$0: cannot create: $out: $!\n";
10
11print OUT "#include <asm/cpufeature.h>\n\n";
12print OUT "const char * const x86_cap_flags[NCAPINTS*32] = {\n";
13
55f6cb9d
PA
14%features = ();
15$err = 0;
16
7414aa41
PA
17while (defined($line = <IN>)) {
18 if ($line =~ /^\s*\#\s*define\s+(X86_FEATURE_(\S+))\s+(.*)$/) {
19 $macro = $1;
55f6cb9d 20 $feature = "\L$2";
7414aa41
PA
21 $tail = $3;
22 if ($tail =~ /\/\*\s*\"([^"]*)\".*\*\//) {
55f6cb9d 23 $feature = "\L$1";
7414aa41
PA
24 }
25
55f6cb9d
PA
26 next if ($feature eq '');
27
28 if ($features{$feature}++) {
29 print STDERR "$in: duplicate feature name: $feature\n";
30 $err++;
7414aa41 31 }
1b6b7c9f 32 printf OUT "\t%-32s = \"%s\",\n", "[$macro]", $feature;
7414aa41
PA
33 }
34}
35print OUT "};\n";
36
37close(IN);
38close(OUT);
55f6cb9d
PA
39
40if ($err) {
41 unlink($out);
42 exit(1);
43}
44
45exit(0);