time-util: add macros around timespec_store() that operates on compund literal allocated timespec struct
This way we can convert usec_t to timespec on-the-fly, without a buffer. No actual behaviour change just some shortening of code.
This commit is contained in:
@@ -115,9 +115,13 @@ nsec_t timespec_load_nsec(const struct timespec *ts) _pure_;
|
||||
struct timespec* timespec_store(struct timespec *ts, usec_t u);
|
||||
struct timespec* timespec_store_nsec(struct timespec *ts, nsec_t n);
|
||||
|
||||
#define TIMESPEC_STORE(u) timespec_store(&(struct timespec) {}, (u))
|
||||
|
||||
usec_t timeval_load(const struct timeval *tv) _pure_;
|
||||
struct timeval* timeval_store(struct timeval *tv, usec_t u);
|
||||
|
||||
#define TIMEVAL_STORE(u) timeval_store(&(struct timeval) {}, (u))
|
||||
|
||||
char* format_timestamp_style(char *buf, size_t l, usec_t t, TimestampStyle style) _warn_unused_result_;
|
||||
char* format_timestamp_relative(char *buf, size_t l, usec_t t) _warn_unused_result_;
|
||||
char* format_timespan(char *buf, size_t l, usec_t t, usec_t accuracy) _warn_unused_result_;
|
||||
|
||||
Reference in New Issue
Block a user