From: Francois Cartegnie Date: Mon, 14 Jun 2010 16:36:52 +0000 (+0200) Subject: vlc_GetCPUCount: add Solaris detection X-Git-Tag: 1.2.0-pre1~6174 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=f5b52a214d4053b3e4b6c26e9371f9c89f692d42;p=vlc vlc_GetCPUCount: add Solaris detection Signed-off-by: RĂ©mi Denis-Courmont --- diff --git a/src/misc/cpu.c b/src/misc/cpu.c index 83b95603b9..71aed9dc16 100644 --- a/src/misc/cpu.c +++ b/src/misc/cpu.c @@ -49,6 +49,13 @@ #include #endif +#if defined(__SunOS) +#include +#include +#include +#include +#endif + #if defined( __i386__ ) || defined( __x86_64__ ) || defined( __powerpc__ ) \ || defined( __ppc__ ) || defined( __ppc64__ ) || defined( __powerpc64__ ) # ifndef WIN32 @@ -351,6 +358,26 @@ unsigned vlc_GetCPUCount(void) if (sysctlbyname("hw.ncpu", &count, &size, NULL, 0)) return 1; /* Failure */ return count; +#elif defined(__SunOS) + unsigned count = 0; + int type; + u_int numcpus; + processorid_t *cpulist; + processor_info_t cpuinfo; + cpulist = malloc(sizeof(processorid_t) * sysconf(_SC_NPROCESSORS_MAX)); + if (!cpulist) return 1; + if (pset_info(PS_MYID, &type, &numcpus, cpulist)==0) + { + for (u_int i = 0; i < numcpus; i++) + { + if (!processor_info(cpulist[i], &cpuinfo)) + count += (cpuinfo.pi_state == P_ONLINE)?1:0; + } + } else { + count = sysconf(_SC_NPROCESSORS_ONLN); + } + free(cpulist); + return (count>0)?count:1; #else # warning "vlc_GetCPUCount is not implemented for your platform" return 1;