kerncompat.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #ifndef __KERNCOMPAT
  2. #define __KERNCOMPAT
  3. #define gfp_t int
  4. #define get_cpu_var(p) (p)
  5. #define __get_cpu_var(p) (p)
  6. #define BITS_PER_LONG 64
  7. #define __GFP_BITS_SHIFT 20
  8. #define __GFP_BITS_MASK ((int)((1 << __GFP_BITS_SHIFT) - 1))
  9. #define GFP_KERNEL 0
  10. #define __read_mostly
  11. #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
  12. #define PAGE_SHIFT 12
  13. #define ULONG_MAX (~0UL)
  14. #define BUG() abort()
  15. #ifdef __CHECKER__
  16. #define __force __attribute__((force))
  17. #define __bitwise__ __attribute__((bitwise))
  18. #else
  19. #define __force
  20. #define __bitwise__
  21. #endif
  22. typedef unsigned int u32;
  23. typedef u32 __u32;
  24. typedef unsigned long long u64;
  25. typedef unsigned char u8;
  26. typedef unsigned short u16;
  27. typedef unsigned long pgoff_t;
  28. #include <stdio.h>
  29. #include <stdlib.h>
  30. #include <string.h>
  31. struct vma_shared { int prio_tree_node; };
  32. struct vm_area_struct {
  33. unsigned long vm_pgoff;
  34. unsigned long vm_start;
  35. unsigned long vm_end;
  36. struct vma_shared shared;
  37. };
  38. struct page {
  39. unsigned long index;
  40. };
  41. static inline void preempt_enable(void) { do {; } while(0);}
  42. static inline void preempt_disable(void) { do {; } while(0);}
  43. static inline void __set_bit(int bit, unsigned long *map) {
  44. unsigned long *p = map + bit / BITS_PER_LONG;
  45. bit = bit & (BITS_PER_LONG -1);
  46. *p |= 1UL << bit;
  47. }
  48. static inline int test_bit(int bit, unsigned long *map) {
  49. unsigned long *p = map + bit / BITS_PER_LONG;
  50. bit = bit & (BITS_PER_LONG -1);
  51. return *p & (1UL << bit) ? 1 : 0;
  52. }
  53. static inline void __clear_bit(int bit, unsigned long *map) {
  54. unsigned long *p = map + bit / BITS_PER_LONG;
  55. bit = bit & (BITS_PER_LONG -1);
  56. *p &= ~(1UL << bit);
  57. }
  58. #define BUG_ON(c) do { if (c) abort(); } while (0)
  59. #define container_of(ptr, type, member) ({ \
  60. const typeof( ((type *)0)->member ) *__mptr = (ptr); \
  61. (type *)( (char *)__mptr - __builtin_offsetof(type,member) );})
  62. #define ENOMEM 5
  63. #define EEXIST 6
  64. #define __CHECK_ENDIAN__
  65. #ifdef __CHECK_ENDIAN__
  66. #define __bitwise __bitwise__
  67. #else
  68. #define __bitwise
  69. #endif
  70. typedef u16 __bitwise __le16;
  71. typedef u16 __bitwise __be16;
  72. typedef u32 __bitwise __le32;
  73. typedef u32 __bitwise __be32;
  74. typedef u64 __bitwise __le64;
  75. typedef u64 __bitwise __be64;
  76. #define cpu_to_le64(x) ((__force __le64)(u64)(x))
  77. #define le64_to_cpu(x) ((__force u64)(__le64)(x))
  78. #define cpu_to_le32(x) ((__force __le32)(u32)(x))
  79. #define le32_to_cpu(x) ((__force u32)(__le32)(x))
  80. #define cpu_to_le16(x) ((__force __le16)(u16)(x))
  81. #define le16_to_cpu(x) ((__force u16)(__le16)(x))
  82. #endif