mirror of https://git.kore.io/kore.git
Detect right amount of cpu's available under osx. From Vaibhav Bhembre via github.
This commit is contained in:
parent
659e19f92f
commit
3eb3665600
19
src/bsd.c
19
src/bsd.c
|
@ -17,6 +17,10 @@
|
|||
#include <sys/param.h>
|
||||
#include <sys/event.h>
|
||||
|
||||
#ifdef __MACH__
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
|
||||
#include "kore.h"
|
||||
|
||||
static int kfd = -1;
|
||||
|
@ -28,7 +32,22 @@ static u_int32_t event_count = 0;
|
|||
void
|
||||
kore_platform_init(void)
|
||||
{
|
||||
#ifndef __MACH__
|
||||
cpu_count = 0;
|
||||
#else
|
||||
long n;
|
||||
size_t len = sizeof(n);
|
||||
int mib[] = { CTL_HW, HW_AVAILCPU };
|
||||
|
||||
sysctl(mib, 2, &n, &len, NULL, 0);
|
||||
if (n < 1) {
|
||||
mib[1] = HW_NCPU;
|
||||
sysctl(mib, 2, &n, &len, NULL, 0);
|
||||
}
|
||||
|
||||
if (n >= 1)
|
||||
cpu_count = (u_int16_t)n;
|
||||
#endif /* !__MACH__ */
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in New Issue