| 1 | --- plugins/tracers/gstrusage.c.orig 2016-11-05 11:23:32.000000000 -0700 |
| 2 | +++ plugins/tracers/gstrusage.c 2016-11-05 11:25:40.000000000 -0700 |
| 3 | @@ -39,6 +39,22 @@ |
| 4 | #include <sys/resource.h> |
| 5 | #endif |
| 6 | |
| 7 | +#ifdef __APPLE__ |
| 8 | +#ifndef __MAC_OS_X_VERSION_MIN_REQUIRED |
| 9 | +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050 |
| 10 | +#include <Availability.h> |
| 11 | +#else |
| 12 | +#include <AvailabilityMacros.h> |
| 13 | +#endif |
| 14 | +#endif |
| 15 | +#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050 |
| 16 | + |
| 17 | +#include <sys/types.h> |
| 18 | +#include <sys/sysctl.h> |
| 19 | + |
| 20 | +#endif |
| 21 | +#endif |
| 22 | + |
| 23 | GST_DEBUG_CATEGORY_STATIC (gst_rusage_debug); |
| 24 | #define GST_CAT_DEFAULT gst_rusage_debug |
| 25 | |
| 26 | @@ -274,6 +290,32 @@ |
| 27 | |
| 28 | gobject_class->finalize = gst_rusage_tracer_finalize; |
| 29 | |
| 30 | +#ifdef __APPLE__ |
| 31 | +#ifndef __MAC_OS_X_VERSION_MIN_REQUIRED |
| 32 | +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050 |
| 33 | +#include <Availability.h> |
| 34 | +#else |
| 35 | +#include <AvailabilityMacros.h> |
| 36 | +#endif |
| 37 | +#endif |
| 38 | +#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050 |
| 39 | + |
| 40 | + int nm[2]; |
| 41 | + size_t len = 4; |
| 42 | + uint32_t count; |
| 43 | + |
| 44 | + nm[0] = CTL_HW; nm[1] = HW_AVAILCPU; |
| 45 | + sysctl(nm, 2, &count, &len, NULL, 0); |
| 46 | + |
| 47 | + if (count < 1) { |
| 48 | + nm[1] = HW_NCPU; |
| 49 | + sysctl(nm, 2, &count, &len, NULL, 0); |
| 50 | + if (count < 1) { count = 1; } |
| 51 | + } |
| 52 | + num_cpus = (glong)count; |
| 53 | + |
| 54 | +#else |
| 55 | + |
| 56 | if ((num_cpus = sysconf (_SC_NPROCESSORS_ONLN)) == -1) { |
| 57 | GST_WARNING ("failed to get number of cpus online"); |
| 58 | if ((num_cpus = sysconf (_SC_NPROCESSORS_CONF)) == -1) { |
| 59 | @@ -281,6 +323,10 @@ |
| 60 | num_cpus = 1; |
| 61 | } |
| 62 | } |
| 63 | + |
| 64 | +#endif |
| 65 | +#endif |
| 66 | + |
| 67 | GST_DEBUG ("rusage: num_cpus=%ld", num_cpus); |
| 68 | |
| 69 | /* announce trace formats */ |