]> git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Foundation/Include/X64/EfiBind.h
change the error usage of "#if __GNUC__" Condition Macro to "#if defined(__GNUC__)"
[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 #pragma pack()
39
40 #if __INTEL_COMPILER
41 //
42 // Disable ICC's warning: trailing comma is nonstandard
43 //
44 //#pragma warning ( disable : 271 )
45
46 //
47 // Disable ICC's warning: extra ";" ignored
48 //
49 #pragma warning ( disable : 424 )
50
51 //
52 // Disable ICC's warning: : variable "foo" was set but never used
53 //
54 #pragma warning ( disable : 593 )
55
56 //
57 // Disable ICC's remark #1418: external function definition with no prior declaration.
58 // This is legal ANSI C code so we disable the remark that is turned on with /W4
59 //
60 #pragma warning ( disable : 1418 )
61
62
63 //
64 // Disable ICC's remark #1419: external declaration in primary source file
65 // This is legal ANSI C code so we disable the remark that is turned on with /W4
66 //
67 #pragma warning ( disable : 1419 )
68
69 //
70 // Disable ICC's remark #869: "Parameter" was never referenced warning.
71 // This is legal ANSI C code so we disable the remark that is turned on with -Wall
72 //
73 #pragma warning ( disable : 869 )
74
75 #endif
76
77
78 #if _MSC_EXTENSIONS
79
80 //
81 // Disable warning that make it impossible to compile at /W4
82 // This only works for Microsoft* tools
83 //
84
85 //
86 // Disabling bitfield type checking warnings.
87 //
88 #pragma warning ( disable : 4214 )
89
90 //
91 // Disabling the unreferenced formal parameter warnings.
92 //
93 #pragma warning ( disable : 4100 )
94
95 //
96 // Disable slightly different base types warning as CHAR8 * can not be set
97 // to a constant string.
98 //
99 #pragma warning ( disable : 4057 )
100
101 //
102 // ASSERT(FALSE) or while (TRUE) are legal constructes so supress this warning
103 //
104 #pragma warning ( disable : 4127 )
105
106 //
107 // Int64ShllMod32 unreferenced inline function
108 //
109 #pragma warning ( disable : 4514 )
110
111 //
112 // Unreferenced formal parameter - We are object oriented, so we pass This even
113 // if we don't need them.
114 //
115 #pragma warning ( disable : 4100 )
116
117 //
118 // This warning is caused by empty (after preprocessing) souce file.
119 //
120 #pragma warning ( disable : 4206 )
121
122 //
123 // Warning: The result of the unary '&' operator may be unaligned. Ignore it.
124 //
125 #pragma warning ( disable : 4366 )
126
127 #endif
128
129
130 #if !defined(__GNUC__) && (__STDC_VERSION__ < 199901L)
131 //
132 // No ANSI C 2000 stdint.h integer width declarations, so define equivalents
133 //
134
135 #if _MSC_EXTENSIONS
136
137 //
138 // use Microsoft* C complier dependent interger width types
139 //
140 typedef unsigned __int64 uint64_t;
141 typedef __int64 int64_t;
142 typedef unsigned __int32 uint32_t;
143 typedef __int32 int32_t;
144 typedef unsigned short uint16_t;
145 typedef short int16_t;
146 typedef unsigned char uint8_t;
147 typedef char int8_t;
148 #else
149
150 //
151 // Assume standard IA-32 alignment.
152 // BugBug: Need to check portability of long long
153 //
154 typedef unsigned long long uint64_t;
155 typedef long long int64_t;
156 typedef unsigned int uint32_t;
157 typedef int int32_t;
158 typedef unsigned short uint16_t;
159 typedef short int16_t;
160 typedef unsigned char uint8_t;
161 typedef char int8_t;
162 #endif
163 #else
164 //
165 // Use ANSI C 2000 stdint.h integer width declarations
166 //
167 #include "stdint.h"
168 #endif
169
170 //
171 // Native integer size in stdint.h
172 //
173 typedef uint64_t uintn_t;
174 typedef int64_t intn_t;
175
176 //
177 // Processor specific defines
178 //
179 #define EFI_MAX_BIT 0x8000000000000000ULL
180 #define MAX_2_BITS 0xC000000000000000ULL
181
182 //
183 // Maximum legal IA-32 address
184 //
185 #define EFI_MAX_ADDRESS 0xFFFFFFFFFFFFFFFFULL
186
187 //
188 // Bad pointer value to use in check builds.
189 // if you see this value you are using uninitialized or free'ed data
190 //
191 #define EFI_BAD_POINTER 0xAFAFAFAFAFAFAFAFULL
192 #define EFI_BAD_POINTER_AS_BYTE 0xAF
193
194 //
195 // Inject a break point in the code to assist debugging.
196 //
197 #define EFI_DEADLOOP() { volatile int __iii; __iii = 1; while (__iii); }
198 #if _MSC_EXTENSIONS
199 #define EFI_BREAKPOINT() __debugbreak()
200 #elif __GNUC__
201 #define EFI_BREAKPOINT() asm(" int $3");
202 #endif
203
204 //
205 // Memory Fence forces serialization, and is needed to support out of order
206 // memory transactions. The Memory Fence is mainly used to make sure IO
207 // transactions complete in a deterministic sequence, and to syncronize locks
208 // an other MP code. Currently no memory fencing is required.
209 //
210 #define MEMORY_FENCE()
211
212 //
213 // Some compilers don't support the forward reference construct:
214 // typedef struct XXXXX. The forward reference is required for
215 // ANSI compatibility.
216 //
217 // The following macro provide a workaround for such cases.
218 //
219
220
221 #ifdef EFI_NO_INTERFACE_DECL
222 #define EFI_FORWARD_DECLARATION(x)
223 #else
224 #define EFI_FORWARD_DECLARATION(x) typedef struct _##x x
225 #endif
226
227
228 //
229 // Some C compilers optimize the calling conventions to increase performance.
230 // _EFIAPI is used to make all public APIs follow the standard C calling
231 // convention.
232 //
233 #if _MSC_EXTENSIONS
234 //
235 // Microsoft* compiler requires _EFIAPI useage, __cdecl is Microsoft* specific C.
236 //
237
238 #define _EFIAPI __cdecl
239 #else
240 #define _EFIAPI
241 #endif
242
243
244 #ifdef _EFI_WINNT
245
246 #define EFI_SUPPRESS_BENIGN_REDEFINITION_OF_TYPE_WARNING() \
247 warning ( disable : 4142 )
248
249 #define EFI_DEFAULT_BENIGN_REDEFINITION_OF_TYPE_WARNING() \
250 warning ( default : 4142 )
251 #else
252
253 #define EFI_SUPPRESS_BENIGN_REDEFINITION_OF_TYPE_WARNING() \
254 warning ( disable : 4068 )
255
256 #define EFI_DEFAULT_BENIGN_REDEFINITION_OF_TYPE_WARNING() \
257 warning ( default : 4068 )
258
259 #endif
260
261 //
262 // For symbol name in GNU assembly code, an extra "_" is necessary
263 //
264 #if defined(__GNUC__)
265 #if defined(linux)
266 #define ASM_PFX(name) name
267 #else
268 #define ASM_PFX(name) _##name
269 #endif
270 #endif
271
272 #endif
273