Revision: 16334
          http://sourceforge.net/p/edk2/code/16334
Author:   lzeng14
Date:     2014-11-12 03:18:09 +0000 (Wed, 12 Nov 2014)
Log Message:
-----------
MdePkg: Add RETURN_ADDRESS macro into Base.h.

Based on compiler intrinsic function.
MSVC: _ReturnAddress
GCC: __builtin_return_address

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <[email protected]>
Reviewed-by: Jiewen Yao <[email protected]>

Modified Paths:
--------------
    trunk/edk2/MdePkg/Include/Base.h

Modified: trunk/edk2/MdePkg/Include/Base.h
===================================================================
--- trunk/edk2/MdePkg/Include/Base.h    2014-11-12 01:07:23 UTC (rev 16333)
+++ trunk/edk2/MdePkg/Include/Base.h    2014-11-12 03:18:09 UTC (rev 16334)
@@ -6,7 +6,7 @@
   environment. There are a set of base libraries in the Mde Package that can
   be used to implement base modules.
 
-Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
 Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
@@ -1016,5 +1016,26 @@
 #define SIGNATURE_64(A, B, C, D, E, F, G, H) \
     (SIGNATURE_32 (A, B, C, D) | ((UINT64) (SIGNATURE_32 (E, F, G, H)) << 32))
 
+#if defined(_MSC_EXTENSIONS)
+  //
+  // Intrinsic function provides the address of the instruction in the calling
+  // function that will be executed after control returns to the caller.
+  //
+  #pragma intrinsic(_ReturnAddress)
+  #define RETURN_ADDRESS(L)     ((L == 0) ? _ReturnAddress() : (VOID *) 0)
+#elif defined(__GNUC__)
+  //
+  // Built-in Function returns the return address of the current function,
+  // or of one of its callers.
+  //
+  void * __builtin_return_address (unsigned int level);
+  #define RETURN_ADDRESS(L)     __builtin_return_address (L)
+#else
+  //
+  // Compilers don't support this feature.
+  //
+  #define RETURN_ADDRESS(L)     ((VOID *) 0)
 #endif
 
+#endif
+


------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://pubads.g.doubleclick.net/gampad/clk?id=154624111&iu=/4140/ostg.clktrk
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to