aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main/imports.h
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-09-14 11:09:08 +0200
committermarha <marha@users.sourceforge.net>2012-09-14 11:09:08 +0200
commitb08ba56019b146786e1cde553c036dd0c4fd02e5 (patch)
tree651ada0a32bd95a5c80838f11d31205c8d3e8807 /mesalib/src/mesa/main/imports.h
parentaa10a08696cae93799fcddae3f0245ceee905e01 (diff)
downloadvcxsrv-b08ba56019b146786e1cde553c036dd0c4fd02e5.tar.gz
vcxsrv-b08ba56019b146786e1cde553c036dd0c4fd02e5.tar.bz2
vcxsrv-b08ba56019b146786e1cde553c036dd0c4fd02e5.zip
fontconfig libX11 mesa xkeyboard-config git update 14 sep 2012
Diffstat (limited to 'mesalib/src/mesa/main/imports.h')
-rw-r--r--mesalib/src/mesa/main/imports.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/mesalib/src/mesa/main/imports.h b/mesalib/src/mesa/main/imports.h
index abf216c99..81da51047 100644
--- a/mesalib/src/mesa/main/imports.h
+++ b/mesalib/src/mesa/main/imports.h
@@ -520,6 +520,28 @@ extern unsigned int
_mesa_bitcount_64(uint64_t n);
#endif
+/**
+ * Find the last (most significant) bit set in a word.
+ *
+ * Essentially ffs() in the reverse direction.
+ */
+static inline unsigned int
+_mesa_fls(unsigned int n)
+{
+#if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 304)
+ return n == 0 ? 0 : 32 - __builtin_clz(n);
+#else
+ unsigned int v = 1;
+
+ if (n == 0)
+ return 0;
+
+ while (n >>= 1)
+ v++;
+
+ return v;
+#endif
+}
extern GLhalfARB
_mesa_float_to_half(float f);