Make life a little easier by adding an is_exp2() macro.

svn path=/trunk/yasm/; revision=1682
This commit is contained in:
Peter Johnson 2006-11-11 05:47:09 +00:00
parent 9fde4e1657
commit 5ab6b53062
6 changed files with 20 additions and 13 deletions

7
util.h
View file

@ -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