|
Boost-Commit : |
From: anthony_at_[hidden]
Date: 2007-12-20 03:37:03
Author: anthonyw
Date: 2007-12-20 03:37:02 EST (Thu, 20 Dec 2007)
New Revision: 42195
URL: http://svn.boost.org/trac/boost/changeset/42195
Log:
added hardware_concurrency support for apple, freebsd and sun platforms
Text files modified:
trunk/libs/thread/src/pthread/thread.cpp | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
Modified: trunk/libs/thread/src/pthread/thread.cpp
==============================================================================
--- trunk/libs/thread/src/pthread/thread.cpp (original)
+++ trunk/libs/thread/src/pthread/thread.cpp 2007-12-20 03:37:02 EST (Thu, 20 Dec 2007)
@@ -15,6 +15,11 @@
#include <boost/thread/tss.hpp>
#ifdef __linux__
#include <sys/sysinfo.h>
+#elif defined(__APPLE__) || defined(__FreeBSD__)
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#elif defined(__sun)
+#include <unistd.h>
#endif
#include "timeconv.inl"
@@ -415,6 +420,13 @@
return pthread_num_processors_np();
#elif defined(__linux__)
return get_nprocs();
+#elif defined(__APPLE__) || defined(__FreeBSD__)
+ int count;
+ size_t size=sizeof(count);
+ return sysctlbyname("hw.ncpu",&count,&size,NULL,0)?0:count;
+#elif defined(__sun)
+ int const count=sysconf(_SC_NPROCESSORS_ONLN);
+ return (count>0)?count:0;
#else
return 0;
#endif
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk