1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-30 22:43:12 +03:00

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.
This commit is contained in:
Mike Crowe
2019-06-19 18:05:12 -03:00
committed by Adhemerval Zanella
parent 21cc130b78
commit db13e32cb8
2 changed files with 14 additions and 0 deletions

View File

@ -1,3 +1,7 @@
2019-06-20 Mike Crowe <mac@mcrowe.com>
* support/xtime.h: Add xclock_now() helper function.
2019-06-20 Dmitry V. Levin <ldv@altlinux.org> 2019-06-20 Dmitry V. Levin <ldv@altlinux.org>
Florian Weimer <fweimer@redhat.com> Florian Weimer <fweimer@redhat.com>

View File

@ -28,6 +28,16 @@ __BEGIN_DECLS
void xclock_gettime (clockid_t clock, struct timespec *ts); 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 __END_DECLS
#endif /* SUPPORT_TIME_H */ #endif /* SUPPORT_TIME_H */