-static struct {
- int feature;
- unsigned mask;
- bool use_edx; /* ecx will be used if false. */
-} features[] = {
- { CF_MMX, 1 << 23, true },
- { CF_SSE, 1 << 25, true },
- { CF_SSE2, 1 << 26, true },
- { CF_SSE3, 1 << 9, false },
- { CF_FPU, 1 << 0, true },
-
- { CF_TSC, 1 << 4, true },
- { CF_MSR, 1 << 5, true },
-
- { CF_SSSE3, 1 << 9, false },
- { CF_AVX, 1 << 28, false },
-
- /* Extended ones. */
- { CEF_x64, 1 << 30, true },
- { CEF_FPU, 1 << 0, true },
- { CEF_DE, 1 << 2, true },
- { CEF_SYSCALLRET, 1 << 11, true },
- { CEF_CMOV, 1 << 15, true },
-
- { CEF_SSE4a, 1 << 6, false },
- { CEF_FMA4, 1 << 16, false },
- { CEF_XOP, 1 << 11, false }
-};
-
-static bool has_feature(int feature, uint32_t ecx, uint32_t edx)
-{
- int i;
-
- for (i = 0; i < sizeof(features) / sizeof(features[0]); ++i) {
- if (features[i].feature == feature) {
- if (features[i].use_edx)
- return (edx & features[i].mask);
- else
- return (ecx & features[i].mask);
- }
- }
-
- return false;
-}
-