mkcapflags.pl 781 B

123456789101112131415161718192021222324252627282930313233343536
  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 "#ifndef _ASM_X86_CPUFEATURE_H\n";
  9. print OUT "#include <asm/cpufeature.h>\n";
  10. print OUT "#endif\n";
  11. print OUT "\n";
  12. print OUT "const char * const x86_cap_flags[NCAPINTS*32] = {\n";
  13. while (defined($line = <IN>)) {
  14. if ($line =~ /^\s*\#\s*define\s+(X86_FEATURE_(\S+))\s+(.*)$/) {
  15. $macro = $1;
  16. $feature = $2;
  17. $tail = $3;
  18. if ($tail =~ /\/\*\s*\"([^"]*)\".*\*\//) {
  19. $feature = $1;
  20. }
  21. if ($feature ne '') {
  22. printf OUT "\t%-32s = \"%s\",\n",
  23. "[$macro]", "\L$feature";
  24. }
  25. }
  26. }
  27. print OUT "};\n";
  28. close(IN);
  29. close(OUT);