[vlc-commits] commit: vlc_GetCPUCount: add Solaris detection (Francois Cartegnie )

git at videolan.org git at videolan.org
Tue Jun 15 03:18:10 CEST 2010


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Jun 14 18:36:52 2010 +0200| [f5b52a214d4053b3e4b6c26e9371f9c89f692d42] | committer: Rémi Denis-Courmont 

vlc_GetCPUCount: add Solaris detection

Signed-off-by: Rémi Denis-Courmont <remi at remlab.net>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f5b52a214d4053b3e4b6c26e9371f9c89f692d42
---

 src/misc/cpu.c |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/src/misc/cpu.c b/src/misc/cpu.c
index 83b9560..71aed9d 100644
--- a/src/misc/cpu.c
+++ b/src/misc/cpu.c
@@ -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;



More information about the vlc-commits mailing list