summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2021-03-02 21:07:12 +0100
committerThomas Haller <thaller@redhat.com>2021-03-05 11:09:12 +0100
commitb3f51135031377daf0904f02799029009afd4e83 (patch)
treeea4d5247341c57e026e585e71b59952bf8547e01
parent9c32ba19101db0d820ca77fda9ef733fd9399859 (diff)
downloadNetworkManager-b3f51135031377daf0904f02799029009afd4e83.tar.gz
glib-aux: move nm_utils_exp10() from core to libnm-glib-aux
-rw-r--r--src/core/nm-core-utils.c31
-rw-r--r--src/core/nm-core-utils.h2
-rw-r--r--src/libnm-glib-aux/nm-shared-utils.c31
-rw-r--r--src/libnm-glib-aux/nm-shared-utils.h4
4 files changed, 35 insertions, 33 deletions
diff --git a/src/core/nm-core-utils.c b/src/core/nm-core-utils.c
index de3363e48e..9d764b27fe 100644
--- a/src/core/nm-core-utils.c
+++ b/src/core/nm-core-utils.c
@@ -156,37 +156,6 @@ _nm_singleton_instance_register_destruction(GObject *instance)
/*****************************************************************************/
-static double
-_exp10(guint16 ex)
-{
- double v;
-
- if (ex == 0)
- return 1.0;
-
- v = _exp10(ex / 2);
- v = v * v;
- if (ex % 2)
- v *= 10;
- return v;
-}
-
-/*
- * nm_utils_exp10:
- * @ex: the exponent
- *
- * Returns: 10^ex, or pow(10, ex), or exp10(ex).
- */
-double
-nm_utils_exp10(gint16 ex)
-{
- if (ex >= 0)
- return _exp10(ex);
- return 1.0 / _exp10(-((gint32) ex));
-}
-
-/*****************************************************************************/
-
gboolean
nm_ether_addr_is_valid(const NMEtherAddr *addr)
{
diff --git a/src/core/nm-core-utils.h b/src/core/nm-core-utils.h
index 01d8322568..9591e9b08d 100644
--- a/src/core/nm-core-utils.h
+++ b/src/core/nm-core-utils.h
@@ -185,8 +185,6 @@ nm_hash_update_in6addr_prefix(NMHashState *h, const struct in6_addr *addr, guint
nm_hash_update_in6addr(h, &a);
}
-double nm_utils_exp10(gint16 e);
-
/**
* nm_utils_ip6_route_metric_normalize:
* @metric: the route metric
diff --git a/src/libnm-glib-aux/nm-shared-utils.c b/src/libnm-glib-aux/nm-shared-utils.c
index 9477cc3e74..f52c8e7f82 100644
--- a/src/libnm-glib-aux/nm-shared-utils.c
+++ b/src/libnm-glib-aux/nm-shared-utils.c
@@ -5708,3 +5708,34 @@ nm_utils_name_to_uid(const char *name, uid_t *out_uid)
buf = buf_heap;
}
}
+
+/*****************************************************************************/
+
+static double
+_exp10(guint16 ex)
+{
+ double v;
+
+ if (ex == 0)
+ return 1.0;
+
+ v = _exp10(ex / 2);
+ v = v * v;
+ if (ex % 2)
+ v *= 10;
+ return v;
+}
+
+/*
+ * nm_utils_exp10:
+ * @ex: the exponent
+ *
+ * Returns: 10^ex, or pow(10, ex), or exp10(ex).
+ */
+double
+nm_utils_exp10(gint16 ex)
+{
+ if (ex >= 0)
+ return _exp10(ex);
+ return 1.0 / _exp10(-((gint32) ex));
+}
diff --git a/src/libnm-glib-aux/nm-shared-utils.h b/src/libnm-glib-aux/nm-shared-utils.h
index b30d27bda4..a01dd26dbf 100644
--- a/src/libnm-glib-aux/nm-shared-utils.h
+++ b/src/libnm-glib-aux/nm-shared-utils.h
@@ -2491,4 +2491,8 @@ gboolean nm_utils_is_specific_hostname(const char *name);
char * nm_utils_uid_to_name(uid_t uid);
gboolean nm_utils_name_to_uid(const char *name, uid_t *out_uid);
+/*****************************************************************************/
+
+double nm_utils_exp10(gint16 e);
+
#endif /* __NM_SHARED_UTILS_H__ */