From f5b52a214d4053b3e4b6c26e9371f9c89f692d42 Mon Sep 17 00:00:00 2001 From: Francois Cartegnie Date: Mon, 14 Jun 2010 18:36:52 +0200 Subject: [PATCH] vlc_GetCPUCount: add Solaris detection MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémi Denis-Courmont --- src/misc/cpu.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) 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; -- 2.39.2