int main(int argc, char *argv[]) { NaClCPUFeaturesX86 fv; NaClCPUData cpu_data; int feature_id; NaClCPUDataGet(&cpu_data); NaClGetCurrentCPUFeatures(&fv); if (NaClArchSupported(&fv)) { printf("This is a native client %d-bit %s compatible computer\n", NACL_TARGET_SUBARCH, GetCPUIDString(&cpu_data)); } else { if (!fv.arch_features.f_cpuid_supported) { printf("Computer doesn't support CPUID\n"); } if (!fv.arch_features.f_cpu_supported) { printf("Computer id %s is not supported\n", GetCPUIDString(&cpu_data)); } } printf("This processor has:\n"); for (feature_id = 0; feature_id < NaClCPUFeature_Max; ++feature_id) { if (NaClGetCPUFeature(&fv, feature_id)) printf(" %s\n", NaClGetCPUFeatureName(feature_id)); } return 0; }
void NaClInitSwitchToApp(struct NaClApp *nap) { NaClCPUFeaturesX86 cpu_features; UNREFERENCED_PARAMETER(nap); /* * TODO(mcgrathr): This call is repeated in platform qualification and * in every application of the validator. It would be more efficient * to do it once and then reuse the same data. */ NaClGetCurrentCPUFeatures(&cpu_features); if (NaClGetCPUFeature(&cpu_features, NaClCPUFeature_AVX)) { NaClSwitch = NaClSwitchAVX; } else { NaClSwitch = NaClSwitchSSE; } }