at v4.10 1.5 kB view raw
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 10#include "../../include/linux/compiler.h" 11#include "../../include/linux/err.h" 12#include "../../../include/linux/kconfig.h" 13 14#ifdef BENCHMARK 15#define RADIX_TREE_MAP_SHIFT 6 16#else 17#define RADIX_TREE_MAP_SHIFT 3 18#endif 19 20#ifndef NULL 21#define NULL 0 22#endif 23 24#define BUG_ON(expr) assert(!(expr)) 25#define WARN_ON(expr) assert(!(expr)) 26#define __init 27#define __must_check 28#define panic(expr) 29#define printk printf 30#define __force 31#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) 32#define pr_debug printk 33 34#define smp_rmb() barrier() 35#define smp_wmb() barrier() 36#define cpu_relax() barrier() 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 45#define cond_resched() sched_yield() 46 47static inline int in_interrupt(void) 48{ 49 return 0; 50} 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 62#define xchg(ptr, x) uatomic_xchg(ptr, x) 63 64#endif /* _KERNEL_H */