radix tree test suite: Remove duplicate bitops code
[linux-block.git] / tools / testing / radix-tree / linux / kernel.h
1 #ifndef _KERNEL_H
2 #define _KERNEL_H
3
4 #include <assert.h>
5 #include <string.h>
6 #include <stdio.h>
7 #include <stddef.h>
8 #include <limits.h>
9
10 #include <linux/compiler.h>
11 #include <linux/err.h>
12 #include <linux/bitops.h>
13 #include <linux/log2.h>
14 #include "../../../include/linux/kconfig.h"
15
16 #ifdef BENCHMARK
17 #define RADIX_TREE_MAP_SHIFT    6
18 #else
19 #define RADIX_TREE_MAP_SHIFT    3
20 #endif
21
22 #ifndef NULL
23 #define NULL    0
24 #endif
25
26 #define BUG_ON(expr)    assert(!(expr))
27 #define WARN_ON(expr)   assert(!(expr))
28 #define __init
29 #define __must_check
30 #define panic(expr)
31 #define printk printf
32 #define __force
33 #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
34 #define pr_debug printk
35
36 #define smp_rmb()       barrier()
37 #define smp_wmb()       barrier()
38 #define cpu_relax()     barrier()
39
40 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
41
42 #define container_of(ptr, type, member) ({                      \
43         const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
44         (type *)( (char *)__mptr - offsetof(type, member) );})
45 #define min(a, b) ((a) < (b) ? (a) : (b))
46
47 #define cond_resched()  sched_yield()
48
49 static inline int in_interrupt(void)
50 {
51         return 0;
52 }
53
54 /*
55  * This looks more complex than it should be. But we need to
56  * get the type for the ~ right in round_down (it needs to be
57  * as wide as the result!), and we want to evaluate the macro
58  * arguments just once each.
59  */
60 #define __round_mask(x, y) ((__typeof__(x))((y)-1))
61 #define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1)
62 #define round_down(x, y) ((x) & ~__round_mask(x, y))
63
64 #define xchg(ptr, x)    uatomic_xchg(ptr, x)
65
66 #endif /* _KERNEL_H */