blob: 9b43b4975d832b8c1b682fd5ef0ac0f4d5b5cf6d [file] [log] [blame]
Matthew Wilcox1366c372016-03-17 14:21:45 -07001#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 Wilcoxf518b162016-05-20 17:01:36 -070010#include "../../include/linux/compiler.h"
Matthew Wilcoxde1af8f2016-12-14 15:09:25 -080011#include "../../include/linux/err.h"
Ross Zwisler21ef5332016-05-20 17:02:26 -070012#include "../../../include/linux/kconfig.h"
Matthew Wilcoxd42cb1a2016-05-20 17:01:39 -070013
Konstantin Khlebnikovcfa40bc2016-12-14 15:08:14 -080014#ifdef BENCHMARK
15#define RADIX_TREE_MAP_SHIFT 6
16#else
Ross Zwisler97d778b2016-05-20 17:01:42 -070017#define RADIX_TREE_MAP_SHIFT 3
Konstantin Khlebnikovcfa40bc2016-12-14 15:08:14 -080018#endif
Ross Zwisler97d778b2016-05-20 17:01:42 -070019
Matthew Wilcox1366c372016-03-17 14:21:45 -070020#ifndef NULL
21#define NULL 0
22#endif
23
24#define BUG_ON(expr) assert(!(expr))
Matthew Wilcoxf518b162016-05-20 17:01:36 -070025#define WARN_ON(expr) assert(!(expr))
Matthew Wilcox1366c372016-03-17 14:21:45 -070026#define __init
Konstantin Khlebnikov2d6f45b2016-03-17 14:22:08 -070027#define __must_check
Matthew Wilcox1366c372016-03-17 14:21:45 -070028#define panic(expr)
29#define printk printf
30#define __force
Matthew Wilcox1366c372016-03-17 14:21:45 -070031#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
Matthew Wilcoxf518b162016-05-20 17:01:36 -070032#define pr_debug printk
33
34#define smp_rmb() barrier()
35#define smp_wmb() barrier()
36#define cpu_relax() barrier()
Matthew Wilcox1366c372016-03-17 14:21:45 -070037
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 Wilcoxf518b162016-05-20 17:01:36 -070045#define cond_resched() sched_yield()
46
Matthew Wilcox1366c372016-03-17 14:21:45 -070047static inline int in_interrupt(void)
48{
49 return 0;
50}
Matthew Wilcox06295732016-12-14 15:08:29 -080051
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 Wilcoxde1af8f2016-12-14 15:09:25 -080062#define xchg(ptr, x) uatomic_xchg(ptr, x)
63
Matthew Wilcox1366c372016-03-17 14:21:45 -070064#endif /* _KERNEL_H */