x86: switch 64-bit to generic find_first_bit
[deliverable/linux.git] / include / asm-x86 / bitops_64.h
CommitLineData
1da177e4
LT
1#ifndef _X86_64_BITOPS_H
2#define _X86_64_BITOPS_H
3
4/*
5 * Copyright 1992, Linus Torvalds.
6 */
7
2aba6925 8#ifndef CONFIG_GENERIC_FIND_FIRST_BIT
ade8c56c 9extern long find_first_zero_bit(const unsigned long *addr, unsigned long size);
ade8c56c 10extern long find_first_bit(const unsigned long *addr, unsigned long size);
1da177e4
LT
11
12/* return index of first bet set in val or max when no bit is set */
d2ccc3fd 13static inline long __scanbit(unsigned long val, unsigned long max)
1da177e4
LT
14{
15 asm("bsfq %1,%0 ; cmovz %2,%0" : "=&r" (val) : "r" (val), "r" (max));
16 return val;
17}
18
49f74946
JP
19#define find_first_bit(addr, size) \
20 ((__builtin_constant_p((size)) && (size) <= BITS_PER_LONG \
21 ? (__scanbit(*(unsigned long *)(addr), (size))) \
22 : find_first_bit((addr), (size))))
23
24#define find_first_zero_bit(addr, size) \
25 ((__builtin_constant_p((size)) && (size) <= BITS_PER_LONG \
26 ? (__scanbit(~*(unsigned long *)(addr), (size))) \
27 : find_first_zero_bit((addr), (size))))
2aba6925 28#endif
49f74946
JP
29
30static inline void set_bit_string(unsigned long *bitmap, unsigned long i,
31 int len)
32{
33 unsigned long end = i + len;
1da177e4 34 while (i < end) {
49f74946 35 __set_bit(i, bitmap);
1da177e4
LT
36 i++;
37 }
49f74946 38}
1da177e4 39
1da177e4
LT
40#ifdef __KERNEL__
41
f33e2fba 42#include <asm-generic/bitops/sched.h>
1da177e4 43
0136611c
AK
44#define ARCH_HAS_FAST_MULTIPLIER 1
45
f33e2fba 46#include <asm-generic/bitops/hweight.h>
1da177e4
LT
47
48#endif /* __KERNEL__ */
49
d57594c2
AH
50#include <asm-generic/bitops/fls64.h>
51
1da177e4
LT
52#ifdef __KERNEL__
53
f33e2fba
AM
54#include <asm-generic/bitops/ext2-non-atomic.h>
55
49f74946
JP
56#define ext2_set_bit_atomic(lock, nr, addr) \
57 test_and_set_bit((nr), (unsigned long *)(addr))
58#define ext2_clear_bit_atomic(lock, nr, addr) \
59 test_and_clear_bit((nr), (unsigned long *)(addr))
f33e2fba
AM
60
61#include <asm-generic/bitops/minix.h>
1da177e4 62
1da177e4
LT
63#endif /* __KERNEL__ */
64
65#endif /* _X86_64_BITOPS_H */
This page took 0.334538 seconds and 5 git commands to generate.