All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ring: cleanup file-local macros at end-of-file
@ 2015-03-03 16:38 Bruce Richardson
       [not found] ` <1425400717-24322-1-git-send-email-bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Bruce Richardson @ 2015-03-03 16:38 UTC (permalink / raw)
  To: dev-VfR2kkLFssw

The ENQUEUE_PTRS and DEQUEUE_PTRS macros defined in rte_ring.h are
not meant to be global and are not prefixed with the RTE_ prefix.
Therefore undef the macros at end of file to avoid pollution of the
global namespace, in case ends apps end up wanting to reuse those names.

Signed-off-by: Bruce Richardson <bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
 lib/librte_ring/rte_ring.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/librte_ring/rte_ring.h b/lib/librte_ring/rte_ring.h
index bdf69b7..0d35648 100644
--- a/lib/librte_ring/rte_ring.h
+++ b/lib/librte_ring/rte_ring.h
@@ -1232,6 +1232,10 @@ rte_ring_dequeue_burst(struct rte_ring *r, void **obj_table, unsigned n)
 		return rte_ring_mc_dequeue_burst(r, obj_table, n);
 }
 
+/* undef un-prefixed macros which are local to this file */
+#undef ENQUEUE_PTRS
+#undef DEQUEUE_PTRS
+
 #ifdef __cplusplus
 }
 #endif
-- 
2.1.0

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

* Re: [PATCH] ring: cleanup file-local macros at end-of-file
       [not found] ` <1425400717-24322-1-git-send-email-bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
@ 2015-03-03 21:03   ` Thomas Monjalon
  2015-03-04 10:22     ` Bruce Richardson
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Monjalon @ 2015-03-03 21:03 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev-VfR2kkLFssw

2015-03-03 16:38, Bruce Richardson:
> The ENQUEUE_PTRS and DEQUEUE_PTRS macros defined in rte_ring.h are
> not meant to be global and are not prefixed with the RTE_ prefix.
> Therefore undef the macros at end of file to avoid pollution of the
> global namespace, in case ends apps end up wanting to reuse those names.
> 
> Signed-off-by: Bruce Richardson <bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> ---
>  lib/librte_ring/rte_ring.h | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/lib/librte_ring/rte_ring.h b/lib/librte_ring/rte_ring.h
> index bdf69b7..0d35648 100644
> --- a/lib/librte_ring/rte_ring.h
> +++ b/lib/librte_ring/rte_ring.h
> @@ -1232,6 +1232,10 @@ rte_ring_dequeue_burst(struct rte_ring *r, void **obj_table, unsigned n)
>  		return rte_ring_mc_dequeue_burst(r, obj_table, n);
>  }
>  
> +/* undef un-prefixed macros which are local to this file */
> +#undef ENQUEUE_PTRS
> +#undef DEQUEUE_PTRS
> +

Thanks for trying to clean-up things.
Note that if an application is using this macro name, it will be destroyed
when including rte_ring.h.
Globally, DPDK namespace is awful and I hope we will be able to improve it.

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

