[v4,25/27] eal: mark old naming as deprecated
diff mbox series

Message ID 20200701202359.17006-26-stephen@networkplumber.org
State Superseded
Delegated to: Thomas Monjalon
Headers show
Series
  • Replace references to master and slave
Related show

Checks

Context Check Description
ci/Intel-compilation fail Compilation issues
ci/checkpatch warning coding style issues

Commit Message

Stephen Hemminger July 1, 2020, 8:23 p.m. UTC
Use of old RTE_LCORE_FOREACH_SLAVE and rte_get_master_lcore_id()
are marked as deprecated.

All uses of these in DPDK itself is gone. This will cause warnings
for applications still using them.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/librte_eal/include/rte_launch.h | 4 ++--
 lib/librte_eal/include/rte_lcore.h  | 4 +++-
 2 files changed, 5 insertions(+), 3 deletions(-)

Comments

Burakov, Anatoly July 15, 2020, 1:28 p.m. UTC | #1
On 01-Jul-20 9:23 PM, Stephen Hemminger wrote:
> Use of old RTE_LCORE_FOREACH_SLAVE and rte_get_master_lcore_id()
> are marked as deprecated.
> 
> All uses of these in DPDK itself is gone. This will cause warnings
> for applications still using them.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>   lib/librte_eal/include/rte_launch.h | 4 ++--
>   lib/librte_eal/include/rte_lcore.h  | 4 +++-
>   2 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/librte_eal/include/rte_launch.h b/lib/librte_eal/include/rte_launch.h
> index 9b68685d99d4..8d58ca5302a7 100644
> --- a/lib/librte_eal/include/rte_launch.h
> +++ b/lib/librte_eal/include/rte_launch.h
> @@ -76,8 +76,8 @@ enum rte_rmt_call_initial_t {
>   /**
>    * Deprecated backward compatiable definitions
>    */
> -#define SKIP_MASTER	SKIP_INITIAL
> -#define CALL_MASTER	CALL_INITIAL
> +#define SKIP_MASTER _Pragma("GCC warning \"'SKIP_MASTER' is deprecated\"") SKIP_INITIAL
> +#define CALL_MASTER _Pragma("GCC warning \"'CALL_MASTER' is deprecated\"") CALL_INITIAL

Presumably this is a generic header, should we introduce GCC-specific 
things there?

>   
>   /**
>    * Launch a function on all lcores.
> diff --git a/lib/librte_eal/include/rte_lcore.h b/lib/librte_eal/include/rte_lcore.h
> index 069cb1f427b9..eaa7c0f0b67c 100644
> --- a/lib/librte_eal/include/rte_lcore.h
> +++ b/lib/librte_eal/include/rte_lcore.h
> @@ -67,6 +67,7 @@ unsigned int rte_get_initial_lcore(void);
>    * @return
>    *   the id of the initial lcore
>    */
> +__rte_deprecated
>   unsigned int rte_get_master_lcore(void);
>   
>   /**
> @@ -216,7 +217,8 @@ unsigned int rte_get_next_lcore(unsigned int i, int skip_initial, int wrap);
>   /**
>    * Backward compatibility
>    */
> -#define RTE_LCORE_FOREACH_SLAVE(x)		\
> +#define RTE_LCORE_FOREACH_SLAVE(x)					\
> +	_Pragma("GCC warning \"'RTE_LCORE_FOREACH_SLAVE' macro is deprecated\"") \
>   	RTE_LCORE_FOREACH_WORKER(x)

Same as above.

>   
>   
>
Stephen Hemminger July 15, 2020, 8:29 p.m. UTC | #2
On Wed, 15 Jul 2020 14:28:17 +0100
"Burakov, Anatoly" <anatoly.burakov@intel.com> wrote:

> > -#define SKIP_MASTER	SKIP_INITIAL
> > -#define CALL_MASTER	CALL_INITIAL
> > +#define SKIP_MASTER _Pragma("GCC warning \"'SKIP_MASTER' is deprecated\"") SKIP_INITIAL
> > +#define CALL_MASTER _Pragma("GCC warning \"'CALL_MASTER' is deprecated\"") CALL_INITIAL  
> 
> Presumably this is a generic header, should we introduce GCC-specific 
> things there?

It works with Clang as well. Likely ICC but don't have that.
Burakov, Anatoly July 16, 2020, 1:41 p.m. UTC | #3
On 15-Jul-20 9:29 PM, Stephen Hemminger wrote:
> On Wed, 15 Jul 2020 14:28:17 +0100
> "Burakov, Anatoly" <anatoly.burakov@intel.com> wrote:
> 
>>> -#define SKIP_MASTER	SKIP_INITIAL
>>> -#define CALL_MASTER	CALL_INITIAL
>>> +#define SKIP_MASTER _Pragma("GCC warning \"'SKIP_MASTER' is deprecated\"") SKIP_INITIAL
>>> +#define CALL_MASTER _Pragma("GCC warning \"'CALL_MASTER' is deprecated\"") CALL_INITIAL
>>
>> Presumably this is a generic header, should we introduce GCC-specific
>> things there?
> 
> It works with Clang as well. Likely ICC but don't have that.
> 

What about MSVC?
Stephen Hemminger July 16, 2020, 10:04 p.m. UTC | #4
On Thu, 16 Jul 2020 14:41:41 +0100
"Burakov, Anatoly" <anatoly.burakov@intel.com> wrote:

> On 15-Jul-20 9:29 PM, Stephen Hemminger wrote:
> > On Wed, 15 Jul 2020 14:28:17 +0100
> > "Burakov, Anatoly" <anatoly.burakov@intel.com> wrote:
> >   
> >>> -#define SKIP_MASTER	SKIP_INITIAL
> >>> -#define CALL_MASTER	CALL_INITIAL
> >>> +#define SKIP_MASTER _Pragma("GCC warning \"'SKIP_MASTER' is deprecated\"") SKIP_INITIAL
> >>> +#define CALL_MASTER _Pragma("GCC warning \"'CALL_MASTER' is deprecated\"") CALL_INITIAL  
> >>
> >> Presumably this is a generic header, should we introduce GCC-specific
> >> things there?  
> > 
> > It works with Clang as well. Likely ICC but don't have that.
> >   
> 
> What about MSVC?
> 

_Pragma is C99 standard so MSVC know it.
MSVC should ignore any pragman it doesn't understand.

There is a better pragma for deprecating keywords in MSVC, but GCC and Clang don't
understand it.
Stephen Hemminger July 16, 2020, 10:05 p.m. UTC | #5
On Thu, 16 Jul 2020 14:41:41 +0100
"Burakov, Anatoly" <anatoly.burakov@intel.com> wrote:

> On 15-Jul-20 9:29 PM, Stephen Hemminger wrote:
> > On Wed, 15 Jul 2020 14:28:17 +0100
> > "Burakov, Anatoly" <anatoly.burakov@intel.com> wrote:
> >   
> >>> -#define SKIP_MASTER	SKIP_INITIAL
> >>> -#define CALL_MASTER	CALL_INITIAL
> >>> +#define SKIP_MASTER _Pragma("GCC warning \"'SKIP_MASTER' is deprecated\"") SKIP_INITIAL
> >>> +#define CALL_MASTER _Pragma("GCC warning \"'CALL_MASTER' is deprecated\"") CALL_INITIAL  
> >>
> >> Presumably this is a generic header, should we introduce GCC-specific
> >> things there?  
> > 
> > It works with Clang as well. Likely ICC but don't have that.
> >   
> 
> What about MSVC?
> 



The compiler issues a warning when it finds a pragma that it doesn't recognize, and continues compilation.
Burakov, Anatoly July 17, 2020, 3:21 p.m. UTC | #6
On 16-Jul-20 11:04 PM, Stephen Hemminger wrote:
> On Thu, 16 Jul 2020 14:41:41 +0100
> "Burakov, Anatoly" <anatoly.burakov@intel.com> wrote:
> 
>> On 15-Jul-20 9:29 PM, Stephen Hemminger wrote:
>>> On Wed, 15 Jul 2020 14:28:17 +0100
>>> "Burakov, Anatoly" <anatoly.burakov@intel.com> wrote:
>>>    
>>>>> -#define SKIP_MASTER	SKIP_INITIAL
>>>>> -#define CALL_MASTER	CALL_INITIAL
>>>>> +#define SKIP_MASTER _Pragma("GCC warning \"'SKIP_MASTER' is deprecated\"") SKIP_INITIAL
>>>>> +#define CALL_MASTER _Pragma("GCC warning \"'CALL_MASTER' is deprecated\"") CALL_INITIAL
>>>>
>>>> Presumably this is a generic header, should we introduce GCC-specific
>>>> things there?
>>>
>>> It works with Clang as well. Likely ICC but don't have that.
>>>    
>>
>> What about MSVC?
>>
> 
> _Pragma is C99 standard so MSVC know it.
> MSVC should ignore any pragman it doesn't understand.
> 
> There is a better pragma for deprecating keywords in MSVC, but GCC and Clang don't
> understand it.
> 

Deprecating macros sounds like something we might want to do in the 
future, can't we put some macro into rte_common.h to address this? e.g. 
something like

#ifdef MSVC
#define rte_deprecated_macro _msvc_pragma_whatever()
#else
#define rte_deprecated_macro _Pragma("GCC warning ...")
#endif

and use this macro here?
Dmitry Kozlyuk July 17, 2020, 3:35 p.m. UTC | #7
On Fri, Jul 17, 2020, 18:21 Burakov, Anatoly <anatoly.burakov@intel.com>
wrote:

> On 16-Jul-20 11:04 PM, Stephen Hemminger wrote:
> > On Thu, 16 Jul 2020 14:41:41 +0100
> > "Burakov, Anatoly" <anatoly.burakov@intel.com> wrote:
> >
> >> On 15-Jul-20 9:29 PM, Stephen Hemminger wrote:
> >>> On Wed, 15 Jul 2020 14:28:17 +0100
> >>> "Burakov, Anatoly" <anatoly.burakov@intel.com> wrote:
> >>>
> >>>>> -#define SKIP_MASTER      SKIP_INITIAL
> >>>>> -#define CALL_MASTER      CALL_INITIAL
> >>>>> +#define SKIP_MASTER _Pragma("GCC warning \"'SKIP_MASTER' is
> deprecated\"") SKIP_INITIAL
> >>>>> +#define CALL_MASTER _Pragma("GCC warning \"'CALL_MASTER' is
> deprecated\"") CALL_INITIAL
> >>>>
> >>>> Presumably this is a generic header, should we introduce GCC-specific
> >>>> things there?
> >>>
> >>> It works with Clang as well. Likely ICC but don't have that.
> >>>
> >>
> >> What about MSVC?
>

