yuezonghe | 824eb0c | 2024-06-27 02:32:26 -0700 | [diff] [blame^] | 1 | #ifndef _LINUX_COMPAT_H_ |
| 2 | #define _LINUX_COMPAT_H_ |
| 3 | |
| 4 | #include <memory.h> |
| 5 | |
| 6 | #define __user |
| 7 | #define __iomem |
| 8 | |
| 9 | #define ndelay(x) udelay(1) |
| 10 | |
| 11 | #define printk printf |
| 12 | |
| 13 | #define KERN_EMERG |
| 14 | #define KERN_ALERT |
| 15 | #define KERN_CRIT |
| 16 | #define KERN_ERR |
| 17 | #define KERN_WARNING |
| 18 | #define KERN_NOTICE |
| 19 | #define KERN_INFO |
| 20 | #define KERN_DEBUG |
| 21 | |
| 22 | #if DEBUG |
| 23 | #define kmalloc(size, flags) MEM_malloc(__FILE__, __LINE__, (size)) |
| 24 | #define kzalloc(size, flags) MEM_malloc(__FILE__, __LINE__, (size)) |
| 25 | #define vmalloc(size) MEM_malloc(__FILE__, __LINE__, (size)) |
| 26 | #define kfree(ptr) MEM_free((ptr)) |
| 27 | #define vfree(ptr) MEM_free((ptr)) |
| 28 | #else |
| 29 | #define kmalloc(size, flags) malloc((size)) |
| 30 | #define kzalloc(size, flags) calloc((size), 1) |
| 31 | #define vmalloc(size) malloc((size)) |
| 32 | #define kfree(ptr) free((ptr)) |
| 33 | #define vfree(ptr) free((ptr)) |
| 34 | |
| 35 | #endif /* DEBUG */ |
| 36 | |
| 37 | #define DECLARE_WAITQUEUE(...) do { } while (0) |
| 38 | #define add_wait_queue(...) do { } while (0) |
| 39 | #define remove_wait_queue(...) do { } while (0) |
| 40 | |
| 41 | #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) |
| 42 | |
| 43 | /* |
| 44 | * ..and if you can't take the strict |
| 45 | * types, you can specify one yourself. |
| 46 | * |
| 47 | * Or not use min/max at all, of course. |
| 48 | */ |
| 49 | #define min_t(type,x,y) \ |
| 50 | ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; }) |
| 51 | #define max_t(type,x,y) \ |
| 52 | ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; }) |
| 53 | |
| 54 | #ifndef BUG |
| 55 | #define BUG() do { \ |
| 56 | printf("U-Boot BUG at %s:%d!\n", __FILE__, __LINE__); \ |
| 57 | } while (0) |
| 58 | |
| 59 | #define BUG_ON(condition) do { if (condition) BUG(); } while(0) |
| 60 | #endif /* BUG */ |
| 61 | |
| 62 | #define PAGE_SIZE 4096 |
| 63 | #endif |