* Re: [PATCH] ring: cleanup file-local macros at end-of-file
  2015-03-03 21:03   ` Thomas Monjalon
@ 2015-03-04 10:22     ` Bruce Richardson
  2015-03-04 10:26       ` Ananyev, Konstantin
  0 siblings, 1 reply; 5+ messages in thread
From: Bruce Richardson @ 2015-03-04 10:22 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev-VfR2kkLFssw

On Tue, Mar 03, 2015 at 10:03:45PM +0100, Thomas Monjalon wrote:
> 2015-03-03 16:38, Bruce Richardson:
> > The ENQUEUE_PTRS and DEQUEUE_PTRS macros defined in rte_ring.h are
> > not meant to be global and are not prefixed with the RTE_ prefix.
> > Therefore undef the macros at end of file to avoid pollution of the
> > global namespace, in case ends apps end up wanting to reuse those names.
> > 
> > Signed-off-by: Bruce Richardson <bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> > ---
> >  lib/librte_ring/rte_ring.h | 4 ++++
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/lib/librte_ring/rte_ring.h b/lib/librte_ring/rte_ring.h
> > index bdf69b7..0d35648 100644
> > --- a/lib/librte_ring/rte_ring.h
> > +++ b/lib/librte_ring/rte_ring.h
> > @@ -1232,6 +1232,10 @@ rte_ring_dequeue_burst(struct rte_ring *r, void **obj_table, unsigned n)
> >  		return rte_ring_mc_dequeue_burst(r, obj_table, n);
> >  }
> >  
> > +/* undef un-prefixed macros which are local to this file */
> > +#undef ENQUEUE_PTRS
> > +#undef DEQUEUE_PTRS
> > +
> 
> Thanks for trying to clean-up things.
> Note that if an application is using this macro name, it will be destroyed
> when including rte_ring.h.
> Globally, DPDK namespace is awful and I hope we will be able to improve it.
> 
Only if they are defining such a macro before including rte_ring.h, which I would
expect to be an edge case. Also, in such a case, the compiler/preprocessor will
give an error at the duplicate macro definition stage, and the simple fix is to
reorder the header file inclusion to avoid problems i.e. no changing of dpdk 
required.
I suppose a better fix to go along with this is to RTE-prefix the macros. I'll 
see about doing a V2.

/Bruce

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

* Re: [PATCH] ring: cleanup file-local macros at end-of-file
  2015-03-04 10:22     ` Bruce Richardson
@ 2015-03-04 10:26       ` Ananyev, Konstantin
       [not found]         ` <2601191342CEEE43887BDE71AB977258213F3C63-pww93C2UFcwu0RiL9chJVbfspsVTdybXVpNB7YpNyf8@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Ananyev, Konstantin @ 2015-03-04 10:26 UTC (permalink / raw)
  To: Richardson, Bruce, Thomas Monjalon; +Cc: dev-VfR2kkLFssw



> -----Original Message-----
> From: dev [mailto:dev-bounces-VfR2kkLFssw@public.gmane.org] On Behalf Of Bruce Richardson
> Sent: Wednesday, March 04, 2015 10:23 AM
> To: Thomas Monjalon
> Cc: dev-VfR2kkLFssw@public.gmane.org
> Subject: Re: [dpdk-dev] [PATCH] ring: cleanup file-local macros at end-of-file
> 
> On Tue, Mar 03, 2015 at 10:03:45PM +0100, Thomas Monjalon wrote:
> > 2015-03-03 16:38, Bruce Richardson:
> > > The ENQUEUE_PTRS and DEQUEUE_PTRS macros defined in rte_ring.h are
> > > not meant to be global and are not prefixed with the RTE_ prefix.
> > > Therefore undef the macros at end of file to avoid pollution of the
> > > global namespace, in case ends apps end up wanting to reuse those names.
> > >
> > > Signed-off-by: Bruce Richardson <bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> > > ---
> > >  lib/librte_ring/rte_ring.h | 4 ++++
> > >  1 file changed, 4 insertions(+)
> > >
> > > diff --git a/lib/librte_ring/rte_ring.h b/lib/librte_ring/rte_ring.h
> > > index bdf69b7..0d35648 100644
> > > --- a/lib/librte_ring/rte_ring.h
> > > +++ b/lib/librte_ring/rte_ring.h
> > > @@ -1232,6 +1232,10 @@ rte_ring_dequeue_burst(struct rte_ring *r, void **obj_table, unsigned n)
> > >  		return rte_ring_mc_dequeue_burst(r, obj_table, n);
> > >  }
> > >
> > > +/* undef un-prefixed macros which are local to this file */
> > > +#undef ENQUEUE_PTRS
> > > +#undef DEQUEUE_PTRS
> > > +
> >
> > Thanks for trying to clean-up things.
> > Note that if an application is using this macro name, it will be destroyed
> > when including rte_ring.h.
> > Globally, DPDK namespace is awful and I hope we will be able to improve it.
> >
> Only if they are defining such a macro before including rte_ring.h, which I would
> expect to be an edge case. Also, in such a case, the compiler/preprocessor will
> give an error at the duplicate macro definition stage, and the simple fix is to
> reorder the header file inclusion to avoid problems i.e. no changing of dpdk
> required.
> I suppose a better fix to go along with this is to RTE-prefix the macros. I'll
> see about doing a V2.

Why not just to rename it to __RTE_RING_ENQUEUE_PTRS__ or something,
and put in the comments that it is for internal usage?
Konstantin
> 
> /Bruce

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

