types.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. #ifndef _LINUX_TYPES_H
  2. #define _LINUX_TYPES_H
  3. #include <asm/types.h>
  4. #ifndef __ASSEMBLY__
  5. #ifdef __KERNEL__
  6. #define DECLARE_BITMAP(name,bits) \
  7. unsigned long name[BITS_TO_LONGS(bits)]
  8. #else
  9. #ifndef __EXPORTED_HEADERS__
  10. #warning "Attempt to use kernel headers from user space, see http://kernelnewbies.org/KernelHeaders"
  11. #endif /* __EXPORTED_HEADERS__ */
  12. #endif
  13. #include <linux/posix_types.h>
  14. #ifdef __KERNEL__
  15. typedef __u32 __kernel_dev_t;
  16. typedef __kernel_fd_set fd_set;
  17. typedef __kernel_dev_t dev_t;
  18. typedef __kernel_ino_t ino_t;
  19. typedef __kernel_mode_t mode_t;
  20. typedef __kernel_nlink_t nlink_t;
  21. typedef __kernel_off_t off_t;
  22. typedef __kernel_pid_t pid_t;
  23. typedef __kernel_daddr_t daddr_t;
  24. typedef __kernel_key_t key_t;
  25. typedef __kernel_suseconds_t suseconds_t;
  26. typedef __kernel_timer_t timer_t;
  27. typedef __kernel_clockid_t clockid_t;
  28. typedef __kernel_mqd_t mqd_t;
  29. typedef _Bool bool;
  30. typedef __kernel_uid32_t uid_t;
  31. typedef __kernel_gid32_t gid_t;
  32. typedef __kernel_uid16_t uid16_t;
  33. typedef __kernel_gid16_t gid16_t;
  34. typedef unsigned long uintptr_t;
  35. #ifdef CONFIG_UID16
  36. /* This is defined by include/asm-{arch}/posix_types.h */
  37. typedef __kernel_old_uid_t old_uid_t;
  38. typedef __kernel_old_gid_t old_gid_t;
  39. #endif /* CONFIG_UID16 */
  40. #if defined(__GNUC__)
  41. typedef __kernel_loff_t loff_t;
  42. #endif
  43. /*
  44. * The following typedefs are also protected by individual ifdefs for
  45. * historical reasons:
  46. */
  47. #ifndef _SIZE_T
  48. #define _SIZE_T
  49. typedef __kernel_size_t size_t;
  50. #endif
  51. #ifndef _SSIZE_T
  52. #define _SSIZE_T
  53. typedef __kernel_ssize_t ssize_t;
  54. #endif
  55. #ifndef _PTRDIFF_T
  56. #define _PTRDIFF_T
  57. typedef __kernel_ptrdiff_t ptrdiff_t;
  58. #endif
  59. #ifndef _TIME_T
  60. #define _TIME_T
  61. typedef __kernel_time_t time_t;
  62. #endif
  63. #ifndef _CLOCK_T
  64. #define _CLOCK_T
  65. typedef __kernel_clock_t clock_t;
  66. #endif
  67. #ifndef _CADDR_T
  68. #define _CADDR_T
  69. typedef __kernel_caddr_t caddr_t;
  70. #endif
  71. /* bsd */
  72. typedef unsigned char u_char;
  73. typedef unsigned short u_short;
  74. typedef unsigned int u_int;
  75. typedef unsigned long u_long;
  76. /* sysv */
  77. typedef unsigned char unchar;
  78. typedef unsigned short ushort;
  79. typedef unsigned int uint;
  80. typedef unsigned long ulong;
  81. #ifndef __BIT_TYPES_DEFINED__
  82. #define __BIT_TYPES_DEFINED__
  83. typedef __u8 u_int8_t;
  84. typedef __s8 int8_t;
  85. typedef __u16 u_int16_t;
  86. typedef __s16 int16_t;
  87. typedef __u32 u_int32_t;
  88. typedef __s32 int32_t;
  89. #endif /* !(__BIT_TYPES_DEFINED__) */
  90. typedef __u8 uint8_t;
  91. typedef __u16 uint16_t;
  92. typedef __u32 uint32_t;
  93. #if defined(__GNUC__)
  94. typedef __u64 uint64_t;
  95. typedef __u64 u_int64_t;
  96. typedef __s64 int64_t;
  97. #endif
  98. /*
  99. * aligned_u64 should be used in defining kernel<->userspace ABIs to avoid
  100. * common 32/64-bit compat problems.
  101. * 64-bit values align to 4-byte boundaries on x86_32 (and possibly other
  102. * architectures) and to 8-byte boundaries on 64-bit architetures. The new
  103. * aligned_64 type enforces 8-byte alignment so that structs containing
  104. * aligned_64 values have the same alignment on 32-bit and 64-bit architectures.
  105. * No conversions are necessary between 32-bit user-space and a 64-bit kernel.
  106. */
  107. #define aligned_u64 __u64 __attribute__((aligned(8)))
  108. #define aligned_be64 __be64 __attribute__((aligned(8)))
  109. #define aligned_le64 __le64 __attribute__((aligned(8)))
  110. /**
  111. * The type used for indexing onto a disc or disc partition.
  112. *
  113. * Linux always considers sectors to be 512 bytes long independently
  114. * of the devices real block size.
  115. *
  116. * blkcnt_t is the type of the inode's block count.
  117. */
  118. #ifdef CONFIG_LBDAF
  119. typedef u64 sector_t;
  120. typedef u64 blkcnt_t;
  121. #else
  122. typedef unsigned long sector_t;
  123. typedef unsigned long blkcnt_t;
  124. #endif
  125. /*
  126. * The type of an index into the pagecache. Use a #define so asm/types.h
  127. * can override it.
  128. */
  129. #ifndef pgoff_t
  130. #define pgoff_t unsigned long
  131. #endif
  132. #endif /* __KERNEL__ */
  133. /*
  134. * Below are truly Linux-specific types that should never collide with
  135. * any application/library that wants linux/types.h.
  136. */
  137. #ifdef __CHECKER__
  138. #define __bitwise__ __attribute__((bitwise))
  139. #else
  140. #define __bitwise__
  141. #endif
  142. #ifdef __CHECK_ENDIAN__
  143. #define __bitwise __bitwise__
  144. #else
  145. #define __bitwise
  146. #endif
  147. typedef __u16 __bitwise __le16;
  148. typedef __u16 __bitwise __be16;
  149. typedef __u32 __bitwise __le32;
  150. typedef __u32 __bitwise __be32;
  151. typedef __u64 __bitwise __le64;
  152. typedef __u64 __bitwise __be64;
  153. typedef __u16 __bitwise __sum16;
  154. typedef __u32 __bitwise __wsum;
  155. /* this is a special 64bit data type that is 8-byte aligned */
  156. #define __aligned_u64 __u64 __attribute__((aligned(8)))
  157. #define __aligned_be64 __be64 __attribute__((aligned(8)))
  158. #define __aligned_le64 __le64 __attribute__((aligned(8)))
  159. #ifdef __KERNEL__
  160. typedef unsigned __bitwise__ gfp_t;
  161. typedef unsigned __bitwise__ fmode_t;
  162. #ifdef CONFIG_PHYS_ADDR_T_64BIT
  163. typedef u64 phys_addr_t;
  164. #else
  165. typedef u32 phys_addr_t;
  166. #endif
  167. typedef phys_addr_t resource_size_t;
  168. typedef struct {
  169. int counter;
  170. } atomic_t;
  171. #ifdef CONFIG_64BIT
  172. typedef struct {
  173. long counter;
  174. } atomic64_t;
  175. #endif
  176. struct list_head {
  177. struct list_head *next, *prev;
  178. };
  179. struct hlist_head {
  180. struct hlist_node *first;
  181. };
  182. struct hlist_node {
  183. struct hlist_node *next, **pprev;
  184. };
  185. struct ustat {
  186. __kernel_daddr_t f_tfree;
  187. __kernel_ino_t f_tinode;
  188. char f_fname[6];
  189. char f_fpack[6];
  190. };
  191. #endif /* __KERNEL__ */
  192. #endif /* __ASSEMBLY__ */
  193. #endif /* _LINUX_TYPES_H */