Message ID | 1425400717-24322-1-git-send-email-bruce.richardson@intel.com (mailing list archive) |
---|---|
State | Changes Requested, archived |
Headers |
Return-Path: <dev-bounces@dpdk.org> X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 1D61C5FEB; Tue, 3 Mar 2015 17:38:44 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id D8A0B5AA0 for <dev@dpdk.org>; Tue, 3 Mar 2015 17:38:41 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP; 03 Mar 2015 08:33:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,682,1418112000"; d="scan'208";a="686242321" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga002.fm.intel.com with ESMTP; 03 Mar 2015 08:38:38 -0800 Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com [10.237.217.45]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id t23GcbML025441; Tue, 3 Mar 2015 16:38:38 GMT Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id t23Gcbsq024358; Tue, 3 Mar 2015 16:38:37 GMT Received: (from bricha3@localhost) by sivswdev01.ir.intel.com with id t23Gcbm7024354; Tue, 3 Mar 2015 16:38:37 GMT From: Bruce Richardson <bruce.richardson@intel.com> To: dev@dpdk.org Date: Tue, 3 Mar 2015 16:38:37 +0000 Message-Id: <1425400717-24322-1-git-send-email-bruce.richardson@intel.com> X-Mailer: git-send-email 1.7.4.1 Subject: [dpdk-dev] [PATCH] ring: cleanup file-local macros at end-of-file X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK <dev.dpdk.org> List-Unsubscribe: <http://dpdk.org/ml/options/dev>, <mailto:dev-request@dpdk.org?subject=unsubscribe> List-Archive: <http://dpdk.org/ml/archives/dev/> List-Post: <mailto:dev@dpdk.org> List-Help: <mailto:dev-request@dpdk.org?subject=help> List-Subscribe: <http://dpdk.org/ml/listinfo/dev>, <mailto:dev-request@dpdk.org?subject=subscribe> Errors-To: dev-bounces@dpdk.org Sender: "dev" <dev-bounces@dpdk.org> |
Commit Message
Bruce Richardson
March 3, 2015, 4:38 p.m. UTC
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@intel.com>
---
lib/librte_ring/rte_ring.h | 4 ++++
1 file changed, 4 insertions(+)
Comments
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@intel.com> > --- > 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.
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@intel.com> > > --- > > 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
> -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Bruce Richardson > Sent: Wednesday, March 04, 2015 10:23 AM > To: Thomas Monjalon > Cc: dev@dpdk.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@intel.com> > > > --- > > > 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
On Wed, Mar 04, 2015 at 10:26:24AM +0000, Ananyev, Konstantin wrote: > > > > -----Original Message----- > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Bruce Richardson > > Sent: Wednesday, March 04, 2015 10:23 AM > > To: Thomas Monjalon > > Cc: dev@dpdk.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@intel.com> > > > > --- > > > > 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
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