summaryrefslogtreecommitdiff
path: root/usr/src/boot/libsa/string/fls.c
diff options
context:
space:
mode:
authorRichard Lowe <richlowe@richlowe.net>2022-02-22 18:00:48 -0600
committerRichard Lowe <richlowe@richlowe.net>2022-02-22 18:00:48 -0600
commit3971085411b91c5d82e278443ab68fca1946cb21 (patch)
tree8e6d01d8aea1c3d8179a47b929ff5bfa8b42f752 /usr/src/boot/libsa/string/fls.c
parent1df45418ec3688847e142a9a2213965459ff39c7 (diff)
parentca783257c986cddcc674ae22916a6766b98a2d36 (diff)
downloadillumos-joyent-3971085411b91c5d82e278443ab68fca1946cb21.tar.gz
Merge branch 'master' of https://github.com/illumos/illumos-gate into man/big-reorg
# Conflicts: # usr/src/cmd/fmthard/fmthard.c # usr/src/cmd/zoneadmd/zcons.c # usr/src/man/man2/chmod.2 # usr/src/man/man2/close.2 # usr/src/man/man2/open.2 # usr/src/man/man3c/grantpt.3c # usr/src/man/man3c/posix_openpt.3c # usr/src/man/man3c/ptsname.3c # usr/src/man/man3c/unlockpt.3c # usr/src/man/man3utempter/utempter_add_record.3utempter # usr/src/man/man4/Makefile # usr/src/man/man4d/ptm.4d # usr/src/man/man4d/pts.4d # usr/src/man/man4d/pty.4d # usr/src/man/man4d/zcons.4d # usr/src/man/man4m/pckt.4m # usr/src/man/man4m/ptem.4m # usr/src/man/man4p/vxlan.7p # usr/src/man/man5/Makefile # usr/src/man/man5/bhyve_config.5 # usr/src/man/man7d/Makefile # usr/src/man/man7p/Makefile # usr/src/man/man8/bhyve.8 # usr/src/man/man8/dladm.8 # usr/src/man/man8/flowadm.8 # usr/src/man/man8/fmthard.8 # usr/src/man/man8/in.rlogind.8 # usr/src/man/man8/in.telnetd.8 # usr/src/man/man8/nvmeadm.8 # usr/src/man/man8/pppd.8 # usr/src/pkg/manifests/SUNWcs.man4d.inc # usr/src/uts/common/io/zcons.c
Diffstat (limited to 'usr/src/boot/libsa/string/fls.c')
-rw-r--r--usr/src/boot/libsa/string/fls.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/usr/src/boot/libsa/string/fls.c b/usr/src/boot/libsa/string/fls.c
new file mode 100644
index 0000000000..7145b909f0
--- /dev/null
+++ b/usr/src/boot/libsa/string/fls.c
@@ -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.
+ * 3. 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 <strings.h>
+
+/*
+ * Find Last Set bit
+ */
+int
+fls(int mask)
+{
+ int bit;
+
+ if (mask == 0)
+ return (0);
+ for (bit = 1; mask != 1; bit++)
+ mask = (unsigned int)mask >> 1;
+ return (bit);
+}