summaryrefslogtreecommitdiff
path: root/nasmlib.h
diff options
context:
space:
mode:
authorCyrill Gorcunov <gorcunov@gmail.com>2009-11-06 09:03:08 +0300
committerCyrill Gorcunov <gorcunov@gmail.com>2009-11-06 21:01:45 +0300
commit09e2895fbeb014daccf80537083048171f12c621 (patch)
treeb87b88a4ec8097f7a650ee01cc54f7a8c3d41431 /nasmlib.h
parent19f9f60efbc3f240a9cdb04b4c33e7812d78463c (diff)
downloadnasm-09e2895fbeb014daccf80537083048171f12c621.tar.gz
nasm-09e2895fbeb014daccf80537083048171f12c621.tar.bz2
nasm-09e2895fbeb014daccf80537083048171f12c621.zip
Introduce is_power2 helper
We will need it for hash tables Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Diffstat (limited to 'nasmlib.h')
-rw-r--r--nasmlib.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/nasmlib.h b/nasmlib.h
index 2600109..fb2e6e3 100644
--- a/nasmlib.h
+++ b/nasmlib.h
@@ -422,4 +422,7 @@ static inline bool overflow_unsigned(int64_t value, int bytes)
int idata_bytes(int opcode);
+/* check if value is power of 2 */
+#define is_power2(v) ((v) && ((v) & ((v) - 1)) == 0)
+
#endif