summaryrefslogtreecommitdiff
path: root/MdePkg
diff options
context:
space:
mode:
authorStar Zeng <star.zeng@intel.com>2014-11-12 03:18:09 +0000
committerlzeng14 <lzeng14@Edk2>2014-11-12 03:18:09 +0000
commitdad83a8c1207e585b2cb417d0680fe2e9452d262 (patch)
tree377dddadd2c41fdc7449c487f91f9deafe05e814 /MdePkg
parent1531a469ebc1e0130af04aa10c533b497fc3198a (diff)
downloadedk2-platforms-dad83a8c1207e585b2cb417d0680fe2e9452d262.tar.xz
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 <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
Diffstat (limited to 'MdePkg')
-rw-r--r--MdePkg/Include/Base.h23
1 files changed, 22 insertions, 1 deletions
diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h
index 4dda3c2f40..5934b0f998 100644
--- a/MdePkg/Include/Base.h
+++ b/MdePkg/Include/Base.h
@@ -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 @@ typedef UINTN RETURN_STATUS;
#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