From: "H. Peter Anvin (Intel)" <hpa@xxxxxxxxx>
Introduce an AWK script to auto-generate a header with required and
disabled feature masks based on <asm/cpufeatures.h> and current build
config. Thus for any CPU feature with a build config, e.g., X86_FRED,
simply add
+
+ printf "\n#define %s_MASKS ", s;
+ pfx = "{";
+ for (i = 0; i < ncapints; i++) {
+ printf "%s \\\n\t%s_MASK_%d", pfx, s, i;
+ pfx = ",";
+ }
+ printf " \\\n}\n\n";
+
+ printf "#define %s_FEATURE(x) \\\n", s;
+ printf "\t((( ";
+ for (i = 0; i < ncapints; i++) {
+ if (masks[i]) {
+ printf "\\\n\t\t((x) >> 5) == %2d ? %s_MASK%-3d : ", i, s, i;
+ }
+ }
+ printf "0 \\\n";
+ printf "\t) >> ((x) & 31)) & 1)\n\n";