public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v3 1/3] MdePkg: add RETURNS_TWICE attribute
@ 2017-12-27 19:28 M1cha
  2017-12-27 19:28 ` [PATCH v3 3/3] MdePkg: add NORETURN attribute to LongJump and InternalLongJump M1cha
  0 siblings, 1 reply; 5+ messages in thread
From: M1cha @ 2017-12-27 19:28 UTC (permalink / raw)
  To: edk2-devel; +Cc: Ard Biesheuvel, Michael D Kinney, Liming Gao

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael Zimmermann <sigmaepsilon92@gmail.com>
---
V3: add code comments

 MdePkg/Include/Base.h | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h
index 22ab5d3715fb..8c7345609ed5 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
 //
-- 
2.15.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-01-10  3:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-27 19:28 [PATCH v3 1/3] MdePkg: add RETURNS_TWICE attribute M1cha
2017-12-27 19:28 ` [PATCH v3 3/3] MdePkg: add NORETURN attribute to LongJump and InternalLongJump M1cha
2018-01-08  5:34   ` Gao, Liming
2018-01-08  6:22     ` Michael Zimmermann
2018-01-10  3:45       ` Gao, Liming

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox