]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Include/Base.h
MdePkg/Include: Add support for flexible array members
[mirror_edk2.git] / MdePkg / Include / Base.h
index e1ffa7d23b6434c2270a4f11885a5a126cef06cc..85ed34f0887beb97a4ab525754b2ee14382e1c18 100644 (file)
@@ -6,7 +6,7 @@
   environment. There are a set of base libraries in the Mde Package that can\r
   be used to implement base modules.\r
 \r
-Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
 Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
@@ -27,6 +27,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 //\r
 #include <ProcessorBind.h>\r
 \r
+#if defined(_MSC_EXTENSIONS)\r
+//\r
+// Disable warning when last field of data structure is a zero sized array.\r
+//\r
+#pragma warning ( disable : 4200 )\r
+#endif\r
 \r
 /**\r
   Verifies the storage size of a given data type.\r
@@ -79,21 +85,20 @@ VERIFY_SIZE_OF (CHAR16, 2);
 #endif\r
 \r
 //\r
-// For symbol name in GNU assembly code, an extra "_" is necessary\r
+// For symbol name in assembly code, an extra "_" is sometimes necessary\r
 //\r
-#if defined(__GNUC__)\r
-  ///\r
-  /// Private worker functions for ASM_PFX()\r
-  ///\r
-  #define _CONCATENATE(a, b)  __CONCATENATE(a, b)\r
-  #define __CONCATENATE(a, b) a ## b\r
 \r
-  ///\r
-  /// The __USER_LABEL_PREFIX__ macro predefined by GNUC represents the prefix\r
-  /// on symbols in assembly language.\r
-  ///\r
-  #define ASM_PFX(name) _CONCATENATE (__USER_LABEL_PREFIX__, name)\r
-#endif\r
+///\r
+/// Private worker functions for ASM_PFX()\r
+///\r
+#define _CONCATENATE(a, b)  __CONCATENATE(a, b)\r
+#define __CONCATENATE(a, b) a ## b\r
+\r
+///\r
+/// The __USER_LABEL_PREFIX__ macro predefined by GNUC represents the prefix\r
+/// on symbols in assembly language.\r
+///\r
+#define ASM_PFX(name) _CONCATENATE (__USER_LABEL_PREFIX__, name)\r
 \r
 #if __APPLE__\r
   //\r
@@ -1017,5 +1022,46 @@ typedef UINTN RETURN_STATUS;
 #define SIGNATURE_64(A, B, C, D, E, F, G, H) \\r
     (SIGNATURE_32 (A, B, C, D) | ((UINT64) (SIGNATURE_32 (E, F, G, H)) << 32))\r
 \r
+#if defined(_MSC_EXTENSIONS) && !defined (MDE_CPU_EBC)\r
+  #pragma intrinsic(_ReturnAddress)\r
+  /**\r
+    Get the return address of the calling funcation.\r
+\r
+    Based on intrinsic function _ReturnAddress that provides the address of\r
+    the instruction in the calling function that will be executed after\r
+    control returns to the caller.\r
+\r
+    @param L    Return Level.\r
+\r
+    @return The return address of the calling funcation or 0 if L != 0.\r
+\r
+  **/\r
+  #define RETURN_ADDRESS(L)     ((L == 0) ? _ReturnAddress() : (VOID *) 0)\r
+#elif defined(__GNUC__)\r
+  void * __builtin_return_address (unsigned int level);\r
+  /**\r
+    Get the return address of the calling funcation.\r
+\r
+    Based on built-in Function __builtin_return_address that returns\r
+    the return address of the current function, or of one of its callers.\r
+\r
+    @param L    Return Level.\r
+\r
+    @return The return address of the calling funcation.\r
+\r
+  **/\r
+  #define RETURN_ADDRESS(L)     __builtin_return_address (L)\r
+#else\r
+  /**\r
+    Get the return address of the calling funcation.\r
+\r
+    @param L    Return Level.\r
+\r
+    @return 0 as compilers don't support this feature.\r
+\r
+  **/\r
+  #define RETURN_ADDRESS(L)     ((VOID *) 0)\r
+#endif\r
+\r
 #endif\r
 \r