Commit f5b52a21 authored by Francois Cartegnie's avatar Francois Cartegnie Committed by Rémi Denis-Courmont

vlc_GetCPUCount: add Solaris detection

Signed-off-by: default avatarRémi Denis-Courmont <remi@remlab.net>
parent 06389567
......@@ -49,6 +49,13 @@
#include <sys/sysctl.h>
#endif
#if defined(__SunOS)
#include <unistd.h>
#include <sys/types.h>
#include <sys/processor.h>
#include <sys/pset.h>
#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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment