summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-08-07 09:21:45 +0200
committerThomas Haller <thaller@redhat.com>2018-08-10 10:38:19 +0200
commitb7c8e3dbfa51017a40b0f7229a1e50074c0d9204 (patch)
tree9f5dae248dbe614f1ce4c7624420550dfaba8c2d
parentdf30651b8906cfe6a5cb7aef01a220d1f21b80f3 (diff)
downloadNetworkManager-b7c8e3dbfa51017a40b0f7229a1e50074c0d9204.tar.gz
shared: add NM_DIV_ROUND_UP() helper macro
Inspired by ethtool's DIV_ROUND_UP() and systemd's DIV_ROUND_UP().
-rw-r--r--shared/nm-utils/nm-macros-internal.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/shared/nm-utils/nm-macros-internal.h b/shared/nm-utils/nm-macros-internal.h
index d1391073eb..3d2520d131 100644
--- a/shared/nm-utils/nm-macros-internal.h
+++ b/shared/nm-utils/nm-macros-internal.h
@@ -1137,6 +1137,14 @@ nm_clear_g_cancellable (GCancellable **cancellable)
&& ((__x & (__x - (((typeof(__x)) 1)))) == ((typeof(__x)) 0))); \
})
+#define NM_DIV_ROUND_UP(x, y) \
+ ({ \
+ const typeof(x) _x = (x); \
+ const typeof(y) _y = (y); \
+ \
+ (_x / _y + !!(_x % _y)); \
+ })
+
/*****************************************************************************/
#define NM_UTILS_LOOKUP_DEFAULT(v) return (v)