X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fmisc%2Fffs.c;h=673ce5a9758284c7eca182b32de3902c9b353b3f;hb=c8ea985748a6857ac5db9ef50f9c92e2966c04d5;hp=2f7cb32198462895a67350e87816849c977c4811;hpb=0b44a0315b47dd8eced9f3b7f31580cf14bbfc01;p=musl diff --git a/src/misc/ffs.c b/src/misc/ffs.c index 2f7cb321..673ce5a9 100644 --- a/src/misc/ffs.c +++ b/src/misc/ffs.c @@ -1,9 +1,7 @@ #include +#include "atomic.h" int ffs(int i) { - unsigned int j = i; - for (i=1; j && !(j&1); j>>=1, i++); - if (j) return i; - return 0; + return i ? a_ctz_l(i)+1 : 0; }