kernel.h 1.5 KB

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