.. | .. |
---|
33 | 33 | #define __ALIGN_KERNEL(x, a) __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1) |
---|
34 | 34 | #define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask)) |
---|
35 | 35 | #define ALIGN(x, a) __ALIGN_KERNEL((x), (a)) |
---|
| 36 | +#define ALIGN_DOWN(x, a) __ALIGN_KERNEL((x) - ((a) - 1), (a)) |
---|
36 | 37 | |
---|
37 | 38 | #define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE) |
---|
38 | 39 | |
---|
.. | .. |
---|
114 | 115 | return malloc(size); |
---|
115 | 116 | } |
---|
116 | 117 | |
---|
| 118 | +static inline void * |
---|
| 119 | +kmalloc_array(unsigned int n, unsigned int size, unsigned int flags) |
---|
| 120 | +{ |
---|
| 121 | + return malloc(n * size); |
---|
| 122 | +} |
---|
| 123 | + |
---|
117 | 124 | #define kfree(x) free(x) |
---|
118 | 125 | |
---|
119 | 126 | #define kmemleak_alloc(a, b, c, d) |
---|
.. | .. |
---|
122 | 129 | #define PageSlab(p) (0) |
---|
123 | 130 | #define flush_kernel_dcache_page(p) |
---|
124 | 131 | |
---|
| 132 | +#define MAX_ERRNO 4095 |
---|
| 133 | + |
---|
| 134 | +#define IS_ERR_VALUE(x) unlikely((unsigned long)(void *)(x) >= (unsigned long)-MAX_ERRNO) |
---|
| 135 | + |
---|
| 136 | +static inline void * __must_check ERR_PTR(long error) |
---|
| 137 | +{ |
---|
| 138 | + return (void *) error; |
---|
| 139 | +} |
---|
| 140 | + |
---|
| 141 | +static inline long __must_check PTR_ERR(__force const void *ptr) |
---|
| 142 | +{ |
---|
| 143 | + return (long) ptr; |
---|
| 144 | +} |
---|
| 145 | + |
---|
| 146 | +static inline bool __must_check IS_ERR(__force const void *ptr) |
---|
| 147 | +{ |
---|
| 148 | + return IS_ERR_VALUE((unsigned long)ptr); |
---|
| 149 | +} |
---|
| 150 | + |
---|
| 151 | +static inline int __must_check PTR_ERR_OR_ZERO(__force const void *ptr) |
---|
| 152 | +{ |
---|
| 153 | + if (IS_ERR(ptr)) |
---|
| 154 | + return PTR_ERR(ptr); |
---|
| 155 | + else |
---|
| 156 | + return 0; |
---|
| 157 | +} |
---|
| 158 | + |
---|
| 159 | +#define IS_ENABLED(x) (0) |
---|
| 160 | + |
---|
125 | 161 | #endif |
---|