DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 1/2] lib: Fix pointer arithmetic for C++
@ 2015-07-03 12:51 Joongi Kim
  2015-07-03 12:51 ` [dpdk-dev] [PATCH 2/2] eal: Fix compilation on C++ Joongi Kim
  2015-08-17 15:22 ` [dpdk-dev] [PATCH 1/2] lib: Fix pointer arithmetic for C++ Thomas Monjalon
  0 siblings, 2 replies; 8+ messages in thread
From: Joongi Kim @ 2015-07-03 12:51 UTC (permalink / raw)
  To: dev

 * C++ requires explicit conversion of void pointer types to other
   pointer types.

 * This issue was introduced by previous commits 6cf14ce4 and 7755baae8.
   Two subsequent commits 2f935c12 and 7621d6a also have the same issue,
   I did not fix them because they are NOT headers potentially included
   by C++ sources.

Signed-off-by: Joongi Kim <joongi@an.kaist.ac.kr>
---
 lib/librte_malloc/malloc_elem.h  | 4 ++--
 lib/librte_mbuf/rte_mbuf.h       | 2 +-
 lib/librte_mempool/rte_mempool.c | 2 +-
 lib/librte_mempool/rte_mempool.h | 4 ++--
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/lib/librte_malloc/malloc_elem.h b/lib/librte_malloc/malloc_elem.h
index 9790b1a..2b18d06 100644
--- a/lib/librte_malloc/malloc_elem.h
+++ b/lib/librte_malloc/malloc_elem.h
@@ -124,10 +124,10 @@ malloc_elem_from_data(const void *data)
 	if (data == NULL)
 		return NULL;
 
-	struct malloc_elem *elem = RTE_PTR_SUB(data, MALLOC_ELEM_HEADER_LEN);
+	struct malloc_elem *elem = (struct malloc_elem *) RTE_PTR_SUB(data, MALLOC_ELEM_HEADER_LEN);
 	if (!malloc_elem_cookies_ok(elem))
 		return NULL;
-	return elem->state != ELEM_PAD ? elem:  RTE_PTR_SUB(elem, elem->pad);
+	return elem->state != ELEM_PAD ? elem: (struct malloc_elem *) RTE_PTR_SUB(elem, elem->pad);
 }
 
 /*
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 8a2cae1..4fc770b 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -348,7 +348,7 @@ static inline uint16_t rte_pktmbuf_priv_size(struct rte_mempool *mp);
 static inline struct rte_mbuf *
 rte_mbuf_from_indirect(struct rte_mbuf *mi)
 {
-	return RTE_PTR_SUB(mi->buf_addr, sizeof(*mi) + mi->priv_size);
+	return (struct rte_mbuf *) RTE_PTR_SUB(mi->buf_addr, sizeof(*mi) + mi->priv_size);
 }
 
 /**
diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
index 02699a1..e22ddb3 100644
--- a/lib/librte_mempool/rte_mempool.c
+++ b/lib/librte_mempool/rte_mempool.c
@@ -136,7 +136,7 @@ mempool_add_elem(struct rte_mempool *mp, void *obj, uint32_t obj_idx,
 	obj = (char *)obj + mp->header_size;
 
 	/* set mempool ptr in header */
-	hdr = RTE_PTR_SUB(obj, sizeof(*hdr));
+	hdr = (struct rte_mempool_objhdr *) RTE_PTR_SUB(obj, sizeof(*hdr));
 	hdr->mp = mp;
 
 #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h
