11 #include <linux/compiler.h>
12 #include <linux/types.h>
13 #include <linux/printk.h>
14 #include <linux/bug.h>
17 #include <asm/barrier.h>
21 #define PAGE_SIZE getpagesize()
22 #define PAGE_MASK (~(PAGE_SIZE-1))
24 typedef unsigned long long dma_addr_t
;
25 typedef size_t __kernel_size_t
;
26 typedef unsigned int __wsum
;
29 unsigned long long dummy
;
32 /* Physical == Virtual */
33 #define virt_to_phys(p) ((unsigned long)p)
34 #define phys_to_virt(a) ((void *)(unsigned long)(a))
35 /* Page address: Virtual / 4K */
36 #define page_to_phys(p) ((dma_addr_t)(unsigned long)(p))
37 #define virt_to_page(p) ((struct page *)((unsigned long)p & PAGE_MASK))
39 #define offset_in_page(p) (((unsigned long)p) % PAGE_SIZE)
41 #define __printf(a,b) __attribute__((format(printf,a,b)))
43 #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
45 extern void *__kmalloc_fake
, *__kfree_ignore_start
, *__kfree_ignore_end
;
46 static inline void *kmalloc(size_t s
, gfp_t gfp
)
49 return __kmalloc_fake
;
52 static inline void *kzalloc(size_t s
, gfp_t gfp
)
54 void *p
= kmalloc(s
, gfp
);
60 static inline void kfree(void *p
)
62 if (p
>= __kfree_ignore_start
&& p
< __kfree_ignore_end
)
67 static inline void *krealloc(void *p
, size_t s
, gfp_t gfp
)
73 static inline unsigned long __get_free_page(gfp_t gfp
)
77 posix_memalign(&p
, PAGE_SIZE
, PAGE_SIZE
);
78 return (unsigned long)p
;
81 static inline void free_page(unsigned long addr
)
86 #define container_of(ptr, type, member) ({ \
87 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
88 (type *)( (char *)__mptr - offsetof(type,member) );})
90 #define uninitialized_var(x) x = x
93 # define likely(x) (__builtin_expect(!!(x), 1))
96 # define unlikely(x) (__builtin_expect(!!(x), 0))
99 #define pr_err(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
101 #define pr_debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
103 #define pr_debug(format, ...) do {} while (0)
105 #define dev_err(dev, format, ...) fprintf (stderr, format, ## __VA_ARGS__)
106 #define dev_warn(dev, format, ...) fprintf (stderr, format, ## __VA_ARGS__)
108 #define min(x, y) ({ \
109 typeof(x) _min1 = (x); \
110 typeof(y) _min2 = (y); \
111 (void) (&_min1 == &_min2); \
112 _min1 < _min2 ? _min1 : _min2; })
114 /* TODO: empty stubs for now. Broken but enough for virtio_ring.c */
115 #define list_add_tail(a, b) do {} while (0)
116 #define list_del(a) do {} while (0)
117 #define list_for_each_entry(a, b, c) while (0)
120 #endif /* KERNEL_H */
This page took 0.033247 seconds and 6 git commands to generate.