mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-07-22 02:35:25 +00:00
shared/trivial: rename time related functions to use "nsec"/"msec" abbreviation instead of "ns"/"ms"
The "ns" abbreviation doesn't look too nice. We mostly use "nsec" at other places. Rename.
This commit is contained in:
parent
53f6858a27
commit
8b63b229dd
|
@ -49,7 +49,7 @@ _nm_log_impl_cs (NMLogLevel level,
|
|||
break;
|
||||
}
|
||||
|
||||
ts = nm_utils_clock_gettime_ns (CLOCK_BOOTTIME);
|
||||
ts = nm_utils_clock_gettime_nsec (CLOCK_BOOTTIME);
|
||||
|
||||
g_print ("[%"G_GINT64_FORMAT".%05"G_GINT64_FORMAT"] %s %s\n",
|
||||
ts / NM_UTILS_NSEC_PER_SEC,
|
||||
|
|
|
@ -5846,7 +5846,7 @@ nm_utils_get_timestamp_msec (void)
|
|||
{
|
||||
gint64 ts;
|
||||
|
||||
ts = nm_utils_clock_gettime_ms (CLOCK_BOOTTIME);
|
||||
ts = nm_utils_clock_gettime_msec (CLOCK_BOOTTIME);
|
||||
if (ts >= 0)
|
||||
return ts;
|
||||
|
||||
|
@ -5855,7 +5855,7 @@ nm_utils_get_timestamp_msec (void)
|
|||
* criminally old kernel, prior to 2.6.39 (released on 18 May, 2011).
|
||||
* That happens during buildcheck on old builders, we don't expect to
|
||||
* be actually runs on kernels that old. */
|
||||
ts = nm_utils_clock_gettime_ms (CLOCK_MONOTONIC);
|
||||
ts = nm_utils_clock_gettime_msec (CLOCK_MONOTONIC);
|
||||
if (ts >= 0)
|
||||
return ts;
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ _nml_dbus_log (NMLDBusLogLevel level,
|
|||
break;
|
||||
}
|
||||
|
||||
ts = nm_utils_clock_gettime_ns (CLOCK_BOOTTIME);
|
||||
ts = nm_utils_clock_gettime_nsec (CLOCK_BOOTTIME);
|
||||
|
||||
g_printerr ("libnm-dbus: %s[%"G_GINT64_FORMAT".%05"G_GINT64_FORMAT"] %s\n",
|
||||
prefix,
|
||||
|
|
|
@ -312,21 +312,21 @@ nm_utils_monotonic_timestamp_from_boottime (guint64 boottime, gint64 timestamp_n
|
|||
}
|
||||
|
||||
gint64
|
||||
nm_utils_clock_gettime_ns (clockid_t clockid)
|
||||
nm_utils_clock_gettime_nsec (clockid_t clockid)
|
||||
{
|
||||
struct timespec tp;
|
||||
|
||||
if (clock_gettime (clockid, &tp) != 0)
|
||||
return -NM_ERRNO_NATIVE (errno);
|
||||
return nm_utils_timespec_to_ns (&tp);
|
||||
return nm_utils_timespec_to_nsec (&tp);
|
||||
}
|
||||
|
||||
gint64
|
||||
nm_utils_clock_gettime_ms (clockid_t clockid)
|
||||
nm_utils_clock_gettime_msec (clockid_t clockid)
|
||||
{
|
||||
struct timespec tp;
|
||||
|
||||
if (clock_gettime (clockid, &tp) != 0)
|
||||
return -NM_ERRNO_NATIVE (errno);
|
||||
return nm_utils_timespec_to_ms (&tp);
|
||||
return nm_utils_timespec_to_msec (&tp);
|
||||
}
|
||||
|
|
|
@ -9,14 +9,14 @@
|
|||
#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_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_NSEC_PER_SEC / 1000));
|
||||
|
@ -26,17 +26,18 @@ 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_ns_cached (gint64 *cache_now)
|
||||
nm_utils_get_monotonic_timestamp_nsec_cached (gint64 *cache_now)
|
||||
{
|
||||
return (*cache_now)
|
||||
?: (*cache_now = nm_utils_get_monotonic_timestamp_nsec ());
|
||||
}
|
||||
|
||||
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__ */
|
||||
|
|
|
@ -2719,7 +2719,7 @@ concheck_periodic_schedule_set (NMDevice *self, int addr_family, ConcheckSchedul
|
|||
switch (mode) {
|
||||
case CONCHECK_SCHEDULE_UPDATE_INTERVAL_RESTART:
|
||||
priv->concheck_x[IS_IPv4].p_cur_interval = NM_MIN (priv->concheck_x[IS_IPv4].p_max_interval, CONCHECK_P_PROBE_INTERVAL);
|
||||
priv->concheck_x[IS_IPv4].p_cur_basetime_ns = nm_utils_get_monotonic_timestamp_ns_cached (&now_ns);
|
||||
priv->concheck_x[IS_IPv4].p_cur_basetime_ns = nm_utils_get_monotonic_timestamp_nsec_cached (&now_ns);
|
||||
if (concheck_periodic_schedule_do (self, addr_family, now_ns))
|
||||
concheck_start (self, addr_family, NULL, NULL, TRUE);
|
||||
return;
|
||||
|
@ -2740,7 +2740,7 @@ concheck_periodic_schedule_set (NMDevice *self, int addr_family, ConcheckSchedul
|
|||
}
|
||||
|
||||
cur_expiry = priv->concheck_x[IS_IPv4].p_cur_basetime_ns + (priv->concheck_x[IS_IPv4].p_max_interval * NM_UTILS_NSEC_PER_SEC);
|
||||
nm_utils_get_monotonic_timestamp_ns_cached (&now_ns);
|
||||
nm_utils_get_monotonic_timestamp_nsec_cached (&now_ns);
|
||||
|
||||
priv->concheck_x[IS_IPv4].p_cur_interval = priv->concheck_x[IS_IPv4].p_max_interval;
|
||||
if (cur_expiry <= now_ns) {
|
||||
|
@ -2763,7 +2763,7 @@ concheck_periodic_schedule_set (NMDevice *self, int addr_family, ConcheckSchedul
|
|||
|
||||
case CONCHECK_SCHEDULE_CHECK_EXTERNAL:
|
||||
/* a external connectivity check delays our periodic check. We reset the counter. */
|
||||
priv->concheck_x[IS_IPv4].p_cur_basetime_ns = nm_utils_get_monotonic_timestamp_ns_cached (&now_ns);
|
||||
priv->concheck_x[IS_IPv4].p_cur_basetime_ns = nm_utils_get_monotonic_timestamp_nsec_cached (&now_ns);
|
||||
concheck_periodic_schedule_do (self, addr_family, now_ns);
|
||||
return;
|
||||
|
||||
|
@ -2794,7 +2794,7 @@ concheck_periodic_schedule_set (NMDevice *self, int addr_family, ConcheckSchedul
|
|||
* pretty close to now_ns.
|
||||
*
|
||||
* We want to reschedule the timeout at exp_expiry (aka now) + cur_interval. */
|
||||
nm_utils_get_monotonic_timestamp_ns_cached (&now_ns);
|
||||
nm_utils_get_monotonic_timestamp_nsec_cached (&now_ns);
|
||||
exp_expiry = priv->concheck_x[IS_IPv4].p_cur_basetime_ns + (old_interval * NM_UTILS_NSEC_PER_SEC);
|
||||
new_expiry = exp_expiry + (priv->concheck_x[IS_IPv4].p_cur_interval * NM_UTILS_NSEC_PER_SEC);
|
||||
tdiff = NM_MAX (new_expiry - now_ns, 0);
|
||||
|
@ -2833,7 +2833,7 @@ concheck_periodic_schedule_set (NMDevice *self, int addr_family, ConcheckSchedul
|
|||
* when we schedule checks be at precise intervals, without including the time it took for
|
||||
* the connectivity check. */
|
||||
new_expiry = priv->concheck_x[IS_IPv4].p_cur_basetime_ns + (priv->concheck_x[IS_IPv4].p_cur_interval * NM_UTILS_NSEC_PER_SEC);
|
||||
tdiff = NM_MAX (new_expiry - nm_utils_get_monotonic_timestamp_ns_cached (&now_ns), 0);
|
||||
tdiff = NM_MAX (new_expiry - nm_utils_get_monotonic_timestamp_nsec_cached (&now_ns), 0);
|
||||
priv->concheck_x[IS_IPv4].p_cur_basetime_ns = now_ns + tdiff - (priv->concheck_x[IS_IPv4].p_cur_interval * NM_UTILS_NSEC_PER_SEC);
|
||||
concheck_periodic_schedule_do (self, addr_family, now_ns);
|
||||
}
|
||||
|
|
|
@ -398,7 +398,7 @@ lease_parse_address (NDhcp4ClientLease *lease,
|
|||
|
||||
a_timestamp = ts / NM_UTILS_NSEC_PER_SEC;
|
||||
a_lifetime = NM_MIN (lifetime / NM_UTILS_NSEC_PER_SEC, NM_PLATFORM_LIFETIME_PERMANENT - 1);
|
||||
a_expiry = time (NULL) + ((lifetime - (nm_utils_clock_gettime_ns (CLOCK_BOOTTIME) - nettools_basetime)) / NM_UTILS_NSEC_PER_SEC);
|
||||
a_expiry = time (NULL) + ((lifetime - (nm_utils_clock_gettime_nsec (CLOCK_BOOTTIME) - nettools_basetime)) / NM_UTILS_NSEC_PER_SEC);
|
||||
}
|
||||
|
||||
if (!lease_get_in_addr (lease, NM_DHCP_OPTION_DHCP4_SUBNET_MASK, &a_netmask)) {
|
||||
|
|
|
@ -2434,7 +2434,7 @@ _host_id_read_timestamp (gboolean use_secret_key_file,
|
|||
&& stat (SECRET_KEY_FILE, &st) == 0) {
|
||||
/* don't check for overflow or timestamps in the future. We get whatever
|
||||
* (bogus) date is on the file. */
|
||||
*out_timestamp_ns = nm_utils_timespec_to_ns (&st.st_mtim);
|
||||
*out_timestamp_ns = nm_utils_timespec_to_nsec (&st.st_mtim);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -741,7 +741,7 @@ _addrtime_timestamp_to_nm (guint32 timestamp, gint32 *out_now_nm)
|
|||
/* do all the calculations in milliseconds scale */
|
||||
|
||||
now_nm = nm_utils_get_monotonic_timestamp_msec ();
|
||||
now_nl = nm_utils_clock_gettime_ms (CLOCK_MONOTONIC);
|
||||
now_nl = nm_utils_clock_gettime_msec (CLOCK_MONOTONIC);
|
||||
|
||||
nm_assert (now_nm >= 1000);
|
||||
nm_assert (now_nl >= 0);
|
||||
|
|
Loading…
Reference in a new issue