Matthew Wilcox | 1366c37 | 2016-03-17 14:21:45 -0700 | [diff] [blame] | 1 | #ifndef _KERNEL_H |
| 2 | #define _KERNEL_H |
| 3 | |
| 4 | #include <assert.h> |
| 5 | #include <string.h> |
| 6 | #include <stdio.h> |
| 7 | #include <stddef.h> |
| 8 | #include <limits.h> |
| 9 | |
Matthew Wilcox | f518b16 | 2016-05-20 17:01:36 -0700 | [diff] [blame] | 10 | #include "../../include/linux/compiler.h" |
Matthew Wilcox | de1af8f | 2016-12-14 15:09:25 -0800 | [diff] [blame^] | 11 | #include "../../include/linux/err.h" |
Ross Zwisler | 21ef533 | 2016-05-20 17:02:26 -0700 | [diff] [blame] | 12 | #include "../../../include/linux/kconfig.h" |
Matthew Wilcox | d42cb1a | 2016-05-20 17:01:39 -0700 | [diff] [blame] | 13 | |
Konstantin Khlebnikov | cfa40bc | 2016-12-14 15:08:14 -0800 | [diff] [blame] | 14 | #ifdef BENCHMARK |
| 15 | #define RADIX_TREE_MAP_SHIFT 6 |
| 16 | #else |
Ross Zwisler | 97d778b | 2016-05-20 17:01:42 -0700 | [diff] [blame] | 17 | #define RADIX_TREE_MAP_SHIFT 3 |
Konstantin Khlebnikov | cfa40bc | 2016-12-14 15:08:14 -0800 | [diff] [blame] | 18 | #endif |
Ross Zwisler | 97d778b | 2016-05-20 17:01:42 -0700 | [diff] [blame] | 19 | |
Matthew Wilcox | 1366c37 | 2016-03-17 14:21:45 -0700 | [diff] [blame] | 20 | #ifndef NULL |
| 21 | #define NULL 0 |
| 22 | #endif |
| 23 | |
| 24 | #define BUG_ON(expr) assert(!(expr)) |
Matthew Wilcox | f518b16 | 2016-05-20 17:01:36 -0700 | [diff] [blame] | 25 | #define WARN_ON(expr) assert(!(expr)) |
Matthew Wilcox | 1366c37 | 2016-03-17 14:21:45 -0700 | [diff] [blame] | 26 | #define __init |
Konstantin Khlebnikov | 2d6f45b | 2016-03-17 14:22:08 -0700 | [diff] [blame] | 27 | #define __must_check |
Matthew Wilcox | 1366c37 | 2016-03-17 14:21:45 -0700 | [diff] [blame] | 28 | #define panic(expr) |
| 29 | #define printk printf |
| 30 | #define __force |
Matthew Wilcox | 1366c37 | 2016-03-17 14:21:45 -0700 | [diff] [blame] | 31 | #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) |
Matthew Wilcox | f518b16 | 2016-05-20 17:01:36 -0700 | [diff] [blame] | 32 | #define pr_debug printk |
| 33 | |
| 34 | #define smp_rmb() barrier() |
| 35 | #define smp_wmb() barrier() |
| 36 | #define cpu_relax() barrier() |
Matthew Wilcox | 1366c37 | 2016-03-17 14:21:45 -0700 | [diff] [blame] | 37 | |
| 38 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) |
| 39 | |
| 40 | #define container_of(ptr, type, member) ({ \ |
| 41 | const typeof( ((type *)0)->member ) *__mptr = (ptr); \ |
| 42 | (type *)( (char *)__mptr - offsetof(type, member) );}) |
| 43 | #define min(a, b) ((a) < (b) ? (a) : (b)) |
| 44 | |
Matthew Wilcox | f518b16 | 2016-05-20 17:01:36 -0700 | [diff] [blame] | 45 | #define cond_resched() sched_yield() |
| 46 | |
Matthew Wilcox | 1366c37 | 2016-03-17 14:21:45 -0700 | [diff] [blame] | 47 | static inline int in_interrupt(void) |
| 48 | { |
| 49 | return 0; |
| 50 | } |
Matthew Wilcox | 0629573 | 2016-12-14 15:08:29 -0800 | [diff] [blame] | 51 | |
| 52 | /* |
| 53 | * This looks more complex than it should be. But we need to |
| 54 | * get the type for the ~ right in round_down (it needs to be |
| 55 | * as wide as the result!), and we want to evaluate the macro |
| 56 | * arguments just once each. |
| 57 | */ |
| 58 | #define __round_mask(x, y) ((__typeof__(x))((y)-1)) |
| 59 | #define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1) |
| 60 | #define round_down(x, y) ((x) & ~__round_mask(x, y)) |
| 61 | |
Matthew Wilcox | de1af8f | 2016-12-14 15:09:25 -0800 | [diff] [blame^] | 62 | #define xchg(ptr, x) uatomic_xchg(ptr, x) |
| 63 | |
Matthew Wilcox | 1366c37 | 2016-03-17 14:21:45 -0700 | [diff] [blame] | 64 | #endif /* _KERNEL_H */ |