Commit 753e386f by Thomas Zander Committed by Christian Kern

Provide embb_core_count_available() implementation for FreeBSD

  (this probably works on MacOS too, but not tested yet)

While on it, fix error message. The missing include file
is not the root cause of the problem. The missing implementation
of embb_core_count_available() is.
parent b3cb2345
...@@ -94,12 +94,22 @@ void embb_core_set_init(embb_core_set_t* core_set, int initializer) { ...@@ -94,12 +94,22 @@ void embb_core_set_init(embb_core_set_t* core_set, int initializer) {
#ifdef EMBB_HAS_HEADER_SYSINFO #ifdef EMBB_HAS_HEADER_SYSINFO
#include <sys/sysinfo.h> #include <sys/sysinfo.h>
#endif #endif
#ifdef __FreeBSD__
#include <sys/types.h>
#include <sys/sysctl.h>
#endif
unsigned int embb_core_count_available() { unsigned int embb_core_count_available() {
#ifdef EMBB_HAS_HEADER_SYSINFO #ifdef EMBB_HAS_HEADER_SYSINFO
return get_nprocs(); return get_nprocs();
#elif defined __FreeBSD__
const size_t bs = sizeof(unsigned int);
char buf[bs];
size_t len = bs;
sysctlbyname("hw.ncpu", buf, &len, NULL, 0);
return *(unsigned int*)&buf;
#else #else
#error "No header sysinfo available!" #error "No implementation for embb_core_count_available()!"
#endif #endif
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment