Blame view
tools/include/linux/bitops.h
1.67 KB
88bcea43f tools: Introduce ... |
1 2 |
#ifndef _TOOLS_LINUX_BITOPS_H_ #define _TOOLS_LINUX_BITOPS_H_ |
5a116dd27 perf tools: Use k... |
3 |
|
25cd480e4 tools: Remove bit... |
4 |
#include <asm/types.h> |
fb72014d9 perf tools: Don't... |
5 |
#include <linux/kernel.h> |
a860a6081 perf tools: Add m... |
6 |
#include <linux/compiler.h> |
5a116dd27 perf tools: Use k... |
7 |
|
3f34f6c02 perf tools: inclu... |
8 9 10 |
#ifndef __WORDSIZE #define __WORDSIZE (__SIZEOF_LONG__ * 8) #endif |
fb72014d9 perf tools: Don't... |
11 |
#define BITS_PER_LONG __WORDSIZE |
93c49b3e5 tools: Whitespace... |
12 13 14 15 16 17 18 19 |
#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) #define BIT_WORD(nr) ((nr) / BITS_PER_LONG) #define BITS_PER_BYTE 8 #define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) #define BITS_TO_U64(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(u64)) #define BITS_TO_U32(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(u32)) #define BITS_TO_BYTES(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE) |
ee3d25044 perf tools: Fix c... |
20 |
|
25cd480e4 tools: Remove bit... |
21 22 23 24 |
extern unsigned int __sw_hweight8(unsigned int w); extern unsigned int __sw_hweight16(unsigned int w); extern unsigned int __sw_hweight32(unsigned int w); extern unsigned long __sw_hweight64(__u64 w); |
88bcea43f tools: Introduce ... |
25 26 27 28 29 30 31 |
/* * Include this here because some architectures need generic_ffs/fls in * scope * * XXX: this needs to be asm/bitops.h, when we get to per arch optimizations */ #include <asm-generic/bitops.h> |
b1e5a9bee perf tools: Use f... |
32 33 34 35 36 37 |
#define for_each_set_bit(bit, addr, size) \ for ((bit) = find_first_bit((addr), (size)); \ (bit) < (size); \ (bit) = find_next_bit((addr), (size), (bit) + 1)) /* same as for_each_set_bit() but use bit as value to start with */ |
307b1cd7e bitops: rename fo... |
38 |
#define for_each_set_bit_from(bit, addr, size) \ |
b1e5a9bee perf tools: Use f... |
39 40 41 |
for ((bit) = find_next_bit((addr), (size), (bit)); \ (bit) < (size); \ (bit) = find_next_bit((addr), (size), (bit) + 1)) |
fb72014d9 perf tools: Don't... |
42 43 44 45 |
static inline unsigned long hweight_long(unsigned long w) { return sizeof(w) == 4 ? hweight32(w) : hweight64(w); } |
5a116dd27 perf tools: Use k... |
46 |
|
afcd4f623 tools: Adopt fls_... |
47 48 49 50 51 52 |
static inline unsigned fls_long(unsigned long l) { if (sizeof(l) == 4) return fls(l); return fls64(l); } |
5a116dd27 perf tools: Use k... |
53 |
#endif |