kernel.h 1.5 KB

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