From: Kenneth Graunke Date: Mon, 30 Mar 2015 23:08:26 +0000 (-0700) Subject: mesa: Implement _mesa_flsll(). X-Git-Tag: upstream/17.1.0~19676 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3d166b313db14523c2e618e0ebf22b83c86d6334;p=platform%2Fupstream%2Fmesa.git mesa: Implement _mesa_flsll(). This is _mesa_fls() for 64-bit values. Signed-off-by: Kenneth Graunke Reviewed-by: Matt Turner --- diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h index 29f2499..c4d917e 100644 --- a/src/mesa/main/imports.h +++ b/src/mesa/main/imports.h @@ -433,6 +433,30 @@ _mesa_fls(unsigned int n) #endif } +/** + * Find the last (most significant) bit set in a uint64_t value. + * + * Essentially ffsll() in the reverse direction. + */ +static inline unsigned int +_mesa_flsll(uint64_t n) +{ +#ifdef HAVE___BUILTIN_CLZLL + return n == 0 ? 0 : 64 - __builtin_clzll(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);