diff options
| author | Sebastien Bacher <seb128@ubuntu.com> | 2019-08-09 11:09:27 +0200 |
|---|---|---|
| committer | Sebastien Bacher <seb128@ubuntu.com> | 2019-08-09 11:18:39 +0200 |
| commit | 820498b2158e0b05421ce0922f203a0699927fa8 (patch) | |
| tree | 3bf6d1089b762535ec5e59738d47ae2d2f54750f /shared/nm-glib-aux/nm-time-utils.h | |
| parent | 1bd9f376796563dfb5016bada66c78b203f41d33 (diff) | |
| parent | 488dda3930545969f5644b57cfca81e21df031c3 (diff) | |
Merge remote-tracking branch 'salsa/master'
Diffstat (limited to 'shared/nm-glib-aux/nm-time-utils.h')
| -rw-r--r-- | shared/nm-glib-aux/nm-time-utils.h | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/shared/nm-glib-aux/nm-time-utils.h b/shared/nm-glib-aux/nm-time-utils.h index 7e4f4f25..52d6637d 100644 --- a/shared/nm-glib-aux/nm-time-utils.h +++ b/shared/nm-glib-aux/nm-time-utils.h @@ -21,6 +21,22 @@ #ifndef __NM_TIME_UTILS_H__ #define __NM_TIME_UTILS_H__ +#include <time.h> + +static inline gint64 +nm_utils_timespec_to_ns (const struct timespec *ts) +{ + return (((gint64) ts->tv_sec) * ((gint64) NM_UTILS_NS_PER_SECOND)) + + ((gint64) ts->tv_nsec); +} + +static inline gint64 +nm_utils_timespec_to_ms (const struct timespec *ts) +{ + return (((gint64) ts->tv_sec) * ((gint64) 1000)) + + (((gint64) ts->tv_nsec) / ((gint64) NM_UTILS_NS_PER_SECOND / 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); @@ -34,12 +50,7 @@ nm_utils_get_monotonic_timestamp_ns_cached (gint64 *cache_now) ?: (*cache_now = nm_utils_get_monotonic_timestamp_ns ()); } -struct timespec; - -/* this function must be implemented to handle the notification when - * the first monotonic-timestamp is fetched. */ -extern void _nm_utils_monotonic_timestamp_initialized (const struct timespec *tp, - gint64 offset_sec, - gboolean is_boottime); +gint64 nm_utils_clock_gettime_ns (clockid_t clockid); +gint64 nm_utils_clock_gettime_ms (clockid_t clockid); #endif /* __NM_TIME_UTILS_H__ */ |