FYI, DPDK on Windows is compiled with Clang, only linker is from MSVC. And
MinGW uses GCC toolchain. Why care about MSVC here?
Burakov, Anatoly July 17, 2020, 3:43 p.m. UTC | #8
On 17-Jul-20 4:35 PM, Dmitry Kozliuk wrote:
> On Fri, Jul 17, 2020, 18:21 Burakov, Anatoly <anatoly.burakov@intel.com 
> <mailto:anatoly.burakov@intel.com>> wrote:
> 
>     On 16-Jul-20 11:04 PM, Stephen Hemminger wrote:
>      > On Thu, 16 Jul 2020 14:41:41 +0100
>      > "Burakov, Anatoly" <anatoly.burakov@intel.com
>     <mailto:anatoly.burakov@intel.com>> wrote:
>      >
>      >> On 15-Jul-20 9:29 PM, Stephen Hemminger wrote:
>      >>> On Wed, 15 Jul 2020 14:28:17 +0100
>      >>> "Burakov, Anatoly" <anatoly.burakov@intel.com
>     <mailto:anatoly.burakov@intel.com>> wrote:
>      >>>
>      >>>>> -#define SKIP_MASTER      SKIP_INITIAL
>      >>>>> -#define CALL_MASTER      CALL_INITIAL
>      >>>>> +#define SKIP_MASTER _Pragma("GCC warning \"'SKIP_MASTER' is
>     deprecated\"") SKIP_INITIAL
>      >>>>> +#define CALL_MASTER _Pragma("GCC warning \"'CALL_MASTER' is
>     deprecated\"") CALL_INITIAL
>      >>>>
>      >>>> Presumably this is a generic header, should we introduce
>     GCC-specific
>      >>>> things there?
>      >>>
>      >>> It works with Clang as well. Likely ICC but don't have that.
>      >>>
>      >>
>      >> What about MSVC?
> 
> 
> FYI, DPDK on Windows is compiled with Clang, only linker is from MSVC. 
> And MinGW uses GCC toolchain. Why care about MSVC here?

