aboutsummaryrefslogtreecommitdiff
path: root/libiberty
diff options
context:
space:
mode:
authorDJ Delorie <dj@redhat.com>2001-07-05 17:29:17 +0000
committerDJ Delorie <dj@redhat.com>2001-07-05 17:29:17 +0000
commit7b78baae9b0beeee74aa508c150c35b4f9f35982 (patch)
treea3cac4407bb945ea2425479741572dd5b05545a9 /libiberty
parentaf703f96203b5320baec426e5864cff71735a071 (diff)
downloadbinutils-7b78baae9b0beeee74aa508c150c35b4f9f35982.zip
binutils-7b78baae9b0beeee74aa508c150c35b4f9f35982.tar.gz
binutils-7b78baae9b0beeee74aa508c150c35b4f9f35982.tar.bz2
merge from gcc
Diffstat (limited to 'libiberty')
-rw-r--r--libiberty/ChangeLog6
-rw-r--r--libiberty/Makefile.in2
-rwxr-xr-xlibiberty/configure3
-rw-r--r--libiberty/configure.in3
-rw-r--r--libiberty/ffs.c29
5 files changed, 40 insertions, 3 deletions
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index 43ff94e..c5c3910 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -1,3 +1,9 @@
+2001-07-05 Mark Klein <mklein@dis.com>
+
+ * Makefile.in: Add ffs.c dependency.
+ * configure.in: Add ffs.c.
+ * ffs.c: New file.
+
2001-06-18 Richard Henderson <rth@redhat.com>
* concat.c: Include <sys/types.h>.
diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in
index 92b90fa..66aa510 100644
--- a/libiberty/Makefile.in
+++ b/libiberty/Makefile.in
@@ -122,7 +122,7 @@ dvi: dvi-subdir
# configure.in.
CFILES = asprintf.c alloca.c argv.c atexit.c basename.c bcmp.c bcopy.c \
bzero.c calloc.c choose-temp.c clock.c concat.c cplus-dem.c \
- cp-demangle.c dyn-string.c fdmatch.c fnmatch.c getcwd.c \
+ cp-demangle.c dyn-string.c fdmatch.c fnmatch.c ffs.c getcwd.c \
getpwd.c getopt.c getopt1.c getpagesize.c getruntime.c \
floatformat.c hashtab.c hex.c index.c insque.c lbasename.c \
md5.c make-temp-file.c memchr.c \
diff --git a/libiberty/configure b/libiberty/configure
index 6b0aa20..7025397 100755
--- a/libiberty/configure
+++ b/libiberty/configure
@@ -1329,6 +1329,7 @@ funcs="$funcs bsearch"
funcs="$funcs bzero"
funcs="$funcs calloc"
funcs="$funcs clock"
+funcs="$funcs ffs"
funcs="$funcs getcwd"
funcs="$funcs getpagesize"
funcs="$funcs index"
@@ -1700,7 +1701,7 @@ else
fi
done
- for ac_func in sysconf times sbrk gettimeofday
+ for ac_func in sysconf times sbrk gettimeofday ffs
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:1707: checking for $ac_func" >&5
diff --git a/libiberty/configure.in b/libiberty/configure.in
index 6adf48e..65f9402 100644
--- a/libiberty/configure.in
+++ b/libiberty/configure.in
@@ -87,6 +87,7 @@ funcs="$funcs bsearch"
funcs="$funcs bzero"
funcs="$funcs calloc"
funcs="$funcs clock"
+funcs="$funcs ffs"
funcs="$funcs getcwd"
funcs="$funcs getpagesize"
funcs="$funcs index"
@@ -134,7 +135,7 @@ if test "x" = "y"; then
AC_CHECK_FUNCS(strcasecmp setenv strchr strdup strncasecmp strrchr strstr)
AC_CHECK_FUNCS(strtod strtol strtoul tmpnam vasprintf vfprintf vprintf)
AC_CHECK_FUNCS(vsprintf waitpid getrusage on_exit psignal strerror strsignal)
- AC_CHECK_FUNCS(sysconf times sbrk gettimeofday)
+ AC_CHECK_FUNCS(sysconf times sbrk gettimeofday ffs)
AC_DEFINE(HAVE_SYS_ERRLIST, 1, [Define if you have the sys_errlist variable.])
AC_DEFINE(HAVE_SYS_NERR, 1, [Define if you have the sys_nerr variable.])
AC_DEFINE(HAVE_SYS_SIGLIST, 1, [Define if you have the sys_siglist variable.])
diff --git a/libiberty/ffs.c b/libiberty/ffs.c
new file mode 100644
index 0000000..8ffb03e
--- /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;
+}
+