]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdePkg: add RETURNS_TWICE attribute
authorM1cha <sigmaepsilon92@gmail.com>
Wed, 27 Dec 2017 19:28:49 +0000 (03:28 +0800)
committerLiming Gao <liming.gao@intel.com>
Wed, 10 Jan 2018 03:42:16 +0000 (11:42 +0800)
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael Zimmermann <sigmaepsilon92@gmail.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
MdePkg/Include/Base.h

index 4fd5161f507cb5290e68d2fb9400a8356b96c80c..29db8a253e2f67d701308c3e98b0c065696f6d66 100644 (file)
@@ -218,6 +218,26 @@ VERIFY_SIZE_OF (__VERIFY_UINT32_ENUM_SIZE, 4);
   #endif\r
 #endif\r
 \r
+///\r
+/// Tell the code optimizer that the function will return twice.\r
+/// This prevents wrong optimizations which can cause bugs.\r
+///\r
+#ifndef RETURNS_TWICE\r
+  #if defined (__GNUC__) || defined (__clang__)\r
+    ///\r
+    /// Tell the code optimizer that the function will return twice.\r
+    /// This prevents wrong optimizations which can cause bugs.\r
+    ///\r
+    #define RETURNS_TWICE  __attribute__((returns_twice))\r
+  #else\r
+    ///\r
+    /// Tell the code optimizer that the function will return twice.\r
+    /// This prevents wrong optimizations which can cause bugs.\r
+    ///\r
+    #define RETURNS_TWICE\r
+  #endif\r
+#endif\r
+\r
 //\r
 // For symbol name in assembly code, an extra "_" is sometimes necessary\r
 //\r