Ah, OK. I'm not too familiar with Windows port, i was assuming it uses MSVC.
Burakov, Anatoly July 17, 2020, 3:44 p.m. UTC | #9
On 17-Jul-20 4:43 PM, Burakov, Anatoly wrote:
> On 17-Jul-20 4:35 PM, Dmitry Kozliuk wrote:
>> On Fri, Jul 17, 2020, 18:21 Burakov, Anatoly 
>> <anatoly.burakov@intel.com <mailto:anatoly.burakov@intel.com>> wrote:
>>
>>     On 16-Jul-20 11:04 PM, Stephen Hemminger wrote:
>>      > On Thu, 16 Jul 2020 14:41:41 +0100
>>      > "Burakov, Anatoly" <anatoly.burakov@intel.com
>>     <mailto:anatoly.burakov@intel.com>> wrote:
>>      >
>>      >> On 15-Jul-20 9:29 PM, Stephen Hemminger wrote:
>>      >>> On Wed, 15 Jul 2020 14:28:17 +0100
>>      >>> "Burakov, Anatoly" <anatoly.burakov@intel.com
>>     <mailto:anatoly.burakov@intel.com>> wrote:
>>      >>>
>>      >>>>> -#define SKIP_MASTER      SKIP_INITIAL
>>      >>>>> -#define CALL_MASTER      CALL_INITIAL
>>      >>>>> +#define SKIP_MASTER _Pragma("GCC warning \"'SKIP_MASTER' is
>>     deprecated\"") SKIP_INITIAL
>>      >>>>> +#define CALL_MASTER _Pragma("GCC warning \"'CALL_MASTER' is
>>     deprecated\"") CALL_INITIAL
>>      >>>>
>>      >>>> Presumably this is a generic header, should we introduce
>>     GCC-specific
>>      >>>> things there?
>>      >>>
>>      >>> It works with Clang as well. Likely ICC but don't have that.
>>      >>>
>>      >>
>>      >> What about MSVC?
>>
>>
>> FYI, DPDK on Windows is compiled with Clang, only linker is from MSVC. 
>> And MinGW uses GCC toolchain. Why care about MSVC here?
> 
> Ah, OK. I'm not too familiar with Windows port, i was assuming it uses 
> MSVC.
> 

Nevertheless, i would prefer having a macro for these kinds of cases, 
however rare they are.
Stephen Hemminger July 18, 2020, 2:22 a.m. UTC | #10
On Fri, 17 Jul 2020 16:21:37 +0100
"Burakov, Anatoly" <anatoly.burakov@intel.com> wrote:

> On 16-Jul-20 11:04 PM, Stephen Hemminger wrote:
> > On Thu, 16 Jul 2020 14:41:41 +0100
> > "Burakov, Anatoly" <anatoly.burakov@intel.com> wrote:
> >   
> >> On 15-Jul-20 9:29 PM, Stephen Hemminger wrote:  
> >>> On Wed, 15 Jul 2020 14:28:17 +0100
> >>> "Burakov, Anatoly" <anatoly.burakov@intel.com> wrote:
> >>>      
> >>>>> -#define SKIP_MASTER	SKIP_INITIAL
> >>>>> -#define CALL_MASTER	CALL_INITIAL
> >>>>> +#define SKIP_MASTER _Pragma("GCC warning \"'SKIP_MASTER' is deprecated\"") SKIP_INITIAL
> >>>>> +#define CALL_MASTER _Pragma("GCC warning \"'CALL_MASTER' is deprecated\"") CALL_INITIAL  
> >>>>
> >>>> Presumably this is a generic header, should we introduce GCC-specific
> >>>> things there?  
> >>>
> >>> It works with Clang as well. Likely ICC but don't have that.
> >>>      
> >>
> >> What about MSVC?
> >>  
> > 
> > _Pragma is C99 standard so MSVC know it.
> > MSVC should ignore any pragman it doesn't understand.
> > 
> > There is a better pragma for deprecating keywords in MSVC, but GCC and Clang don't
> > understand it.
> >   
> 
> Deprecating macros sounds like something we might want to do in the 
> future, can't we put some macro into rte_common.h to address this? e.g. 
> something like
> 
> #ifdef MSVC
> #define rte_deprecated_macro _msvc_pragma_whatever()
> #else
> #define rte_deprecated_macro _Pragma("GCC warning ...")
> #endif
> 
> and use this macro here?

It gets hard to do macro in a macro,
Burakov, Anatoly July 20, 2020, 12:32 p.m. UTC | #11
On 18-Jul-20 3:22 AM, Stephen Hemminger wrote:
> On Fri, 17 Jul 2020 16:21:37 +0100
> "Burakov, Anatoly" <anatoly.burakov@intel.com> wrote:
> 
>> On 16-Jul-20 11:04 PM, Stephen Hemminger wrote:
>>> On Thu, 16 Jul 2020 14:41:41 +0100
>>> "Burakov, Anatoly" <anatoly.burakov@intel.com> wrote:
>>>    
>>>> On 15-Jul-20 9:29 PM, Stephen Hemminger wrote:
>>>>> On Wed, 15 Jul 2020 14:28:17 +0100
>>>>> "Burakov, Anatoly" <anatoly.burakov@intel.com> wrote:
>>>>>       
>>>>>>> -#define SKIP_MASTER	SKIP_INITIAL
>>>>>>> -#define CALL_MASTER	CALL_INITIAL
>>>>>>> +#define SKIP_MASTER _Pragma("GCC warning \"'SKIP_MASTER' is deprecated\"") SKIP_INITIAL
>>>>>>> +#define CALL_MASTER _Pragma("GCC warning \"'CALL_MASTER' is deprecated\"") CALL_INITIAL
>>>>>>
>>>>>> Presumably this is a generic header, should we introduce GCC-specific
>>>>>> things there?
>>>>>
>>>>> It works with Clang as well. Likely ICC but don't have that.
>>>>>       
>>>>
>>>> What about MSVC?
>>>>   
>>>
>>> _Pragma is C99 standard so MSVC know it.
>>> MSVC should ignore any pragman it doesn't understand.
>>>
>>> There is a better pragma for deprecating keywords in MSVC, but GCC and Clang don't
>>> understand it.
>>>    
>>
>> Deprecating macros sounds like something we might want to do in the
>> future, can't we put some macro into rte_common.h to address this? e.g.
>> something like
>>
>> #ifdef MSVC
>> #define rte_deprecated_macro _msvc_pragma_whatever()
>> #else
>> #define rte_deprecated_macro _Pragma("GCC warning ...")
>> #endif
>>
>> and use this macro here?
> 
> It gets hard to do macro in a macro,
> 

I don't have a strong opinion on this, but IMO it's certainly better 
than having a compiler-specific things in an API header file :)
Stephen Hemminger July 20, 2020, 6:51 p.m. UTC | #12
On Mon, 20 Jul 2020 13:32:27 +0100
"Burakov, Anatoly" <anatoly.burakov@intel.com> wrote:

> On 18-Jul-20 3:22 AM, Stephen Hemminger wrote:
> > On Fri, 17 Jul 2020 16:21:37 +0100
> > "Burakov, Anatoly" <anatoly.burakov@intel.com> wrote:
> >   
> >> On 16-Jul-20 11:04 PM, Stephen Hemminger wrote:  
> >>> On Thu, 16 Jul 2020 14:41:41 +0100
> >>> "Burakov, Anatoly" <anatoly.burakov@intel.com> wrote:
> >>>      
> >>>> On 15-Jul-20 9:29 PM, Stephen Hemminger wrote:  
> >>>>> On Wed, 15 Jul 2020 14:28:17 +0100
> >>>>> "Burakov, Anatoly" <anatoly.burakov@intel.com> wrote:
> >>>>>         
> >>>>>>> -#define SKIP_MASTER	SKIP_INITIAL
> >>>>>>> -#define CALL_MASTER	CALL_INITIAL
> >>>>>>> +#define SKIP_MASTER _Pragma("GCC warning \"'SKIP_MASTER' is deprecated\"") SKIP_INITIAL
> >>>>>>> +#define CALL_MASTER _Pragma("GCC warning \"'CALL_MASTER' is deprecated\"") CALL_INITIAL  
> >>>>>>
> >>>>>> Presumably this is a generic header, should we introduce GCC-specific
> >>>>>> things there?  
> >>>>>
> >>>>> It works with Clang as well. Likely ICC but don't have that.
> >>>>>         
> >>>>
> >>>> What about MSVC?
> >>>>     
> >>>
> >>> _Pragma is C99 standard so MSVC know it.
> >>> MSVC should ignore any pragman it doesn't understand.
> >>>
> >>> There is a better pragma for deprecating keywords in MSVC, but GCC and Clang don't
> >>> understand it.
> >>>      
> >>
> >> Deprecating macros sounds like something we might want to do in the
> >> future, can't we put some macro into rte_common.h to address this? e.g.
> >> something like
> >>
> >> #ifdef MSVC
> >> #define rte_deprecated_macro _msvc_pragma_whatever()
> >> #else
> >> #define rte_deprecated_macro _Pragma("GCC warning ...")
> >> #endif
> >>
> >> and use this macro here?  
> > 
> > It gets hard to do macro in a macro,
> >   
> 
> I don't have a strong opinion on this, but IMO it's certainly better 
> than having a compiler-specific things in an API header file :)
> 

I was hoping for macro volunteer?

