diff options
author | Peter Johnson <peter@tortall.net> | 2006-11-11 05:47:09 +0000 |
---|---|---|
committer | Peter Johnson <peter@tortall.net> | 2006-11-11 05:47:09 +0000 |
commit | 5ab6b53062018f7a75595aceef5a5910f8f1ae50 (patch) | |
tree | 949e0c0907550d34e9574b11f42fa3b291ea5435 /util.h | |
parent | 9fde4e16570b9c32491f621d302573906419f771 (diff) | |
download | yasm-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.h | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -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 |