timespec: new function current_timespec
commit0a1ced59e6fb3c3b11c423e51002c57920480b24
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 16 Sep 2018 21:41:36 +0000 (16 14:41 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 17 Sep 2018 04:29:44 +0000 (16 21:29 -0700)
tree643d32e1e7e8342061e3273dfa173aadf033f8e4
parent6642aeb47aee3d82978a27497dc9ca57058c66b4
timespec: new function current_timespec

* lib/gettime.c (gettime): Prefer clock_gettime to nanotime,
and don’t worry about it failing on a CLOCK_REALTIME arg.
POSIX requires it to succeed and I don’t know of any
counterexamples where the fallbacks would work.
(current_timespec): New function, taken from Emacs.  It is more
convenient than gettime, and can help register allocation.
* lib/timespec.h: Include arg-nonnull.h.
(current_timespec): New declaration.
(gettime, settime): Declare args to be nonnull.
* modules/timespec (Depends-on): Add snippet/arg-nonnull.
ChangeLog
lib/gettime.c
lib/timespec.h
modules/timespec