[dpdk-dev] [PATCH v2 1/6] lib/eal: add a common wrapper for restricted pointers

Joyce Kong Joyce.Kong at arm.com
Wed Jul 8 04:46:15 CEST 2020


> -----Original Message-----
> From: David Marchand <david.marchand at redhat.com>
> Sent: Tuesday, July 7, 2020 9:57 PM
> To: Joyce Kong <Joyce.Kong at arm.com>
> Cc: Maxime Coquelin <maxime.coquelin at redhat.com>; jerinj at marvell.com;
> Zhihong Wang <zhihong.wang at intel.com>; Xiaolong Ye
> <xiaolong.ye at intel.com>; Beilei Xing <beilei.xing at intel.com>; Jeff Guo
> <jia.guo at intel.com>; Mcnamara, John <john.mcnamara at intel.com>; Matan
> Azrad <matan at mellanox.com>; Shahaf Shuler <shahafs at mellanox.com>;
> Viacheslav Ovsiienko <viacheslavo at mellanox.com>; Honnappa Nagarahalli
> <Honnappa.Nagarahalli at arm.com>; Phil Yang <Phil.Yang at arm.com>;
> Ruifeng Wang <Ruifeng.Wang at arm.com>; dev <dev at dpdk.org>; nd
> <nd at arm.com>
> Subject: Re: [dpdk-dev] [PATCH v2 1/6] lib/eal: add a common wrapper for
> restricted pointers
> 
> On Mon, Jul 6, 2020 at 9:50 AM Joyce Kong <joyce.kong at arm.com> wrote:
> >
> > The 'restrict' keyword is recognized in C99, while type qulifier
> > '__restrict' compiles ok in C with all language levels. This patch is
> > to add a wrapper defining '__rte_restrict' with 'restrict' and
> > '__restrict' to be supported by all compilers.
> >
> > Signed-off-by: Joyce Kong <joyce.kong at arm.com>
> > ---
> >  lib/librte_eal/include/rte_common.h | 10 ++++++++++
> >  1 file changed, 10 insertions(+)
> >
> > diff --git a/lib/librte_eal/include/rte_common.h
> > b/lib/librte_eal/include/rte_common.h
> > index 0843ce69e..cda32c056 100644
> > --- a/lib/librte_eal/include/rte_common.h
> > +++ b/lib/librte_eal/include/rte_common.h
> > @@ -103,6 +103,16 @@ typedef uint16_t unaligned_uint16_t;
> >   */
> >  #define __rte_unused __attribute__((__unused__))
> >
> > +/**
> > + * Define a wrapper for restricted pointers which can be supported
> > + * by all compilers.
> > + */
> > +#if __STDC_VERSION__ >= 199901
> > +#define __rte_restrict restrict
> > +#else
> > +#define __rte_restrict __restrict
> > +#endif
> > +
> >  /**
> >   * definition to mark a variable or function parameter as used so
> >   * as to avoid a compiler warning
> > --
> > 2.27.0
> >
> 
> This triggers a build error on Centos 7 as reported by the CI.
> I suppose the following would do the trick, though it is untested:
> 
> /**
>  * Define a wrapper for restricted pointers which can be supported
>  * by all compilers.
>  */
> #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L #define
> __rte_restrict __restrict #else #define __rte_restrict restrict #endif
> 

Will add this judgement in next version.

> 
> --
> David Marchand



More information about the dev mailing list