1 /* $NetBSD: bitops.h,v 1.11 2012/12/07 02:27:58 christos Exp $ */
4 * Copyright (c) 2007, 2010 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Christos Zoulas and Joerg Sonnenberger.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #ifndef COMPAT_BITOPS_H
33 #define COMPAT_BITOPS_H
39 * Find First Set functions
42 static inline int __unused
51 if ((_n
& 0x0000FFFFU
) == 0) {
55 if ((_n
& 0x000000FFU
) == 0) {
59 if ((_n
& 0x0000000FU
) == 0) {
63 if ((_n
& 0x00000003U
) == 0) {
67 if ((_n
& 0x00000001U
) == 0) {
76 static inline int __unused
85 if ((_n
& 0x00000000FFFFFFFFULL
) == 0) {
89 if ((_n
& 0x000000000000FFFFULL
) == 0) {
93 if ((_n
& 0x00000000000000FFULL
) == 0) {
97 if ((_n
& 0x000000000000000FULL
) == 0) {
101 if ((_n
& 0x0000000000000003ULL
) == 0) {
105 if ((_n
& 0x0000000000000001ULL
) == 0) {
114 * Find Last Set functions
117 static __inline
int __unused
126 if ((_n
& 0xFFFF0000U
) == 0) {
130 if ((_n
& 0xFF000000U
) == 0) {
134 if ((_n
& 0xF0000000U
) == 0) {
138 if ((_n
& 0xC0000000U
) == 0) {
142 if ((_n
& 0x80000000U
) == 0) {
160 if ((_n
& 0xFFFFFFFF00000000ULL
) == 0) {
164 if ((_n
& 0xFFFF000000000000ULL
) == 0) {
168 if ((_n
& 0xFF00000000000000ULL
) == 0) {
172 if ((_n
& 0xF000000000000000ULL
) == 0) {
176 if ((_n
& 0xC000000000000000ULL
) == 0) {
180 if ((_n
& 0x8000000000000000ULL
) == 0) {
188 #endif /* COMPAT_BITOPS_H_ */