--- libgfortran/caf/shmem/supervisor.c +++ libgfortran/caf/shmem/supervisor.c @@ -31,6 +31,13 @@ #include #include #include +#ifdef __APPLE__ +#include +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1050 || __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1050 +#include +#include +#endif +#endif #ifdef HAVE_WAIT_H #include #elif HAVE_SYS_WAIT_H @@ -74,6 +81,22 @@ num_images_char = getenv ("NUMBER_OF_PROCESSORS"); #elif defined (__hpux__) return mpctl (MPC_GETNUMSPUS, 0, 0); +#elif defined(__APPLE__) && (MAC_OS_X_VERSION_MIN_REQUIRED < 1050 || __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1050) +{ + int nm[2]; + size_t len = 4; + uint32_t count; + + nm[0] = CTL_HW; nm[1] = HW_AVAILCPU; + sysctl(nm, 2, &count, &len, NULL, 0); + + if(count < 1) { + nm[1] = HW_NCPU; + sysctl(nm, 2, &count, &len, NULL, 0); + if(count < 1) { count = 1; } + } + return count; +} #else #error "Unsupported system: No known way to get number of cores!" #endif