summaryrefslogtreecommitdiff
path: root/util.h
diff options
context:
space:
mode:
authorPeter Johnson <peter@tortall.net>2006-11-11 05:47:09 +0000
committerPeter Johnson <peter@tortall.net>2006-11-11 05:47:09 +0000
commit5ab6b53062018f7a75595aceef5a5910f8f1ae50 (patch)
tree949e0c0907550d34e9574b11f42fa3b291ea5435 /util.h
parent9fde4e16570b9c32491f621d302573906419f771 (diff)
downloadyasm-5ab6b53062018f7a75595aceef5a5910f8f1ae50.tar.gz
Make life a little easier by adding an is_exp2() macro.
svn path=/trunk/yasm/; revision=1682
Diffstat (limited to 'util.h')
-rw-r--r--util.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/util.h b/util.h
index 01b200f9..2384e008 100644
--- a/util.h
+++ b/util.h
@@ -151,6 +151,13 @@
d = BC_COUNT(d, 4); \
} while (0)
+/** Determine if a value is exactly a power of 2. Zero is treated as a power
+ * of two.
+ * \param x value
+ * \return Nonzero if x is a power of 2.
+ */
+#define is_exp2(x) ((x & (x - 1)) == 0)
+
#ifndef NELEMS
/** Get the number of elements in an array.
* \internal