Fix use of _POSIX_THREAD*
authorMark Abraham <mark.j.abraham@gmail.com>
Wed, 1 Jun 2016 08:48:07 +0000 (10:48 +0200)
committerTeemu Murtola <teemu.murtola@gmail.com>
Fri, 1 Jul 2016 18:57:33 +0000 (20:57 +0200)
commit6d850e72454a0ae16a5560c5b07f366f2af6fbd4
tree7d3c0517ff6f913c841f36fd41a839ff46b90b3c
parented8d537d336d90081b62d78a8ecd63f67cfb7a17
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
src/gromacs/timing/walltime_accounting.cpp