Something like:
#define RTE_DEPRECATED(foo) ...
Burakov, Anatoly July 22, 2020, 9:05 a.m. UTC | #13
On 20-Jul-20 7:51 PM, Stephen Hemminger wrote:
> On Mon, 20 Jul 2020 13:32:27 +0100
> "Burakov, Anatoly" <anatoly.burakov@intel.com> wrote:
> 
>> On 18-Jul-20 3:22 AM, Stephen Hemminger wrote:
>>> On Fri, 17 Jul 2020 16:21:37 +0100
>>> "Burakov, Anatoly" <anatoly.burakov@intel.com> wrote:
>>>    
>>>> On 16-Jul-20 11:04 PM, Stephen Hemminger wrote:
>>>>> On Thu, 16 Jul 2020 14:41:41 +0100
>>>>> "Burakov, Anatoly" <anatoly.burakov@intel.com> wrote:
>>>>>       
>>>>>> On 15-Jul-20 9:29 PM, Stephen Hemminger wrote:
>>>>>>> On Wed, 15 Jul 2020 14:28:17 +0100
>>>>>>> "Burakov, Anatoly" <anatoly.burakov@intel.com> wrote:
>>>>>>>          
>>>>>>>>> -#define SKIP_MASTER	SKIP_INITIAL
>>>>>>>>> -#define CALL_MASTER	CALL_INITIAL
>>>>>>>>> +#define SKIP_MASTER _Pragma("GCC warning \"'SKIP_MASTER' is deprecated\"") SKIP_INITIAL
>>>>>>>>> +#define CALL_MASTER _Pragma("GCC warning \"'CALL_MASTER' is deprecated\"") CALL_INITIAL
>>>>>>>>
>>>>>>>> Presumably this is a generic header, should we introduce GCC-specific
>>>>>>>> things there?
>>>>>>>
>>>>>>> It works with Clang as well. Likely ICC but don't have that.
>>>>>>>          
>>>>>>
>>>>>> What about MSVC?
>>>>>>      
>>>>>
>>>>> _Pragma is C99 standard so MSVC know it.
>>>>> MSVC should ignore any pragman it doesn't understand.
>>>>>
>>>>> There is a better pragma for deprecating keywords in MSVC, but GCC and Clang don't
>>>>> understand it.
>>>>>       
>>>>
>>>> Deprecating macros sounds like something we might want to do in the
>>>> future, can't we put some macro into rte_common.h to address this? e.g.
>>>> something like
>>>>
>>>> #ifdef MSVC
>>>> #define rte_deprecated_macro _msvc_pragma_whatever()
>>>> #else
>>>> #define rte_deprecated_macro _Pragma("GCC warning ...")
>>>> #endif
>>>>
>>>> and use this macro here?
>>>
>>> It gets hard to do macro in a macro,
>>>    
>>
>> I don't have a strong opinion on this, but IMO it's certainly better
>> than having a compiler-specific things in an API header file :)
>>
> 
> I was hoping for macro volunteer?
> 
> Something like:
> #define RTE_DEPRECATED(foo) ...
> 

Oh, sure, apologies for not picking up on that :D

A bit on the ugly side, but should work:

#define __rte_deprecated_macro(val) (_Pragma("GCC warning \"'" #val "'\" 
is deprecated\"") (val))

To be used as:

#define NEW __rte_deprecated_macro(OLD)

