1 From: David Schleef <ds@ginger.bigkitten.com>
2 Date: Tue, 10 Jun 2008 18:48:06 +0000 (-0700)
3 Subject: [core] Check number of processors correctly on OS/X. Patch from
4 X-Git-Url: http://diracvideo.org/git?p=schroedinger.git;a=commitdiff_plain;h=7e125aa636e520393ebf8e9315d3956e399f4175
6 [core] Check number of processors correctly on OS/X. Patch from
7 Karl Rasche <karlrasche@gmail.com>
10 diff --git a/schroedinger/schroasync-pthread.c b/schroedinger/schroasync-pthread.c
11 index 3a975e0..60bf1c1 100644
12 --- a/schroedinger/schroasync-pthread.c
13 +++ b/schroedinger/schroasync-pthread.c
19 +#include <sys/sysctl.h>
25 @@ -79,14 +83,23 @@ schro_async_new(int n_threads,
30 - n_threads = sysconf(_SC_NPROCESSORS_CONF);
33 const char *s = getenv("NUMBER_OF_PROCESSORS");
38 +#elif defined __APPLE__
40 + int mib[] = {CTL_HW, HW_NCPU};
41 + size_t dataSize = sizeof(int);
43 + if (sysctl(mib, 2, &n_threads, &dataSize, NULL, 0)) {
48 + n_threads = sysconf(_SC_NPROCESSORS_CONF);