diff options
author | M1cha <sigmaepsilon92@gmail.com> | 2017-12-28 03:28:49 +0800 |
---|---|---|
committer | Liming Gao <liming.gao@intel.com> | 2018-01-10 11:42:16 +0800 |
commit | 2d94c38ba5e0318f9ac42c15150e6748d84587ec (patch) | |
tree | 85e5bd07c505123695a10d0110db488a4edb32f6 /MdePkg | |
parent | c7c5a6c4f7f58cff4329fa69426cd2aef724c026 (diff) | |
download | edk2-2d94c38ba5e0318f9ac42c15150e6748d84587ec.tar.gz edk2-2d94c38ba5e0318f9ac42c15150e6748d84587ec.tar.bz2 edk2-2d94c38ba5e0318f9ac42c15150e6748d84587ec.zip |
MdePkg: add RETURNS_TWICE attribute
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael Zimmermann <sigmaepsilon92@gmail.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Diffstat (limited to 'MdePkg')
-rw-r--r-- | MdePkg/Include/Base.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h index 4fd5161f50..29db8a253e 100644 --- a/MdePkg/Include/Base.h +++ b/MdePkg/Include/Base.h @@ -218,6 +218,26 @@ VERIFY_SIZE_OF (__VERIFY_UINT32_ENUM_SIZE, 4); #endif
#endif
+///
+/// Tell the code optimizer that the function will return twice.
+/// This prevents wrong optimizations which can cause bugs.
+///
+#ifndef RETURNS_TWICE
+ #if defined (__GNUC__) || defined (__clang__)
+ ///
+ /// Tell the code optimizer that the function will return twice.
+ /// This prevents wrong optimizations which can cause bugs.
+ ///
+ #define RETURNS_TWICE __attribute__((returns_twice))
+ #else
+ ///
+ /// Tell the code optimizer that the function will return twice.
+ /// This prevents wrong optimizations which can cause bugs.
+ ///
+ #define RETURNS_TWICE
+ #endif
+#endif
+
//
// For symbol name in assembly code, an extra "_" is sometimes necessary
//
|