(I feel there could be confusion between __rte_deprecated and 
RTE_DEPRECATED, so both for consistency and clarity, i believe 
"__rte_deprecated_macro" would be a better name - however, no strong 
opinion, RTE_DEPRECATED is fine by me as well)
Burakov, Anatoly July 22, 2020, 10:07 a.m. UTC | #14
On 22-Jul-20 10:05 AM, Burakov, Anatoly wrote:
> On 20-Jul-20 7:51 PM, Stephen Hemminger wrote:
>> On Mon, 20 Jul 2020 13:32:27 +0100
>> "Burakov, Anatoly" <anatoly.burakov@intel.com> wrote:
>>
>>> On 18-Jul-20 3:22 AM, Stephen Hemminger wrote:
>>>> On Fri, 17 Jul 2020 16:21:37 +0100
>>>> "Burakov, Anatoly" <anatoly.burakov@intel.com> wrote:
>>>>> On 16-Jul-20 11:04 PM, Stephen Hemminger wrote:
>>>>>> On Thu, 16 Jul 2020 14:41:41 +0100
>>>>>> "Burakov, Anatoly" <anatoly.burakov@intel.com> wrote:
>>>>>>> On 15-Jul-20 9:29 PM, Stephen Hemminger wrote:
>>>>>>>> On Wed, 15 Jul 2020 14:28:17 +0100
>>>>>>>> "Burakov, Anatoly" <anatoly.burakov@intel.com> wrote:
>>>>>>>>>> -#define SKIP_MASTER    SKIP_INITIAL
>>>>>>>>>> -#define CALL_MASTER    CALL_INITIAL
>>>>>>>>>> +#define SKIP_MASTER _Pragma("GCC warning \"'SKIP_MASTER' is 
>>>>>>>>>> deprecated\"") SKIP_INITIAL
>>>>>>>>>> +#define CALL_MASTER _Pragma("GCC warning \"'CALL_MASTER' is 
>>>>>>>>>> deprecated\"") CALL_INITIAL
>>>>>>>>>
>>>>>>>>> Presumably this is a generic header, should we introduce 
>>>>>>>>> GCC-specific
>>>>>>>>> things there?
>>>>>>>>
>>>>>>>> It works with Clang as well. Likely ICC but don't have that.
>>>>>>>
>>>>>>> What about MSVC?
>>>>>>
>>>>>> _Pragma is C99 standard so MSVC know it.
>>>>>> MSVC should ignore any pragman it doesn't understand.
>>>>>>
>>>>>> There is a better pragma for deprecating keywords in MSVC, but GCC 
>>>>>> and Clang don't
>>>>>> understand it.
>>>>>
>>>>> Deprecating macros sounds like something we might want to do in the
>>>>> future, can't we put some macro into rte_common.h to address this? 
>>>>> e.g.
>>>>> something like
>>>>>
>>>>> #ifdef MSVC
>>>>> #define rte_deprecated_macro _msvc_pragma_whatever()
>>>>> #else
>>>>> #define rte_deprecated_macro _Pragma("GCC warning ...")
>>>>> #endif
>>>>>
>>>>> and use this macro here?
>>>>
>>>> It gets hard to do macro in a macro,
>>>
>>> I don't have a strong opinion on this, but IMO it's certainly better
>>> than having a compiler-specific things in an API header file :)
>>>
>>
>> I was hoping for macro volunteer?
>>
>> Something like:
>> #define RTE_DEPRECATED(foo) ...
>>
> 
> Oh, sure, apologies for not picking up on that :D
> 
> A bit on the ugly side, but should work:
> 
> #define __rte_deprecated_macro(val) (_Pragma("GCC warning \"'" #val "'\" 
> is deprecated\"") (val))
> 
> To be used as:
> 
> #define NEW __rte_deprecated_macro(OLD)
> 
> (I feel there could be confusion between __rte_deprecated and 
> RTE_DEPRECATED, so both for consistency and clarity, i believe 
> "__rte_deprecated_macro" would be a better name - however, no strong 
> opinion, RTE_DEPRECATED is fine by me as well)
> 

Sorry, realized that i've done it the other way around :D

Perhaps this one would be better:

#define __rte_deprecated_macro(old) _Pragma("GCC warning \"'" #old "'\" 
is deprecated\"")

...

#define OLD __rte_deprecated_macro(OLD) NEW
Stephen Hemminger July 22, 2020, 1:53 p.m. UTC | #15
On Wed, 22 Jul 2020 10:05:09 +0100
"Burakov, Anatoly" <anatoly.burakov@intel.com> wrote:

