types.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  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. /* this is a special 64bit data type that is 8-byte aligned */
  99. #define aligned_u64 __u64 __attribute__((aligned(8)))
  100. #define aligned_be64 __be64 __attribute__((aligned(8)))
  101. #define aligned_le64 __le64 __attribute__((aligned(8)))
  102. /**
  103. * The type used for indexing onto a disc or disc partition.
  104. *
  105. * Linux always considers sectors to be 512 bytes long independently
  106. * of the devices real block size.
  107. *
  108. * blkcnt_t is the type of the inode's block count.
  109. */
  110. #ifdef CONFIG_LBDAF
  111. typedef u64 sector_t;
  112. typedef u64 blkcnt_t;
  113. #else
  114. typedef unsigned long sector_t;
  115. typedef unsigned long blkcnt_t;
  116. #endif
  117. /*
  118. * The type of an index into the pagecache. Use a #define so asm/types.h
  119. * can override it.
  120. */
  121. #ifndef pgoff_t
  122. #define pgoff_t unsigned long
  123. #endif
  124. #ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
  125. typedef u64 dma_addr_t;
  126. #else
  127. typedef u32 dma_addr_t;
  128. #endif /* dma_addr_t */
  129. #endif /* __KERNEL__ */
  130. /*
  131. * Below are truly Linux-specific types that should never collide with
  132. * any application/library that wants linux/types.h.
  133. */
  134. #ifdef __CHECKER__
  135. #define __bitwise__ __attribute__((bitwise))
  136. #else
  137. #define __bitwise__
  138. #endif
  139. #ifdef __CHECK_ENDIAN__
  140. #define __bitwise __bitwise__
  141. #else
  142. #define __bitwise
  143. #endif
  144. typedef __u16 __bitwise __le16;
  145. typedef __u16 __bitwise __be16;
  146. typedef __u32 __bitwise __le32;
  147. typedef __u32 __bitwise __be32;
  148. typedef __u64 __bitwise __le64;
  149. typedef __u64 __bitwise __be64;
  150. typedef __u16 __bitwise __sum16;
  151. typedef __u32 __bitwise __wsum;
  152. /*
  153. * aligned_u64 should be used in defining kernel<->userspace ABIs to avoid
  154. * common 32/64-bit compat problems.
  155. * 64-bit values align to 4-byte boundaries on x86_32 (and possibly other
  156. * architectures) and to 8-byte boundaries on 64-bit architectures. The new
  157. * aligned_64 type enforces 8-byte alignment so that structs containing
  158. * aligned_64 values have the same alignment on 32-bit and 64-bit architectures.
  159. * No conversions are necessary between 32-bit user-space and a 64-bit kernel.
  160. */
  161. #define __aligned_u64 __u64 __attribute__((aligned(8)))
  162. #define __aligned_be64 __be64 __attribute__((aligned(8)))
  163. #define __aligned_le64 __le64 __attribute__((aligned(8)))
  164. #ifdef __KERNEL__
  165. typedef unsigned __bitwise__ gfp_t;
  166. typedef unsigned __bitwise__ fmode_t;
  167. #ifdef CONFIG_PHYS_ADDR_T_64BIT
  168. typedef u64 phys_addr_t;
  169. #else
  170. typedef u32 phys_addr_t;
  171. #endif
  172. typedef phys_addr_t resource_size_t;
  173. typedef struct {
  174. int counter;
  175. } atomic_t;
  176. #ifdef CONFIG_64BIT
  177. typedef struct {
  178. long counter;
  179. } atomic64_t;
  180. #endif
  181. struct list_head {
  182. struct list_head *next, *prev;
  183. };
  184. struct hlist_head {
  185. struct hlist_node *first;
  186. };
  187. struct hlist_node {
  188. struct hlist_node *next, **pprev;
  189. };
  190. struct ustat {
  191. __kernel_daddr_t f_tfree;
  192. __kernel_ino_t f_tinode;
  193. char f_fname[6];
  194. char f_fpack[6];
  195. };
  196. /**
  197. * struct rcu_head - callback structure for use with RCU
  198. * @next: next update requests in a list
  199. * @func: actual update function to call after the grace period.
  200. */
  201. struct rcu_head {
  202. struct rcu_head *next;
  203. void (*func)(struct rcu_head *head);
  204. };
  205. #endif /* __KERNEL__ */
  206. #endif /* __ASSEMBLY__ */
  207. #endif /* _LINUX_TYPES_H */