This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: implementation of std::thread::hardware_concurrency()


On 1 November 2011 15:47, Jonathan Wakely wrote:
> I've put gcc-patches@ back in the CC list and removed gcc@

Oops, *now* I've 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.
>

Also, you should include <sys/sysctl.h> before calling sysctlbyname.

What header is required for pthread_num_processors_np?  If it is not
<pthread.h> then that must be included explicitly too.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]