mkcapflags.pl 700 B

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/perl
  2. #
  3. # Generate the x86_cap_flags[] array from include/asm-x86/cpufeature.h
  4. #
  5. ($in, $out) = @ARGV;
  6. open(IN, "< $in\0") or die "$0: cannot open: $in: $!\n";
  7. open(OUT, "> $out\0") or die "$0: cannot create: $out: $!\n";
  8. print OUT "#include <asm/cpufeature.h>\n\n";
  9. print OUT "const char * const x86_cap_flags[NCAPINTS*32] = {\n";
  10. while (defined($line = <IN>)) {
  11. if ($line =~ /^\s*\#\s*define\s+(X86_FEATURE_(\S+))\s+(.*)$/) {
  12. $macro = $1;
  13. $feature = $2;
  14. $tail = $3;
  15. if ($tail =~ /\/\*\s*\"([^"]*)\".*\*\//) {
  16. $feature = $1;
  17. }
  18. if ($feature ne '') {
  19. printf OUT "\t%-32s = \"%s\",\n",
  20. "[$macro]", "\L$feature";
  21. }
  22. }
  23. }
  24. print OUT "};\n";
  25. close(IN);
  26. close(OUT);