mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-03-23 21:20:41 +01:00
glib-aux: move nm_utils_exp10() from core to libnm-glib-aux
This commit is contained in:
parent
9c32ba1910
commit
b3f5113503
4 changed files with 35 additions and 33 deletions
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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__ */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue