summaryrefslogtreecommitdiffstats
path: root/wsutil/pow2.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 20:34:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 20:34:10 +0000
commite4ba6dbc3f1e76890b22773807ea37fe8fa2b1bc (patch)
tree68cb5ef9081156392f1dd62a00c6ccc1451b93df /wsutil/pow2.h
parentInitial commit. (diff)
downloadwireshark-e4ba6dbc3f1e76890b22773807ea37fe8fa2b1bc.tar.xz
wireshark-e4ba6dbc3f1e76890b22773807ea37fe8fa2b1bc.zip
Adding upstream version 4.2.2.upstream/4.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--wsutil/pow2.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/wsutil/pow2.h b/wsutil/pow2.h
new file mode 100644
index 00000000..1555f3c4
--- /dev/null
+++ b/wsutil/pow2.h
@@ -0,0 +1,29 @@
+/** @file
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef __WS_POW2_H__
+#define __WS_POW2_H__
+
+/*
+ * Macros to calculate pow2^M, for various power-of-2 values and positive
+ * integer values of M. That's (2^N)^M, i.e. 2^(N*M).
+ *
+ * The first argument is the type of the desired result; the second
+ * argument is M.
+ */
+#define pow2(type, m) (((type)1U) << (m))
+#define pow4(type, m) (((type)1U) << (2*(m)))
+#define pow8(type, m) (((type)1U) << (3*(m)))
+#define pow16(type, m) (((type)1U) << (4*(m)))
+#define pow32(type, m) (((type)1U) << (5*(m)))
+#define pow64(type, m) (((type)1U) << (6*(m)))
+#define pow128(type, m) (((type)1U) << (7*(m)))
+#define pow256(type, m) (((type)1U) << (8*(m)))
+
+#endif /* __WS_POW2_H__ */