]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdePkg: Add RETURN_ADDRESS macro into Base.h.
authorStar Zeng <star.zeng@intel.com>
Wed, 12 Nov 2014 03:18:09 +0000 (03:18 +0000)
committerlzeng14 <lzeng14@Edk2>
Wed, 12 Nov 2014 03:18:09 +0000 (03:18 +0000)
Based on compiler intrinsic function.
MSVC: _ReturnAddress
GCC: __builtin_return_address

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16334 6f19259b-4bc3-4df7-8a09-765794883524

MdePkg/Include/Base.h

index 4dda3c2f408684fb967b4da3e5f2c3ab0fb64fa1..5934b0f998114cbf9628eb7a77033c4852a2ff34 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 - 2014, 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
@@ -1016,5 +1016,26 @@ 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)\r
+  //\r
+  // Intrinsic function provides the address of the instruction in the calling\r
+  // function that will be executed after control returns to the caller.\r
+  //\r
+  #pragma intrinsic(_ReturnAddress)\r
+  #define RETURN_ADDRESS(L)     ((L == 0) ? _ReturnAddress() : (VOID *) 0)\r
+#elif defined(__GNUC__)\r
+  //\r
+  // Built-in Function returns the return address of the current function,\r
+  // or of one of its callers.\r
+  //\r
+  void * __builtin_return_address (unsigned int level);\r
+  #define RETURN_ADDRESS(L)     __builtin_return_address (L)\r
+#else\r
+  //\r
+  // Compilers don't support this feature.\r
+  //\r
+  #define RETURN_ADDRESS(L)     ((VOID *) 0)\r
+#endif\r
+\r
 #endif\r
 \r