aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2009-08-21 18:07:35 +0100
committerKeith Whitwell <[email protected]>2009-08-21 18:07:35 +0100
commitb1cc196e6d18494348c2974aad5d85d1b8281ce0 (patch)
treeb344c986ad0a3ea5195bff5fdb417e2eba8a3472 /src/gallium
parent00c835918259f8d41c3f74eca679a972713b11b2 (diff)
util: add util_is_power_of_two function
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/auxiliary/util/u_math.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h
index d30fa3c2d59..163522d3ef8 100644
--- a/src/gallium/auxiliary/util/u_math.h
+++ b/src/gallium/auxiliary/util/u_math.h
@@ -273,6 +273,14 @@ util_fast_pow(float x, float y)
return util_fast_exp2(util_fast_log2(x) * y);
}
+/* Note that this counts zero as a power of two.
+ */
+static INLINE boolean
+util_is_power_of_two( unsigned v )
+{
+ return (v & (v-1)) == 0;
+}
+
/**