types.h 3.1 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 _Bool bool;
  45. enum { false = 0, true = 1 };
  46. /*
  47. * Below are truly Linux-specific types that should never collide with
  48. * any application/library that wants linux/types.h.
  49. */
  50. #ifdef __CHECKER__
  51. #define __bitwise__ __attribute__((bitwise))
  52. #else
  53. #define __bitwise__
  54. #endif
  55. #define __bitwise __bitwise__
  56. typedef __u16 __bitwise __le16;
  57. typedef __u16 __bitwise __be16;
  58. typedef __u32 __bitwise __le32;
  59. typedef __u32 __bitwise __be32;
  60. typedef __u64 __bitwise __le64;
  61. typedef __u64 __bitwise __be64;
  62. typedef __u16 __bitwise __sum16;
  63. typedef __u32 __bitwise __wsum;
  64. /*
  65. * aligned_u64 should be used in defining kernel<->userspace ABIs to avoid
  66. * common 32/64-bit compat problems.
  67. * 64-bit values align to 4-byte boundaries on x86_32 (and possibly other
  68. * architectures) and to 8-byte boundaries on 64-bit architectures. The new
  69. * aligned_64 type enforces 8-byte alignment so that structs containing
  70. * aligned_64 values have the same alignment on 32-bit and 64-bit architectures.
  71. * No conversions are necessary between 32-bit user-space and a 64-bit kernel.
  72. */
  73. #define __aligned_u64 __u64 __attribute__((aligned(8)))
  74. #define __aligned_be64 __be64 __attribute__((aligned(8)))
  75. #define __aligned_le64 __le64 __attribute__((aligned(8)))
  76. /*
  77. * The following typedefs are also protected by individual ifdefs for
  78. * historical reasons:
  79. */
  80. #ifndef _SIZE_T
  81. #define _SIZE_T
  82. typedef __kernel_size_t size_t;
  83. #endif
  84. #ifndef _SSIZE_T
  85. #define _SSIZE_T
  86. typedef __kernel_ssize_t ssize_t;
  87. #endif
  88. #ifndef _PTRDIFF_T
  89. #define _PTRDIFF_T
  90. typedef __kernel_ptrdiff_t ptrdiff_t;
  91. #endif
  92. #ifndef _CLOCK_T
  93. #define _CLOCK_T
  94. typedef __kernel_clock_t clock_t;
  95. #endif
  96. #ifndef _CADDR_T
  97. #define _CADDR_T
  98. typedef __kernel_caddr_t caddr_t;
  99. #endif
  100. /* bsd */
  101. typedef unsigned char u_char;
  102. typedef unsigned short u_short;
  103. typedef unsigned int u_int;
  104. typedef unsigned long u_long;
  105. /* sysv */
  106. typedef unsigned char unchar;
  107. typedef unsigned short ushort;
  108. typedef unsigned int uint;
  109. typedef unsigned long ulong;
  110. typedef unsigned __bitwise __poll_t;