util: refactor so ifdef's are withing each time-related function
The time-related functions have two implementations, one if clock_gettime() is
available and the other if not.
Previously, there was one big ifdef-else with the clock_gettime()
implementation of each function followed by the other implementation of each
function.
With this commit, each function is defined once, with an ifdef-else inside it
with the two implementations of that function. For ease of review, no other
code changes are made, but the intent will become obvious with later changes.