summaryrefslogtreecommitdiff
path: root/src/openvpn/integer.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvpn/integer.h')
-rw-r--r--src/openvpn/integer.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/openvpn/integer.h b/src/openvpn/integer.h
index 240781b..9bb00a3 100644
--- a/src/openvpn/integer.h
+++ b/src/openvpn/integer.h
@@ -118,6 +118,24 @@ modulo_add(int x, int y, int mod)
return sum;
}
+/*
+ * Return the next largest power of 2
+ * or u if u is a power of 2.
+ */
+static inline size_t
+adjust_power_of_2(size_t u)
+{
+ size_t ret = 1;
+
+ while (ret < u)
+ {
+ ret <<= 1;
+ ASSERT(ret > 0);
+ }
+
+ return ret;
+}
+
static inline int
index_verify(int index, int size, const char *file, int line)
{