@@ -, +, @@ --- src/sna/kgem.c | 17 +++++++++++++---- 1 files changed, 13 insertions(+), 4 deletions(-) --- a/src/sna/kgem.c +++ a/src/sna/kgem.c @@ -516,10 +516,19 @@ static void gem_close(int fd, uint32_t handle) constant inline static unsigned long __fls(unsigned long word) { - asm("bsr %1,%0" - : "=r" (word) - : "rm" (word)); - return word; +#if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 304) + return word == 0 ? 0 : 32 - __builtin_clz(word); +#else + unsigned int v = 1; + + if (word == 0) + return 0; + + while (word >>= 1) + v++; + + return v; +#endif } constant inline static int cache_bucket(int num_pages) --