summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-01-28 16:21:23 +0100
committerThomas Haller <thaller@redhat.com>2020-02-10 19:11:50 +0100
commit8b63b229dd2466caba2a9e3cda2e26e79dabd401 (patch)
tree35bc33289cb99ac5ef28fe4a1899026608d2d3f8
parent53f6858a27a0d9b426bab9b7abedaa82d152fb68 (diff)
downloadNetworkManager-8b63b229dd2466caba2a9e3cda2e26e79dabd401.tar.gz
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.
-rw-r--r--clients/cloud-setup/nm-cloud-setup-utils.c2
-rw-r--r--libnm-core/nm-utils.c4
-rw-r--r--libnm/nm-libnm-utils.c2
-rw-r--r--shared/nm-glib-aux/nm-time-utils.c8
-rw-r--r--shared/nm-glib-aux/nm-time-utils.h11
-rw-r--r--src/devices/nm-device.c10
-rw-r--r--src/dhcp/nm-dhcp-nettools.c2
-rw-r--r--src/nm-core-utils.c2
-rw-r--r--src/platform/nm-linux-platform.c2
9 files changed, 22 insertions, 21 deletions
diff --git a/clients/cloud-setup/nm-cloud-setup-utils.c b/clients/cloud-setup/nm-cloud-setup-utils.c
index fb802a0812..13c9566a8b 100644
--- a/clients/cloud-setup/nm-cloud-setup-utils.c
+++ b/clients/cloud-setup/nm-cloud-setup-utils.c
@@ -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,
diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c
index 3fb067e046..f97e20c1c9 100644
--- a/libnm-core/nm-utils.c
+++ b/libnm-core/nm-utils.c
@@ -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;
}
diff --git a/libnm/nm-libnm-utils.c b/libnm/nm-libnm-utils.c
index f04a7419f5..7b4db11ef3 100644
--- a/libnm/nm-libnm-utils.c
+++ b/libnm/nm-libnm-utils.c
@@ -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,
diff --git a/shared/nm-glib-aux/nm-time-utils.c b/shared/nm-glib-aux/nm-time-utils.c
index 6afaf05aa3..356ed1a5dc 100644
--- a/shared/nm-glib-aux/nm-time-utils.c
+++ b/shared/nm-glib-aux/nm-time-utils.c
@@ -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);
}
diff --git a/shared/nm-glib-aux/nm-time-utils.h b/shared/nm-glib-aux/nm-time-utils.h
index fe48be0aed..47715bf50a 100644
--- a/shared/nm-glib-aux/nm-time-utils.h
+++ b/shared/nm-glib-aux/nm-time-utils.h
@@ -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__ */
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index e26a1602ac..763008048c 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -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);
}
diff --git a/src/dhcp/nm-dhcp-nettools.c b/src/dhcp/nm-dhcp-nettools.c
index da1d2598a8..23bdefabb8 100644
--- a/src/dhcp/nm-dhcp-nettools.c
+++ b/src/dhcp/nm-dhcp-nettools.c
@@ -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)) {
diff --git a/src/nm-core-utils.c b/src/nm-core-utils.c
index cbbac2816b..54c3ee629a 100644
--- a/src/nm-core-utils.c
+++ b/src/nm-core-utils.c
@@ -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;
}
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c
index 3ae5726d1c..b71576d5d2 100644
--- a/src/platform/nm-linux-platform.c
+++ b/src/platform/nm-linux-platform.c
@@ -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);