types.h 4.5 KB

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