aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main/imports.h
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-06-09 09:24:20 +0200
committermarha <marha@users.sourceforge.net>2011-06-09 09:24:20 +0200
commit0a9d2abef2e6fac5d52556969655a62711df6418 (patch)
tree86d46767bedf8271ec0f67442259c5b3e7a8bb87 /mesalib/src/mesa/main/imports.h
parentadeb8256da9b636648178f729d7b3316a0a8e990 (diff)
downloadvcxsrv-0a9d2abef2e6fac5d52556969655a62711df6418.tar.gz
vcxsrv-0a9d2abef2e6fac5d52556969655a62711df6418.tar.bz2
vcxsrv-0a9d2abef2e6fac5d52556969655a62711df6418.zip
mesa xkbcomp xkeyboard-config git update 9 Jun 2011
Diffstat (limited to 'mesalib/src/mesa/main/imports.h')
-rw-r--r--mesalib/src/mesa/main/imports.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/mesalib/src/mesa/main/imports.h b/mesalib/src/mesa/main/imports.h
index ce7baabe2..3fa1db02a 100644
--- a/mesalib/src/mesa/main/imports.h
+++ b/mesalib/src/mesa/main/imports.h
@@ -486,6 +486,27 @@ _mesa_next_pow_two_64(uint64_t x)
}
+/*
+ * Returns the floor form of binary logarithm for a 32-bit integer.
+ */
+static INLINE GLuint
+_mesa_logbase2(GLuint n)
+{
+#if defined(__GNUC__) && \
+ ((__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || __GNUC__ >= 4)
+ return (31 - __builtin_clz(n | 1));
+#else
+ GLuint pos = 0;
+ if (n >= 1<<16) { n >>= 16; pos += 16; }
+ if (n >= 1<< 8) { n >>= 8; pos += 8; }
+ if (n >= 1<< 4) { n >>= 4; pos += 4; }
+ if (n >= 1<< 2) { n >>= 2; pos += 2; }
+ if (n >= 1<< 1) { pos += 1; }
+ return pos;
+#endif
+}
+
+
/**
* Return 1 if this is a little endian machine, 0 if big endian.
*/