Improve TIMESPEC_TO_TIME

Add explicit TO_NSEC and TO_USEC versions to make it clearer and to
allow for some optimizations.
This commit is contained in:
Wim Taymans 2018-11-07 09:56:24 +01:00
parent bf6843743a
commit 088ee9f09e
8 changed files with 20 additions and 18 deletions

View file

@ -129,8 +129,10 @@ struct spa_fraction {
#define SPA_USEC_PER_MSEC (1000ll)
#define SPA_MSEC_PER_SEC (1000ll)
#define SPA_TIMESPEC_TO_TIME(ts) ((ts)->tv_sec * SPA_NSEC_PER_SEC + (ts)->tv_nsec)
#define SPA_TIMEVAL_TO_TIME(tv) ((tv)->tv_sec * SPA_NSEC_PER_SEC + (tv)->tv_usec * 1000ll)
#define SPA_TIMESPEC_TO_NSEC(ts) ((ts)->tv_sec * SPA_NSEC_PER_SEC + (ts)->tv_nsec)
#define SPA_TIMESPEC_TO_USEC(ts) ((ts)->tv_sec * SPA_USEC_PER_SEC + (ts)->tv_nsec / SPA_NSEC_PER_USEC)
#define SPA_TIMEVAL_TO_NSEC(tv) ((tv)->tv_sec * SPA_NSEC_PER_SEC + (tv)->tv_usec * SPA_NSEC_PER_USEC)
#define SPA_TIMEVAL_TO_USEC(tv) ((tv)->tv_sec * SPA_USEC_PER_SEC + (tv)->tv_usec)
#ifdef __GNUC__
#define SPA_PRINTF_FUNC(fmt, arg1) __attribute__((format(printf, fmt, arg1)))