workaround for time(2) being non-monotonic
commit0a6b4a2c54784c90ec1b762cb6880ebc745658e9
authorEric Wong <bofh@yhbt.net>
Sun, 19 Mar 2023 20:24:29 +0000 (19 20:24 +0000)
committerEric Wong <bofh@yhbt.net>
Thu, 11 May 2023 21:27:08 +0000 (11 21:27 +0000)
tree025adccf5797753079673dc7dd7b463c046e8bfb
parent461c3d49b7910e0f96c55404b6db75ea092b77f3
workaround for time(2) being non-monotonic

Apparently, time(2) may go backwards in the first 1 - 2.5ms of
every second since Linux + glibc 2.31+ (and some proprietary
OSes).  Use clock_gettime(2) with CLOCK_REALTIME to workaround
the problem at the cost of a slight performance hit(*).  While git
will likely use gettimeofday(2) for compatibility with
proprietary OSes, gettimeofday(2) was declared obsolete in
POSIX.1-2008 and we don't support proprietary OSes.

(*) https://inbox.sourceware.org/libc-alpha/87ttywq0je.fsf@oldenburg.str.redhat.com/
Link: https://lore.kernel.org/git/20230319064353.686226-3-eggert@cs.ucla.edu/T/
ext/clogger_ext/clogger.c