1 #ifndef __LVGL_TESTS_MAKEFILE_UEFI_EFI_H__
2 #define __LVGL_TESTS_MAKEFILE_UEFI_EFI_H__
3 
4 #ifndef __clang__
5     #error This file is only for use with the clang compiler
6 #endif
7 
8 /*************************************
9  * TYPES
10 *************************************/
11 #if defined(__x86_64__)
12     typedef unsigned long long UINT64;
13     typedef long long INT64;
14     typedef unsigned int UINT32;
15     typedef int INT32;
16     typedef unsigned short UINT16;
17     typedef unsigned short CHAR16;
18     typedef short INT16;
19     typedef unsigned char BOOLEAN;
20     typedef unsigned char UINT8;
21     typedef char CHAR8;
22     typedef signed char INT8;
23     typedef UINT64 UINTN;
24     typedef INT64 INTN;
25     typedef INT64 INTMAX;
26 #elif defined(__i386__)
27     typedef unsigned long long UINT64;
28     typedef long long INT64;
29     typedef unsigned int UINT32;
30     typedef int INT32;
31     typedef unsigned short UINT16;
32     typedef unsigned short CHAR16;
33     typedef short INT16;
34     typedef unsigned char BOOLEAN;
35     typedef unsigned char UINT8;
36     typedef char CHAR8;
37     typedef signed char INT8;
38     typedef UINT32 UINTN;
39     typedef INT32 INTN;
40     typedef INT64 INTMAX;
41 #elif defined(__aarch64__)
42     typedef unsigned long long UINT64;
43     typedef long long INT64;
44     typedef unsigned int UINT32;
45     typedef int INT32;
46     typedef unsigned short UINT16;
47     typedef unsigned short CHAR16;
48     typedef short INT16;
49     typedef unsigned char BOOLEAN;
50     typedef unsigned char UINT8;
51     typedef char CHAR8;
52     typedef signed char INT8;
53     typedef UINT64 UINTN;
54     typedef INT64 INTN;
55     typedef INT64 INTMAX;
56 #else
57     #error Architecture is not supported
58 #endif
59 
60 typedef UINT8 uint8_t;
61 typedef UINT16 uint16_t;
62 typedef UINT32 uint32_t;
63 typedef UINT64 uint64_t;
64 typedef INT8 int8_t;
65 typedef INT16 int16_t;
66 typedef INT32 int32_t;
67 typedef INT64 int64_t;
68 typedef void VOID;
69 
70 typedef uint32_t uint_fast32_t;
71 typedef UINTN uintptr_t;
72 typedef UINTN size_t;
73 typedef INTN intptr_t;
74 typedef INTMAX intmax_t;
75 typedef INTN ptrdiff_t;
76 
77 typedef UINT8 bool;
78 
79 /*************************************
80  * DEFINES
81 *************************************/
82 #define false 0
83 #define true 1
84 #define NULL ((void*)0)
85 
86 #define PRId8       "d"
87 #define PRId16      "d"
88 #define PRId32      "d"
89 #define PRId64      "d"
90 
91 #define PRIu8       "u"
92 #define PRIu16      "u"
93 #define PRIu32      "u"
94 #define PRIu64      "u"
95 
96 #define PRIx8       "x"
97 #define PRIx16      "x"
98 #define PRIx32      "x"
99 #define PRIx64      "x"
100 
101 #define PRIX8       "X"
102 #define PRIX16      "X"
103 #define PRIX32      "X"
104 #define PRIX64      "X"
105 
106 #define offsetof(TYPE, Field)     ((UINTN) __builtin_offsetof(TYPE, Field))
107 
108 /*************************************
109  * LIMITS
110 *************************************/
111 #define INT8_MAX    (0x7F)
112 #define UINT8_MAX   (0xFF)
113 #define INT16_MAX   (0x7FFF)
114 #define UINT16_MAX  (0xFFFF)
115 #define INT32_MAX   (0x7FFFFFFF)
116 #define UINT32_MAX  (0xFFFFFFFF)
117 #define INT64_MAX   (0x7FFFFFFFFFFFFFFFULL)
118 #define UINT64_MAX  (0xFFFFFFFFFFFFFFFFULL)
119 #define INT_MAX   (0x7FFFFFFFFFFFFFFFULL)
120 #define UINT_MAX  (0xFFFFFFFFFFFFFFFFULL)
121 
122 ///
123 /// Minimum values for the signed UEFI Data Types
124 ///
125 #define INT8_MIN   ((  -127) - 1)
126 #define INT16_MIN  (( -32767) - 1)
127 #define INT32_MIN  (( -2147483647) - 1)
128 #define INT64_MIN  (( -9223372036854775807LL) - 1)
129 
130 #define SIZE_MAX (0xFFFFFFFF)
131 #define LONG_MAX (0x7FFFFFFF)
132 #define CHAR_BIT 8
133 
134 /*************************************
135  * VA_ARG
136 *************************************/
137 typedef __builtin_va_list va_list;
138 #define va_start(Marker, Parameter)  __builtin_va_start (Marker, Parameter)
139 #define va_arg(Marker, TYPE)  ((sizeof (TYPE) < sizeof (UINTN)) ? (TYPE)(__builtin_va_arg (Marker, UINTN)) : (TYPE)(__builtin_va_arg (Marker, TYPE)))
140 #define va_end(Marker)  __builtin_va_end (Marker)
141 #define va_copy(Dest, Start)  __builtin_va_copy (Dest, Start)
142 
143 /*************************************
144  * VERIFICATION
145 *************************************/
146 _Static_assert(sizeof(bool)     == 1, "Size check for 'bool' failed.");
147 _Static_assert(sizeof(int8_t)   == 1, "Size check for 'int8_t' failed.");
148 _Static_assert(sizeof(uint8_t)  == 1, "Size check for 'uint8_t' failed.");
149 _Static_assert(sizeof(int16_t)  == 2, "Size check for 'int16_t' failed.");
150 _Static_assert(sizeof(uint16_t) == 2, "Size check for 'uint16_t' failed.");
151 _Static_assert(sizeof(int32_t)  == 4, "Size check for 'int32_t' failed.");
152 _Static_assert(sizeof(uint32_t) == 4, "Size check for 'uint32_t' failed.");
153 _Static_assert(sizeof(uint_fast32_t) == 4, "Size check for 'uint_fast32_t' failed.");
154 _Static_assert(sizeof(int64_t)  == 8, "Size check for 'int64_t' failed.");
155 _Static_assert(sizeof(uint64_t) == 8, "Size check for 'uint64_t' failed.");
156 _Static_assert(sizeof(intptr_t) == sizeof(void *), "Size check for 'intptr_t' failed.");
157 _Static_assert(sizeof(ptrdiff_t) == sizeof(void *), "Size check for 'ptrdiff_t' failed.");
158 _Static_assert(sizeof(uintptr_t) == sizeof(void *), "Size check for 'uintptr_t' failed.");
159 
160 #endif
161