X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Fimports.c;h=d798f80e25316612ba3d0b6616c8113ed1079896;hb=eded7f010d344a909cf9c403eb3bdad91804d174;hp=d8d35af15e2033f83e98c2bc6be0178a1775dc19;hpb=938c307e4526298d2703818d5fa848a31b076905;p=mesa.git diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c index d8d35af15e2..d798f80e253 100644 --- a/src/mesa/main/imports.c +++ b/src/mesa/main/imports.c @@ -542,26 +542,24 @@ int _mesa_ffs(int i) { #if (defined(_WIN32) && !defined(__MINGW32__) ) || defined(__IBMC__) || defined(__IBMCPP__) - register int bit = 0; - if (i != 0) { - if ((i & 0xffff) == 0) { - bit += 16; - i >>= 16; - } - if ((i & 0xff) == 0) { - bit += 8; - i >>= 8; - } - if ((i & 0xf) == 0) { - bit += 4; - i >>= 4; - } - while ((i & 1) == 0) { - bit++; - i >>= 1; - } + register int bit = 1; + if ((i & 0xffff) == 0) { + bit += 16; + i >>= 16; + } + if ((i & 0xff) == 0) { + bit += 8; + i >>= 8; + } + if ((i & 0xf) == 0) { + bit += 4; + i >>= 4; + } + if ((i & 0x3) == 0) { + bit += 2; + i >>= 2; } - return bit; + return (i) ? (bit + ((i + 1) & 0x01)) : 0; #else return ffs(i); #endif