From 0a9d2abef2e6fac5d52556969655a62711df6418 Mon Sep 17 00:00:00 2001 From: marha Date: Thu, 9 Jun 2011 09:24:20 +0200 Subject: mesa xkbcomp xkeyboard-config git update 9 Jun 2011 --- mesalib/src/mesa/main/imports.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'mesalib/src/mesa/main/imports.h') 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. */ -- cgit v1.2.3