warning: "_POSIX_THREAD_CPUTIME" is not defined - Redmine #1980
Archive from user: Patrick Welche
warning: “_POSIX_THREAD_CPUTIME” is not defined [-Wundef]
#if HAVE_CLOCK_GETTIME && _POSIX_THREAD_CPUTIME >= 0
as this is sometimes defined in pthread.h. However, why is that test there?
Is something like the attached what is intended?
Or up the stakes to -std=c++11 and assume std::chrono implemented everywhere? (Not sure it does per-thread timing)
(from redmine: issue id 1980, created on 2016-05-31 by gmxdefault, closed on 2016-07-07)
- Revision 6d850e72 by Mark Abraham on 2016-07-01T18:57:33Z:
Fix use of _POSIX_THREAD* This fixes a couple of aspects of behaviour. Formerly, if _POSIX_THREADS was defined and equal to zero, we might have used clock_gettime and got some kind of error (compiling/linking/runtime behaviour). Similarly, if _POSIX_THREADS was undefined, C99 defines such preprocessor symbols as zero, so we again used clock_gettime inappropriately. Now we avoid compiler warnings if the symbol is undefined, and when it is defined we use clock_gettime only when _POSIX_THREADS_ has a value such that it is supposed to work. Adapted this an the BG/Q fix also for gmx_gettime_per_thread(). Expanded the documentation of why the code is the way it is. Noted future TODO to consider std::chrono. Fixes #1980 Change-Id: Ib3e40903e2344354074c5328d40e8467f264b51f