summaryrefslogtreecommitdiff
path: root/libiberty/ffs.c
diff options
context:
space:
mode:
authordj <dj@138bc75d-0d04-0410-961f-82ee72b054a4>2001-07-05 17:24:39 +0000
committerdj <dj@138bc75d-0d04-0410-961f-82ee72b054a4>2001-07-05 17:24:39 +0000
commit8568af222660626565421b8cff22c897806172ea (patch)
treee1a90952f7c17b7f4189ba7c65da694b76a2b58c /libiberty/ffs.c
parenta130b9001ec2a8273cbe7c1eee3a7cf9a77b8424 (diff)
downloadgcc-8568af222660626565421b8cff22c897806172ea.tar.gz
* Makefile.in: Add ffs.c dependency.
* configure.in: Add ffs.c. * ffs.c: New file. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@43784 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libiberty/ffs.c')
-rw-r--r--libiberty/ffs.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/libiberty/ffs.c b/libiberty/ffs.c
new file mode 100644
index 00000000000..8ffb03e7c5e
--- /dev/null
+++ b/libiberty/ffs.c
@@ -0,0 +1,29 @@
+/* ffs -- Find the first bit set in the parameter
+
+NAME
+ ffs -- Find the first bit set in the parameter
+
+SYNOPSIS
+ int ffs (int valu)
+
+DESCRIPTION
+ Find the first bit set in the parameter. Bits are numbered from
+ right to left, starting with bit 1.
+
+*/
+
+int
+ffs (valu)
+ register int valu;
+{
+ register int bit;
+
+ if (valu == 0)
+ return 0;
+
+ for (bit = 1; !(valu & 1); bit++)
+ valu >>= 1;
+
+ return bit;
+}
+