[01/15] eal: add macro to mark macros as deprecated

Message ID 20200911190701.29171-2-stephen@networkplumber.org (mailing list archive)
State Superseded, archived
Headers
Series Replace terms master/slave lcore with main/worker lcore |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Stephen Hemminger Sept. 11, 2020, 7:06 p.m. UTC
  Add a macro that causes GCC and CLANG to emit a warning when
a deprecated macro is used.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/librte_eal/include/rte_common.h | 11 +++++++++++
 1 file changed, 11 insertions(+)
  

Comments

Bruce Richardson Sept. 14, 2020, 8:43 a.m. UTC | #1
On Fri, Sep 11, 2020 at 12:06:47PM -0700, Stephen Hemminger wrote:
> Add a macro that causes GCC and CLANG to emit a warning when
> a deprecated macro is used.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  lib/librte_eal/include/rte_common.h | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/lib/librte_eal/include/rte_common.h b/lib/librte_eal/include/rte_common.h
> index 8f487a563dfc..1ade136b64e4 100644
> --- a/lib/librte_eal/include/rte_common.h
> +++ b/lib/librte_eal/include/rte_common.h
> @@ -86,6 +86,17 @@ typedef uint16_t unaligned_uint16_t;
>  /******* Macro to mark functions and fields scheduled for removal *****/
>  #define __rte_deprecated	__attribute__((__deprecated__))
>  
> +/**
> + *  Macro to mark macros and defines scheduled for removal
> + */
> +#if defined(RTE_CC_GCC) || defined(RTE_CC_CLANG)
> +#define RTE_PRAGMA(x)  _Pragma(#x)
> +#define RTE_PRAGMA_WARNING(w) RTE_PRAGMA(GCC warning #w)
> +#define RTE_DEPRECATED(o, n)  RTE_PRAGMA_WARNING(#o is deprecated use #n)
> +#else
> +#define RTE_DEPRECATED(o, n)
> +#endif
> +
>  /**
>   * Mark a function or variable to a weak reference.
>   */

Great to see this, as this is something I was looking for myself recently
too!

Acked-by: Bruce Richardson <bruce.richardson@intel.com>
  

Patch

diff --git a/lib/librte_eal/include/rte_common.h b/lib/librte_eal/include/rte_common.h
index 8f487a563dfc..1ade136b64e4 100644
--- a/lib/librte_eal/include/rte_common.h
+++ b/lib/librte_eal/include/rte_common.h
@@ -86,6 +86,17 @@  typedef uint16_t unaligned_uint16_t;
 /******* Macro to mark functions and fields scheduled for removal *****/
 #define __rte_deprecated	__attribute__((__deprecated__))
 
+/**
+ *  Macro to mark macros and defines scheduled for removal
+ */
+#if defined(RTE_CC_GCC) || defined(RTE_CC_CLANG)
+#define RTE_PRAGMA(x)  _Pragma(#x)
+#define RTE_PRAGMA_WARNING(w) RTE_PRAGMA(GCC warning #w)
+#define RTE_DEPRECATED(o, n)  RTE_PRAGMA_WARNING(#o is deprecated use #n)
+#else
+#define RTE_DEPRECATED(o, n)
+#endif
+
 /**
  * Mark a function or variable to a weak reference.
  */