vlc/vlc-2.0 | branch: master | Brad Smith <[email protected]> | Sat Jan 28 17:05:37 2012 -0500| [87b5f8f6c1cba05b4b549587988e0553482ea7e2] | committer: Rémi Denis-Courmont
thread: Simplify vlc_GetCPUCount / add FreeBSD/NetBSD support Looking at the current vlc_GetCPUCount() function this can be simplified. The sysconf(4) variable _SC_NPROCESSORS_CONF is available for OS X and OpenBSD. The change as is also adds FreeBSD and NetBSD support to vlc_GetCPUCount(). Signed-off-by: Rafaël Carré <[email protected]> (cherry picked from commit 3a50918d89ebd66d43af99b8750fe8a1558f8b92) Signed-off-by: Rémi Denis-Courmont <[email protected]> > http://git.videolan.org/gitweb.cgi/vlc/vlc-2.0.git/?a=commit;h=87b5f8f6c1cba05b4b549587988e0553482ea7e2 --- src/posix/thread.c | 26 +------------------------- 1 files changed, 1 insertions(+), 25 deletions(-) diff --git a/src/posix/thread.c b/src/posix/thread.c index f6b5165..1d0d077 100644 --- a/src/posix/thread.c +++ b/src/posix/thread.c @@ -53,13 +53,6 @@ #ifdef __APPLE__ # include <mach/mach_init.h> /* mach_task_self in semaphores */ -# include <sys/sysctl.h> -#endif - -#if defined(__OpenBSD__) -# include <sys/param.h> -# include <sys/sysctl.h> -# include <machine/cpu.h> #endif #if defined(__SunOS) @@ -1181,23 +1174,6 @@ unsigned vlc_GetCPUCount(void) return CPU_COUNT (&cpu); -#elif defined(__APPLE__) - int count; - size_t size = sizeof(count) ; - - if (sysctlbyname ("hw.ncpu", &count, &size, NULL, 0)) - return 1; /* Failure */ - return count; - -#elif defined(__OpenBSD__) - int selectors[2] = { CTL_HW, HW_NCPU }; - int count; - size_t size = sizeof(count); - - if (sysctl (selectors, 2, &count, &size, NULL, 0)) - return 1; /* Failure */ - return count; - #elif defined(__SunOS) unsigned count = 0; int type; @@ -1218,7 +1194,7 @@ unsigned vlc_GetCPUCount(void) count = sysconf (_SC_NPROCESSORS_ONLN); free (cpulist); return count ? count : 1; -#elif defined(__ANDROID__) +#elif defined(_SC_NPROCESSORS_CONF) return sysconf(_SC_NPROCESSORS_CONF); #else # warning "vlc_GetCPUCount is not implemented for your platform" _______________________________________________ vlc-commits mailing list [email protected] http://mailman.videolan.org/listinfo/vlc-commits
