kernel.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #ifndef _KERNEL_H
  2. #define _KERNEL_H
  3. #include <assert.h>
  4. #include <string.h>
  5. #include <stdio.h>
  6. #include <stddef.h>
  7. #include <limits.h>
  8. #include <linux/compiler.h>
  9. #include <linux/err.h>
  10. #include <linux/bitops.h>
  11. #include <linux/log2.h>
  12. #include "../../../include/linux/kconfig.h"
  13. #ifdef BENCHMARK
  14. #define RADIX_TREE_MAP_SHIFT 6
  15. #else
  16. #define RADIX_TREE_MAP_SHIFT 3
  17. #endif
  18. #ifndef NULL
  19. #define NULL 0
  20. #endif
  21. #define BUG_ON(expr) assert(!(expr))
  22. #define __init
  23. #define __must_check
  24. #define panic(expr)
  25. #define printk printf
  26. #define __force
  27. #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
  28. #define pr_debug printk
  29. #define smp_rmb() barrier()
  30. #define smp_wmb() barrier()
  31. #define cpu_relax() barrier()
  32. #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
  33. #define container_of(ptr, type, member) ({ \
  34. const typeof( ((type *)0)->member ) *__mptr = (ptr); \
  35. (type *)( (char *)__mptr - offsetof(type, member) );})
  36. #define min(a, b) ((a) < (b) ? (a) : (b))
  37. #define cond_resched() sched_yield()
  38. static inline int in_interrupt(void)
  39. {
  40. return 0;
  41. }
  42. /*
  43. * This looks more complex than it should be. But we need to
  44. * get the type for the ~ right in round_down (it needs to be
  45. * as wide as the result!), and we want to evaluate the macro
  46. * arguments just once each.
  47. */
  48. #define __round_mask(x, y) ((__typeof__(x))((y)-1))
  49. #define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1)
  50. #define round_down(x, y) ((x) & ~__round_mask(x, y))
  51. #define xchg(ptr, x) uatomic_xchg(ptr, x)
  52. #endif /* _KERNEL_H */