Changeset 6246

Show
Ignore:
Timestamp:
02/21/07 12:16:04
Author:
robert
Message:

From Eric Wing, implemented OSX path for GetNumberOfPrecessors() avoiding the use of Carbon API.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • OpenThreads/trunk/pthread_src/PThread.c++

    r6111 r6246  
    3434    #include <sched.h> 
    3535#endif 
    36 #if defined (__APPLE__) 
    37         #include <CoreServices/CoreServices.h> 
     36#if defined (__FreeBSD__) || defined (__APPLE__) || defined (__MACH__) 
     37        #include <sys/types.h> 
     38        #include <sys/sysctl.h> 
    3839#endif 
    3940 
     
    896897#if defined(__linux__) 
    897898    return sysconf(_SC_NPROCESSORS_CONF); 
    898 #elif defined(__APPLE__) 
    899     return MPProcessorsScheduled(); 
    900899#else 
    901     return 1; 
     900        #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__MACH__) 
     901                uint64_t num_cpus = 0; 
     902                size_t num_cpus_length = sizeof(num_cpus); 
     903                #if defined(__FreeBSD__) 
     904                        sysctlbyname("hw.ncpu", &num_cpus, &num_cpus_length, NULL, 0);                   
     905                #else 
     906                        sysctlbyname("hw.activecpu", &num_cpus, &num_cpus_length, NULL, 0); 
     907                #endif 
     908                return num_cpus; 
     909        #else 
     910                return 1; 
     911        #endif 
    902912#endif 
    903913}