kerncompat.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 unsigned long long u64;
  24. typedef unsigned char u8;
  25. typedef unsigned short u16;
  26. typedef unsigned long pgoff_t;
  27. #include <stdio.h>
  28. #include <stdlib.h>
  29. #include <string.h>
  30. struct vma_shared { int prio_tree_node; };
  31. struct vm_area_struct {
  32. unsigned long vm_pgoff;
  33. unsigned long vm_start;
  34. unsigned long vm_end;
  35. struct vma_shared shared;
  36. };
  37. struct page {
  38. unsigned long index;
  39. };
  40. static inline void preempt_enable(void) { do {; } while(0);}
  41. static inline void preempt_disable(void) { do {; } while(0);}
  42. static inline void __set_bit(int bit, unsigned long *map) {
  43. unsigned long *p = map + bit / BITS_PER_LONG;
  44. bit = bit & (BITS_PER_LONG -1);
  45. *p |= 1UL << bit;
  46. }
  47. static inline int test_bit(int bit, unsigned long *map) {
  48. unsigned long *p = map + bit / BITS_PER_LONG;
  49. bit = bit & (BITS_PER_LONG -1);
  50. return *p & (1UL << bit) ? 1 : 0;
  51. }
  52. static inline void __clear_bit(int bit, unsigned long *map) {
  53. unsigned long *p = map + bit / BITS_PER_LONG;
  54. bit = bit & (BITS_PER_LONG -1);
  55. *p &= ~(1UL << bit);
  56. }
  57. #define BUG_ON(c) do { if (c) abort(); } while (0)
  58. #define container_of(ptr, type, member) ({ \
  59. const typeof( ((type *)0)->member ) *__mptr = (ptr); \
  60. (type *)( (char *)__mptr - __builtin_offsetof(type,member) );})
  61. #define ENOMEM 5
  62. #define EEXIST 6
  63. #define __CHECK_ENDIAN__
  64. #ifdef __CHECK_ENDIAN__
  65. #define __bitwise __bitwise__
  66. #else
  67. #define __bitwise
  68. #endif
  69. typedef u16 __bitwise __le16;
  70. typedef u16 __bitwise __be16;
  71. typedef u32 __bitwise __le32;
  72. typedef u32 __bitwise __be32;
  73. typedef u64 __bitwise __le64;
  74. typedef u64 __bitwise __be64;
  75. #define cpu_to_le64(x) ((__force __le64)(u64)(x))
  76. #define le64_to_cpu(x) ((__force u64)(__le64)(x))
  77. #define cpu_to_le32(x) ((__force __le32)(u32)(x))
  78. #define le32_to_cpu(x) ((__force u32)(__le32)(x))
  79. #define cpu_to_le16(x) ((__force __le16)(u16)(x))
  80. #define le16_to_cpu(x) ((__force u16)(__le16)(x))
  81. #endif