Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SSE detection on non-AVX CPUs #135

Merged
merged 13 commits into from
Oct 9, 2020
Prev Previous commit
Next Next commit
Completely guard OS specific parts in x86 tests
  • Loading branch information
gchatelet committed Oct 9, 2020
commit 9ed5371b0a14659492937102c1640a8da1393084
24 changes: 14 additions & 10 deletions test/cpuinfo_x86_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,6 @@ class FakeCpu {

uint32_t GetXCR0Eax() const { return xcr0_eax_; }

bool GetDarwinSysCtlByName(std::string name) const {
return darwin_sysctlbyname_.count(name);
}

bool GetWindowsIsProcessorFeaturePresent(unsigned long ProcessorFeature) {
return windows_isprocessorfeaturepresent_.count(ProcessorFeature);
}

void SetLeaves(std::map<std::pair<uint32_t, int>, Leaf> configuration) {
cpuid_leaves_ = std::move(configuration);
}
Expand All @@ -57,21 +49,33 @@ class FakeCpu {
}

#if defined(CPU_FEATURES_OS_DARWIN)
bool GetDarwinSysCtlByName(std::string name) const {
return darwin_sysctlbyname_.count(name);
}

void SetDarwinSysCtlByName(std::string name) {
darwin_sysctlbyname_.insert(name);
}
#endif // CPU_FEATURES_OS_DARWIN

#if defined(CPU_FEATURES_OS_WINDOWS)
void SetWindowsIsProcessorFeaturePresent(unsigned long ProcessorFeature) {
bool GetWindowsIsProcessorFeaturePresent(DWORD ProcessorFeature) {
return windows_isprocessorfeaturepresent_.count(ProcessorFeature);
}

void SetWindowsIsProcessorFeaturePresent(DWORD ProcessorFeature) {
windows_isprocessorfeaturepresent_.insert(ProcessorFeature);
}
#endif // CPU_FEATURES_OS_WINDOWS

private:
std::map<std::pair<uint32_t, int>, Leaf> cpuid_leaves_;
#if defined(CPU_FEATURES_OS_DARWIN)
std::set<std::string> darwin_sysctlbyname_;
std::set<unsigned> windows_isprocessorfeaturepresent_;
#endif // CPU_FEATURES_OS_DARWIN
#if defined(CPU_FEATURES_OS_WINDOWS)
std::set<unsigned long> windows_isprocessorfeaturepresent_;
gchatelet marked this conversation as resolved.
Show resolved Hide resolved
#endif // CPU_FEATURES_OS_WINDOWS
uint32_t xcr0_eax_;
};

Expand Down