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

Fails on FreeBSD: error: "Unsupported fallback detection of SSE OS support." #158

Closed
yurivict opened this issue Jun 6, 2021 · 3 comments · Fixed by #163 or #167
Closed

Fails on FreeBSD: error: "Unsupported fallback detection of SSE OS support." #158

yurivict opened this issue Jun 6, 2021 · 3 comments · Fixed by #163 or #167
Assignees
Labels
bug Something isn't working enhancement New feature or request
Milestone

Comments

@yurivict
Copy link

yurivict commented Jun 6, 2021

#error "Unsupported OS"
 ^
/wrkdirs/usr/ports/devel/volk/work/volk-2.5.0/cpu_features/src/cpuinfo_x86.c:1268:2: error: "Unsupported fallback detection of SSE OS support."
#error "Unsupported fallback detection of SSE OS support."
 ^
2 errors generated.
@Mizux Mizux added the bug Something isn't working label Jun 7, 2021
@Mizux
Copy link
Collaborator

Mizux commented Jun 7, 2021

cpu_features/src/cpuinfo_x86.c

Lines 1230 to 1274 in bc2846e

static void DetectSseViaOs(X86Features* features) {
#if defined(CPU_FEATURES_OS_WINDOWS)
// https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-isprocessorfeaturepresent
features->sse =
GetWindowsIsProcessorFeaturePresent(PF_XMMI_INSTRUCTIONS_AVAILABLE);
features->sse2 =
GetWindowsIsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE);
features->sse3 =
GetWindowsIsProcessorFeaturePresent(PF_SSE3_INSTRUCTIONS_AVAILABLE);
#elif defined(CPU_FEATURES_OS_DARWIN)
// Handling Darwin platform through sysctlbyname.
features->sse = GetDarwinSysCtlByName("hw.optional.sse");
features->sse2 = GetDarwinSysCtlByName("hw.optional.sse2");
features->sse3 = GetDarwinSysCtlByName("hw.optional.sse3");
features->ssse3 = GetDarwinSysCtlByName("hw.optional.supplementalsse3");
features->sse4_1 = GetDarwinSysCtlByName("hw.optional.sse4_1");
features->sse4_2 = GetDarwinSysCtlByName("hw.optional.sse4_2");
#elif defined(CPU_FEATURES_OS_LINUX_OR_ANDROID)
// Handling Linux platform through /proc/cpuinfo.
const int fd = CpuFeatures_OpenFile("/proc/cpuinfo");
if (fd >= 0) {
StackLineReader reader;
StackLineReader_Initialize(&reader, fd);
for (;;) {
const LineResult result = StackLineReader_NextLine(&reader);
const StringView line = result.line;
StringView key, value;
if (CpuFeatures_StringView_GetAttributeKeyValue(line, &key, &value)) {
if (CpuFeatures_StringView_IsEquals(key, str("flags"))) {
features->sse = CpuFeatures_StringView_HasWord(value, "sse");
features->sse2 = CpuFeatures_StringView_HasWord(value, "sse2");
features->sse3 = CpuFeatures_StringView_HasWord(value, "sse3");
features->ssse3 = CpuFeatures_StringView_HasWord(value, "ssse3");
features->sse4_1 = CpuFeatures_StringView_HasWord(value, "sse4_1");
features->sse4_2 = CpuFeatures_StringView_HasWord(value, "sse4_2");
break;
}
}
if (result.eof) break;
}
CpuFeatures_CloseFile(fd);
}
#else
#error "Unsupported fallback detection of SSE OS support."
#endif

@yurivict Do you know which functions/implementation we could use to support SSE detection on a FreeBSD OS ?

@Mizux Mizux added the enhancement New feature or request label Jun 7, 2021
@Mizux
Copy link
Collaborator

Mizux commented Jun 7, 2021

First it means we must detect FreeBSD OS here

#if defined(__linux__)
#define CPU_FEATURES_OS_LINUX_OR_ANDROID
#endif
#if defined(__ANDROID__)
#define CPU_FEATURES_OS_ANDROID
#endif
#if (defined(_WIN64) || defined(_WIN32))
#define CPU_FEATURES_OS_WINDOWS
#endif
#if (defined(__apple__) || defined(__APPLE__) || defined(__MACH__))
#define CPU_FEATURES_OS_DARWIN
#endif

note: https://docs.freebsd.org/en/books/porters-handbook/porting-dads/#porting-versions

@yurivict
Copy link
Author

yurivict commented Jun 7, 2021

You can detect FreeBSD with

#if defined(__FreeBSD__)
#endif 

@gchatelet gchatelet linked a pull request Jun 11, 2021 that will close this issue
@gchatelet gchatelet self-assigned this Jun 11, 2021
@gchatelet gchatelet linked a pull request Jun 30, 2021 that will close this issue
gchatelet pushed a commit that referenced this issue Jun 30, 2021
First step to fixing #158 : add a CI for FreeBSD.
@Mizux Mizux added this to the v0.7.0 milestone Nov 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
3 participants