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

Re: How to find number of processors?



Hi!

On Sat, 2010-01-09 at 21:28:33 +0100, Robert Millan wrote:
> On Sat, Jan 09, 2010 at 02:08:07PM -0600, Steve M. Robbins wrote:
> > 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();
> 
> It seems that get_nprocs() is always implemented by Glibc.  Worst-case it'd
> be a dummy stub.  I'd just try to figure out why <sys/sysinfo.h> is not
> included or not providing its declaration.

In addition to what everyone has said, _GNU_SOURCE seems the wrong check
to me, that's a user definition to request the system to expose GNU
extensions, if the code is trying to check for a glibc implementation
it should be using __GLIBC__ instead, or I guess better yet, it should
be checking for the functions availability at build time and use the
best one found.

regards,
guillem


Reply to: