]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - include/linux/compat.h
Merge branch 'master' of git://git.denx.de/u-boot-arc
[karo-tx-uboot.git] / include / linux / compat.h
1 #ifndef _LINUX_COMPAT_H_
2 #define _LINUX_COMPAT_H_
3
4 #include <malloc.h>
5 #include <linux/types.h>
6 #include <linux/err.h>
7
8 struct unused {};
9 typedef struct unused unused_t;
10
11 struct p_current{
12        int pid;
13 };
14
15 extern struct p_current *current;
16
17 #define ndelay(x)       udelay(1)
18
19 #define dev_dbg(dev, fmt, args...)              \
20         debug(fmt, ##args)
21 #define dev_vdbg(dev, fmt, args...)             \
22         debug(fmt, ##args)
23 #define dev_info(dev, fmt, args...)             \
24         printf(fmt, ##args)
25 #define dev_err(dev, fmt, args...)              \
26         printf(fmt, ##args)
27 #define printk  printf
28 #define printk_once     printf
29
30 #define KERN_EMERG
31 #define KERN_ALERT
32 #define KERN_CRIT
33 #define KERN_ERR
34 #define KERN_WARNING
35 #define KERN_NOTICE
36 #define KERN_INFO
37 #define KERN_DEBUG
38
39 void *kmalloc(size_t size, int flags);
40 void *kzalloc(size_t size, int flags);
41 #define vmalloc(size)   kmalloc(size, 0)
42 #define __vmalloc(size, flags, pgsz)    kmalloc(size, flags)
43 #define kfree(ptr)      free(ptr)
44 #define vfree(ptr)      free(ptr)
45
46 struct kmem_cache { int sz; };
47
48 struct kmem_cache *get_mem(int element_sz);
49 #define kmem_cache_create(a, sz, c, d, e)       get_mem(sz)
50 void *kmem_cache_alloc(struct kmem_cache *obj, int flag);
51 #define kmem_cache_free(obj, size)      free(size)
52 #define kmem_cache_destroy(obj)         free(obj)
53
54 #define DECLARE_WAITQUEUE(...)  do { } while (0)
55 #define add_wait_queue(...)     do { } while (0)
56 #define remove_wait_queue(...)  do { } while (0)
57
58 #define KERNEL_VERSION(a,b,c)   (((a) << 16) + ((b) << 8) + (c))
59
60 /*
61  * ..and if you can't take the strict
62  * types, you can specify one yourself.
63  *
64  * Or not use min/max at all, of course.
65  */
66 #define min_t(type,x,y) \
67         ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; })
68 #define max_t(type,x,y) \
69         ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; })
70
71 #ifndef BUG
72 #define BUG() do { \
73         printf("U-Boot BUG at %s:%d!\n", __FILE__, __LINE__); \
74 } while (0)
75
76 #define BUG_ON(condition) do { if (condition) BUG(); } while(0)
77 #endif /* BUG */
78
79 #define WARN_ON(x) if (x) {printf("WARNING in %s line %d\n" \
80                                   , __FILE__, __LINE__); }
81
82 #define PAGE_SIZE       4096
83
84 /**
85  * upper_32_bits - return MSB bits 32-63 of a number if little endian, or
86  * return MSB bits 0-31 of a number if big endian.
87  * @n: the number we're accessing
88  *
89  * A basic shift-right of a 64- or 32-bit quantity.  Use this to suppress
90  * the "right shift count >= width of type" warning when that quantity is
91  * 32-bits.
92  */
93 #define upper_32_bits(n) ((u32)(((n) >> 16) >> 16))
94
95 /**
96  * lower_32_bits - return LSB bits 0-31 of a number if little endian, or
97  * return LSB bits 32-63 of a number if big endian.
98  * @n: the number we're accessing
99  */
100 #define lower_32_bits(n) ((u32)(n))
101
102 /* drivers/char/random.c */
103 #define get_random_bytes(...)
104
105 /* idr.c */
106 #define GFP_ATOMIC ((gfp_t) 0)
107 #define GFP_KERNEL ((gfp_t) 0)
108 #define GFP_NOFS ((gfp_t) 0)
109 #define GFP_USER ((gfp_t) 0)
110 #define __GFP_NOWARN ((gfp_t) 0)
111
112 /* include/linux/leds.h */
113 struct led_trigger {};
114
115 #define DEFINE_LED_TRIGGER(x)           static struct led_trigger *x;
116 enum led_brightness {
117         LED_OFF         = 0,
118         LED_HALF        = 127,
119         LED_FULL        = 255,
120 };
121
122 static inline void led_trigger_register_simple(const char *name,
123                                         struct led_trigger **trigger) {}
124 static inline void led_trigger_unregister_simple(struct led_trigger *trigger) {}
125 static inline void led_trigger_event(struct led_trigger *trigger,
126                                         enum led_brightness event) {}
127
128 /* include/linux/log2.h */
129 static inline int is_power_of_2(unsigned long n)
130 {
131         return (n != 0 && ((n & (n - 1)) == 0));
132 }
133
134 /* uapi/linux/limits.h */
135 #define XATTR_LIST_MAX 65536    /* size of extended attribute namelist (64k) */
136
137 /**
138  * The type used for indexing onto a disc or disc partition.
139  *
140  * Linux always considers sectors to be 512 bytes long independently
141  * of the devices real block size.
142  *
143  * blkcnt_t is the type of the inode's block count.
144  */
145 #ifdef CONFIG_LBDAF
146 typedef u64 sector_t;
147 typedef u64 blkcnt_t;
148 #else
149 typedef unsigned long sector_t;
150 typedef unsigned long blkcnt_t;
151 #endif
152
153 #define ENOTSUPP        524     /* Operation is not supported */
154
155 /* from include/linux/kernel.h */
156 /*
157  * This looks more complex than it should be. But we need to
158  * get the type for the ~ right in round_down (it needs to be
159  * as wide as the result!), and we want to evaluate the macro
160  * arguments just once each.
161  */
162 #define __round_mask(x, y) ((__typeof__(x))((y)-1))
163 #define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1)
164 #define round_down(x, y) ((x) & ~__round_mask(x, y))
165
166 /* module */
167 #define THIS_MODULE             0
168 #define try_module_get(...)     1
169 #define module_put(...)         do { } while (0)
170 #define module_init(...)
171 #define module_exit(...)
172 #define EXPORT_SYMBOL(...)
173 #define EXPORT_SYMBOL_GPL(...)
174 #define module_param(...)
175 #define module_param_call(...)
176 #define MODULE_PARM_DESC(...)
177 #define MODULE_VERSION(...)
178 #define MODULE_DESCRIPTION(...)
179 #define MODULE_AUTHOR(...)
180 #define MODULE_LICENSE(...)
181 #define MODULE_ALIAS(...)
182 #define __module_get(...)
183
184 /* character device */
185 #define MKDEV(...)                      0
186 #define MAJOR(dev)                      0
187 #define MINOR(dev)                      0
188
189 #define alloc_chrdev_region(...)        0
190 #define unregister_chrdev_region(...)
191
192 #define class_create(...)               __builtin_return_address(0)
193 #define class_create_file(...)          0
194 #define class_remove_file(...)
195 #define class_destroy(...)
196 #define misc_register(...)              0
197 #define misc_deregister(...)
198
199 #define blocking_notifier_call_chain(...) 0
200
201 /*
202  * Multiplies an integer by a fraction, while avoiding unnecessary
203  * overflow or loss of precision.
204  */
205 #define mult_frac(x, numer, denom)(                     \
206 {                                                       \
207         typeof(x) quot = (x) / (denom);                 \
208         typeof(x) rem  = (x) % (denom);                 \
209         (quot * (numer)) + ((rem * (numer)) / (denom)); \
210 }                                                       \
211 )
212
213 #define __initdata
214 #define late_initcall(...)
215
216 #define dev_set_name(...)               do { } while (0)
217 #define device_register(...)            0
218 #define volume_sysfs_init(...)          0
219 #define volume_sysfs_close(...)         do { } while (0)
220
221 #define init_waitqueue_head(...)        do { } while (0)
222 #define wait_event_interruptible(...)   0
223 #define wake_up_interruptible(...)      do { } while (0)
224 #define print_hex_dump(...)             do { } while (0)
225 #define dump_stack(...)                 do { } while (0)
226
227 #define task_pid_nr(x)                  0
228 #define set_freezable(...)              do { } while (0)
229 #define try_to_freeze(...)              0
230 #define set_current_state(...)          do { } while (0)
231 #define kthread_should_stop(...)        0
232 #define schedule()                      do { } while (0)
233
234 #define setup_timer(timer, func, data) do {} while (0)
235 #define del_timer_sync(timer) do {} while (0)
236 #define schedule_work(work) do {} while (0)
237 #define INIT_WORK(work, fun) do {} while (0)
238
239 struct work_struct {};
240
241 unsigned long copy_from_user(void *dest, const void *src,
242                              unsigned long count);
243
244 void *vzalloc(unsigned long size);
245
246 typedef unused_t spinlock_t;
247 typedef int     wait_queue_head_t;
248
249 #define spin_lock_init(lock) do {} while (0)
250 #define spin_lock(lock) do {} while (0)
251 #define spin_unlock(lock) do {} while (0)
252 #define spin_lock_irqsave(lock, flags) do { debug("%lu\n", flags); } while (0)
253 #define spin_unlock_irqrestore(lock, flags) do { flags = 0; } while (0)
254
255 #define DEFINE_MUTEX(...)
256 #define mutex_init(...)
257 #define mutex_lock(...)
258 #define mutex_unlock(...)
259
260 #define init_rwsem(...)                 do { } while (0)
261 #define down_read(...)                  do { } while (0)
262 #define down_write(...)                 do { } while (0)
263 #define down_write_trylock(...)         1
264 #define up_read(...)                    do { } while (0)
265 #define up_write(...)                   do { } while (0)
266
267 #define cond_resched()                  do { } while (0)
268 #define yield()                         do { } while (0)
269
270 #define INT_MAX                         ((int)(~0U>>1))
271
272 #define __user
273 #define __init
274 #define __exit
275 #define __devinit
276 #define __devinitdata
277 #define __devinitconst
278 #define __iomem
279
280 #define kthread_create(...)     __builtin_return_address(0)
281 #define kthread_stop(...)       do { } while (0)
282 #define wake_up_process(...)    do { } while (0)
283
284 struct rw_semaphore { int i; };
285 #define down_write(...)                 do { } while (0)
286 #define up_write(...)                   do { } while (0)
287 #define down_read(...)                  do { } while (0)
288 #define up_read(...)                    do { } while (0)
289 struct device {
290         struct device           *parent;
291         struct class            *class;
292         dev_t                   devt;   /* dev_t, creates the sysfs "dev" */
293         void    (*release)(struct device *dev);
294         /* This is used from drivers/usb/musb-new subsystem only */
295         void            *driver_data;   /* data private to the driver */
296         void            *device_data;   /* data private to the device */
297 };
298 struct mutex { int i; };
299 struct kernel_param { int i; };
300
301 struct cdev {
302         int owner;
303         dev_t dev;
304 };
305 #define cdev_init(...)          do { } while (0)
306 #define cdev_add(...)           0
307 #define cdev_del(...)           do { } while (0)
308
309 #define MAX_ERRNO               4095
310
311 #define prandom_u32(...)        0
312
313 typedef struct {
314         uid_t val;
315 } kuid_t;
316
317 typedef struct {
318         gid_t val;
319 } kgid_t;
320
321 /* from include/linux/types.h */
322
323 typedef int     atomic_t;
324 /**
325  * struct callback_head - callback structure for use with RCU and task_work
326  * @next: next update requests in a list
327  * @func: actual update function to call after the grace period.
328  */
329 struct callback_head {
330         struct callback_head *next;
331         void (*func)(struct callback_head *head);
332 };
333 #define rcu_head callback_head
334 enum writeback_sync_modes {
335         WB_SYNC_NONE,   /* Don't wait on anything */
336         WB_SYNC_ALL,    /* Wait on every mapping */
337 };
338
339 /* from include/linux/writeback.h */
340 /*
341  * A control structure which tells the writeback code what to do.  These are
342  * always on the stack, and hence need no locking.  They are always initialised
343  * in a manner such that unspecified fields are set to zero.
344  */
345 struct writeback_control {
346         long nr_to_write;               /* Write this many pages, and decrement
347                                            this for each page written */
348         long pages_skipped;             /* Pages which were not written */
349
350         /*
351          * For a_ops->writepages(): if start or end are non-zero then this is
352          * a hint that the filesystem need only write out the pages inside that
353          * byterange.  The byte at `end' is included in the writeout request.
354          */
355         loff_t range_start;
356         loff_t range_end;
357
358         enum writeback_sync_modes sync_mode;
359
360         unsigned for_kupdate:1;         /* A kupdate writeback */
361         unsigned for_background:1;      /* A background writeback */
362         unsigned tagged_writepages:1;   /* tag-and-write to avoid livelock */
363         unsigned for_reclaim:1;         /* Invoked from the page allocator */
364         unsigned range_cyclic:1;        /* range_start is cyclic */
365         unsigned for_sync:1;            /* sync(2) WB_SYNC_ALL writeback */
366 };
367
368 void *kmemdup(const void *src, size_t len, gfp_t gfp);
369
370 typedef int irqreturn_t;
371
372 struct timer_list {};
373 struct notifier_block {};
374
375 typedef unsigned long dmaaddr_t;
376
377 #define cpu_relax() do {} while (0)
378
379 #define pm_runtime_get_sync(dev) do {} while (0)
380 #define pm_runtime_put(dev) do {} while (0)
381 #define pm_runtime_put_sync(dev) do {} while (0)
382 #define pm_runtime_use_autosuspend(dev) do {} while (0)
383 #define pm_runtime_set_autosuspend_delay(dev, delay) do {} while (0)
384 #define pm_runtime_enable(dev) do {} while (0)
385
386 #define IRQ_NONE 0
387 #define IRQ_HANDLED 1
388
389 #define dev_set_drvdata(dev, data) do {} while (0)
390
391 #define enable_irq(...)
392 #define disable_irq(...)
393 #define disable_irq_wake(irq) do {} while (0)
394 #define enable_irq_wake(irq) -EINVAL
395 #define free_irq(irq, data) do {} while (0)
396 #define request_irq(nr, f, flags, nm, data) 0
397
398 #endif