summaryrefslogtreecommitdiff
path: root/src/platform.c
blob: 5e0573e7efcf51c9ca646c661d31138a844adedc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <util.h>
#include <platform.h>

#ifdef __APPLE__
#include <sys/types.h>
#include <sys/sysctl.h>
#elif linux
#else
#error unsupported platform
#endif


#ifdef __APPLE__
int nr_cpus()
{
        int n;
        size_t size = sizeof(n);

        if (sysctlbyname("machdep.cpu.core_count", &n, &size, NULL, 0) != 0) {
                pr_err("failed to get number of cpu cores: %s\n", strerrno());
                return -1;
        }

        return n;
}
#endif