Steve M. Robbins <steve@sumost.ca> (09/01/2010):
> Hello,
Hi,
> unsigned thread::hardware_concurrency()
> {
> #if defined(PTW32_VERSION) || defined(__hpux)
> return pthread_num_processors_np();
> #elif defined(_GNU_SOURCE)
> 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(BOOST_HAS_UNISTD_H) && defined(_SC_NPROCESSORS_ONLN)
> int const count=sysconf(_SC_NPROCESSORS_ONLN);
> return (count>0)?count:0;
I've just checked that sysconf(…) is available, and I guess it should
do the job. Unfortunately I only have a UP machine to test this on, so
I can't tell for sure.
So at first glance, somebody wanting to provide a patch might just
want to tweak the _GNU_SOURCE check to exclude the __FreeBSD_kernel__
case, so that the BOOST_HAS_UNISTD_H && _SC_NPROCESSORS_ONLN case is
used.
Mraw,
KiBi.
Attachment:
signature.asc
Description: Digital signature