index 6d4ce9a..7c966a1 100644
--- a/lib/librte_mempool/rte_mempool.h
+++ b/lib/librte_mempool/rte_mempool.h
@@ -262,13 +262,13 @@ struct rte_mempool {
 /* return the header of a mempool object (internal) */
 static inline struct rte_mempool_objhdr *__mempool_get_header(void *obj)
 {
-	return RTE_PTR_SUB(obj, sizeof(struct rte_mempool_objhdr));
+	return (struct rte_mempool_objhdr *) RTE_PTR_SUB(obj, sizeof(struct rte_mempool_objhdr));
 }
 
 /* return the trailer of a mempool object (internal) */
 static inline struct rte_mempool_objtlr *__mempool_get_trailer(void *obj)
 {
-	return RTE_PTR_SUB(obj, sizeof(struct rte_mempool_objtlr));
+	return (struct rte_mempool_objtlr *) RTE_PTR_SUB(obj, sizeof(struct rte_mempool_objtlr));
 }
 
 /**
-- 
1.9.1

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

* [dpdk-dev] [PATCH 2/2] eal: Fix compilation on C++
  2015-07-03 12:51 [dpdk-dev] [PATCH 1/2] lib: Fix pointer arithmetic for C++ Joongi Kim
@ 2015-07-03 12:51 ` Joongi Kim
  2015-08-17 15:29   ` Thomas Monjalon
  2015-11-13  9:35   ` [dpdk-dev] [PATCH 1/2] Revert "eal: fix C++ app build" David Marchand
  2015-08-17 15:22 ` [dpdk-dev] [PATCH 1/2] lib: Fix pointer arithmetic for C++ Thomas Monjalon
  1 sibling, 2 replies; 8+ messages in thread
From: Joongi Kim @ 2015-07-03 12:51 UTC (permalink / raw)
  To: dev

 * Forward declaration of enum in C++ requires explicit underlying
   type definitions.

 * This fixes the issue at:
   http://dpdk.org/ml/archives/dev/2015-April/017065.html

Signed-off-by: Joongi Kim <joongi@an.kaist.ac.kr>
---
 lib/librte_eal/common/include/arch/x86/rte_cpuflags.h |  4 ++--
 lib/librte_eal/common/include/generic/rte_cpuflags.h  | 12 ++++++++++--
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/lib/librte_eal/common/include/arch/x86/rte_cpuflags.h b/lib/librte_eal/common/include/arch/x86/rte_cpuflags.h
index dd56553..df1834c 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_cpuflags.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_cpuflags.h
@@ -45,7 +45,7 @@ extern "C" {
 
 #include "generic/rte_cpuflags.h"
 
-enum rte_cpu_flag_t {
+enum rte_cpu_flag_t __RTE_CPUFLAG_UNDERLYING_TYPE {
 	/* (EAX 01h) ECX features*/
 	RTE_CPUFLAG_SSE3 = 0,               /**< SSE3 */
 	RTE_CPUFLAG_PCLMULQDQ,              /**< PCLMULQDQ */
@@ -150,7 +150,7 @@ enum rte_cpu_flag_t {
 	RTE_CPUFLAG_NUMFLAGS,               /**< This should always be the last! */
 };
 
-enum cpu_register_t {
+enum cpu_register_t __RTE_REGISTER_UNDERLYING_TYPE {
 	RTE_REG_EAX = 0,
 	RTE_REG_EBX,
 	RTE_REG_ECX,
diff --git a/lib/librte_eal/common/include/generic/rte_cpuflags.h b/lib/librte_eal/common/include/generic/rte_cpuflags.h
index 61c4db1..5352cbc 100644
--- a/lib/librte_eal/common/include/generic/rte_cpuflags.h
+++ b/lib/librte_eal/common/include/generic/rte_cpuflags.h
@@ -44,15 +44,23 @@
 #include <errno.h>
 #include <stdint.h>
 
+#ifdef __cplusplus
+#define __RTE_CPUFLAG_UNDERLYING_TYPE  : unsigned int
+#define __RTE_REGISTER_UNDERLYING_TYPE : unsigned int
+#else
+#define __RTE_CPUFLAG_UNDERLYING_TYPE
+#define __RTE_REGISTER_UNDERLYING_TYPE
+#endif
+
 /**
  * Enumeration of all CPU features supported
  */
-enum rte_cpu_flag_t;
+enum rte_cpu_flag_t __RTE_CPUFLAG_UNDERLYING_TYPE;
 
 /**
  * Enumeration of CPU registers
  */
-enum cpu_register_t;
+enum cpu_register_t __RTE_REGISTER_UNDERLYING_TYPE;
 
 typedef uint32_t cpuid_registers_t[4];
 
-- 
1.9.1

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

* Re: [dpdk-dev] [PATCH 1/2] lib: Fix pointer arithmetic for C++
  2015-07-03 12:51 [dpdk-dev] [PATCH 1/2] lib: Fix pointer arithmetic for C++ Joongi Kim
  2015-07-03 12:51 ` [dpdk-dev] [PATCH 2/2] eal: Fix compilation on C++ Joongi Kim
@ 2015-08-17 15:22 ` Thomas Monjalon
  1 sibling, 0 replies; 8+ messages in thread
From: Thomas Monjalon @ 2015-08-17 15:22 UTC (permalink / raw)
  To: Joongi Kim; +Cc: dev

2015-07-03 21:51, Joongi Kim:
>  lib/librte_malloc/malloc_elem.h  | 4 ++--
>  lib/librte_mempool/rte_mempool.c | 2 +-

These files are not part of the API and should not be included.
No need to fix them for C++.

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

* Re: [dpdk-dev] [PATCH 2/2] eal: Fix compilation on C++
  2015-07-03 12:51 ` [dpdk-dev] [PATCH 2/2] eal: Fix compilation on C++ Joongi Kim
@ 2015-08-17 15:29   ` Thomas Monjalon
  2015-08-17 15:50     ` Thomas Monjalon
  2015-11-13  9:35   ` [dpdk-dev] [PATCH 1/2] Revert "eal: fix C++ app build" David Marchand
  1 sibling, 1 reply; 8+ messages in thread
From: Thomas Monjalon @ 2015-08-17 15:29 UTC (permalink / raw)
  To: Joongi Kim; +Cc: dev

2015-07-03 21:51, Joongi Kim:
>  * Forward declaration of enum in C++ requires explicit underlying
>    type definitions.
> 
>  * This fixes the issue at:
>    http://dpdk.org/ml/archives/dev/2015-April/017065.html
> 
> Signed-off-by: Joongi Kim <joongi@an.kaist.ac.kr>

Does the problem appear only with rte_hash_crc.h inclusion?

The reported errors were:

include/generic/rte_cpuflags.h:50:6:
error: use of enum ‘rte_cpu_flag_t’ without previous declaration
 enum rte_cpu_flag_t;

include/generic/rte_cpuflags.h:55:6:
error: use of enum ‘cpu_register_t’ without previous declaration
 enum cpu_register_t;

>  lib/librte_eal/common/include/arch/x86/rte_cpuflags.h |  4 ++--
>  lib/librte_eal/common/include/generic/rte_cpuflags.h  | 12 ++++++++++--

Do we need to update lib/librte_eal/common/include/arch/ppc_64/rte_cpuflags.h
and lib/librte_eal/common/include/arch/tile/rte_cpuflags.h as well?

Thanks

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

* Re: [dpdk-dev] [PATCH 2/2] eal: Fix compilation on C++
  2015-08-17 15:29   ` Thomas Monjalon
@ 2015-08-17 15:50     ` Thomas Monjalon
  0 siblings, 0 replies; 8+ messages in thread
From: Thomas Monjalon @ 2015-08-17 15:50 UTC (permalink / raw)
  To: Joongi Kim; +Cc: dev

2015-08-17 17:29, Thomas Monjalon:
> 2015-07-03 21:51, Joongi Kim:
> >  * Forward declaration of enum in C++ requires explicit underlying
> >    type definitions.
> > 
> >  * This fixes the issue at:
> >    http://dpdk.org/ml/archives/dev/2015-April/017065.html
> > 
> > Signed-off-by: Joongi Kim <joongi@an.kaist.ac.kr>
> 
> Does the problem appear only with rte_hash_crc.h inclusion?
> 
> The reported errors were:
> 
> include/generic/rte_cpuflags.h:50:6:
> error: use of enum ‘rte_cpu_flag_t’ without previous declaration
>  enum rte_cpu_flag_t;
> 
> include/generic/rte_cpuflags.h:55:6:
> error: use of enum ‘cpu_register_t’ without previous declaration
>  enum cpu_register_t;
> 
> >  lib/librte_eal/common/include/arch/x86/rte_cpuflags.h |  4 ++--
> >  lib/librte_eal/common/include/generic/rte_cpuflags.h  | 12 ++++++++++--
> 
> Do we need to update lib/librte_eal/common/include/arch/ppc_64/rte_cpuflags.h
> and lib/librte_eal/common/include/arch/tile/rte_cpuflags.h as well?
> 
> Thanks

Applied with same fixes for ppc and tile, thanks

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

* [dpdk-dev] [PATCH 1/2] Revert "eal: fix C++ app build"
  2015-07-03 12:51 ` [dpdk-dev] [PATCH 2/2] eal: Fix compilation on C++ Joongi Kim
  2015-08-17 15:29   ` Thomas Monjalon
@ 2015-11-13  9:35   ` David Marchand
  2015-11-13  9:35     ` [dpdk-dev] [PATCH 2/2] eal: move empty declarations to doc David Marchand
  1 sibling, 1 reply; 8+ messages in thread
From: David Marchand @ 2015-11-13  9:35 UTC (permalink / raw)
  To: dev

This reverts commit 621389bbbe0860d41538aeac893b6d74e714530c.

Signed-off-by: David Marchand <david.marchand@6wind.com>
---
 lib/librte_eal/common/include/arch/ppc_64/rte_cpuflags.h |  4 ++--
 lib/librte_eal/common/include/arch/tile/rte_cpuflags.h   |  4 ++--
 lib/librte_eal/common/include/arch/x86/rte_cpuflags.h    |  4 ++--
 lib/librte_eal/common/include/generic/rte_cpuflags.h     | 12 ++----------
 4 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/lib/librte_eal/common/include/arch/ppc_64/rte_cpuflags.h b/lib/librte_eal/common/include/arch/ppc_64/rte_cpuflags.h
index f1cfc4f..df45047 100644
--- a/lib/librte_eal/common/include/arch/ppc_64/rte_cpuflags.h
+++ b/lib/librte_eal/common/include/arch/ppc_64/rte_cpuflags.h
@@ -49,7 +49,7 @@ extern "C" {
 #define AT_HWCAP2 26
 
 /* software based registers */
-enum cpu_register_t __RTE_REGISTER_UNDERLYING_TYPE {
+enum cpu_register_t {
 	REG_HWCAP = 0,
 	REG_HWCAP2,
 };
@@ -57,7 +57,7 @@ enum cpu_register_t __RTE_REGISTER_UNDERLYING_TYPE {
 /**
  * Enumeration of all CPU features supported
  */
-enum rte_cpu_flag_t __RTE_CPUFLAG_UNDERLYING_TYPE {
+enum rte_cpu_flag_t {
 	RTE_CPUFLAG_PPC_LE = 0,
 	RTE_CPUFLAG_TRUE_LE,
 	RTE_CPUFLAG_PSERIES_PERFMON_COMPAT,
diff --git a/lib/librte_eal/common/include/arch/tile/rte_cpuflags.h b/lib/librte_eal/common/include/arch/tile/rte_cpuflags.h
index d6696d3..08aa957 100644
--- a/lib/librte_eal/common/include/arch/tile/rte_cpuflags.h
+++ b/lib/librte_eal/common/include/arch/tile/rte_cpuflags.h
@@ -45,14 +45,14 @@ extern "C" {
 #include "generic/rte_cpuflags.h"
 
 /* software based registers */
-enum cpu_register_t __RTE_REGISTER_UNDERLYING_TYPE {
+enum cpu_register_t {
 	REG_DUMMY = 0
 };
 
 /**
  * Enumeration of all CPU features supported
  */
-enum rte_cpu_flag_t __RTE_CPUFLAG_UNDERLYING_TYPE {
+enum rte_cpu_flag_t {
 	RTE_CPUFLAG_NUMFLAGS /**< This should always be the last! */
 };
 
diff --git a/lib/librte_eal/common/include/arch/x86/rte_cpuflags.h b/lib/librte_eal/common/include/arch/x86/rte_cpuflags.h
index df1834c..dd56553 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_cpuflags.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_cpuflags.h
@@ -45,7 +45,7 @@ extern "C" {
 
 #include "generic/rte_cpuflags.h"
 
-enum rte_cpu_flag_t __RTE_CPUFLAG_UNDERLYING_TYPE {
+enum rte_cpu_flag_t {
 	/* (EAX 01h) ECX features*/
 	RTE_CPUFLAG_SSE3 = 0,               /**< SSE3 */
 	RTE_CPUFLAG_PCLMULQDQ,              /**< PCLMULQDQ */
@@ -150,7 +150,7 @@ enum rte_cpu_flag_t __RTE_CPUFLAG_UNDERLYING_TYPE {
 	RTE_CPUFLAG_NUMFLAGS,               /**< This should always be the last! */
 };
 
-enum cpu_register_t __RTE_REGISTER_UNDERLYING_TYPE {
+enum cpu_register_t {
 	RTE_REG_EAX = 0,
 	RTE_REG_EBX,
 	RTE_REG_ECX,
diff --git a/lib/librte_eal/common/include/generic/rte_cpuflags.h b/lib/librte_eal/common/include/generic/rte_cpuflags.h
index 5352cbc..61c4db1 100644
--- a/lib/librte_eal/common/include/generic/rte_cpuflags.h
+++ b/lib/librte_eal/common/include/generic/rte_cpuflags.h
@@ -44,23 +44,15 @@
 #include <errno.h>
 #include <stdint.h>
 
-#ifdef __cplusplus
-#define __RTE_CPUFLAG_UNDERLYING_TYPE  : unsigned int
-#define __RTE_REGISTER_UNDERLYING_TYPE : unsigned int
-#else
-#define __RTE_CPUFLAG_UNDERLYING_TYPE
-#define __RTE_REGISTER_UNDERLYING_TYPE
-#endif
-
 /**
  * Enumeration of all CPU features supported
  */
-enum rte_cpu_flag_t __RTE_CPUFLAG_UNDERLYING_TYPE;
+enum rte_cpu_flag_t;
 
 /**
  * Enumeration of CPU registers
  */
-enum cpu_register_t __RTE_REGISTER_UNDERLYING_TYPE;
+enum cpu_register_t;
 
 typedef uint32_t cpuid_registers_t[4];
 
-- 
1.9.1

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

* [dpdk-dev] [PATCH 2/2] eal: move empty declarations to doc
  2015-11-13  9:35   ` [dpdk-dev] [PATCH 1/2] Revert "eal: fix C++ app build" David Marchand
@ 2015-11-13  9:35     ` David Marchand
  2015-11-23 15:19       ` Thomas Monjalon
  0 siblings, 1 reply; 8+ messages in thread
From: David Marchand @ 2015-11-13  9:35 UTC (permalink / raw)
  To: dev

No need for those forward declarations (which breaks build when asking for
C++11 or adding pedantic flag).

Signed-off-by: David Marchand <david.marchand@6wind.com>
---
 lib/librte_eal/common/include/generic/rte_cpuflags.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lib/librte_eal/common/include/generic/rte_cpuflags.h b/lib/librte_eal/common/include/generic/rte_cpuflags.h
index 61c4db1..5738a2a 100644
--- a/lib/librte_eal/common/include/generic/rte_cpuflags.h
+++ b/lib/librte_eal/common/include/generic/rte_cpuflags.h
@@ -47,12 +47,16 @@
 /**
  * Enumeration of all CPU features supported
  */
+#ifdef __DOXYGEN__
 enum rte_cpu_flag_t;
+#endif
 
 /**
  * Enumeration of CPU registers
  */
+#ifdef __DOXYGEN__
 enum cpu_register_t;
+#endif
 
 typedef uint32_t cpuid_registers_t[4];
 
@@ -100,8 +104,10 @@ rte_cpu_get_features(uint32_t leaf, uint32_t subleaf, cpuid_registers_t out);
  *     0 if flag is not available
  *     -ENOENT if flag is invalid
  */
+#ifdef __DOXYGEN__
 static inline int
 rte_cpu_get_flag_enabled(enum rte_cpu_flag_t feature);
+#endif
 
 /**
  * This function checks that the currently used CPU supports the CPU features
-- 
1.9.1

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

* Re: [dpdk-dev] [PATCH 2/2] eal: move empty declarations to doc
  2015-11-13  9:35     ` [dpdk-dev] [PATCH 2/2] eal: move empty declarations to doc David Marchand
@ 2015-11-23 15:19       ` Thomas Monjalon
  0 siblings, 0 replies; 8+ messages in thread
From: Thomas Monjalon @ 2015-11-23 15:19 UTC (permalink / raw)
  To: David Marchand; +Cc: dev

2015-11-13 10:35, David Marchand:
> No need for those forward declarations (which breaks build when asking for
> C++11 or adding pedantic flag).
> 
> Signed-off-by: David Marchand <david.marchand@6wind.com>

Applied, thanks

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

end of thread, other threads:[~2015-11-23 15:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-03 12:51 [dpdk-dev] [PATCH 1/2] lib: Fix pointer arithmetic for C++ Joongi Kim
2015-07-03 12:51 ` [dpdk-dev] [PATCH 2/2] eal: Fix compilation on C++ Joongi Kim
2015-08-17 15:29   ` Thomas Monjalon
2015-08-17 15:50     ` Thomas Monjalon
2015-11-13  9:35   ` [dpdk-dev] [PATCH 1/2] Revert "eal: fix C++ app build" David Marchand
2015-11-13  9:35     ` [dpdk-dev] [PATCH 2/2] eal: move empty declarations to doc David Marchand
2015-11-23 15:19       ` Thomas Monjalon
2015-08-17 15:22 ` [dpdk-dev] [PATCH 1/2] lib: Fix pointer arithmetic for C++ Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).