kore

Kore is a web application platform for writing scalable, concurrent web based processes in C or Python.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit 3eb3665600296ac75e852aeef0514b3c4035bc4f
parent 659e19f92f4e4e5584c62f72aefa2ba07562ad53
Author: Joris Vink <joris@coders.se>
Date:   Sun, 28 Jul 2013 19:21:49 +0200

Detect right amount of cpu's available under osx. From Vaibhav Bhembre via github.

Diffstat:
src/bsd.c | 19+++++++++++++++++++
1 file changed, 19 insertions(+), 0 deletions(-)

diff --git a/src/bsd.c b/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