Add missing header <sys/time.h> for gettimeofday

The patch adds `<sys/time.h>` header for `clock_gettime()`. Also make
sure `_POSIX_TIMERS` is defined before checking its value.

On Darwin/OSX one could use `mach_absolute_time()` and
`AbsoluteToNanoseconds` provided by CoreServices framework instead.

Details and examples are here: https://developer.apple.com/library/mac/qa/qa1398/_index.html

Signed-off-by: David Abdurachmanov <davidlt@cern.ch>