add owner and type fields to the extents aand block headers
[platform/upstream/btrfs-progs.git] / kerncompat.h
1 #ifndef __KERNCOMPAT
2 #define __KERNCOMPAT
3 #define gfp_t int
4 #define get_cpu_var(p) (p)
5 #define __get_cpu_var(p) (p)
6 #define BITS_PER_LONG 64
7 #define __GFP_BITS_SHIFT 20
8 #define __GFP_BITS_MASK ((int)((1 << __GFP_BITS_SHIFT) - 1))
9 #define GFP_KERNEL 0
10 #define GFP_NOFS 0
11 #define __read_mostly
12 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
13 #define PAGE_SHIFT 12
14 #define ULONG_MAX       (~0UL)
15 #define BUG() abort()
16 #ifdef __CHECKER__
17 #define __force    __attribute__((force))
18 #define __bitwise__ __attribute__((bitwise))
19 #else
20 #define __force
21 #define __bitwise__
22 #endif
23
24 typedef unsigned int u32;
25 typedef u32 __u32;
26 typedef unsigned long long u64;
27 typedef unsigned char u8;
28 typedef unsigned short u16;
29
30 typedef unsigned long pgoff_t;
31
32 #include <stdio.h>
33 #include <stdlib.h>
34 #include <string.h>
35
36 struct vma_shared { int prio_tree_node; };
37 struct vm_area_struct {
38         unsigned long vm_pgoff;
39         unsigned long vm_start;
40         unsigned long vm_end;
41         struct vma_shared shared;
42 };
43
44 struct page {
45         unsigned long index;
46 };
47
48 static inline void preempt_enable(void) { do {; } while(0);}
49 static inline void preempt_disable(void) { do {; } while(0);}
50
51 #define BITOP_MASK(nr)          (1UL << ((nr) % BITS_PER_LONG))
52 #define BITOP_WORD(nr)          ((nr) / BITS_PER_LONG)
53
54 /**
55  * __set_bit - Set a bit in memory
56  * @nr: the bit to set
57  * @addr: the address to start counting from
58  *
59  * Unlike set_bit(), this function is non-atomic and may be reordered.
60  * If it's called on the same region of memory simultaneously, the effect
61  * may be that only one operation succeeds.
62  */
63 static inline void __set_bit(int nr, volatile unsigned long *addr)
64 {
65         unsigned long mask = BITOP_MASK(nr);
66         unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr);
67
68         *p  |= mask;
69 }
70
71 static inline void __clear_bit(int nr, volatile unsigned long *addr)
72 {
73         unsigned long mask = BITOP_MASK(nr);
74         unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr);
75
76         *p &= ~mask;
77 }
78
79 /**
80  * test_bit - Determine whether a bit is set
81  * @nr: bit number to test
82  * @addr: Address to start counting from
83  */
84 static inline int test_bit(int nr, const volatile unsigned long *addr)
85 {
86         return 1UL & (addr[BITOP_WORD(nr)] >> (nr & (BITS_PER_LONG-1)));
87 }
88
89 #define BUG_ON(c) do { if (c) abort(); } while (0)
90
91 #define container_of(ptr, type, member) ({                      \
92         const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
93                 (type *)( (char *)__mptr - __builtin_offsetof(type,member) );})
94
95 #define ENOMEM 5
96 #define EEXIST 6
97
98 #define __CHECK_ENDIAN__
99 #ifdef __CHECK_ENDIAN__
100 #define __bitwise __bitwise__
101 #else
102 #define __bitwise
103 #endif
104
105 typedef u16 __bitwise __le16;
106 typedef u16 __bitwise __be16;
107 typedef u32 __bitwise __le32;
108 typedef u32 __bitwise __be32;
109 typedef u64 __bitwise __le64;
110 typedef u64 __bitwise __be64;
111
112 #define cpu_to_le64(x) ((__force __le64)(u64)(x))
113 #define le64_to_cpu(x) ((__force u64)(__le64)(x))
114 #define cpu_to_le32(x) ((__force __le32)(u32)(x))
115 #define le32_to_cpu(x) ((__force u32)(__le32)(x))
116 #define cpu_to_le16(x) ((__force __le16)(u16)(x))
117 #define le16_to_cpu(x) ((__force u16)(__le16)(x))
118 #endif