1 #ifndef _X86_64_BITOPS_H
2 #define _X86_64_BITOPS_H
5 * Copyright 1992, Linus Torvalds.
8 extern long find_first_zero_bit(const unsigned long *addr
, unsigned long size
);
9 extern long find_first_bit(const unsigned long *addr
, unsigned long size
);
11 /* return index of first bet set in val or max when no bit is set */
12 static inline long __scanbit(unsigned long val
, unsigned long max
)
14 asm("bsfq %1,%0 ; cmovz %2,%0" : "=&r" (val
) : "r" (val
), "r" (max
));
18 #define find_next_bit(addr,size,off) \
19 ((__builtin_constant_p(size) && (size) <= BITS_PER_LONG ? \
20 ((off) + (__scanbit((*(unsigned long *)addr) >> (off),(size)-(off)))) : \
21 find_next_bit(addr,size,off)))
23 #define find_next_zero_bit(addr,size,off) \
24 ((__builtin_constant_p(size) && (size) <= BITS_PER_LONG ? \
25 ((off)+(__scanbit(~(((*(unsigned long *)addr)) >> (off)),(size)-(off)))) : \
26 find_next_zero_bit(addr,size,off)))
28 #define find_first_bit(addr, size) \
29 ((__builtin_constant_p((size)) && (size) <= BITS_PER_LONG \
30 ? (__scanbit(*(unsigned long *)(addr), (size))) \
31 : find_first_bit((addr), (size))))
33 #define find_first_zero_bit(addr, size) \
34 ((__builtin_constant_p((size)) && (size) <= BITS_PER_LONG \
35 ? (__scanbit(~*(unsigned long *)(addr), (size))) \
36 : find_first_zero_bit((addr), (size))))
38 static inline void set_bit_string(unsigned long *bitmap
, unsigned long i
,
41 unsigned long end
= i
+ len
;
49 * ffz - find first zero in word.
50 * @word: The word to search
52 * Undefined if no zero exists, so code should check against ~0UL first.
54 static inline unsigned long ffz(unsigned long word
)
63 * __ffs - find first bit in word.
64 * @word: The word to search
66 * Undefined if no bit exists, so code should check against 0 first.
68 static inline unsigned long __ffs(unsigned long word
)
77 * __fls: find last bit set.
78 * @word: The word to search
80 * Undefined if no zero exists, so code should check against ~0UL first.
82 static inline unsigned long __fls(unsigned long word
)
92 #include <asm-generic/bitops/sched.h>
95 * ffs - find first bit set
96 * @x: the word to search
98 * This is defined the same way as
99 * the libc and compiler builtin ffs routines, therefore
100 * differs in spirit from the above ffz (man ffs).
102 static inline int ffs(int x
)
106 __asm__("bsfl %1,%0\n\t"
108 : "=r" (r
) : "rm" (x
), "r" (-1));
113 * fls64 - find last bit set in 64 bit word
114 * @x: the word to search
116 * This is defined the same way as fls.
118 static inline int fls64(__u64 x
)
126 * fls - find last bit set
127 * @x: the word to search
129 * This is defined the same way as ffs.
131 static inline int fls(int x
)
135 __asm__("bsrl %1,%0\n\t"
137 : "=&r" (r
) : "rm" (x
), "rm" (-1));
141 #define ARCH_HAS_FAST_MULTIPLIER 1
143 #include <asm-generic/bitops/hweight.h>
145 #endif /* __KERNEL__ */
149 #include <asm-generic/bitops/ext2-non-atomic.h>
151 #define ext2_set_bit_atomic(lock, nr, addr) \
152 test_and_set_bit((nr), (unsigned long *)(addr))
153 #define ext2_clear_bit_atomic(lock, nr, addr) \
154 test_and_clear_bit((nr), (unsigned long *)(addr))
156 #include <asm-generic/bitops/minix.h>
158 #endif /* __KERNEL__ */
160 #endif /* _X86_64_BITOPS_H */
This page took 0.033575 seconds and 5 git commands to generate.