Re: How to find number of processors?
Steve M. Robbins dixit:
>#elif defined(__APPLE__) || defined(__FreeBSD__)
This would work if defined(__FreeBSD_kernel__) too.
> return sysctlbyname("hw.ncpu",&count,&size,NULL,0)?0:count;
Although CTL_HW and HW_NCPU probably would work better,
and you could just include <sys/sysctl.h> and check for
these two, then use sysctl(3) instead of sysctlbyname()
to also save the additional lookup.
bye,
//mirabilos
--
Sometimes they [people] care too much: pretty printers [and syntax highligh-
ting, d.A.] mechanically produce pretty output that accentuates irrelevant
detail in the program, which is as sensible as putting all the prepositions
in English text in bold font. -- Rob Pike in "Notes on Programming in C"
Reply to: