Richard Frith-Macdonald wrote:
On 13 Nov 2008, at 08:42, Fred Kiefer wrote:
Having an implementation for these methods would be nice, but
going down
the /proc/something parsing route seems wrong to me. Why not call
sysconf() with _SC_NPROCESSORS_CONF (on my GUN/Linux system this is
defined in /usr/include/bits/confname.h).
This too is a system specific solution, but at least we use glibc
instead of doing the parsing ourselves. This should save us the
problem
of adopting to a new kernel every time.
We still will need different solutions for non-Linux systems.
I've implemented a combination ... using sysconf if possible and
falling
back to the /proc code (though I'm not sure that /proc will ever work
where sysconf does not) as well as adding an implementation for
mswindows. The code compiles without error but is completely
untested,
so it would be good if anyone interested could try it out and
report bugs.
Not sure, but for the sysctlbyname() case, don't you have to pass on
&len as well? There must be a reason why you set up that variable, so
most likely that system call is expecting it :-)