implementation of std::thread::hardware_concurrency()

Jonathan Wakely jwakely.gcc@gmail.com
Tue Nov 1 15:47:00 GMT 2011


I've put gcc-patches@ back in the CC list and removed gcc@


On 1 November 2011 15:35, niXman wrote:
>> Er, the macro _GLIBCXX_NPROCS already handles
>> the case sysconf(_SC_NPROCESSORS_ONLN).
>> It looks like you actually want to remove the macro
>> _GLIBCXX_NPROCS completely.
>
> Fixed.

No, this still isn't acceptable.

I do not want to see preprocessor tests like

+#elif defined(__APPLE__) || defined(__FreeBSD__)

in the body of get_thread::hardware_concurrency(), the configure
script should determine what is available on the platform and set an
appropriate macro.

Look at the definition of _GLIBCXX_NPROCS and adjust that to do

#define _GLIBCXX_NPROCS pthread_num_processors_np()

for the relevant platforms.

For the platforms using sysctlbyname there could be an inline function
that calls it, and _GLIBCXX_NPROCS could be defined to call that, so
that thread::hardware_concurrency() can still be defined as it is
today.

Please read the code you're changing and understand how it works today
before making changes.



More information about the Gcc-patches mailing list