Gabe Black has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/45086 )

Change subject: base: Add macros to mark things as deprecated.
......................................................................

base: Add macros to mark things as deprecated.

M5_DEPRECATED(msg) expands to the [[gnu::deprecated(msg)]] attribute on gnu
compatible compilers and marks an entity (function, variable, etc) as
deprecated. The msg parameter should be used to tell the user what they
should do to move away from the deprecated entity.

M5_DEPRECATED_MACRO(macro, x, msg) is used inside an expression-like macro
with body x to mark that macro as deprecated with message msg. For
instance, if there were macros like this:

 #define SUM(a, b) ((a) + (b))
 #define ONE 1

We could mark that as deprecated like so:

 #define SUM(a, b) M5_DEPRECATED_MACRO(SUM, (a) + (b), \
     "The SUM macro is deprecated, use the + operator instead.")
 #define ONE M5_DEPRECATED_MACRO(ONE, 1, "Use the literal 1.")

Note that this macro should not be used for macros which, for instance,
declare variables, since it assumes the body of the macro expands into
an expression and not a statement or statements.

Change-Id: I58f5e834cfeeb23e37a6548433dfe7e4f695a5ec
---
M src/base/compiler.hh
1 file changed, 4 insertions(+), 0 deletions(-)



diff --git a/src/base/compiler.hh b/src/base/compiler.hh
index c003bfa..a5c99da 100644
--- a/src/base/compiler.hh
+++ b/src/base/compiler.hh
@@ -113,6 +113,10 @@
 #  define M5_LIKELY(cond) __builtin_expect(!!(cond), 1)
 #  define M5_UNLIKELY(cond) __builtin_expect(!!(cond), 0)

+#  define M5_DEPRECATED(msg) [[gnu::deprecated(msg)]]
+#  define M5_DEPRECATED_MACRO(macro, x, msg) \
+     ([](){M5_DEPRECATED(msg) int macro{}; return macro;}(), (x))
+
 // Evaluate an expanded parameter pack in order. Multiple arguments can be
 // passed in which be evaluated in order relative to each other as a group.
// The argument(s) must include a parameter pack to expand. This works because

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/45086
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I58f5e834cfeeb23e37a6548433dfe7e4f695a5ec
Gerrit-Change-Number: 45086
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to