diff options
| author | Sebastien Bacher <seb128@ubuntu.com> | 2020-05-19 16:38:36 +0200 |
|---|---|---|
| committer | Sebastien Bacher <seb128@ubuntu.com> | 2020-05-19 17:09:07 +0200 |
| commit | ccf6dc06bbee82c3d49f451545c5317337e0777e (patch) | |
| tree | a8fddc8c6e2b3b99bebab1d5bb2a64581eff4bfd /shared/nm-glib-aux/nm-time-utils.h | |
| parent | f109e55ef130ce84054d5ba3acf4b71cd8c7564a (diff) | |
| parent | 7ffed1e6136de75188f10ba8763bcb942f932f8e (diff) | |
Merge remote-tracking branch 'salsa/debian/master' into ubuntu/master
Diffstat (limited to 'shared/nm-glib-aux/nm-time-utils.h')
| -rw-r--r-- | shared/nm-glib-aux/nm-time-utils.h | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/shared/nm-glib-aux/nm-time-utils.h b/shared/nm-glib-aux/nm-time-utils.h index 8bf41b96..190d9491 100644 --- a/shared/nm-glib-aux/nm-time-utils.h +++ b/shared/nm-glib-aux/nm-time-utils.h @@ -9,34 +9,42 @@ #include <time.h> static inline gint64 -nm_utils_timespec_to_ns (const struct timespec *ts) +nm_utils_timespec_to_nsec (const struct timespec *ts) { - return (((gint64) ts->tv_sec) * ((gint64) NM_UTILS_NS_PER_SECOND)) + return (((gint64) ts->tv_sec) * ((gint64) NM_UTILS_NSEC_PER_SEC)) + ((gint64) ts->tv_nsec); } static inline gint64 -nm_utils_timespec_to_ms (const struct timespec *ts) +nm_utils_timespec_to_msec (const struct timespec *ts) { return (((gint64) ts->tv_sec) * ((gint64) 1000)) - + (((gint64) ts->tv_nsec) / ((gint64) NM_UTILS_NS_PER_SECOND / 1000)); + + (((gint64) ts->tv_nsec) / ((gint64) NM_UTILS_NSEC_PER_SEC / 1000)); } -gint64 nm_utils_get_monotonic_timestamp_ns (void); -gint64 nm_utils_get_monotonic_timestamp_us (void); -gint64 nm_utils_get_monotonic_timestamp_ms (void); -gint32 nm_utils_get_monotonic_timestamp_s (void); -gint64 nm_utils_monotonic_timestamp_as_boottime (gint64 timestamp, gint64 timestamp_ticks_per_ns); -gint64 nm_utils_monotonic_timestamp_from_boottime (guint64 boottime, gint64 timestamp_ns_per_tick); +gint64 nm_utils_get_monotonic_timestamp_nsec (void); +gint64 nm_utils_get_monotonic_timestamp_usec (void); +gint64 nm_utils_get_monotonic_timestamp_msec (void); +gint32 nm_utils_get_monotonic_timestamp_sec (void); + +gint64 nm_utils_monotonic_timestamp_as_boottime (gint64 timestamp, gint64 timestamp_ticks_per_nsec); +gint64 nm_utils_monotonic_timestamp_from_boottime (guint64 boottime, gint64 timestamp_nsec_per_tick); + +static inline gint64 +nm_utils_get_monotonic_timestamp_nsec_cached (gint64 *cache_now) +{ + return (*cache_now) + ?: (*cache_now = nm_utils_get_monotonic_timestamp_nsec ()); +} static inline gint64 -nm_utils_get_monotonic_timestamp_ns_cached (gint64 *cache_now) +nm_utils_get_monotonic_timestamp_msec_cached (gint64 *cache_now) { return (*cache_now) - ?: (*cache_now = nm_utils_get_monotonic_timestamp_ns ()); + ?: (*cache_now = nm_utils_get_monotonic_timestamp_msec ()); } -gint64 nm_utils_clock_gettime_ns (clockid_t clockid); -gint64 nm_utils_clock_gettime_ms (clockid_t clockid); +gint64 nm_utils_clock_gettime_nsec (clockid_t clockid); +gint64 nm_utils_clock_gettime_msec (clockid_t clockid); #endif /* __NM_TIME_UTILS_H__ */ |