types.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. #pragma once
  2. #include <efidef.h>
  3. #include "compiler_attributes.h"
  4. #include "linux/posix_types.h"
  5. #include "linux/bitsperlong.h"
  6. // Simplified version of Linux types.h
  7. #define typeof(p) __typeof__(p)
  8. /*
  9. * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the
  10. * header files exported to user space
  11. */
  12. #ifndef __ASSEMBLY__
  13. /*
  14. * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the
  15. * header files exported to user space
  16. */
  17. typedef __signed__ char __s8;
  18. typedef unsigned char __u8;
  19. typedef __signed__ short __s16;
  20. typedef unsigned short __u16;
  21. typedef __signed__ int __s32;
  22. typedef unsigned int __u32;
  23. #ifdef __GNUC__
  24. __extension__ typedef __signed__ long long __s64;
  25. __extension__ typedef unsigned long long __u64;
  26. #else
  27. typedef __signed__ long long __s64;
  28. typedef unsigned long long __u64;
  29. #endif
  30. #endif /* __ASSEMBLY__ */
  31. typedef __s8 s8;
  32. typedef __u8 u8;
  33. typedef __s16 s16;
  34. typedef __u16 u16;
  35. typedef __s32 s32;
  36. typedef __u32 u32;
  37. typedef __s64 s64;
  38. typedef __u64 u64;
  39. typedef unsigned long efi_status_t;
  40. typedef u8 efi_bool_t;
  41. typedef u16 efi_char16_t; /* UNICODE character */
  42. typedef u64 efi_physical_addr_t;
  43. typedef void *efi_handle_t;
  44. typedef u64 phys_addr_t;
  45. typedef _Bool bool;
  46. enum { false = 0, true = 1 };
  47. /*
  48. * Below are truly Linux-specific types that should never collide with
  49. * any application/library that wants linux/types.h.
  50. */
  51. #ifdef __CHECKER__
  52. #define __bitwise__ __attribute__((bitwise))
  53. #else
  54. #define __bitwise__
  55. #endif
  56. #define __bitwise __bitwise__
  57. typedef __u16 __bitwise __le16;
  58. typedef __u16 __bitwise __be16;
  59. typedef __u32 __bitwise __le32;
  60. typedef __u32 __bitwise __be32;
  61. typedef __u64 __bitwise __le64;
  62. typedef __u64 __bitwise __be64;
  63. typedef __u16 __bitwise __sum16;
  64. typedef __u32 __bitwise __wsum;
  65. /*
  66. * aligned_u64 should be used in defining kernel<->userspace ABIs to avoid
  67. * common 32/64-bit compat problems.
  68. * 64-bit values align to 4-byte boundaries on x86_32 (and possibly other
  69. * architectures) and to 8-byte boundaries on 64-bit architectures. The new
  70. * aligned_64 type enforces 8-byte alignment so that structs containing
  71. * aligned_64 values have the same alignment on 32-bit and 64-bit architectures.
  72. * No conversions are necessary between 32-bit user-space and a 64-bit kernel.
  73. */
  74. #define __aligned_u64 __u64 __attribute__((aligned(8)))
  75. #define __aligned_be64 __be64 __attribute__((aligned(8)))
  76. #define __aligned_le64 __le64 __attribute__((aligned(8)))
  77. /*
  78. * The following typedefs are also protected by individual ifdefs for
  79. * historical reasons:
  80. */
  81. #ifndef _SIZE_T
  82. #define _SIZE_T
  83. typedef __kernel_size_t size_t;
  84. #endif
  85. #ifndef _SSIZE_T
  86. #define _SSIZE_T
  87. typedef __kernel_ssize_t ssize_t;
  88. #endif
  89. #ifndef _PTRDIFF_T
  90. #define _PTRDIFF_T
  91. typedef __kernel_ptrdiff_t ptrdiff_t;
  92. #endif
  93. #ifndef _CLOCK_T
  94. #define _CLOCK_T
  95. typedef __kernel_clock_t clock_t;
  96. #endif
  97. #ifndef _CADDR_T
  98. #define _CADDR_T
  99. typedef __kernel_caddr_t caddr_t;
  100. #endif
  101. /* bsd */
  102. typedef unsigned char u_char;
  103. typedef unsigned short u_short;
  104. typedef unsigned int u_int;
  105. typedef unsigned long u_long;
  106. /* sysv */
  107. typedef unsigned char unchar;
  108. typedef unsigned short ushort;
  109. typedef unsigned int uint;
  110. typedef unsigned long ulong;
  111. typedef unsigned __bitwise __poll_t;