sna: Rewrite __fls without dependence upon x86 assembly

The asm() prevents SNA from compiling on ia64.

Fixes https://bugs.gentoo.org/show_bug.cgi?id=448570
This commit is contained in:
Matt Turner 2013-01-02 16:07:54 +00:00 committed by Chris Wilson
parent bc67bdcec8
commit fc702cdf53
1 changed files with 9 additions and 0 deletions

View File

@ -516,10 +516,19 @@ static void gem_close(int fd, uint32_t handle)
constant inline static unsigned long __fls(unsigned long word)
{
#if defined(__GNUC__) && (defined(__x86__) || defined(__x86_64__))
asm("bsr %1,%0"
: "=r" (word)
: "rm" (word));
return word;
#else
unsigned int v = 1;
while (word >>= 1)
v++;
return v;
#endif
}
constant inline static int cache_bucket(int num_pages)