[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

How to find number of processors?



Hello,

I'm seeking advice -- preferably in the form of a tested patch :-)
for a build failure specific to kFreeBSD [1,2]:

  libs/thread/src/pthread/thread.cpp: In static member function 'static unsigned int boost::thread::hardware_concurrency()':
  libs/thread/src/pthread/thread.cpp:384: error: 'get_nprocs' was not declared in this scope
  ...failed gcc.compile.c++ bin.v2/libs/thread/build/gcc-4.4.2/release/debug-symbols-on/threading-multi/pthread/thread.o...

The code in question is:

    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;
#else
        return 0;
#endif
    }


Thanks,
-Steve


[1] https://buildd.debian.org/fetch.cgi?pkg=boost1.41;ver=1.41.0-1;arch=kfreebsd-i386;stamp=1262804715
[2] https://buildd.debian.org/fetch.cgi?pkg=boost1.41;ver=1.41.0-1;arch=kfreebsd-amd64;stamp=1262804822

Attachment: signature.asc
Description: Digital signature


Reply to: