Skip to contentSkip to conversation

ring: cleanup file-local macros at end-of-file

PATCH In review Bruce Richardson 3 participants 5 messages Mar 3, 2015 – Mar 4, 2015 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ring: cleanup file-local macros at end-of-file

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.

---
 lib/librte_ring/rte_ring.h | 4 ++++
 1 file changed, 4 insertions(+)
lib/librte_ring/rte_ring.h +4 -0
index bdf69b7..0d35648 100644
@@ -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
Signature · 1 line
2.1.0

A message that is not in the archive (sent off-list or not yet received): 1425400717-24322-1-git-send-email-bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

#2 lore raw

2015-03-03 16:38, Bruce Richardson:

Quoted 15 lines

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.

---
 lib/librte_ring/rte_ring.h | 4 ++++
 1 file changed, 4 insertions(+)
lib/librte_ring/rte_ring.h +0 -0
index bdf69b7..0d35648 100644

lib/librte_ring/rte_ring.h rte_ring_dequeue_burst(struct rte_ring *r, void **obj_table, unsigned n) · line 1238

Quoted 7 lines
lib/librte_ring/rte_ring.h +4 -0
@@ -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.

#3 lore raw
Quoted 19 lines · Thomas Monjalon

2015-03-03 16:38, Bruce Richardson:

Quoted 18 lines

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.

---
 lib/librte_ring/rte_ring.h | 4 ++++
 1 file changed, 4 insertions(+)
lib/librte_ring/rte_ring.h +0 -0
index bdf69b7..0d35648 100644
@@ -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);
 }
 
Quoted 10 lines

lib/librte_ring/rte_ring.h rte_ring_dequeue_burst(struct rte_ring *r, void **obj_table, unsigned n) · line 1238

Quoted 4 lines
lib/librte_ring/rte_ring.h +4 -0
+/* 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

#4 lore raw
Quoted 39 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Bruce Richardson
Sent: Wednesday, March 04, 2015 10:23 AM
To: Thomas Monjalon
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH] ring: cleanup file-local macros at end-of-file

Quoted 19 lines · Thomas Monjalon

2015-03-03 16:38, Bruce Richardson:

Quoted 18 lines

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.

---
 lib/librte_ring/rte_ring.h | 4 ++++
 1 file changed, 4 insertions(+)
lib/librte_ring/rte_ring.h +0 -0
index bdf69b7..0d35648 100644
@@ -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);
 }
 
Quoted 10 lines

lib/librte_ring/rte_ring.h rte_ring_dequeue_burst(struct rte_ring *r, void **obj_table, unsigned n) · line 1238

Quoted 4 lines
lib/librte_ring/rte_ring.h +4 -0
+/* 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.

Quoted 7 lines

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

Quoted 2 lines

/Bruce

A message that is not in the archive (sent off-list or not yet received): 2601191342CEEE43887BDE71AB977258213F3C63-pww93C2UFcwu0RiL9chJVbfspsVTdybXVpNB7YpNyf8@public.gmane.org

#6 lore raw
Quoted 47 lines · Konstantin
Quoted 39 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Bruce Richardson
Sent: Wednesday, March 04, 2015 10:23 AM
To: Thomas Monjalon
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH] ring: cleanup file-local macros at end-of-file

Quoted 19 lines · Thomas Monjalon

2015-03-03 16:38, Bruce Richardson:

Quoted 18 lines

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.

---
 lib/librte_ring/rte_ring.h | 4 ++++
 1 file changed, 4 insertions(+)
lib/librte_ring/rte_ring.h +0 -0
index bdf69b7..0d35648 100644
@@ -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);
 }
 
Quoted 10 lines

lib/librte_ring/rte_ring.h rte_ring_dequeue_burst(struct rte_ring *r, void **obj_table, unsigned n) · line 1238

Quoted 4 lines
lib/librte_ring/rte_ring.h +4 -0
+/* 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.

Quoted 7 lines

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.

Quoted 3 lines

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