]> git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Foundation/Include/X64/EfiBind.h
Fixed issues compiling for Apple gcc on IA-32
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Include / X64 / EfiBind.h
1 /*++
2
3 Copyright (c) 2005 - 2008, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 EfiBind.h
15
16 Abstract:
17
18 Processor or Compiler specific defines and types for x64.
19 We are using the ANSI C 2000 _t type definitions for basic types.
20 This it technically a violation of the coding standard, but they
21 are used to make EfiTypes.h portable. Code other than EfiTypes.h
22 should never use any ANSI C 2000 _t integer types.
23
24 --*/
25
26 #ifndef _EFI_BIND_H_
27 #define _EFI_BIND_H_
28
29
30 #define EFI_DRIVER_ENTRY_POINT(InitFunction)
31 #define EFI_APPLICATION_ENTRY_POINT EFI_DRIVER_ENTRY_POINT
32
33
34
35 //
36 // Make sure we are useing the correct packing rules per EFI specification
37 //
38 #ifndef __GNUC__
39 #pragma pack()
40 #endif
41
42 #if __INTEL_COMPILER
43 //
44 // Disable ICC's warning: trailing comma is nonstandard
45 //
46 //#pragma warning ( disable : 271 )
47
48 //
49 // Disable ICC's warning: extra ";" ignored
50 //
51 #pragma warning ( disable : 424 )
52
53 //
54 // Disable ICC's warning: : variable "foo" was set but never used
55 //
56 #pragma warning ( disable : 593 )
57
58 //
59 // Disable ICC's remark #1418: external function definition with no prior declaration.
60 // This is legal ANSI C code so we disable the remark that is turned on with /W4
61 //
62 #pragma warning ( disable : 1418 )
63
64
65 //
66 // Disable ICC's remark #1419: external declaration in primary source file
67 // This is legal ANSI C code so we disable the remark that is turned on with /W4
68 //
69 #pragma warning ( disable : 1419 )
70
71 //
72 // Disable ICC's remark #869: "Parameter" was never referenced warning.
73 // This is legal ANSI C code so we disable the remark that is turned on with -Wall
74 //
75 #pragma warning ( disable : 869 )
76
77 #endif
78
79
80 #if _MSC_EXTENSIONS
81
82 //
83 // Disable warning that make it impossible to compile at /W4
84 // This only works for Microsoft* tools
85 //
86
87 //
88 // Disabling bitfield type checking warnings.
89 //
90 #pragma warning ( disable : 4214 )
91
92 //
93 // Disabling the unreferenced formal parameter warnings.
94 //
95 #pragma warning ( disable : 4100 )
96
97 //
98 // Disable slightly different base types warning as CHAR8 * can not be set
99 // to a constant string.
100 //
101 #pragma warning ( disable : 4057 )
102
103 //
104 // ASSERT(FALSE) or while (TRUE) are legal constructes so supress this warning
105 //
106 #pragma warning ( disable : 4127 )
107
108 //
109 // Int64ShllMod32 unreferenced inline function
110 //
111 #pragma warning ( disable : 4514 )
112
113 //
114 // Unreferenced formal parameter - We are object oriented, so we pass This even
115 // if we don't need them.
116 //
117 #pragma warning ( disable : 4100 )
118
119 //
120 // This warning is caused by empty (after preprocessing) souce file.
121 //
122 #pragma warning ( disable : 4206 )
123
124 //
125 // Warning: The result of the unary '&' operator may be unaligned. Ignore it.
126 //
127 #pragma warning ( disable : 4366 )
128
129 #endif
130
131
132 #if !defined(__GNUC__) && (__STDC_VERSION__ < 199901L)
133 //
134 // No ANSI C 2000 stdint.h integer width declarations, so define equivalents
135 //
136
137 #if _MSC_EXTENSIONS
138
139 //
140 // use Microsoft* C complier dependent interger width types
141 //
142 typedef unsigned __int64 uint64_t;
143 typedef __int64 int64_t;
144 typedef unsigned __int32 uint32_t;
145 typedef __int32 int32_t;
146 typedef unsigned short uint16_t;
147 typedef short int16_t;
148 typedef unsigned char uint8_t;
149 typedef char int8_t;
150 #else
151
152 //
153 // Assume standard IA-32 alignment.
154 // BugBug: Need to check portability of long long
155 //
156 typedef unsigned long long uint64_t;
157 typedef long long int64_t;
158 typedef unsigned int uint32_t;
159 typedef int int32_t;
160 typedef unsigned short uint16_t;
161 typedef short int16_t;
162 typedef unsigned char uint8_t;
163 typedef char int8_t;
164 #endif
165 #else
166 //
167 // Use ANSI C 2000 stdint.h integer width declarations
168 //
169 #include "stdint.h"
170 #endif
171
172 //
173 // Native integer size in stdint.h
174 //
175 typedef uint64_t uintn_t;
176 typedef int64_t intn_t;
177
178 //
179 // Processor specific defines
180 //
181 #define EFI_MAX_BIT 0x8000000000000000ULL
182 #define MAX_2_BITS 0xC000000000000000ULL
183
184 //
185 // Maximum legal IA-32 address
186 //
187 #define EFI_MAX_ADDRESS 0xFFFFFFFFFFFFFFFFULL
188
189 //
190 // Bad pointer value to use in check builds.
191 // if you see this value you are using uninitialized or free'ed data
192 //
193 #define EFI_BAD_POINTER 0xAFAFAFAFAFAFAFAFULL
194 #define EFI_BAD_POINTER_AS_BYTE 0xAF
195
196 //
197 // Inject a break point in the code to assist debugging.
198 //
199 #define EFI_DEADLOOP() { volatile int __iii; __iii = 1; while (__iii); }
200 #if _MSC_EXTENSIONS
201 #define EFI_BREAKPOINT() __debugbreak()
202 #elif __GNUC__
203 #define EFI_BREAKPOINT() asm(" int $3");
204 #endif
205
206 //
207 // Memory Fence forces serialization, and is needed to support out of order
208 // memory transactions. The Memory Fence is mainly used to make sure IO
209 // transactions complete in a deterministic sequence, and to syncronize locks
210 // an other MP code. Currently no memory fencing is required.
211 //
212 #define MEMORY_FENCE()
213
214 //
215 // Some compilers don't support the forward reference construct:
216 // typedef struct XXXXX. The forward reference is required for
217 // ANSI compatibility.
218 //
219 // The following macro provide a workaround for such cases.
220 //
221
222
223 #ifdef EFI_NO_INTERFACE_DECL
224 #define EFI_FORWARD_DECLARATION(x)
225 #else
226 #define EFI_FORWARD_DECLARATION(x) typedef struct _##x x
227 #endif
228
229
230 //
231 // Some C compilers optimize the calling conventions to increase performance.
232 // _EFIAPI is used to make all public APIs follow the standard C calling
233 // convention.
234 //
235 #if _MSC_EXTENSIONS
236 //
237 // Microsoft* compiler requires _EFIAPI useage, __cdecl is Microsoft* specific C.
238 //
239
240 #define _EFIAPI __cdecl
241 #else
242 #define _EFIAPI
243 #endif
244
245
246 #ifdef _EFI_WINNT
247
248 #define EFI_SUPPRESS_BENIGN_REDEFINITION_OF_TYPE_WARNING() \
249 warning ( disable : 4142 )
250
251 #define EFI_DEFAULT_BENIGN_REDEFINITION_OF_TYPE_WARNING() \
252 warning ( default : 4142 )
253 #else
254
255 #define EFI_SUPPRESS_BENIGN_REDEFINITION_OF_TYPE_WARNING() \
256 warning ( disable : 4068 )
257
258 #define EFI_DEFAULT_BENIGN_REDEFINITION_OF_TYPE_WARNING() \
259 warning ( default : 4068 )
260
261 #endif
262
263 //
264 // For symbol name in GNU assembly code, an extra "_" is necessary
265 //
266 #if defined(__GNUC__)
267 ///
268 /// Private worker functions for ASM_PFX()
269 ///
270 #define _CONCATENATE(a, b) __CONCATENATE(a, b)
271 #define __CONCATENATE(a, b) a ## b
272
273 ///
274 /// The __USER_LABEL_PREFIX__ macro predefined by GNUC represents the prefix
275 /// on symbols in assembly language.
276 ///
277 #define ASM_PFX(name) _CONCATENATE (__USER_LABEL_PREFIX__, name)
278
279 #endif
280
281 #endif
282