blob: 105d3f5840896f08f7c9d27500e6c61d5c0e6fc0 [file] [log] [blame]
Chris Mason4920c9a2007-01-26 16:38:42 -05001#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))
Chris Masoneb60cea2007-02-02 09:18:22 -05009#define GFP_KERNEL 0
Chris Mason4920c9a2007-01-26 16:38:42 -050010#define __read_mostly
11#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
Chris Mason4920c9a2007-01-26 16:38:42 -050012#define PAGE_SHIFT 12
13#define ULONG_MAX (~0UL)
14#define BUG() abort()
Chris Masonbb492bb2007-03-12 12:29:44 -040015#ifdef __CHECKER__
16#define __force __attribute__((force))
17#define __bitwise__ __attribute__((bitwise))
18#else
19#define __force
20#define __bitwise__
21#endif
Chris Mason4920c9a2007-01-26 16:38:42 -050022
23typedef unsigned int u32;
Chris Mason62e27492007-03-15 12:56:47 -040024typedef u32 __u32;
Chris Mason7cf75962007-02-26 10:55:01 -050025typedef unsigned long long u64;
Chris Mason4920c9a2007-01-26 16:38:42 -050026typedef unsigned char u8;
27typedef unsigned short u16;
28
29typedef unsigned long pgoff_t;
30
31#include <stdio.h>
32#include <stdlib.h>
33#include <string.h>
34
35struct vma_shared { int prio_tree_node; };
36struct vm_area_struct {
37 unsigned long vm_pgoff;
38 unsigned long vm_start;
39 unsigned long vm_end;
40 struct vma_shared shared;
41};
42
43struct page {
44 unsigned long index;
45};
46
47static inline void preempt_enable(void) { do {; } while(0);}
48static inline void preempt_disable(void) { do {; } while(0);}
49
50static inline void __set_bit(int bit, unsigned long *map) {
51 unsigned long *p = map + bit / BITS_PER_LONG;
52 bit = bit & (BITS_PER_LONG -1);
53 *p |= 1UL << bit;
54}
55
56static inline int test_bit(int bit, unsigned long *map) {
57 unsigned long *p = map + bit / BITS_PER_LONG;
58 bit = bit & (BITS_PER_LONG -1);
59 return *p & (1UL << bit) ? 1 : 0;
60}
61
62static inline void __clear_bit(int bit, unsigned long *map) {
63 unsigned long *p = map + bit / BITS_PER_LONG;
64 bit = bit & (BITS_PER_LONG -1);
65 *p &= ~(1UL << bit);
66}
67#define BUG_ON(c) do { if (c) abort(); } while (0)
68
69#define container_of(ptr, type, member) ({ \
70 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
71 (type *)( (char *)__mptr - __builtin_offsetof(type,member) );})
72
Chris Mason4920c9a2007-01-26 16:38:42 -050073#define ENOMEM 5
74#define EEXIST 6
Chris Masonbb492bb2007-03-12 12:29:44 -040075
76#define __CHECK_ENDIAN__
77#ifdef __CHECK_ENDIAN__
78#define __bitwise __bitwise__
79#else
80#define __bitwise
81#endif
82
83typedef u16 __bitwise __le16;
84typedef u16 __bitwise __be16;
85typedef u32 __bitwise __le32;
86typedef u32 __bitwise __be32;
87typedef u64 __bitwise __le64;
88typedef u64 __bitwise __be64;
89
90#define cpu_to_le64(x) ((__force __le64)(u64)(x))
91#define le64_to_cpu(x) ((__force u64)(__le64)(x))
92#define cpu_to_le32(x) ((__force __le32)(u32)(x))
93#define le32_to_cpu(x) ((__force u32)(__le32)(x))
94#define cpu_to_le16(x) ((__force __le16)(u16)(x))
95#define le16_to_cpu(x) ((__force u16)(__le16)(x))
Chris Masone2fa7222007-03-12 16:22:34 -040096#endif