musl - musl - an implementation of the standard library for Linux-based systems

index : musl
musl - an implementation of the standard library for Linux-based systems
summary refs log tree commit diff
path: root/src/misc/ffs.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/misc/ffs.c')
-rw-r--r--src/misc/ffs.c 6
1 files changed, 2 insertions, 4 deletions
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 <strings.h>
+#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;
}
generated by cgit v1.2.1 (git 2.18.0) at 2025年09月15日 16:50:40 +0000

AltStyle によって変換されたページ (->オリジナル) /