projects
/
mesa.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
8be72bb
)
util: Utility function to check if a number is a power of two.
author
José Fonseca
<jfonseca@vmware.com>
Mon, 7 Sep 2009 13:21:51 +0000
(14:21 +0100)
committer
José Fonseca
<jfonseca@vmware.com>
Mon, 7 Sep 2009 14:02:06 +0000
(15:02 +0100)
src/gallium/auxiliary/util/u_math.h
patch
|
blob
|
history
diff --git
a/src/gallium/auxiliary/util/u_math.h
b/src/gallium/auxiliary/util/u_math.h
index 4c6c2bc00e1ed0993ac7de7c2fb612876ed0645f..b12c97dfb4da6043dcda8d64b8a7d7532789e934 100644
(file)
--- a/
src/gallium/auxiliary/util/u_math.h
+++ b/
src/gallium/auxiliary/util/u_math.h
@@
-340,6
+340,16
@@
util_is_inf_or_nan(float x)
}
+/**
+ * Test whether x is a power of two.
+ */
+static INLINE boolean
+util_is_pot(unsigned x)
+{
+ return (x & (x - 1)) == 0;
+}
+
+
/**
* Find first bit set in word. Least significant bit is 1.
* Return 0 if no bits set.