From: Mike Crowe Date: Wed, 19 Jun 2019 21:05:12 +0000 (-0300) Subject: support: Add xclock_now helper function. X-Git-Tag: glibc-2.30~78 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=db13e32cb8d5f74fe61880459c7ddf8f47da436b;p=thirdparty%2Fglibc.git support: Add xclock_now helper function. It's easier to read and write tests with: const struct timespec ts = xclock_now(CLOCK_REALTIME); than struct timespec ts; xclock_gettime(CLOCK_REALTIME, &ts); * support/xtime.h: Add xclock_now() helper function. --- diff --git a/ChangeLog b/ChangeLog index 05291d78250..de58169b612 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2019-06-20 Mike Crowe + + * support/xtime.h: Add xclock_now() helper function. + 2019-06-20 Dmitry V. Levin Florian Weimer diff --git a/support/xtime.h b/support/xtime.h index 68af1a59d78..6e19ce177f5 100644 --- a/support/xtime.h +++ b/support/xtime.h @@ -28,6 +28,16 @@ __BEGIN_DECLS void xclock_gettime (clockid_t clock, struct timespec *ts); +/* This helper can often simplify tests by avoiding an explicit + variable declaration or allowing that declaration to be const. */ + +static inline struct timespec xclock_now (clockid_t clock) +{ + struct timespec ts; + xclock_gettime (clock, &ts); + return ts; +} + __END_DECLS #endif /* SUPPORT_TIME_H */