> On 20-Jul-20 7:51 PM, Stephen Hemminger wrote:
> > On Mon, 20 Jul 2020 13:32:27 +0100
> > "Burakov, Anatoly" <anatoly.burakov@intel.com> wrote:
> >   
> >> On 18-Jul-20 3:22 AM, Stephen Hemminger wrote:  
> >>> On Fri, 17 Jul 2020 16:21:37 +0100
> >>> "Burakov, Anatoly" <anatoly.burakov@intel.com> wrote:
> >>>      
> >>>> On 16-Jul-20 11:04 PM, Stephen Hemminger wrote:  
> >>>>> On Thu, 16 Jul 2020 14:41:41 +0100
> >>>>> "Burakov, Anatoly" <anatoly.burakov@intel.com> wrote:
> >>>>>         
> >>>>>> On 15-Jul-20 9:29 PM, Stephen Hemminger wrote:  
> >>>>>>> On Wed, 15 Jul 2020 14:28:17 +0100
> >>>>>>> "Burakov, Anatoly" <anatoly.burakov@intel.com> wrote:
> >>>>>>>            
> >>>>>>>>> -#define SKIP_MASTER	SKIP_INITIAL
> >>>>>>>>> -#define CALL_MASTER	CALL_INITIAL
> >>>>>>>>> +#define SKIP_MASTER _Pragma("GCC warning \"'SKIP_MASTER' is deprecated\"") SKIP_INITIAL
> >>>>>>>>> +#define CALL_MASTER _Pragma("GCC warning \"'CALL_MASTER' is deprecated\"") CALL_INITIAL  
> >>>>>>>>
> >>>>>>>> Presumably this is a generic header, should we introduce GCC-specific
> >>>>>>>> things there?  
> >>>>>>>
> >>>>>>> It works with Clang as well. Likely ICC but don't have that.
> >>>>>>>            
> >>>>>>
> >>>>>> What about MSVC?
> >>>>>>        
> >>>>>
> >>>>> _Pragma is C99 standard so MSVC know it.
> >>>>> MSVC should ignore any pragman it doesn't understand.
> >>>>>
> >>>>> There is a better pragma for deprecating keywords in MSVC, but GCC and Clang don't
> >>>>> understand it.
> >>>>>         
> >>>>
> >>>> Deprecating macros sounds like something we might want to do in the
> >>>> future, can't we put some macro into rte_common.h to address this? e.g.
> >>>> something like
> >>>>
> >>>> #ifdef MSVC
> >>>> #define rte_deprecated_macro _msvc_pragma_whatever()
> >>>> #else
> >>>> #define rte_deprecated_macro _Pragma("GCC warning ...")
> >>>> #endif
> >>>>
> >>>> and use this macro here?  
> >>>
> >>> It gets hard to do macro in a macro,
> >>>      
> >>
> >> I don't have a strong opinion on this, but IMO it's certainly better
> >> than having a compiler-specific things in an API header file :)
> >>  
> > 
> > I was hoping for macro volunteer?
> > 
> > Something like:
> > #define RTE_DEPRECATED(foo) ...
> >   
> 
> Oh, sure, apologies for not picking up on that :D
> 
> A bit on the ugly side, but should work:
> 
> #define __rte_deprecated_macro(val) (_Pragma("GCC warning \"'" #val "'\" 
> is deprecated\"") (val))
> 
> To be used as:
> 
> #define NEW __rte_deprecated_macro(OLD)
> 
> (I feel there could be confusion between __rte_deprecated and 
> RTE_DEPRECATED, so both for consistency and clarity, i believe 
> "__rte_deprecated_macro" would be a better name - however, no strong 
> opinion, RTE_DEPRECATED is fine by me as well)
> 

I would prefer to keep to uppercase for macros. Will try it in V2

Patch
diff mbox series

diff --git a/lib/librte_eal/include/rte_launch.h b/lib/librte_eal/include/rte_launch.h
index 9b68685d99d4..8d58ca5302a7 100644
--- a/lib/librte_eal/include/rte_launch.h
+++ b/lib/librte_eal/include/rte_launch.h
@@ -76,8 +76,8 @@  enum rte_rmt_call_initial_t {
 /**
  * Deprecated backward compatiable definitions
  */
-#define SKIP_MASTER	SKIP_INITIAL
-#define CALL_MASTER	CALL_INITIAL
+#define SKIP_MASTER _Pragma("GCC warning \"'SKIP_MASTER' is deprecated\"") SKIP_INITIAL
+#define CALL_MASTER _Pragma("GCC warning \"'CALL_MASTER' is deprecated\"") CALL_INITIAL
 
 /**
  * Launch a function on all lcores.
diff --git a/lib/librte_eal/include/rte_lcore.h b/lib/librte_eal/include/rte_lcore.h
index 069cb1f427b9..eaa7c0f0b67c 100644
--- a/lib/librte_eal/include/rte_lcore.h
+++ b/lib/librte_eal/include/rte_lcore.h
@@ -67,6 +67,7 @@  unsigned int rte_get_initial_lcore(void);
  * @return
  *   the id of the initial lcore
  */
+__rte_deprecated
 unsigned int rte_get_master_lcore(void);
 
 /**
@@ -216,7 +217,8 @@  unsigned int rte_get_next_lcore(unsigned int i, int skip_initial, int wrap);
 /**
  * Backward compatibility
  */
-#define RTE_LCORE_FOREACH_SLAVE(x)		\
+#define RTE_LCORE_FOREACH_SLAVE(x)					\
+	_Pragma("GCC warning \"'RTE_LCORE_FOREACH_SLAVE' macro is deprecated\"") \
 	RTE_LCORE_FOREACH_WORKER(x)