diff options
author | alfred <alfred@FreeBSD.org> | 2013-07-27 20:47:01 +0000 |
---|---|---|
committer | alfred <alfred@FreeBSD.org> | 2013-07-27 20:47:01 +0000 |
commit | fdd68bea0e12d92e6afb245364fba13c3f8b499b (patch) | |
tree | 56df7df9ac8f7b431ecb8a19f2ae000fa5ebdd85 /sys/libkern | |
parent | 24e94a1aa8ae0ae20697703ef7605e13c814621f (diff) | |
download | FreeBSD-src-fdd68bea0e12d92e6afb245364fba13c3f8b499b.zip FreeBSD-src-fdd68bea0e12d92e6afb245364fba13c3f8b499b.tar.gz |
Fix watchdog pretimeout.
The original API calls for pow2ns, however the new APIs from
Linux call for seconds.
We need to be able to convert to/from 2^Nns to seconds in both
userland and kernel to fix this and properly compare units.
Diffstat (limited to 'sys/libkern')
-rw-r--r-- | sys/libkern/flsll.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/sys/libkern/flsll.c b/sys/libkern/flsll.c new file mode 100644 index 0000000..0629480 --- /dev/null +++ b/sys/libkern/flsll.c @@ -0,0 +1,47 @@ +/*- + * 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> +#include <sys/libkern.h> +__FBSDID("$FreeBSD$"); + +/* + * Find Last Set bit + */ +int +flsll(long long mask) +{ + int bit; + + if (mask == 0) + return (0); + for (bit = 1; mask != 1; bit++) + mask = (unsigned long long)mask >> 1; + return (bit); +} |