types.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. #ifndef _LINUX_TYPES_H
  2. #define _LINUX_TYPES_H
  3. #define __EXPORTED_HEADERS__
  4. #include <uapi/linux/types.h>
  5. #ifndef __ASSEMBLY__
  6. #define DECLARE_BITMAP(name,bits) \
  7. unsigned long name[BITS_TO_LONGS(bits)]
  8. typedef __u32 __kernel_dev_t;
  9. typedef __kernel_fd_set fd_set;
  10. typedef __kernel_dev_t dev_t;
  11. typedef __kernel_ino_t ino_t;
  12. typedef __kernel_mode_t mode_t;
  13. typedef unsigned short umode_t;
  14. typedef __u32 nlink_t;
  15. typedef __kernel_off_t off_t;
  16. typedef __kernel_pid_t pid_t;
  17. typedef __kernel_daddr_t daddr_t;
  18. typedef __kernel_key_t key_t;
  19. typedef __kernel_suseconds_t suseconds_t;
  20. typedef __kernel_timer_t timer_t;
  21. typedef __kernel_clockid_t clockid_t;
  22. typedef __kernel_mqd_t mqd_t;
  23. typedef _Bool bool;
  24. typedef __kernel_uid32_t uid_t;
  25. typedef __kernel_gid32_t gid_t;
  26. typedef __kernel_uid16_t uid16_t;
  27. typedef __kernel_gid16_t gid16_t;
  28. typedef unsigned long uintptr_t;
  29. #ifdef CONFIG_HAVE_UID16
  30. /* This is defined by include/asm-{arch}/posix_types.h */
  31. typedef __kernel_old_uid_t old_uid_t;
  32. typedef __kernel_old_gid_t old_gid_t;
  33. #endif /* CONFIG_UID16 */
  34. #if defined(__GNUC__)
  35. typedef __kernel_loff_t loff_t;
  36. #endif
  37. /*
  38. * The following typedefs are also protected by individual ifdefs for
  39. * historical reasons:
  40. */
  41. #ifndef _SIZE_T
  42. #define _SIZE_T
  43. typedef __kernel_size_t size_t;
  44. #endif
  45. #ifndef _SSIZE_T
  46. #define _SSIZE_T
  47. typedef __kernel_ssize_t ssize_t;
  48. #endif
  49. #ifndef _PTRDIFF_T
  50. #define _PTRDIFF_T
  51. typedef __kernel_ptrdiff_t ptrdiff_t;
  52. #endif
  53. #ifndef _TIME_T
  54. #define _TIME_T
  55. typedef __kernel_time_t time_t;
  56. #endif
  57. #ifndef _CLOCK_T
  58. #define _CLOCK_T
  59. typedef __kernel_clock_t clock_t;
  60. #endif
  61. #ifndef _CADDR_T
  62. #define _CADDR_T
  63. typedef __kernel_caddr_t caddr_t;
  64. #endif
  65. /* bsd */
  66. typedef unsigned char u_char;
  67. typedef unsigned short u_short;
  68. typedef unsigned int u_int;
  69. typedef unsigned long u_long;
  70. /* sysv */
  71. typedef unsigned char unchar;
  72. typedef unsigned short ushort;
  73. typedef unsigned int uint;
  74. typedef unsigned long ulong;
  75. #ifndef __BIT_TYPES_DEFINED__
  76. #define __BIT_TYPES_DEFINED__
  77. typedef __u8 u_int8_t;
  78. typedef __s8 int8_t;
  79. typedef __u16 u_int16_t;
  80. typedef __s16 int16_t;
  81. typedef __u32 u_int32_t;
  82. typedef __s32 int32_t;
  83. #endif /* !(__BIT_TYPES_DEFINED__) */
  84. typedef __u8 uint8_t;
  85. typedef __u16 uint16_t;
  86. typedef __u32 uint32_t;
  87. #if defined(__GNUC__)
  88. typedef __u64 uint64_t;
  89. typedef __u64 u_int64_t;
  90. typedef __s64 int64_t;
  91. #endif
  92. /* this is a special 64bit data type that is 8-byte aligned */
  93. #define aligned_u64 __u64 __attribute__((aligned(8)))
  94. #define aligned_be64 __be64 __attribute__((aligned(8)))
  95. #define aligned_le64 __le64 __attribute__((aligned(8)))
  96. /**
  97. * The type used for indexing onto a disc or disc partition.
  98. *
  99. * Linux always considers sectors to be 512 bytes long independently
  100. * of the devices real block size.
  101. *
  102. * blkcnt_t is the type of the inode's block count.
  103. */
  104. #ifdef CONFIG_LBDAF
  105. typedef u64 sector_t;
  106. typedef u64 blkcnt_t;
  107. #else
  108. typedef unsigned long sector_t;
  109. typedef unsigned long blkcnt_t;
  110. #endif
  111. /*
  112. * The type of an index into the pagecache.
  113. */
  114. #define pgoff_t unsigned long
  115. /*
  116. * A dma_addr_t can hold any valid DMA address, i.e., any address returned
  117. * by the DMA API.
  118. *
  119. * If the DMA API only uses 32-bit addresses, dma_addr_t need only be 32
  120. * bits wide. Bus addresses, e.g., PCI BARs, may be wider than 32 bits,
  121. * but drivers do memory-mapped I/O to ioremapped kernel virtual addresses,
  122. * so they don't care about the size of the actual bus addresses.
  123. */
  124. #ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
  125. typedef u64 dma_addr_t;
  126. #else
  127. typedef u32 dma_addr_t;
  128. #endif
  129. typedef unsigned __bitwise__ gfp_t;
  130. typedef unsigned __bitwise__ fmode_t;
  131. typedef unsigned __bitwise__ oom_flags_t;
  132. #ifdef CONFIG_PHYS_ADDR_T_64BIT
  133. typedef u64 phys_addr_t;
  134. #else
  135. typedef u32 phys_addr_t;
  136. #endif
  137. typedef phys_addr_t resource_size_t;
  138. /*
  139. * This type is the placeholder for a hardware interrupt number. It has to be
  140. * big enough to enclose whatever representation is used by a given platform.
  141. */
  142. typedef unsigned long irq_hw_number_t;
  143. typedef struct {
  144. int counter;
  145. } atomic_t;
  146. #ifdef CONFIG_64BIT
  147. typedef struct {
  148. long counter;
  149. } atomic64_t;
  150. #endif
  151. struct list_head {
  152. struct list_head *next, *prev;
  153. };
  154. struct hlist_head {
  155. struct hlist_node *first;
  156. };
  157. struct hlist_node {
  158. struct hlist_node *next, **pprev;
  159. };
  160. struct ustat {
  161. __kernel_daddr_t f_tfree;
  162. __kernel_ino_t f_tinode;
  163. char f_fname[6];
  164. char f_fpack[6];
  165. };
  166. /**
  167. * struct callback_head - callback structure for use with RCU and task_work
  168. * @next: next update requests in a list
  169. * @func: actual update function to call after the grace period.
  170. *
  171. * The struct is aligned to size of pointer. On most architectures it happens
  172. * naturally due ABI requirements, but some architectures (like CRIS) have
  173. * weird ABI and we need to ask it explicitly.
  174. *
  175. * The alignment is required to guarantee that bits 0 and 1 of @next will be
  176. * clear under normal conditions -- as long as we use call_rcu(),
  177. * call_rcu_bh(), call_rcu_sched(), or call_srcu() to queue callback.
  178. *
  179. * This guarantee is important for few reasons:
  180. * - future call_rcu_lazy() will make use of lower bits in the pointer;
  181. * - the structure shares storage spacer in struct page with @compound_head,
  182. * which encode PageTail() in bit 0. The guarantee is needed to avoid
  183. * false-positive PageTail().
  184. */
  185. struct callback_head {
  186. struct callback_head *next;
  187. void (*func)(struct callback_head *head);
  188. } __attribute__((aligned(sizeof(void *))));
  189. #define rcu_head callback_head
  190. typedef void (*rcu_callback_t)(struct rcu_head *head);
  191. typedef void (*call_rcu_func_t)(struct rcu_head *head, rcu_callback_t func);
  192. /* clocksource cycle base type */
  193. typedef u64 cycle_t;
  194. #endif /* __ASSEMBLY__ */
  195. #endif /* _LINUX_TYPES_H */