summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/imports.c
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2008-05-06 07:45:28 +0100
committerKeith Whitwell <[email protected]>2008-05-06 07:45:28 +0100
commit09e6be9b5782870f1f225653687e0d3e7be2a5a9 (patch)
tree67215a913d51451b3a3d52f3f0815d4c81f4ff2b /src/mesa/main/imports.c
parent6361d6f48d13ce481253faf106fba5c6a41488ed (diff)
parentf77442fbd3b539aa3da927630c12c3a1a377f6da (diff)
Merge commit 'origin/gallium-0.1' into gallium-tex-surfaces
Conflicts: src/mesa/state_tracker/st_atom_sampler.c src/mesa/state_tracker/st_cb_texture.c
Diffstat (limited to 'src/mesa/main/imports.c')
-rw-r--r--src/mesa/main/imports.c36
1 files changed, 17 insertions, 19 deletions
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