1124480Sdes/*-
2124480Sdes * Copyright (c) 1990, 1993
3124480Sdes *	The Regents of the University of California.  All rights reserved.
4124480Sdes *
5124480Sdes * Redistribution and use in source and binary forms, with or without
6124480Sdes * modification, are permitted provided that the following conditions
7124480Sdes * are met:
8124480Sdes * 1. Redistributions of source code must retain the above copyright
9124480Sdes *    notice, this list of conditions and the following disclaimer.
10124480Sdes * 2. Redistributions in binary form must reproduce the above copyright
11124480Sdes *    notice, this list of conditions and the following disclaimer in the
12124480Sdes *    documentation and/or other materials provided with the distribution.
13124480Sdes * 4. Neither the name of the University nor the names of its contributors
14124480Sdes *    may be used to endorse or promote products derived from this software
15124480Sdes *    without specific prior written permission.
16124480Sdes *
17124480Sdes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18124480Sdes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19124480Sdes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20124480Sdes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21124480Sdes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22124480Sdes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23124480Sdes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24124480Sdes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25124480Sdes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26124480Sdes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27124480Sdes * SUCH DAMAGE.
28124480Sdes */
29124480Sdes
30124480Sdes#include <sys/cdefs.h>
31124480Sdes__FBSDID("$FreeBSD$");
32124480Sdes
33124480Sdes#include <sys/libkern.h>
34124480Sdes
35124480Sdes/*
36124480Sdes * Find First Set bit
37124480Sdes */
38124480Sdesint
39124480Sdesffsl(long mask)
40124480Sdes{
41124480Sdes	int bit;
42124480Sdes
43124480Sdes	if (mask == 0)
44124480Sdes		return (0);
45124480Sdes	for (bit = 1; !(mask & 1); bit++)
46124514Sdes		mask = (unsigned long)mask >> 1;
47124480Sdes	return (bit);
48124480Sdes}
49