* Re: [PATCH] ring: cleanup file-local macros at end-of-file
       [not found]         ` <2601191342CEEE43887BDE71AB977258213F3C63-pww93C2UFcwu0RiL9chJVbfspsVTdybXVpNB7YpNyf8@public.gmane.org>
@ 2015-03-04 10:49           ` Bruce Richardson
  0 siblings, 0 replies; 5+ messages in thread
From: Bruce Richardson @ 2015-03-04 10:49 UTC (permalink / raw)
  To: Ananyev, Konstantin; +Cc: dev-VfR2kkLFssw

On Wed, Mar 04, 2015 at 10:26:24AM +0000, Ananyev, Konstantin wrote:
> 
> 
> > -----Original Message-----
> > From: dev [mailto:dev-bounces-VfR2kkLFssw@public.gmane.org] On Behalf Of Bruce Richardson
> > Sent: Wednesday, March 04, 2015 10:23 AM
> > To: Thomas Monjalon
> > Cc: dev-VfR2kkLFssw@public.gmane.org
> > Subject: Re: [dpdk-dev] [PATCH] ring: cleanup file-local macros at end-of-file
> > 
> > On Tue, Mar 03, 2015 at 10:03:45PM +0100, Thomas Monjalon wrote:
> > > 2015-03-03 16:38, Bruce Richardson:
> > > > The ENQUEUE_PTRS and DEQUEUE_PTRS macros defined in rte_ring.h are
> > > > not meant to be global and are not prefixed with the RTE_ prefix.
> > > > Therefore undef the macros at end of file to avoid pollution of the
> > > > global namespace, in case ends apps end up wanting to reuse those names.
> > > >
> > > > Signed-off-by: Bruce Richardson <bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> > > > ---
> > > >  lib/librte_ring/rte_ring.h | 4 ++++
> > > >  1 file changed, 4 insertions(+)
> > > >
> > > > diff --git a/lib/librte_ring/rte_ring.h b/lib/librte_ring/rte_ring.h
> > > > index bdf69b7..0d35648 100644
> > > > --- a/lib/librte_ring/rte_ring.h
> > > > +++ b/lib/librte_ring/rte_ring.h
> > > > @@ -1232,6 +1232,10 @@ rte_ring_dequeue_burst(struct rte_ring *r, void **obj_table, unsigned n)
> > > >  		return rte_ring_mc_dequeue_burst(r, obj_table, n);
> > > >  }
> > > >
> > > > +/* undef un-prefixed macros which are local to this file */
> > > > +#undef ENQUEUE_PTRS
> > > > +#undef DEQUEUE_PTRS
> > > > +
> > >
> > > Thanks for trying to clean-up things.
> > > Note that if an application is using this macro name, it will be destroyed
> > > when including rte_ring.h.
> > > Globally, DPDK namespace is awful and I hope we will be able to improve it.
> > >
> > Only if they are defining such a macro before including rte_ring.h, which I would
> > expect to be an edge case. Also, in such a case, the compiler/preprocessor will
> > give an error at the duplicate macro definition stage, and the simple fix is to
> > reorder the header file inclusion to avoid problems i.e. no changing of dpdk
> > required.
> > I suppose a better fix to go along with this is to RTE-prefix the macros. I'll
> > see about doing a V2.
> 
> Why not just to rename it to __RTE_RING_ENQUEUE_PTRS__ or something,
> and put in the comments that it is for internal usage?
> Konstantin

Yes, I'm planning on renaming it. But since it's for internal use only, I might
as well undef it at the end of the file too. I think it's good practice.

/Bruce

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

end of thread, other threads:[~2015-03-04 10:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-03 16:38 [PATCH] ring: cleanup file-local macros at end-of-file Bruce Richardson
     [not found] ` <1425400717-24322-1-git-send-email-bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2015-03-03 21:03   ` Thomas Monjalon
2015-03-04 10:22     ` Bruce Richardson
2015-03-04 10:26       ` Ananyev, Konstantin
     [not found]         ` <2601191342CEEE43887BDE71AB977258213F3C63-pww93C2UFcwu0RiL9chJVbfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2015-03-04 10:49           ` Bruce Richardson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.