]> xenbits.xensource.com Git - people/liuw/freebsd.git/commitdiff
Add libkern ffsll() for parity with flsll()
authorcem <cem@FreeBSD.org>
Thu, 22 Oct 2015 20:28:37 +0000 (20:28 +0000)
committercem <cem@FreeBSD.org>
Thu, 22 Oct 2015 20:28:37 +0000 (20:28 +0000)
Sponsored by: EMC / Isilon Storage Division
Differential Revision: https://reviews.freebsd.org/D3962

sys/conf/files.arm
sys/conf/files.arm64
sys/conf/files.i386
sys/conf/files.mips
sys/conf/files.pc98
sys/conf/files.powerpc
sys/conf/files.sparc64
sys/libkern/ffsll.c [new file with mode: 0644]
sys/sys/libkern.h

index 33838ae146ab33aabb4d878a0506eea695665dc0..66c8daf7e94e86c92c699930120a1a462a3002ba 100644 (file)
@@ -120,6 +120,7 @@ libkern/ashldi3.c           standard
 libkern/ashrdi3.c              standard
 libkern/divdi3.c               standard
 libkern/ffsl.c                 standard
+libkern/ffsll.c                        standard
 libkern/fls.c                  standard
 libkern/flsl.c                 standard
 libkern/flsll.c                        standard
index a3b649e588d73a127e5606caf540f4bb12ab81e1..3a9a651d61c31a494ef42a3ac52061819de569a3 100644 (file)
@@ -82,6 +82,7 @@ kern/subr_dummy_vdso_tc.c     standard
 libkern/bcmp.c                 standard
 libkern/ffs.c                  standard
 libkern/ffsl.c                 standard
+libkern/ffsll.c                        standard
 libkern/fls.c                  standard
 libkern/flsl.c                 standard
 libkern/flsll.c                        standard
index 9f04beff10154340f891b59271262c25b93fed0a..ffe272e382d756d2fbac853d90c73278fedd7f94 100644 (file)
@@ -530,6 +530,7 @@ kern/imgact_aout.c          optional compat_aout
 kern/imgact_gzip.c             optional gzip
 kern/subr_sfbuf.c              standard
 libkern/divdi3.c               standard
+libkern/ffsll.c                        standard
 libkern/flsll.c                        standard
 libkern/memmove.c              standard
 libkern/memset.c               standard
index d0dd23bd8705418c9ff7537ca9f0ef8716759eee..22b947265dcf8a30709b11963d571e41a861a2eb 100644 (file)
@@ -56,6 +56,7 @@ kern/subr_sfbuf.c                     optional        mips | mipsel | mipsn32
 
 # gcc/clang runtime
 libkern/ffsl.c                         standard
+libkern/ffsll.c                                standard
 libkern/fls.c                          standard
 libkern/flsl.c                         standard
 libkern/flsll.c                                standard
index 78f85baeb349c48ac5e300f8207d9db3d71c8ba2..75269b4880076355842f05e215e79da14a2740d4 100644 (file)
@@ -222,6 +222,7 @@ kern/imgact_aout.c          optional compat_aout
 kern/imgact_gzip.c             optional gzip
 kern/subr_sfbuf.c              standard
 libkern/divdi3.c               standard
+libkern/ffsll.c                        standard
 libkern/flsll.c                        standard
 libkern/memmove.c              standard
 libkern/memset.c               standard
index be17b6ee5bdb175a371b0b31850df8e2f35d3bcc..7aa9840881ba7a9abb03e38186fd8d684fed986b 100644 (file)
@@ -87,6 +87,7 @@ libkern/cmpdi2.c              optional        powerpc
 libkern/divdi3.c               optional        powerpc
 libkern/ffs.c                  standard
 libkern/ffsl.c                 standard
+libkern/ffsll.c                        standard
 libkern/fls.c                  standard
 libkern/flsl.c                 standard
 libkern/flsll.c                        standard
index 0a0b721c91f89a41deae0d5099edd0b34ac387d6..84f23ff4b05921b586866308ece11eb4d7d8f419 100644 (file)
@@ -67,6 +67,7 @@ kern/syscalls.c                       optional        ktr
 kern/subr_sfbuf.c              standard
 libkern/ffs.c                  standard
 libkern/ffsl.c                 standard
+libkern/ffsll.c                        standard
 libkern/fls.c                  standard
 libkern/flsl.c                 standard
 libkern/flsll.c                        standard
diff --git a/sys/libkern/ffsll.c b/sys/libkern/ffsll.c
new file mode 100644 (file)
index 0000000..3a610cd
--- /dev/null
@@ -0,0 +1,48 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/libkern.h>
+
+/*
+ * Find First Set bit
+ */
+int
+ffsll(long long mask)
+{
+       int bit;
+
+       if (mask == 0)
+               return (0);
+       for (bit = 1; !(mask & 1); bit++)
+               mask = (unsigned long long)mask >> 1;
+       return (bit);
+}
index 7b0e0e42ec652830c7d023a98a69e9c7f1efe160..7484cdc91986c661cb8ce8cbecd4df8b8d49fbca 100644 (file)
@@ -89,6 +89,9 @@ int    ffs(int);
 #ifndef        HAVE_INLINE_FFSL
 int     ffsl(long);
 #endif
+#ifndef        HAVE_INLINE_FFSLL
+int     ffsll(long long);
+#endif
 #ifndef        HAVE_INLINE_FLS
 int     fls(int);
 #endif