* [dpdk-dev] [PATCH v2 01/11] lib: work around braced-groups within expressions
2016-07-05 10:44 ` [dpdk-dev] [PATCH v2 00/11] Fix build errors related to exported headers Adrien Mazarguil
@ 2016-07-05 10:44 ` Adrien Mazarguil
2016-07-05 10:44 ` [dpdk-dev] [PATCH v2 02/11] lib: work around large enum values Adrien Mazarguil
` (13 subsequent siblings)
14 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-07-05 10:44 UTC (permalink / raw)
To: dev
Exported header files used by applications should allow the strictest
compiler flags. Language extensions used in many places must be explicitly
marked or removed to avoid warnings and compilation failures.
This commit prevents the following errors:
error: ISO C forbids braced-groups within expressions
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
lib/librte_eal/common/include/arch/arm/rte_memcpy_32.h | 3 ++-
lib/librte_eal/common/include/arch/ppc_64/rte_memcpy.h | 3 ++-
lib/librte_eal/common/include/arch/x86/rte_memcpy.h | 4 ++--
lib/librte_eal/common/include/arch/x86/rte_vect.h | 6 ++++--
lib/librte_eal/common/include/rte_common.h | 6 ++++--
5 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/lib/librte_eal/common/include/arch/arm/rte_memcpy_32.h b/lib/librte_eal/common/include/arch/arm/rte_memcpy_32.h
index da6c233..9a7b912 100644
--- a/lib/librte_eal/common/include/arch/arm/rte_memcpy_32.h
+++ b/lib/librte_eal/common/include/arch/arm/rte_memcpy_32.h
@@ -148,7 +148,8 @@ rte_mov256(uint8_t *dst, const uint8_t *src)
}
#define rte_memcpy(dst, src, n) \
- ({ (__builtin_constant_p(n)) ? \
+ __extension__ ({ \
+ __builtin_constant_p(n)) ? \
memcpy((dst), (src), (n)) : \
rte_memcpy_func((dst), (src), (n)); })
diff --git a/lib/librte_eal/common/include/arch/ppc_64/rte_memcpy.h b/lib/librte_eal/common/include/arch/ppc_64/rte_memcpy.h
index acf7aac..a71fb13 100644
--- a/lib/librte_eal/common/include/arch/ppc_64/rte_memcpy.h
+++ b/lib/librte_eal/common/include/arch/ppc_64/rte_memcpy.h
@@ -95,7 +95,8 @@ rte_mov256(uint8_t *dst, const uint8_t *src)
}
#define rte_memcpy(dst, src, n) \
- ({ (__builtin_constant_p(n)) ? \
+ __extension__ ({ \
+ __builtin_constant_p(n)) ? \
memcpy((dst), (src), (n)) : \
rte_memcpy_func((dst), (src), (n)); })
diff --git a/lib/librte_eal/common/include/arch/x86/rte_memcpy.h b/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
index 413035e..b3bfc23 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
@@ -594,7 +594,7 @@ rte_mov256(uint8_t *dst, const uint8_t *src)
* - __m128i <xmm0> ~ <xmm8> must be pre-defined
*/
#define MOVEUNALIGNED_LEFT47_IMM(dst, src, len, offset) \
-({ \
+__extension__ ({ \
int tmp; \
while (len >= 128 + 16 - offset) { \
xmm0 = _mm_loadu_si128((const __m128i *)((const uint8_t *)src - offset + 0 * 16)); \
@@ -655,7 +655,7 @@ rte_mov256(uint8_t *dst, const uint8_t *src)
* - __m128i <xmm0> ~ <xmm8> used in MOVEUNALIGNED_LEFT47_IMM must be pre-defined
*/
#define MOVEUNALIGNED_LEFT47(dst, src, len, offset) \
-({ \
+__extension__ ({ \
switch (offset) { \
case 0x01: MOVEUNALIGNED_LEFT47_IMM(dst, src, n, 0x01); break; \
case 0x02: MOVEUNALIGNED_LEFT47_IMM(dst, src, n, 0x02); break; \
diff --git a/lib/librte_eal/common/include/arch/x86/rte_vect.h b/lib/librte_eal/common/include/arch/x86/rte_vect.h
index b698797..2836f2c 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_vect.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_vect.h
@@ -106,7 +106,8 @@ typedef union rte_ymm {
#endif /* __AVX__ */
#ifdef RTE_ARCH_I686
-#define _mm_cvtsi128_si64(a) ({ \
+#define _mm_cvtsi128_si64(a) \
+__extension__ ({ \
rte_xmm_t m; \
m.x = (a); \
(m.u64[0]); \
@@ -117,7 +118,8 @@ typedef union rte_ymm {
* Prior to version 12.1 icc doesn't support _mm_set_epi64x.
*/
#if (defined(__ICC) && __ICC < 1210)
-#define _mm_set_epi64x(a, b) ({ \
+#define _mm_set_epi64x(a, b) \
+__extension__ ({ \
rte_xmm_t m; \
m.u64[0] = b; \
m.u64[1] = a; \
diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h
index 332f2a4..477472b 100644
--- a/lib/librte_eal/common/include/rte_common.h
+++ b/lib/librte_eal/common/include/rte_common.h
@@ -268,7 +268,8 @@ rte_align64pow2(uint64_t v)
/**
* Macro to return the minimum of two numbers
*/
-#define RTE_MIN(a, b) ({ \
+#define RTE_MIN(a, b) \
+ __extension__ ({ \
typeof (a) _a = (a); \
typeof (b) _b = (b); \
_a < _b ? _a : _b; \
@@ -277,7 +278,8 @@ rte_align64pow2(uint64_t v)
/**
* Macro to return the maximum of two numbers
*/
-#define RTE_MAX(a, b) ({ \
+#define RTE_MAX(a, b) \
+ __extension__ ({ \
typeof (a) _a = (a); \
typeof (b) _b = (b); \
_a > _b ? _a : _b; \
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* [dpdk-dev] [PATCH v2 02/11] lib: work around large enum values
2016-07-05 10:44 ` [dpdk-dev] [PATCH v2 00/11] Fix build errors related to exported headers Adrien Mazarguil
2016-07-05 10:44 ` [dpdk-dev] [PATCH v2 01/11] lib: work around braced-groups within expressions Adrien Mazarguil
@ 2016-07-05 10:44 ` Adrien Mazarguil
2016-07-05 10:44 ` [dpdk-dev] [PATCH v2 03/11] lib: use C99 syntax for zero-size arrays Adrien Mazarguil
` (12 subsequent siblings)
14 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-07-05 10:44 UTC (permalink / raw)
To: dev
Exported header files used by applications should allow the strictest
compiler flags. Language extensions used in many places must be explicitly
marked or removed to avoid warnings and compilation failures.
This commit prevents the following errors:
error: ISO C restricts enumerator values to range of `int'
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
lib/librte_eal/common/include/rte_memory.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/librte_eal/common/include/rte_memory.h b/lib/librte_eal/common/include/rte_memory.h
index 0661109..6a2b3f1 100644
--- a/lib/librte_eal/common/include/rte_memory.h
+++ b/lib/librte_eal/common/include/rte_memory.h
@@ -54,6 +54,7 @@ extern "C" {
#include <rte_common.h>
+__extension__
enum rte_page_sizes {
RTE_PGSIZE_4K = 1ULL << 12,
RTE_PGSIZE_64K = 1ULL << 16,
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* [dpdk-dev] [PATCH v2 03/11] lib: use C99 syntax for zero-size arrays
2016-07-05 10:44 ` [dpdk-dev] [PATCH v2 00/11] Fix build errors related to exported headers Adrien Mazarguil
2016-07-05 10:44 ` [dpdk-dev] [PATCH v2 01/11] lib: work around braced-groups within expressions Adrien Mazarguil
2016-07-05 10:44 ` [dpdk-dev] [PATCH v2 02/11] lib: work around large enum values Adrien Mazarguil
@ 2016-07-05 10:44 ` Adrien Mazarguil
2016-07-05 10:44 ` [dpdk-dev] [PATCH v2 04/11] lib: work around nonstandard bit-fields Adrien Mazarguil
` (11 subsequent siblings)
14 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-07-05 10:44 UTC (permalink / raw)
To: dev
Exported header files used by applications should allow the strictest
compiler flags. Language extensions used in many places must be explicitly
marked or removed to avoid warnings and compilation failures.
The extension keyword is used whenever the C99 syntax cannot do it.
This commit prevents the following errors:
error: ISO C forbids zero-size array `[...]'
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
lib/librte_acl/rte_acl.h | 2 +-
lib/librte_cryptodev/rte_cryptodev.h | 2 +-
lib/librte_cryptodev/rte_cryptodev_pmd.h | 2 +-
lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h | 2 +-
lib/librte_hash/rte_fbk_hash.h | 2 +-
lib/librte_ip_frag/rte_ip_frag.h | 2 +-
lib/librte_lpm/rte_lpm.h | 2 +-
lib/librte_mbuf/rte_mbuf.h | 3 +++
lib/librte_pipeline/rte_pipeline.h | 2 +-
lib/librte_ring/rte_ring.h | 2 +-
lib/librte_sched/rte_bitmap.h | 2 +-
11 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/lib/librte_acl/rte_acl.h b/lib/librte_acl/rte_acl.h
index 0979a09..c059dc3 100644
--- a/lib/librte_acl/rte_acl.h
+++ b/lib/librte_acl/rte_acl.h
@@ -144,7 +144,7 @@ struct rte_acl_rule_data {
struct rte_acl_field field[fld_num]; \
}
-RTE_ACL_RULE_DEF(rte_acl_rule, 0);
+RTE_ACL_RULE_DEF(rte_acl_rule,);
#define RTE_ACL_RULE_SZ(fld_num) \
(sizeof(struct rte_acl_rule) + sizeof(struct rte_acl_field) * (fld_num))
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index 7768f0a..0123c24 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -759,7 +759,7 @@ struct rte_cryptodev_sym_session {
} __rte_aligned(8);
/**< Public symmetric session details */
- char _private[0];
+ char _private[];
/**< Private session material */
};
diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h b/lib/librte_cryptodev/rte_cryptodev_pmd.h
index 7d049ea..3a3845c 100644
--- a/lib/librte_cryptodev/rte_cryptodev_pmd.h
+++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h
@@ -71,7 +71,7 @@ struct rte_cryptodev_session {
struct rte_mempool *mp;
} __rte_aligned(8);
- char _private[0];
+ char _private[];
};
struct rte_cryptodev_driver;
diff --git a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
index 2acdfd9..7f458a3 100644
--- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
+++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
@@ -102,7 +102,7 @@ struct rte_kni_fifo {
volatile unsigned read; /**< Next position to be read */
unsigned len; /**< Circular buffer length */
unsigned elem_size; /**< Pointer size - for 32/64 bit OS */
- void * volatile buffer[0]; /**< The buffer contains mbuf pointers */
+ void *volatile buffer[]; /**< The buffer contains mbuf pointers */
};
/*
diff --git a/lib/librte_hash/rte_fbk_hash.h b/lib/librte_hash/rte_fbk_hash.h
index a430961..bd46048 100644
--- a/lib/librte_hash/rte_fbk_hash.h
+++ b/lib/librte_hash/rte_fbk_hash.h
@@ -115,7 +115,7 @@ struct rte_fbk_hash_table {
uint32_t init_val; /**< For initialising hash function. */
/** A flat table of all buckets. */
- union rte_fbk_hash_entry t[0];
+ union rte_fbk_hash_entry t[];
};
/**
diff --git a/lib/librte_ip_frag/rte_ip_frag.h b/lib/librte_ip_frag/rte_ip_frag.h
index 92cedf2..4c3faad 100644
--- a/lib/librte_ip_frag/rte_ip_frag.h
+++ b/lib/librte_ip_frag/rte_ip_frag.h
@@ -124,7 +124,7 @@ struct rte_ip_frag_tbl {
struct ip_frag_pkt *last; /**< last used entry. */
struct ip_pkt_list lru; /**< LRU list for table entries. */
struct ip_frag_tbl_stat stat; /**< statistics counters. */
- struct ip_frag_pkt pkt[0]; /**< hash table. */
+ struct ip_frag_pkt pkt[]; /**< hash table. */
};
/** IPv6 fragment extension header */
diff --git a/lib/librte_lpm/rte_lpm.h b/lib/librte_lpm/rte_lpm.h
index 2df1d67..79a4593 100644
--- a/lib/librte_lpm/rte_lpm.h
+++ b/lib/librte_lpm/rte_lpm.h
@@ -193,7 +193,7 @@ struct rte_lpm_v20 {
__rte_cache_aligned; /**< LPM tbl24 table. */
struct rte_lpm_tbl_entry_v20 tbl8[RTE_LPM_TBL8_NUM_ENTRIES]
__rte_cache_aligned; /**< LPM tbl8 table. */
- struct rte_lpm_rule_v20 rules_tbl[0] \
+ struct rte_lpm_rule_v20 rules_tbl[]
__rte_cache_aligned; /**< LPM rules. */
};
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 101485f..434ec31 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -756,8 +756,11 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask);
/* define a set of marker types that can be used to refer to set points in the
* mbuf */
+__extension__
typedef void *MARKER[0]; /**< generic marker for a point in a structure */
+__extension__
typedef uint8_t MARKER8[0]; /**< generic marker with 1B alignment */
+__extension__
typedef uint64_t MARKER64[0]; /**< marker that allows us to overwrite 8 bytes
* with a single assignment */
diff --git a/lib/librte_pipeline/rte_pipeline.h b/lib/librte_pipeline/rte_pipeline.h
index 84d1802..7736945 100644
--- a/lib/librte_pipeline/rte_pipeline.h
+++ b/lib/librte_pipeline/rte_pipeline.h
@@ -252,7 +252,7 @@ struct rte_pipeline_table_entry {
uint32_t table_id;
};
/** Start of table entry area for user defined actions and meta-data */
- uint8_t action_data[0];
+ uint8_t action_data[];
};
/**
diff --git a/lib/librte_ring/rte_ring.h b/lib/librte_ring/rte_ring.h
index eb45e41..12874f7 100644
--- a/lib/librte_ring/rte_ring.h
+++ b/lib/librte_ring/rte_ring.h
@@ -179,7 +179,7 @@ struct rte_ring {
struct rte_ring_debug_stats stats[RTE_MAX_LCORE];
#endif
- void * ring[0] __rte_cache_aligned; /**< Memory space of ring starts here.
+ void *ring[] __rte_cache_aligned; /**< Memory space of ring starts here.
* not volatile so need to be careful
* about compiler re-ordering */
};
diff --git a/lib/librte_sched/rte_bitmap.h b/lib/librte_sched/rte_bitmap.h
index ff675c5..1b5df02 100644
--- a/lib/librte_sched/rte_bitmap.h
+++ b/lib/librte_sched/rte_bitmap.h
@@ -103,7 +103,7 @@ struct rte_bitmap {
uint32_t go2; /**< Bitmap scan: Go/stop condition for current array2 cache line */
/* Storage space for array1 and array2 */
- uint8_t memory[0];
+ uint8_t memory[];
};
static inline void
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* [dpdk-dev] [PATCH v2 04/11] lib: work around nonstandard bit-fields
2016-07-05 10:44 ` [dpdk-dev] [PATCH v2 00/11] Fix build errors related to exported headers Adrien Mazarguil
` (2 preceding siblings ...)
2016-07-05 10:44 ` [dpdk-dev] [PATCH v2 03/11] lib: use C99 syntax for zero-size arrays Adrien Mazarguil
@ 2016-07-05 10:44 ` Adrien Mazarguil
2016-07-05 10:44 ` [dpdk-dev] [PATCH v2 05/11] lib: work around structs with no members Adrien Mazarguil
` (10 subsequent siblings)
14 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-07-05 10:44 UTC (permalink / raw)
To: dev
Exported header files used by applications should allow the strictest
compiler flags. Language extensions used in many places must be explicitly
marked or removed to avoid warnings and compilation failures.
This commit prevents the following errors:
error: type of bit-field `[...]' is a GCC extension
Note: the standard does not require implementations to issue a diagnostic
message with these, and such errors do not occur with recent GCC or clang
versions. However, GCC 4.7 is still common and using the extension keyword
is easier than checking compiler version.
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
lib/librte_cryptodev/rte_cryptodev.h | 2 ++
lib/librte_ether/rte_ethdev.h | 4 ++++
lib/librte_lpm/rte_lpm.h | 4 ++++
lib/librte_mbuf/rte_mbuf.h | 1 +
4 files changed, 11 insertions(+)
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index 0123c24..7991add 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -619,6 +619,7 @@ struct rte_cryptodev {
struct rte_cryptodev_cb_list link_intr_cbs;
/**< User application callback for interrupts if present */
+ __extension__
uint8_t attached : 1;
/**< Flag indicating the device is attached */
} __rte_cache_aligned;
@@ -642,6 +643,7 @@ struct rte_cryptodev_data {
char name[RTE_CRYPTODEV_NAME_MAX_LEN];
/**< Unique identifier name */
+ __extension__
uint8_t dev_started : 1;
/**< Device state: STARTED(1)/STOPPED(0) */
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 0f17323..755f150 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -255,6 +255,7 @@ struct rte_eth_stats {
/**
* A structure used to retrieve link-level information of an Ethernet port.
*/
+__extension__
struct rte_eth_link {
uint32_t link_speed; /**< ETH_SPEED_NUM_ */
uint16_t link_duplex : 1; /**< ETH_LINK_[HALF/FULL]_DUPLEX */
@@ -346,6 +347,7 @@ struct rte_eth_rxmode {
enum rte_eth_rx_mq_mode mq_mode;
uint32_t max_rx_pkt_len; /**< Only used if jumbo_frame enabled. */
uint16_t split_hdr_size; /**< hdr buf size (header_split enabled).*/
+ __extension__
uint16_t header_split : 1, /**< Header Split enable. */
hw_ip_checksum : 1, /**< IP/UDP/TCP checksum offload enable. */
hw_vlan_filter : 1, /**< VLAN filter enable. */
@@ -645,6 +647,7 @@ struct rte_eth_txmode {
/* For i40e specifically */
uint16_t pvid;
+ __extension__
uint8_t hw_vlan_reject_tagged : 1,
/**< If set, reject sending out tagged pkts */
hw_vlan_reject_untagged : 1,
@@ -1696,6 +1699,7 @@ struct rte_eth_dev_data {
struct ether_addr* hash_mac_addrs;
/** Device Ethernet MAC addresses of hash filtering. */
uint8_t port_id; /**< Device [external] port identifier. */
+ __extension__
uint8_t promiscuous : 1, /**< RX promiscuous mode ON(1) / OFF(0). */
scattered_rx : 1, /**< RX of scattered packets is ON(1) / OFF(0) */
all_multicast : 1, /**< RX all multicast mode ON(1) / OFF(0). */
diff --git a/lib/librte_lpm/rte_lpm.h b/lib/librte_lpm/rte_lpm.h
index 79a4593..28668a3 100644
--- a/lib/librte_lpm/rte_lpm.h
+++ b/lib/librte_lpm/rte_lpm.h
@@ -93,6 +93,7 @@ extern "C" {
#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
/** @internal Tbl24 entry structure. */
+__extension__
struct rte_lpm_tbl_entry_v20 {
/**
* Stores Next hop (tbl8 or tbl24 when valid_group is not set) or
@@ -116,6 +117,7 @@ struct rte_lpm_tbl_entry_v20 {
uint8_t depth :6; /**< Rule depth. */
};
+__extension__
struct rte_lpm_tbl_entry {
/**
* Stores Next hop (tbl8 or tbl24 when valid_group is not set) or
@@ -137,6 +139,7 @@ struct rte_lpm_tbl_entry {
};
#else
+__extension__
struct rte_lpm_tbl_entry_v20 {
uint8_t depth :6;
uint8_t valid_group :1;
@@ -147,6 +150,7 @@ struct rte_lpm_tbl_entry_v20 {
};
};
+__extension__
struct rte_lpm_tbl_entry {
uint32_t depth :6;
uint32_t valid_group :1;
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 434ec31..3d3e847 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -865,6 +865,7 @@ struct rte_mbuf {
/* fields to support TX offloads */
union {
uint64_t tx_offload; /**< combined for easy fetch */
+ __extension__
struct {
uint64_t l2_len:7; /**< L2 (MAC) Header Length. */
uint64_t l3_len:9; /**< L3 (IP) Header Length. */
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* [dpdk-dev] [PATCH v2 05/11] lib: work around structs with no members
2016-07-05 10:44 ` [dpdk-dev] [PATCH v2 00/11] Fix build errors related to exported headers Adrien Mazarguil
` (3 preceding siblings ...)
2016-07-05 10:44 ` [dpdk-dev] [PATCH v2 04/11] lib: work around nonstandard bit-fields Adrien Mazarguil
@ 2016-07-05 10:44 ` Adrien Mazarguil
2016-07-05 10:44 ` [dpdk-dev] [PATCH v2 06/11] lib: work around unnamed structs/unions Adrien Mazarguil
` (9 subsequent siblings)
14 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-07-05 10:44 UTC (permalink / raw)
To: dev
Exported header files used by applications should allow the strictest
compiler flags. Language extensions used in many places must be explicitly
marked or removed to avoid warnings and compilation failures.
This commit prevents the following errors:
error: struct has no members
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
lib/librte_mempool/rte_mempool.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h
index fb7052e..fc33db8 100644
--- a/lib/librte_mempool/rte_mempool.h
+++ b/lib/librte_mempool/rte_mempool.h
@@ -169,6 +169,7 @@ STAILQ_HEAD(rte_mempool_objhdr_list, rte_mempool_objhdr);
* In debug mode, each object stored in mempools are suffixed by this
* trailer structure containing a cookie preventing memory corruptions.
*/
+__extension__
struct rte_mempool_objtlr {
#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
uint64_t cookie; /**< Debug cookie. */
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* [dpdk-dev] [PATCH v2 06/11] lib: work around unnamed structs/unions
2016-07-05 10:44 ` [dpdk-dev] [PATCH v2 00/11] Fix build errors related to exported headers Adrien Mazarguil
` (4 preceding siblings ...)
2016-07-05 10:44 ` [dpdk-dev] [PATCH v2 05/11] lib: work around structs with no members Adrien Mazarguil
@ 2016-07-05 10:44 ` Adrien Mazarguil
2016-07-05 10:44 ` [dpdk-dev] [PATCH v2 07/11] lib: add missing include dependencies Adrien Mazarguil
` (8 subsequent siblings)
14 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-07-05 10:44 UTC (permalink / raw)
To: dev
Exported header files used by applications should allow the strictest
compiler flags. Language extensions used in many places must be explicitly
marked to avoid warnings and compilation failures.
Unnamed structs/unions are allowed since C11, however many compiler
versions do not use this mode by default.
This commit prevents the following errors:
error: ISO C99 doesn't support unnamed structs/unions
error: struct has no named members
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
lib/librte_cryptodev/rte_crypto.h | 2 ++
lib/librte_cryptodev/rte_crypto_sym.h | 3 +++
lib/librte_cryptodev/rte_cryptodev.h | 4 ++++
lib/librte_cryptodev/rte_cryptodev_pmd.h | 2 ++
lib/librte_eal/common/include/arch/ppc_64/rte_cycles.h | 2 ++
lib/librte_eal/common/include/arch/x86/rte_atomic_32.h | 3 +++
lib/librte_eal/common/include/arch/x86/rte_cycles.h | 2 ++
lib/librte_eal/common/include/rte_common.h | 7 +++++++
lib/librte_eal/common/include/rte_devargs.h | 1 +
lib/librte_eal/common/include/rte_interrupts.h | 2 ++
lib/librte_eal/common/include/rte_memory.h | 1 +
lib/librte_eal/common/include/rte_memzone.h | 2 ++
lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h | 1 +
lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h | 4 ++++
lib/librte_hash/rte_thash.h | 3 +++
lib/librte_lpm/rte_lpm.h | 1 +
lib/librte_mbuf/rte_mbuf.h | 5 +++++
lib/librte_mempool/rte_mempool.h | 2 ++
lib/librte_pipeline/rte_pipeline.h | 2 ++
lib/librte_timer/rte_timer.h | 2 ++
20 files changed, 51 insertions(+)
diff --git a/lib/librte_cryptodev/rte_crypto.h b/lib/librte_cryptodev/rte_crypto.h
index 5bc3eaa..9019518 100644
--- a/lib/librte_cryptodev/rte_crypto.h
+++ b/lib/librte_cryptodev/rte_crypto.h
@@ -48,6 +48,7 @@ extern "C" {
#include <rte_mbuf.h>
#include <rte_memory.h>
#include <rte_mempool.h>
+#include <rte_common.h>
#include "rte_crypto_sym.h"
@@ -111,6 +112,7 @@ struct rte_crypto_op {
void *opaque_data;
/**< Opaque pointer for user data */
+ RTE_STD_C11
union {
struct rte_crypto_sym_op *sym;
/**< Symmetric operation parameters */
diff --git a/lib/librte_cryptodev/rte_crypto_sym.h b/lib/librte_cryptodev/rte_crypto_sym.h
index d9bd821..8178e5a 100644
--- a/lib/librte_cryptodev/rte_crypto_sym.h
+++ b/lib/librte_cryptodev/rte_crypto_sym.h
@@ -51,6 +51,7 @@ extern "C" {
#include <rte_mbuf.h>
#include <rte_memory.h>
#include <rte_mempool.h>
+#include <rte_common.h>
/** Symmetric Cipher Algorithms */
@@ -333,6 +334,7 @@ struct rte_crypto_sym_xform {
/**< next xform in chain */
enum rte_crypto_sym_xform_type type
; /**< xform type */
+ RTE_STD_C11
union {
struct rte_crypto_auth_xform auth;
/**< Authentication / hash xform */
@@ -371,6 +373,7 @@ struct rte_crypto_sym_op {
enum rte_crypto_sym_op_sess_type sess_type;
+ RTE_STD_C11
union {
struct rte_cryptodev_sym_session *session;
/**< Handle for the initialised session context */
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index 7991add..be9a544 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -48,6 +48,7 @@ extern "C" {
#include "rte_kvargs.h"
#include "rte_crypto.h"
#include "rte_dev.h"
+#include <rte_common.h>
#define CRYPTODEV_NAME_NULL_PMD ("cryptodev_null_pmd")
/**< Null crypto PMD device name */
@@ -104,6 +105,7 @@ extern const char **rte_cyptodev_names;
struct rte_cryptodev_symmetric_capability {
enum rte_crypto_sym_xform_type xform_type;
/**< Transform type : Authentication / Cipher */
+ RTE_STD_C11
union {
struct {
enum rte_crypto_auth_algorithm algo;
@@ -177,6 +179,7 @@ struct rte_cryptodev_capabilities {
enum rte_crypto_op_type op;
/**< Operation type */
+ RTE_STD_C11
union {
struct rte_cryptodev_symmetric_capability sym;
/**< Symmetric operation capability parameters */
@@ -751,6 +754,7 @@ rte_cryptodev_enqueue_burst(uint8_t dev_id, uint16_t qp_id,
/** Cryptodev symmetric crypto session */
struct rte_cryptodev_sym_session {
+ RTE_STD_C11
struct {
uint8_t dev_id;
/**< Device Id */
diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h b/lib/librte_cryptodev/rte_cryptodev_pmd.h
index 3a3845c..cf08a50 100644
--- a/lib/librte_cryptodev/rte_cryptodev_pmd.h
+++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h
@@ -52,6 +52,7 @@ extern "C" {
#include <rte_mbuf.h>
#include <rte_mempool.h>
#include <rte_log.h>
+#include <rte_common.h>
#include "rte_crypto.h"
#include "rte_cryptodev.h"
@@ -65,6 +66,7 @@ extern "C" {
#endif
struct rte_cryptodev_session {
+ RTE_STD_C11
struct {
uint8_t dev_id;
enum rte_cryptodev_type type;
diff --git a/lib/librte_eal/common/include/arch/ppc_64/rte_cycles.h b/lib/librte_eal/common/include/arch/ppc_64/rte_cycles.h
index 64beddf..8fa6fc6 100644
--- a/lib/librte_eal/common/include/arch/ppc_64/rte_cycles.h
+++ b/lib/librte_eal/common/include/arch/ppc_64/rte_cycles.h
@@ -40,6 +40,7 @@ extern "C" {
#include "generic/rte_cycles.h"
#include <rte_byteorder.h>
+#include <rte_common.h>
/**
* Read the time base register.
@@ -52,6 +53,7 @@ rte_rdtsc(void)
{
union {
uint64_t tsc_64;
+ RTE_STD_C11
struct {
#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
uint32_t hi_32;
diff --git a/lib/librte_eal/common/include/arch/x86/rte_atomic_32.h b/lib/librte_eal/common/include/arch/x86/rte_atomic_32.h
index 400d8a9..5ce01b3 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_atomic_32.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_atomic_32.h
@@ -40,6 +40,8 @@
#ifndef _RTE_ATOMIC_I686_H_
#define _RTE_ATOMIC_I686_H_
+#include <rte_common.h>
+
/*------------------------- 64 bit atomic operations -------------------------*/
#ifndef RTE_FORCE_INTRINSICS
@@ -47,6 +49,7 @@ static inline int
rte_atomic64_cmpset(volatile uint64_t *dst, uint64_t exp, uint64_t src)
{
uint8_t res;
+ RTE_STD_C11
union {
struct {
uint32_t l32;
diff --git a/lib/librte_eal/common/include/arch/x86/rte_cycles.h b/lib/librte_eal/common/include/arch/x86/rte_cycles.h
index 6e3c7d8..5eb6ce9 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_cycles.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_cycles.h
@@ -75,12 +75,14 @@ extern "C" {
extern int rte_cycles_vmware_tsc_map;
#include <rte_branch_prediction.h>
#endif
+#include <rte_common.h>
static inline uint64_t
rte_rdtsc(void)
{
union {
uint64_t tsc_64;
+ RTE_STD_C11
struct {
uint32_t lo_32;
uint32_t hi_32;
diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h
index 477472b..98ecc1c 100644
--- a/lib/librte_eal/common/include/rte_common.h
+++ b/lib/librte_eal/common/include/rte_common.h
@@ -59,6 +59,13 @@ extern "C" {
#define asm __asm__
#endif
+/** C extension macro for environments lacking C11 features. */
+#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L
+#define RTE_STD_C11 __extension__
+#else
+#define RTE_STD_C11
+#endif
+
#ifdef RTE_ARCH_STRICT_ALIGN
typedef uint64_t unaligned_uint64_t __attribute__ ((aligned(1)));
typedef uint32_t unaligned_uint32_t __attribute__ ((aligned(1)));
diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h
index 53c59f5..c66895f 100644
--- a/lib/librte_eal/common/include/rte_devargs.h
+++ b/lib/librte_eal/common/include/rte_devargs.h
@@ -76,6 +76,7 @@ struct rte_devargs {
TAILQ_ENTRY(rte_devargs) next;
/** Type of device. */
enum rte_devtype type;
+ RTE_STD_C11
union {
/** Used if type is RTE_DEVTYPE_*_PCI. */
struct {
diff --git a/lib/librte_eal/common/include/rte_interrupts.h b/lib/librte_eal/common/include/rte_interrupts.h
index ff11ef3..fd3c6ef 100644
--- a/lib/librte_eal/common/include/rte_interrupts.h
+++ b/lib/librte_eal/common/include/rte_interrupts.h
@@ -34,6 +34,8 @@
#ifndef _RTE_INTERRUPTS_H_
#define _RTE_INTERRUPTS_H_
+#include <rte_common.h>
+
/**
* @file
*
diff --git a/lib/librte_eal/common/include/rte_memory.h b/lib/librte_eal/common/include/rte_memory.h
index 6a2b3f1..38fbe74 100644
--- a/lib/librte_eal/common/include/rte_memory.h
+++ b/lib/librte_eal/common/include/rte_memory.h
@@ -104,6 +104,7 @@ typedef uint64_t phys_addr_t; /**< Physical address definition. */
*/
struct rte_memseg {
phys_addr_t phys_addr; /**< Start physical address. */
+ RTE_STD_C11
union {
void *addr; /**< Start virtual address. */
uint64_t addr_64; /**< Makes sure addr is always 64 bits */
diff --git a/lib/librte_eal/common/include/rte_memzone.h b/lib/librte_eal/common/include/rte_memzone.h
index f69b5a8..c3caf6e 100644
--- a/lib/librte_eal/common/include/rte_memzone.h
+++ b/lib/librte_eal/common/include/rte_memzone.h
@@ -53,6 +53,7 @@
#include <stdio.h>
#include <rte_memory.h>
+#include <rte_common.h>
#ifdef __cplusplus
extern "C" {
@@ -78,6 +79,7 @@ struct rte_memzone {
char name[RTE_MEMZONE_NAMESIZE]; /**< Name of the memory zone. */
phys_addr_t phys_addr; /**< Start physical address. */
+ RTE_STD_C11
union {
void *addr; /**< Start virtual address. */
uint64_t addr_64; /**< Makes sure addr is always 64-bits */
diff --git a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h
index 3dacbff..d459bf4 100644
--- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h
+++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h
@@ -82,6 +82,7 @@ struct rte_epoll_event {
/** Handle for interrupts. */
struct rte_intr_handle {
+ RTE_STD_C11
union {
int vfio_dev_fd; /**< VFIO device file descriptor */
int uio_cfg_fd; /**< UIO config file descriptor
diff --git a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
index 7f458a3..cea6a02 100644
--- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
+++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
@@ -61,6 +61,9 @@
#ifdef __KERNEL__
#include <linux/if.h>
+#define RTE_STD_C11
+#else
+#include <rte_common.h>
#endif
/**
@@ -85,6 +88,7 @@ enum rte_kni_req_id {
*/
struct rte_kni_request {
uint32_t req_id; /**< Request id */
+ RTE_STD_C11
union {
uint32_t new_mtu; /**< New MTU */
uint8_t if_up; /**< 1: interface up, 0: interface down */
diff --git a/lib/librte_hash/rte_thash.h b/lib/librte_hash/rte_thash.h
index d98e98e..a4886a8 100644
--- a/lib/librte_hash/rte_thash.h
+++ b/lib/librte_hash/rte_thash.h
@@ -54,6 +54,7 @@ extern "C" {
#include <stdint.h>
#include <rte_byteorder.h>
#include <rte_ip.h>
+#include <rte_common.h>
#ifdef __SSE3__
#include <rte_vect.h>
@@ -102,6 +103,7 @@ static const __m128i rte_thash_ipv6_bswap_mask = {
struct rte_ipv4_tuple {
uint32_t src_addr;
uint32_t dst_addr;
+ RTE_STD_C11
union {
struct {
uint16_t dport;
@@ -119,6 +121,7 @@ struct rte_ipv4_tuple {
struct rte_ipv6_tuple {
uint8_t src_addr[16];
uint8_t dst_addr[16];
+ RTE_STD_C11
union {
struct {
uint16_t dport;
diff --git a/lib/librte_lpm/rte_lpm.h b/lib/librte_lpm/rte_lpm.h
index 28668a3..3ef4533 100644
--- a/lib/librte_lpm/rte_lpm.h
+++ b/lib/librte_lpm/rte_lpm.h
@@ -100,6 +100,7 @@ struct rte_lpm_tbl_entry_v20 {
* a group index pointing to a tbl8 structure (tbl24 only, when
* valid_group is set)
*/
+ RTE_STD_C11
union {
uint8_t next_hop;
uint8_t group_idx;
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 3d3e847..4b9eb93 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -787,6 +787,7 @@ struct rte_mbuf {
* or non-atomic) is controlled by the CONFIG_RTE_MBUF_REFCNT_ATOMIC
* config option.
*/
+ RTE_STD_C11
union {
rte_atomic16_t refcnt_atomic; /**< Atomically accessed refcnt */
uint16_t refcnt; /**< Non-atomically accessed refcnt */
@@ -806,6 +807,7 @@ struct rte_mbuf {
* would have RTE_PTYPE_L2_ETHER and not RTE_PTYPE_L2_VLAN because the
* vlan is stripped from the data.
*/
+ RTE_STD_C11
union {
uint32_t packet_type; /**< L2/L3/L4 and tunnel information. */
struct {
@@ -827,6 +829,7 @@ struct rte_mbuf {
union {
uint32_t rss; /**< RSS hash result if RSS enabled */
struct {
+ RTE_STD_C11
union {
struct {
uint16_t hash;
@@ -854,6 +857,7 @@ struct rte_mbuf {
/* second cache line - fields only used in slow path or on TX */
MARKER cacheline1 __rte_cache_min_aligned;
+ RTE_STD_C11
union {
void *userdata; /**< Can be used for external metadata */
uint64_t udata64; /**< Allow 8-byte userdata on 32-bit */
@@ -863,6 +867,7 @@ struct rte_mbuf {
struct rte_mbuf *next; /**< Next segment of scattered packet. */
/* fields to support TX offloads */
+ RTE_STD_C11
union {
uint64_t tx_offload; /**< combined for easy fetch */
__extension__
diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h
index fc33db8..70b3953 100644
--- a/lib/librte_mempool/rte_mempool.h
+++ b/lib/librte_mempool/rte_mempool.h
@@ -75,6 +75,7 @@
#include <rte_branch_prediction.h>
#include <rte_ring.h>
#include <rte_memcpy.h>
+#include <rte_common.h>
#ifdef __cplusplus
extern "C" {
@@ -208,6 +209,7 @@ struct rte_mempool_memhdr {
*/
struct rte_mempool {
char name[RTE_MEMPOOL_NAMESIZE]; /**< Name of mempool. */
+ RTE_STD_C11
union {
void *pool_data; /**< Ring or pool to store objects. */
uint64_t pool_id; /**< External mempool identifier. */
diff --git a/lib/librte_pipeline/rte_pipeline.h b/lib/librte_pipeline/rte_pipeline.h
index 7736945..b1193b4 100644
--- a/lib/librte_pipeline/rte_pipeline.h
+++ b/lib/librte_pipeline/rte_pipeline.h
@@ -87,6 +87,7 @@ extern "C" {
#include <rte_port.h>
#include <rte_table.h>
+#include <rte_common.h>
struct rte_mbuf;
@@ -244,6 +245,7 @@ struct rte_pipeline_table_entry {
/** Reserved action */
enum rte_pipeline_action action;
+ RTE_STD_C11
union {
/** Output port ID (meta-data for "Send packet to output port"
action) */
diff --git a/lib/librte_timer/rte_timer.h b/lib/librte_timer/rte_timer.h
index 77547c6..a276a73 100644
--- a/lib/librte_timer/rte_timer.h
+++ b/lib/librte_timer/rte_timer.h
@@ -66,6 +66,7 @@
#include <stdio.h>
#include <stdint.h>
#include <stddef.h>
+#include <rte_common.h>
#ifdef __cplusplus
extern "C" {
@@ -91,6 +92,7 @@ enum rte_timer_type {
* config) and an owner (the id of the lcore that owns the timer).
*/
union rte_timer_status {
+ RTE_STD_C11
struct {
uint16_t state; /**< Stop, pending, running, config. */
int16_t owner; /**< The lcore that owns the timer. */
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* [dpdk-dev] [PATCH v2 07/11] lib: add missing include dependencies
2016-07-05 10:44 ` [dpdk-dev] [PATCH v2 00/11] Fix build errors related to exported headers Adrien Mazarguil
` (5 preceding siblings ...)
2016-07-05 10:44 ` [dpdk-dev] [PATCH v2 06/11] lib: work around unnamed structs/unions Adrien Mazarguil
@ 2016-07-05 10:44 ` Adrien Mazarguil
2016-07-05 10:44 ` [dpdk-dev] [PATCH v2 08/11] lib: work around forward reference to enum types Adrien Mazarguil
` (7 subsequent siblings)
14 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-07-05 10:44 UTC (permalink / raw)
To: dev
Exported header files for use by applications should be self sufficient and
allow out of order inclusion. Moreover, they must include all the system
headers they need for types and macros.
This commit prevents the following errors:
error: `RTE_MAX_LCORE' undeclared here (not in a function)
error: `RTE_LPM_VALID_EXT_ENTRY_BITMASK' undeclared
(first use in this function)
error: #error "Unsupported cache line size"
error: `asm' undeclared (first use in this function)
error: implicit declaration of function `[...]'
error: unknown type name `[...]'
error: field `mac_addr' has incomplete type
error: `CHAR_BIT' undeclared here (not in a function)
error: `struct [...]' declared inside parameter list
error: unknown type name `uint8_t'
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
lib/librte_cfgfile/rte_cfgfile.h | 2 ++
lib/librte_cmdline/cmdline.h | 1 +
lib/librte_cmdline/cmdline_parse_portlist.h | 1 +
lib/librte_cmdline/cmdline_socket.h | 3 +++
lib/librte_eal/common/include/arch/arm/rte_byteorder.h | 2 ++
lib/librte_eal/common/include/arch/arm/rte_prefetch_32.h | 1 +
lib/librte_eal/common/include/arch/arm/rte_prefetch_64.h | 1 +
lib/librte_eal/common/include/arch/arm/rte_vect.h | 1 +
lib/librte_eal/common/include/arch/ppc_64/rte_atomic.h | 1 +
lib/librte_eal/common/include/arch/ppc_64/rte_byteorder.h | 1 +
lib/librte_eal/common/include/arch/ppc_64/rte_prefetch.h | 1 +
lib/librte_eal/common/include/arch/x86/rte_atomic.h | 2 ++
lib/librte_eal/common/include/arch/x86/rte_atomic_32.h | 6 ++++++
lib/librte_eal/common/include/arch/x86/rte_atomic_64.h | 8 ++++++++
lib/librte_eal/common/include/arch/x86/rte_byteorder.h | 2 ++
lib/librte_eal/common/include/arch/x86/rte_byteorder_32.h | 7 +++++++
lib/librte_eal/common/include/arch/x86/rte_byteorder_64.h | 7 +++++++
lib/librte_eal/common/include/arch/x86/rte_prefetch.h | 1 +
lib/librte_eal/common/include/arch/x86/rte_rtm.h | 1 +
lib/librte_eal/common/include/arch/x86/rte_vect.h | 2 ++
lib/librte_eal/common/include/generic/rte_atomic.h | 1 +
lib/librte_eal/common/include/generic/rte_byteorder.h | 2 ++
lib/librte_eal/common/include/rte_eal.h | 1 +
lib/librte_eal/common/include/rte_memory.h | 2 ++
lib/librte_eal/common/include/rte_time.h | 8 ++++++++
lib/librte_eal/common/include/rte_version.h | 1 +
lib/librte_ether/rte_dev_info.h | 2 ++
lib/librte_ether/rte_eth_ctrl.h | 4 ++++
lib/librte_lpm/rte_lpm_neon.h | 1 +
lib/librte_lpm/rte_lpm_sse.h | 1 +
lib/librte_pdump/rte_pdump.h | 4 ++++
lib/librte_reorder/rte_reorder.h | 2 ++
lib/librte_sched/rte_bitmap.h | 1 +
lib/librte_sched/rte_reciprocal.h | 2 ++
lib/librte_sched/rte_sched_common.h | 1 +
35 files changed, 84 insertions(+)
diff --git a/lib/librte_cfgfile/rte_cfgfile.h b/lib/librte_cfgfile/rte_cfgfile.h
index f649836..e81a5a2 100644
--- a/lib/librte_cfgfile/rte_cfgfile.h
+++ b/lib/librte_cfgfile/rte_cfgfile.h
@@ -34,6 +34,8 @@
#ifndef __INCLUDE_RTE_CFGFILE_H__
#define __INCLUDE_RTE_CFGFILE_H__
+#include <stddef.h>
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/lib/librte_cmdline/cmdline.h b/lib/librte_cmdline/cmdline.h
index 2578ca8..65d73b0 100644
--- a/lib/librte_cmdline/cmdline.h
+++ b/lib/librte_cmdline/cmdline.h
@@ -63,6 +63,7 @@
#include <termios.h>
#include <cmdline_rdline.h>
+#include <cmdline_parse.h>
/**
* @file
diff --git a/lib/librte_cmdline/cmdline_parse_portlist.h b/lib/librte_cmdline/cmdline_parse_portlist.h
index 73d70e0..058df3e 100644
--- a/lib/librte_cmdline/cmdline_parse_portlist.h
+++ b/lib/librte_cmdline/cmdline_parse_portlist.h
@@ -61,6 +61,7 @@
#ifndef _PARSE_PORTLIST_H_
#define _PARSE_PORTLIST_H_
+#include <stdint.h>
#include <cmdline_parse.h>
#ifdef __cplusplus
diff --git a/lib/librte_cmdline/cmdline_socket.h b/lib/librte_cmdline/cmdline_socket.h
index 8cc2dfb..aa6068e 100644
--- a/lib/librte_cmdline/cmdline_socket.h
+++ b/lib/librte_cmdline/cmdline_socket.h
@@ -61,6 +61,9 @@
#ifndef _CMDLINE_SOCKET_H_
#define _CMDLINE_SOCKET_H_
+#include <cmdline_parse.h>
+#include <cmdline.h>
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/lib/librte_eal/common/include/arch/arm/rte_byteorder.h b/lib/librte_eal/common/include/arch/arm/rte_byteorder.h
index 3f2dd1f..1b312b3 100644
--- a/lib/librte_eal/common/include/arch/arm/rte_byteorder.h
+++ b/lib/librte_eal/common/include/arch/arm/rte_byteorder.h
@@ -41,6 +41,8 @@
extern "C" {
#endif
+#include <stdint.h>
+#include <rte_common.h>
#include "generic/rte_byteorder.h"
/* fix missing __builtin_bswap16 for gcc older then 4.8 */
diff --git a/lib/librte_eal/common/include/arch/arm/rte_prefetch_32.h b/lib/librte_eal/common/include/arch/arm/rte_prefetch_32.h
index 5aeed22..43cde17 100644
--- a/lib/librte_eal/common/include/arch/arm/rte_prefetch_32.h
+++ b/lib/librte_eal/common/include/arch/arm/rte_prefetch_32.h
@@ -37,6 +37,7 @@
extern "C" {
#endif
+#include <rte_common.h>
#include "generic/rte_prefetch.h"
static inline void rte_prefetch0(const volatile void *p)
diff --git a/lib/librte_eal/common/include/arch/arm/rte_prefetch_64.h b/lib/librte_eal/common/include/arch/arm/rte_prefetch_64.h
index 3ed46a4..0d077ea 100644
--- a/lib/librte_eal/common/include/arch/arm/rte_prefetch_64.h
+++ b/lib/librte_eal/common/include/arch/arm/rte_prefetch_64.h
@@ -37,6 +37,7 @@
extern "C" {
#endif
+#include <rte_common.h>
#include "generic/rte_prefetch.h"
static inline void rte_prefetch0(const volatile void *p)
diff --git a/lib/librte_eal/common/include/arch/arm/rte_vect.h b/lib/librte_eal/common/include/arch/arm/rte_vect.h
index a33c054..b86c2cf 100644
--- a/lib/librte_eal/common/include/arch/arm/rte_vect.h
+++ b/lib/librte_eal/common/include/arch/arm/rte_vect.h
@@ -33,6 +33,7 @@
#ifndef _RTE_VECT_ARM_H_
#define _RTE_VECT_ARM_H_
+#include <stdint.h>
#include "arm_neon.h"
#ifdef __cplusplus
diff --git a/lib/librte_eal/common/include/arch/ppc_64/rte_atomic.h b/lib/librte_eal/common/include/arch/ppc_64/rte_atomic.h
index feae486..3270fce 100644
--- a/lib/librte_eal/common/include/arch/ppc_64/rte_atomic.h
+++ b/lib/librte_eal/common/include/arch/ppc_64/rte_atomic.h
@@ -46,6 +46,7 @@
extern "C" {
#endif
+#include <stdint.h>
#include "generic/rte_atomic.h"
/**
diff --git a/lib/librte_eal/common/include/arch/ppc_64/rte_byteorder.h b/lib/librte_eal/common/include/arch/ppc_64/rte_byteorder.h
index 3c1734e..544de3c 100644
--- a/lib/librte_eal/common/include/arch/ppc_64/rte_byteorder.h
+++ b/lib/librte_eal/common/include/arch/ppc_64/rte_byteorder.h
@@ -42,6 +42,7 @@
extern "C" {
#endif
+#include <stdint.h>
#include "generic/rte_byteorder.h"
/*
diff --git a/lib/librte_eal/common/include/arch/ppc_64/rte_prefetch.h b/lib/librte_eal/common/include/arch/ppc_64/rte_prefetch.h
index 9a1995e..fd2e53b 100644
--- a/lib/librte_eal/common/include/arch/ppc_64/rte_prefetch.h
+++ b/lib/librte_eal/common/include/arch/ppc_64/rte_prefetch.h
@@ -37,6 +37,7 @@
extern "C" {
#endif
+#include <rte_common.h>
#include "generic/rte_prefetch.h"
static inline void rte_prefetch0(const volatile void *p)
diff --git a/lib/librte_eal/common/include/arch/x86/rte_atomic.h b/lib/librte_eal/common/include/arch/x86/rte_atomic.h
index b20056b..00b1cdf 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_atomic.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_atomic.h
@@ -38,6 +38,8 @@
extern "C" {
#endif
+#include <stdint.h>
+#include <rte_common.h>
#include <emmintrin.h>
#include "generic/rte_atomic.h"
diff --git a/lib/librte_eal/common/include/arch/x86/rte_atomic_32.h b/lib/librte_eal/common/include/arch/x86/rte_atomic_32.h
index 5ce01b3..2e04c75 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_atomic_32.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_atomic_32.h
@@ -37,10 +37,16 @@
* All rights reserved.
*/
+#ifndef _RTE_ATOMIC_X86_H_
+#error do not include this file directly, use <rte_atomic.h> instead
+#endif
+
#ifndef _RTE_ATOMIC_I686_H_
#define _RTE_ATOMIC_I686_H_
+#include <stdint.h>
#include <rte_common.h>
+#include <rte_atomic.h>
/*------------------------- 64 bit atomic operations -------------------------*/
diff --git a/lib/librte_eal/common/include/arch/x86/rte_atomic_64.h b/lib/librte_eal/common/include/arch/x86/rte_atomic_64.h
index 4de6600..1a53a76 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_atomic_64.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_atomic_64.h
@@ -37,9 +37,17 @@
* All rights reserved.
*/
+#ifndef _RTE_ATOMIC_X86_H_
+#error do not include this file directly, use <rte_atomic.h> instead
+#endif
+
#ifndef _RTE_ATOMIC_X86_64_H_
#define _RTE_ATOMIC_X86_64_H_
+#include <stdint.h>
+#include <rte_common.h>
+#include <rte_atomic.h>
+
/*------------------------- 64 bit atomic operations -------------------------*/
#ifndef RTE_FORCE_INTRINSICS
diff --git a/lib/librte_eal/common/include/arch/x86/rte_byteorder.h b/lib/librte_eal/common/include/arch/x86/rte_byteorder.h
index ffdb6ef..251f11b 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_byteorder.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_byteorder.h
@@ -38,6 +38,8 @@
extern "C" {
#endif
+#include <stdint.h>
+#include <rte_common.h>
#include "generic/rte_byteorder.h"
#ifndef RTE_BYTE_ORDER
diff --git a/lib/librte_eal/common/include/arch/x86/rte_byteorder_32.h b/lib/librte_eal/common/include/arch/x86/rte_byteorder_32.h
index 51c306f..14d6483 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_byteorder_32.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_byteorder_32.h
@@ -31,9 +31,16 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#ifndef _RTE_BYTEORDER_X86_H_
+#error do not include this file directly, use <rte_byteorder.h> instead
+#endif
+
#ifndef _RTE_BYTEORDER_I686_H_
#define _RTE_BYTEORDER_I686_H_
+#include <stdint.h>
+#include <rte_byteorder.h>
+
/*
* An architecture-optimized byte swap for a 64-bit value.
*
diff --git a/lib/librte_eal/common/include/arch/x86/rte_byteorder_64.h b/lib/librte_eal/common/include/arch/x86/rte_byteorder_64.h
index dda572b..516ac05 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_byteorder_64.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_byteorder_64.h
@@ -31,9 +31,16 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#ifndef _RTE_BYTEORDER_X86_H_
+#error do not include this file directly, use <rte_byteorder.h> instead
+#endif
+
#ifndef _RTE_BYTEORDER_X86_64_H_
#define _RTE_BYTEORDER_X86_64_H_
+#include <stdint.h>
+#include <rte_common.h>
+
/*
* An architecture-optimized byte swap for a 64-bit value.
*
diff --git a/lib/librte_eal/common/include/arch/x86/rte_prefetch.h b/lib/librte_eal/common/include/arch/x86/rte_prefetch.h
index 5dac47e..f464398 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_prefetch.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_prefetch.h
@@ -38,6 +38,7 @@
extern "C" {
#endif
+#include <rte_common.h>
#include "generic/rte_prefetch.h"
static inline void rte_prefetch0(const volatile void *p)
diff --git a/lib/librte_eal/common/include/arch/x86/rte_rtm.h b/lib/librte_eal/common/include/arch/x86/rte_rtm.h
index 0649f79..ab09995 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_rtm.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_rtm.h
@@ -20,6 +20,7 @@
/* Official RTM intrinsics interface matching gcc/icc, but works
on older gcc compatible compilers and binutils. */
+#include <rte_common.h>
#ifdef __cplusplus
extern "C" {
diff --git a/lib/librte_eal/common/include/arch/x86/rte_vect.h b/lib/librte_eal/common/include/arch/x86/rte_vect.h
index 2836f2c..77f2e25 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_vect.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_vect.h
@@ -40,6 +40,8 @@
* RTE SSE/AVX related header.
*/
+#include <stdint.h>
+
#if (defined(__ICC) || (__GNUC__ == 4 && __GNUC_MINOR__ < 4))
#ifdef __SSE__
diff --git a/lib/librte_eal/common/include/generic/rte_atomic.h b/lib/librte_eal/common/include/generic/rte_atomic.h
index bfb4fe4..43a704e 100644
--- a/lib/librte_eal/common/include/generic/rte_atomic.h
+++ b/lib/librte_eal/common/include/generic/rte_atomic.h
@@ -42,6 +42,7 @@
*/
#include <stdint.h>
+#include <rte_common.h>
#ifdef __DOXYGEN__
diff --git a/lib/librte_eal/common/include/generic/rte_byteorder.h b/lib/librte_eal/common/include/generic/rte_byteorder.h
index c46fdcf..e00bccb 100644
--- a/lib/librte_eal/common/include/generic/rte_byteorder.h
+++ b/lib/librte_eal/common/include/generic/rte_byteorder.h
@@ -50,6 +50,8 @@
#include <endian.h>
#endif
+#include <rte_common.h>
+
/*
* Compile-time endianness detection
*/
diff --git a/lib/librte_eal/common/include/rte_eal.h b/lib/librte_eal/common/include/rte_eal.h
index a71d6f5..98d20db 100644
--- a/lib/librte_eal/common/include/rte_eal.h
+++ b/lib/librte_eal/common/include/rte_eal.h
@@ -44,6 +44,7 @@
#include <sched.h>
#include <rte_per_lcore.h>
+#include <rte_config.h>
#ifdef __cplusplus
extern "C" {
diff --git a/lib/librte_eal/common/include/rte_memory.h b/lib/librte_eal/common/include/rte_memory.h
index 38fbe74..3b6b46b 100644
--- a/lib/librte_eal/common/include/rte_memory.h
+++ b/lib/librte_eal/common/include/rte_memory.h
@@ -44,6 +44,8 @@
#include <stddef.h>
#include <stdio.h>
+#include <rte_config.h>
+
#ifdef RTE_EXEC_ENV_LINUXAPP
#include <exec-env/rte_dom0_common.h>
#endif
diff --git a/lib/librte_eal/common/include/rte_time.h b/lib/librte_eal/common/include/rte_time.h
index 4b13b9c..28c6274 100644
--- a/lib/librte_eal/common/include/rte_time.h
+++ b/lib/librte_eal/common/include/rte_time.h
@@ -31,6 +31,12 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#ifndef _RTE_TIME_H_
+#define _RTE_TIME_H_
+
+#include <stdint.h>
+#include <time.h>
+
#define NSEC_PER_SEC 1000000000L
/**
@@ -120,3 +126,5 @@ rte_ns_to_timespec(uint64_t nsec)
return ts;
}
+
+#endif /* _RTE_TIME_H_ */
diff --git a/lib/librte_eal/common/include/rte_version.h b/lib/librte_eal/common/include/rte_version.h
index dbe0997..bcd7005 100644
--- a/lib/librte_eal/common/include/rte_version.h
+++ b/lib/librte_eal/common/include/rte_version.h
@@ -45,6 +45,7 @@ extern "C" {
#include <stdint.h>
#include <string.h>
+#include <stdio.h>
#include <rte_common.h>
/**
diff --git a/lib/librte_ether/rte_dev_info.h b/lib/librte_ether/rte_dev_info.h
index 291bd4d..64b1d18 100644
--- a/lib/librte_ether/rte_dev_info.h
+++ b/lib/librte_ether/rte_dev_info.h
@@ -34,6 +34,8 @@
#ifndef _RTE_DEV_INFO_H_
#define _RTE_DEV_INFO_H_
+#include <stdint.h>
+
/*
* Placeholder for accessing device registers
*/
diff --git a/lib/librte_ether/rte_eth_ctrl.h b/lib/librte_ether/rte_eth_ctrl.h
index c3a2c9e..fe80eb0 100644
--- a/lib/librte_ether/rte_eth_ctrl.h
+++ b/lib/librte_ether/rte_eth_ctrl.h
@@ -34,6 +34,10 @@
#ifndef _RTE_ETH_CTRL_H_
#define _RTE_ETH_CTRL_H_
+#include <stdint.h>
+#include <rte_common.h>
+#include "rte_ether.h"
+
/**
* @file
*
diff --git a/lib/librte_lpm/rte_lpm_neon.h b/lib/librte_lpm/rte_lpm_neon.h
index 7c64315..7efd9a0 100644
--- a/lib/librte_lpm/rte_lpm_neon.h
+++ b/lib/librte_lpm/rte_lpm_neon.h
@@ -43,6 +43,7 @@
#include <rte_byteorder.h>
#include <rte_common.h>
#include <rte_vect.h>
+#include <rte_lpm.h>
#ifdef __cplusplus
extern "C" {
diff --git a/lib/librte_lpm/rte_lpm_sse.h b/lib/librte_lpm/rte_lpm_sse.h
index da83099..ef33c6a 100644
--- a/lib/librte_lpm/rte_lpm_sse.h
+++ b/lib/librte_lpm/rte_lpm_sse.h
@@ -38,6 +38,7 @@
#include <rte_byteorder.h>
#include <rte_common.h>
#include <rte_vect.h>
+#include <rte_lpm.h>
#ifdef __cplusplus
extern "C" {
diff --git a/lib/librte_pdump/rte_pdump.h b/lib/librte_pdump/rte_pdump.h
index b5f4e2f..924b804 100644
--- a/lib/librte_pdump/rte_pdump.h
+++ b/lib/librte_pdump/rte_pdump.h
@@ -41,6 +41,10 @@
* packet dump library to provide packet capturing support on dpdk.
*/
+#include <stdint.h>
+#include <rte_mempool.h>
+#include <rte_ring.h>
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/lib/librte_reorder/rte_reorder.h b/lib/librte_reorder/rte_reorder.h
index c7a2934..737e055 100644
--- a/lib/librte_reorder/rte_reorder.h
+++ b/lib/librte_reorder/rte_reorder.h
@@ -44,6 +44,8 @@
*
*/
+#include <rte_mbuf.h>
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/lib/librte_sched/rte_bitmap.h b/lib/librte_sched/rte_bitmap.h
index 1b5df02..010d752 100644
--- a/lib/librte_sched/rte_bitmap.h
+++ b/lib/librte_sched/rte_bitmap.h
@@ -64,6 +64,7 @@ extern "C" {
*
***/
+#include <string.h>
#include <rte_common.h>
#include <rte_debug.h>
#include <rte_memory.h>
diff --git a/lib/librte_sched/rte_reciprocal.h b/lib/librte_sched/rte_reciprocal.h
index abd1525..5e21f09 100644
--- a/lib/librte_sched/rte_reciprocal.h
+++ b/lib/librte_sched/rte_reciprocal.h
@@ -22,6 +22,8 @@
#ifndef _RTE_RECIPROCAL_H_
#define _RTE_RECIPROCAL_H_
+#include <stdint.h>
+
struct rte_reciprocal {
uint32_t m;
uint8_t sh1, sh2;
diff --git a/lib/librte_sched/rte_sched_common.h b/lib/librte_sched/rte_sched_common.h
index 8920ade..aed144b 100644
--- a/lib/librte_sched/rte_sched_common.h
+++ b/lib/librte_sched/rte_sched_common.h
@@ -38,6 +38,7 @@
extern "C" {
#endif
+#include <stdint.h>
#include <sys/types.h>
#define __rte_aligned_16 __attribute__((__aligned__(16)))
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* [dpdk-dev] [PATCH v2 08/11] lib: work around forward reference to enum types
2016-07-05 10:44 ` [dpdk-dev] [PATCH v2 00/11] Fix build errors related to exported headers Adrien Mazarguil
` (6 preceding siblings ...)
2016-07-05 10:44 ` [dpdk-dev] [PATCH v2 07/11] lib: add missing include dependencies Adrien Mazarguil
@ 2016-07-05 10:44 ` Adrien Mazarguil
2016-07-05 10:44 ` [dpdk-dev] [PATCH v2 09/11] lib: remove named variadic macros in exported headers Adrien Mazarguil
` (6 subsequent siblings)
14 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-07-05 10:44 UTC (permalink / raw)
To: dev
Exported header files used by applications should allow the strictest
compiler flags. Language extensions used in many places must be explicitly
marked or removed to avoid warnings and compilation failures.
This commit prevents the following errors:
error: ISO C forbids forward references to `enum' types
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
lib/librte_eal/common/include/generic/rte_cpuflags.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/librte_eal/common/include/generic/rte_cpuflags.h b/lib/librte_eal/common/include/generic/rte_cpuflags.h
index c1da357..71321f3 100644
--- a/lib/librte_eal/common/include/generic/rte_cpuflags.h
+++ b/lib/librte_eal/common/include/generic/rte_cpuflags.h
@@ -44,6 +44,7 @@
/**
* Enumeration of all CPU features supported
*/
+__extension__
enum rte_cpu_flag_t;
/**
@@ -55,6 +56,7 @@ enum rte_cpu_flag_t;
* flag name
* NULL if flag ID is invalid
*/
+__extension__
const char *
rte_cpu_get_flag_name(enum rte_cpu_flag_t feature);
@@ -68,6 +70,7 @@ rte_cpu_get_flag_name(enum rte_cpu_flag_t feature);
* 0 if flag is not available
* -ENOENT if flag is invalid
*/
+__extension__
int
rte_cpu_get_flag_enabled(enum rte_cpu_flag_t feature);
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* [dpdk-dev] [PATCH v2 09/11] lib: remove named variadic macros in exported headers
2016-07-05 10:44 ` [dpdk-dev] [PATCH v2 00/11] Fix build errors related to exported headers Adrien Mazarguil
` (7 preceding siblings ...)
2016-07-05 10:44 ` [dpdk-dev] [PATCH v2 08/11] lib: work around forward reference to enum types Adrien Mazarguil
@ 2016-07-05 10:44 ` Adrien Mazarguil
2016-07-05 10:44 ` [dpdk-dev] [PATCH v2 10/11] lib: hide static functions never defined Adrien Mazarguil
` (5 subsequent siblings)
14 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-07-05 10:44 UTC (permalink / raw)
To: dev
Exported header files used by applications should allow the strictest
compiler flags. Language extensions used in many places must be explicitly
marked or removed to avoid warnings and compilation failures.
Since there is no way to force named variadic macros as extensions, use a
a standard __VA_ARGS__ with an extra dummy argument to format strings.
This commit prevents the following errors:
error: ISO C does not permit named variadic macros
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
lib/librte_cryptodev/rte_cryptodev.h | 32 ++++++++++++++-----------
lib/librte_cryptodev/rte_cryptodev_pmd.h | 2 +-
lib/librte_eal/common/include/rte_common.h | 9 +++++++
3 files changed, 28 insertions(+), 15 deletions(-)
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index be9a544..febea9b 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -77,26 +77,30 @@ extern const char **rte_cyptodev_names;
/* Logging Macros */
-#define CDEV_LOG_ERR(fmt, args...) \
- RTE_LOG(ERR, CRYPTODEV, "%s() line %u: " fmt "\n", \
- __func__, __LINE__, ## args)
+#define CDEV_LOG_ERR(...) \
+ RTE_LOG(ERR, CRYPTODEV, \
+ RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
+ __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__,)))
-#define CDEV_PMD_LOG_ERR(dev, fmt, args...) \
- RTE_LOG(ERR, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \
- dev, __func__, __LINE__, ## args)
+#define CDEV_PMD_LOG_ERR(dev, ...) \
+ RTE_LOG(ERR, CRYPTODEV, \
+ RTE_FMT("[%s] %s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
+ dev, __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__,)))
#ifdef RTE_LIBRTE_CRYPTODEV_DEBUG
-#define CDEV_LOG_DEBUG(fmt, args...) \
- RTE_LOG(DEBUG, CRYPTODEV, "%s() line %u: " fmt "\n", \
- __func__, __LINE__, ## args) \
+#define CDEV_LOG_DEBUG(...) \
+ RTE_LOG(DEBUG, CRYPTODEV, \
+ RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
+ __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__,)))
-#define CDEV_PMD_TRACE(fmt, args...) \
- RTE_LOG(DEBUG, CRYPTODEV, "[%s] %s: " fmt "\n", \
- dev, __func__, ## args)
+#define CDEV_PMD_TRACE(...) \
+ RTE_LOG(DEBUG, CRYPTODEV, \
+ RTE_FMT("[%s] %s: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
+ dev, __func__, RTE_FMT_TAIL(__VA_ARGS__,)))
#else
-#define CDEV_LOG_DEBUG(fmt, args...)
-#define CDEV_PMD_TRACE(fmt, args...)
+#define CDEV_LOG_DEBUG(...) (void)0
+#define CDEV_PMD_TRACE(...) (void)0
#endif
/**
diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h b/lib/librte_cryptodev/rte_cryptodev_pmd.h
index cf08a50..4a07362 100644
--- a/lib/librte_cryptodev/rte_cryptodev_pmd.h
+++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h
@@ -62,7 +62,7 @@ extern "C" {
#define RTE_PMD_DEBUG_TRACE(...) \
rte_pmd_debug_trace(__func__, __VA_ARGS__)
#else
-#define RTE_PMD_DEBUG_TRACE(fmt, args...)
+#define RTE_PMD_DEBUG_TRACE(...)
#endif
struct rte_cryptodev_session {
diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h
index 98ecc1c..db5ac91 100644
--- a/lib/librte_eal/common/include/rte_common.h
+++ b/lib/librte_eal/common/include/rte_common.h
@@ -335,6 +335,15 @@ rte_bsf32(uint32_t v)
/** Take a macro value and get a string version of it */
#define RTE_STR(x) _RTE_STR(x)
+/**
+ * ISO C helpers to modify format strings using variadic macros.
+ * This is a replacement for the ", ## __VA_ARGS__" GNU extension.
+ * An empty %s argument is appended to avoid a dangling comma.
+ */
+#define RTE_FMT(fmt, ...) fmt "%.0s", __VA_ARGS__ ""
+#define RTE_FMT_HEAD(fmt, ...) fmt
+#define RTE_FMT_TAIL(fmt, ...) __VA_ARGS__
+
/** Mask value of type "tp" for the first "ln" bit set. */
#define RTE_LEN2MASK(ln, tp) \
((tp)((uint64_t)-1 >> (sizeof(uint64_t) * CHAR_BIT - (ln))))
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* [dpdk-dev] [PATCH v2 10/11] lib: hide static functions never defined
2016-07-05 10:44 ` [dpdk-dev] [PATCH v2 00/11] Fix build errors related to exported headers Adrien Mazarguil
` (8 preceding siblings ...)
2016-07-05 10:44 ` [dpdk-dev] [PATCH v2 09/11] lib: remove named variadic macros in exported headers Adrien Mazarguil
@ 2016-07-05 10:44 ` Adrien Mazarguil
2016-07-05 10:44 ` [dpdk-dev] [PATCH v2 11/11] scripts: check compilation of exported header files Adrien Mazarguil
` (4 subsequent siblings)
14 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-07-05 10:44 UTC (permalink / raw)
To: dev
Arch-specific functions not defined for all architectures (missing on x86
in this case) and not used anywhere should not expose a prototype.
This commit prevents the following error:
error: `rte_mov48' declared `static' but never defined
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
lib/librte_eal/common/include/generic/rte_memcpy.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lib/librte_eal/common/include/generic/rte_memcpy.h b/lib/librte_eal/common/include/generic/rte_memcpy.h
index afb0afe..4e9d879 100644
--- a/lib/librte_eal/common/include/generic/rte_memcpy.h
+++ b/lib/librte_eal/common/include/generic/rte_memcpy.h
@@ -64,6 +64,8 @@ rte_mov16(uint8_t *dst, const uint8_t *src);
static inline void
rte_mov32(uint8_t *dst, const uint8_t *src);
+#ifdef __DOXYGEN__
+
/**
* Copy 48 bytes from one location to another using optimised
* instructions. The locations should not overlap.
@@ -76,6 +78,8 @@ rte_mov32(uint8_t *dst, const uint8_t *src);
static inline void
rte_mov48(uint8_t *dst, const uint8_t *src);
+#endif /* __DOXYGEN__ */
+
/**
* Copy 64 bytes from one location to another using optimised
* instructions. The locations should not overlap.
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* [dpdk-dev] [PATCH v2 11/11] scripts: check compilation of exported header files
2016-07-05 10:44 ` [dpdk-dev] [PATCH v2 00/11] Fix build errors related to exported headers Adrien Mazarguil
` (9 preceding siblings ...)
2016-07-05 10:44 ` [dpdk-dev] [PATCH v2 10/11] lib: hide static functions never defined Adrien Mazarguil
@ 2016-07-05 10:44 ` Adrien Mazarguil
2016-07-05 11:15 ` [dpdk-dev] [PATCH v2 00/11] Fix build errors related to exported headers Jan Viktorin
` (3 subsequent siblings)
14 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-07-05 10:44 UTC (permalink / raw)
To: dev
This script checks that header files in a given directory do not miss
dependencies when included on their own, do not conflict and accept being
compiled with the strictest possible flags.
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
MAINTAINERS | 1 +
scripts/check-includes.sh | 286 +++++++++++++++++++++++++++++++++++++++++
scripts/test-build.sh | 14 ++
3 files changed, 301 insertions(+)
diff --git a/MAINTAINERS b/MAINTAINERS
index a59191e..c12db3d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -26,6 +26,7 @@ T: git://dpdk.org/dpdk
F: MAINTAINERS
F: scripts/check-maintainers.sh
F: scripts/check-git-log.sh
+F: scripts/check-includes.sh
F: scripts/checkpatches.sh
F: scripts/load-devel-config.sh
F: scripts/test-build.sh
diff --git a/scripts/check-includes.sh b/scripts/check-includes.sh
new file mode 100755
index 0000000..d65adc6
--- /dev/null
+++ b/scripts/check-includes.sh
@@ -0,0 +1,286 @@
+#!/bin/sh -e
+#
+# BSD LICENSE
+#
+# Copyright 2016 6WIND S.A.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of 6WIND S.A. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# This script checks that header files in a given directory do not miss
+# dependencies when included on their own, do not conflict and accept being
+# compiled with the strictest possible flags.
+#
+# Files are looked up in the directory provided as the first argument,
+# otherwise build/include by default.
+#
+# Recognized environment variables:
+#
+# VERBOSE=1 is the same as -v.
+#
+# QUIET=1 is the same as -q.
+#
+# SUMMARY=1 is the same as -s.
+#
+# CC, CPPFLAGS, CFLAGS, EXTRA_CPPFLAGS, EXTRA_CFLAGS, CXX, CXXFLAGS and
+# EXTRA_CXXFLAGS are taken into account.
+#
+# PEDANTIC_CFLAGS, PEDANTIC_CXXFLAGS and PEDANTIC_CPPFLAGS provide strict
+# C/C++ compilation flags.
+#
+# IGNORE contains a list of shell patterns matching files (relative to the
+# include directory) to avoid. It is set by default to known DPDK headers
+# which must not be included on their own.
+#
+# IGNORE_CXX provides additional files for C++.
+
+while getopts hqvs arg; do
+ case $arg in
+ h)
+ cat <<EOF
+usage: $0 [-h] [-q] [-v] [-s] [DIR]
+
+This script checks that header files in a given directory do not miss
+dependencies when included on their own, do not conflict and accept being
+compiled with the strictest possible flags.
+
+ -h display this help and exit
+ -q quiet mode, disable normal output
+ -v show command lines being executed
+ -s show summary
+
+With no DIR, default to build/include.
+
+Any failed header check yields a nonzero exit status.
+EOF
+ exit
+ ;;
+ q)
+ QUIET=1
+ ;;
+ v)
+ VERBOSE=1
+ ;;
+ s)
+ SUMMARY=1
+ ;;
+ *)
+ exit 1
+ ;;
+ esac
+done
+
+shift $(($OPTIND - 1))
+
+include_dir=${1:-build/include}
+
+: ${PEDANTIC_CFLAGS=-std=c99 -pedantic -Wall -Wextra -Werror}
+: ${PEDANTIC_CXXFLAGS=}
+: ${PEDANTIC_CPPFLAGS=-D_XOPEN_SOURCE=600}
+: ${CC:=cc}
+: ${CXX:=c++}
+: ${IGNORE= \
+ 'rte_atomic_32.h' \
+ 'rte_atomic_64.h' \
+ 'rte_byteorder_32.h' \
+ 'rte_byteorder_64.h' \
+ 'generic/*' \
+ 'exec-env/*' \
+}
+: ${IGNORE_CXX= \
+ 'rte_eth_vhost.h' \
+ 'rte_virtio_net.h' \
+}
+
+temp_cc=/tmp/${0##*/}.$$.c
+pass_cc=
+failures_cc=0
+
+temp_cxx=/tmp/${0##*/}.$$.cc
+pass_cxx=
+failures_cxx=0
+
+# Process output parameters.
+
+[ "$QUIET" = 1 ] &&
+exec 1> /dev/null
+
+[ "$VERBOSE" = 1 ] &&
+output ()
+{
+ local CCV
+ local CXXV
+
+ shift
+ CCV=$CC
+ CXXV=$CXX
+ CC="echo $CC" CXX="echo $CXX" "$@"
+ CC=$CCV
+ CXX=$CXXV
+
+ "$@"
+} ||
+output ()
+{
+
+ printf ' %s\n' "$1"
+ shift
+ "$@"
+}
+
+trap 'rm -f "$temp_cc" "$temp_cxx"' EXIT
+
+compile_cc ()
+{
+ ${CC} -I"$include_dir" \
+ ${PEDANTIC_CPPFLAGS} ${CPPFLAGS} ${EXTRA_CPPFLAGS} \
+ ${PEDANTIC_CFLAGS} ${CFLAGS} ${EXTRA_CFLAGS} \
+ -c -o /dev/null "${temp_cc}"
+}
+
+compile_cxx ()
+{
+ ${CXX} -I"$include_dir" \
+ ${PEDANTIC_CPPFLAGS} ${CPPFLAGS} ${EXTRA_CPPFLAGS} \
+ ${PEDANTIC_CXXFLAGS} ${CXXFLAGS} ${EXTRA_CXXFLAGS} \
+ -c -o /dev/null "${temp_cxx}"
+}
+
+ignore ()
+{
+ file="$1"
+ shift
+ while [ $# -ne 0 ]; do
+ case "$file" in
+ $1)
+ return 0
+ ;;
+ esac
+ shift
+ done
+ return 1
+}
+
+# Check C/C++ compilation for each header file.
+
+while read -r path
+do
+ file=${path#$include_dir}
+ file=${file##/}
+ if ignore "$file" $IGNORE; then
+ output "SKIP $file" :
+ continue
+ fi
+ if printf "\
+#include <%s>
+
+int main(void)
+{
+ return 0;
+}
+" "$file" > "$temp_cc" &&
+ output "CC $file" compile_cc
+ then
+ pass_cc="$pass_cc $file"
+ else
+ failures_cc=$(($failures_cc + 1))
+ fi
+ if ignore "$file" $IGNORE_CXX; then
+ output "SKIP CXX $file" :
+ continue
+ fi
+ if printf "\
+#include <%s>
+
+int main()
+{
+}
+" "$file" > "$temp_cxx" &&
+ output "CXX $file" compile_cxx
+ then
+ pass_cxx="$pass_cxx $file"
+ else
+ failures_cxx=$(($failures_cxx + 1))
+ fi
+done <<EOF
+$(find "$include_dir" -name '*.h')
+EOF
+
+# Check C compilation with all includes.
+
+: > "$temp_cc" &&
+for file in $pass_cc; do
+ printf "\
+#include <%s>
+" "$file" >> $temp_cc
+done
+if printf "\
+int main(void)
+{
+ return 0;
+}
+" >> "$temp_cc" &&
+ output "CC (all includes that did not fail)" compile_cc
+then
+ :
+else
+ failures_cc=$(($failures_cc + 1))
+fi
+
+# Check C++ compilation with all includes.
+
+: > "$temp_cxx" &&
+for file in $pass_cxx; do
+ printf "\
+#include <%s>
+" "$file" >> $temp_cxx
+done
+if printf "\
+int main()
+{
+}
+" >> "$temp_cxx" &&
+ output "CXX (all includes that did not fail)" compile_cxx
+then
+ :
+else
+ failures_cxx=$(($failures_cxx + 1))
+fi
+
+# Report results.
+
+if [ "$SUMMARY" = 1 ]; then
+ printf "\
+Summary:
+ %u failure(s) for C using '%s'.
+ %u failure(s) for C++ using '%s'.
+" $failures_cc "$CC" $failures_cxx "$CXX" 1>&2
+fi
+
+# Exit with nonzero status if there are failures.
+
+[ $failures_cc -eq 0 ] &&
+[ $failures_cxx -eq 0 ]
diff --git a/scripts/test-build.sh b/scripts/test-build.sh
index 5bcecfc..b2ea602 100755
--- a/scripts/test-build.sh
+++ b/scripts/test-build.sh
@@ -229,6 +229,20 @@ for conf in $configs ; do
make -j$J -sC examples/performance-thread \
EXTRA_LDFLAGS="$DPDK_DEP_LDFLAGS" $verbose \
O=$(readlink -m $dir/examples/performance-thread)
+ echo "================== Check includes in $dir"
+ if echo $target | grep -q 'gcc'; then
+ CC=gcc
+ CXX=g++
+ elif echo $target | grep -q 'clang'; then
+ CC=clang
+ CXX=clang++
+ else
+ CXX=$CC
+ fi
+ CC=$CROSS$CC CXX=$CROSS$CXX \
+ VERBOSE="$((! ! ${#verbose}))" \
+ QUIET="$((! ${#verbose}))" \
+ scripts/check-includes.sh "$dir/include"
unset RTE_TARGET
echo "################## $dir done."
done
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* Re: [dpdk-dev] [PATCH v2 00/11] Fix build errors related to exported headers
2016-07-05 10:44 ` [dpdk-dev] [PATCH v2 00/11] Fix build errors related to exported headers Adrien Mazarguil
` (10 preceding siblings ...)
2016-07-05 10:44 ` [dpdk-dev] [PATCH v2 11/11] scripts: check compilation of exported header files Adrien Mazarguil
@ 2016-07-05 11:15 ` Jan Viktorin
2016-07-05 11:35 ` Adrien Mazarguil
2016-07-05 11:27 ` Ferruh Yigit
` (2 subsequent siblings)
14 siblings, 1 reply; 79+ messages in thread
From: Jan Viktorin @ 2016-07-05 11:15 UTC (permalink / raw)
To: Adrien Mazarguil, dev
Hi Adrien,
I am the only one in CC and only in the 00/11 patch. Is it a mistake? Or what is the purpose?
Regards
Jan Viktorin
RehiveTech
Sent from a mobile device
Původní zpráva
Od: Adrien Mazarguil
Odesláno: úterý, 5. července 2016 12:45
Komu: dev@dpdk.org
Kopie: Jan Viktorin
Předmět: [PATCH v2 00/11] Fix build errors related to exported headers
DPDK uses GNU C language extensions in most of its code base. This is fine
for internal source files whose compilation flags are controlled by DPDK,
however user applications that use exported "public" headers may experience
compilation failures when enabling strict error/standard checks (-std and
-pedantic for instance).
Exported headers are installed system-wide and must be as clean as possible
so applications do not have to resort to workarounds.
This patchset affects exported headers only, compilation problems are
addressed as follows:
- Adding the __extension__ keyword to nonstandard constructs (same method
as existing libraries when there is no other choice).
- Adding the __extension__ keyword to C11 constructs to remain compatible
with pure C99.
- Adding missing includes so exported files can be included out of order
and on their own.
- Fixing GNU printf-like variadic macros as there is no magic keyword for
these.
Changes in v2:
- Rebased on top of the current HEAD.
- Added script to check headers automatically (check-includes.sh), for both
C and C++ compilation.
- Updated test-build.sh to use it.
- Fixed consistency of new #include directives, now inside extern "C"
blocks for files that already do that (Jan, fixing these was too much
work for this patchset so I settled on this solution in the meantime).
- Updated headlines to address check-git-log.sh complaints.
Adrien Mazarguil (11):
lib: work around braced-groups within expressions
lib: work around large enum values
lib: use C99 syntax for zero-size arrays
lib: work around nonstandard bit-fields
lib: work around structs with no members
lib: work around unnamed structs/unions
lib: add missing include dependencies
lib: work around forward reference to enum types
lib: remove named variadic macros in exported headers
lib: hide static functions never defined
scripts: check compilation of exported header files
MAINTAINERS | 1 +
lib/librte_acl/rte_acl.h | 2 +-
lib/librte_cfgfile/rte_cfgfile.h | 2 +
lib/librte_cmdline/cmdline.h | 1 +
lib/librte_cmdline/cmdline_parse_portlist.h | 1 +
lib/librte_cmdline/cmdline_socket.h | 3 +
lib/librte_cryptodev/rte_crypto.h | 2 +
lib/librte_cryptodev/rte_crypto_sym.h | 3 +
lib/librte_cryptodev/rte_cryptodev.h | 40 ++-
lib/librte_cryptodev/rte_cryptodev_pmd.h | 6 +-
.../common/include/arch/arm/rte_byteorder.h | 2 +
.../common/include/arch/arm/rte_memcpy_32.h | 3 +-
.../common/include/arch/arm/rte_prefetch_32.h | 1 +
.../common/include/arch/arm/rte_prefetch_64.h | 1 +
.../common/include/arch/arm/rte_vect.h | 1 +
.../common/include/arch/ppc_64/rte_atomic.h | 1 +
.../common/include/arch/ppc_64/rte_byteorder.h | 1 +
.../common/include/arch/ppc_64/rte_cycles.h | 2 +
.../common/include/arch/ppc_64/rte_memcpy.h | 3 +-
.../common/include/arch/ppc_64/rte_prefetch.h | 1 +
.../common/include/arch/x86/rte_atomic.h | 2 +
.../common/include/arch/x86/rte_atomic_32.h | 9 +
.../common/include/arch/x86/rte_atomic_64.h | 8 +
.../common/include/arch/x86/rte_byteorder.h | 2 +
.../common/include/arch/x86/rte_byteorder_32.h | 7 +
.../common/include/arch/x86/rte_byteorder_64.h | 7 +
.../common/include/arch/x86/rte_cycles.h | 2 +
.../common/include/arch/x86/rte_memcpy.h | 4 +-
.../common/include/arch/x86/rte_prefetch.h | 1 +
.../common/include/arch/x86/rte_rtm.h | 1 +
.../common/include/arch/x86/rte_vect.h | 8 +-
.../common/include/generic/rte_atomic.h | 1 +
.../common/include/generic/rte_byteorder.h | 2 +
.../common/include/generic/rte_cpuflags.h | 3 +
.../common/include/generic/rte_memcpy.h | 4 +
lib/librte_eal/common/include/rte_common.h | 22 +-
lib/librte_eal/common/include/rte_devargs.h | 1 +
lib/librte_eal/common/include/rte_eal.h | 1 +
lib/librte_eal/common/include/rte_interrupts.h | 2 +
lib/librte_eal/common/include/rte_memory.h | 4 +
lib/librte_eal/common/include/rte_memzone.h | 2 +
lib/librte_eal/common/include/rte_time.h | 8 +
lib/librte_eal/common/include/rte_version.h | 1 +
.../eal/include/exec-env/rte_interrupts.h | 1 +
.../eal/include/exec-env/rte_kni_common.h | 6 +-
lib/librte_ether/rte_dev_info.h | 2 +
lib/librte_ether/rte_eth_ctrl.h | 4 +
lib/librte_ether/rte_ethdev.h | 4 +
lib/librte_hash/rte_fbk_hash.h | 2 +-
lib/librte_hash/rte_thash.h | 3 +
lib/librte_ip_frag/rte_ip_frag.h | 2 +-
lib/librte_lpm/rte_lpm.h | 7 +-
lib/librte_lpm/rte_lpm_neon.h | 1 +
lib/librte_lpm/rte_lpm_sse.h | 1 +
lib/librte_mbuf/rte_mbuf.h | 9 +
lib/librte_mempool/rte_mempool.h | 3 +
lib/librte_pdump/rte_pdump.h | 4 +
lib/librte_pipeline/rte_pipeline.h | 4 +-
lib/librte_reorder/rte_reorder.h | 2 +
lib/librte_ring/rte_ring.h | 2 +-
lib/librte_sched/rte_bitmap.h | 3 +-
lib/librte_sched/rte_reciprocal.h | 2 +
lib/librte_sched/rte_sched_common.h | 1 +
lib/librte_timer/rte_timer.h | 2 +
scripts/check-includes.sh | 286 +++++++++++++++++++
scripts/test-build.sh | 14 +
66 files changed, 511 insertions(+), 33 deletions(-)
create mode 100755 scripts/check-includes.sh
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* Re: [dpdk-dev] [PATCH v2 00/11] Fix build errors related to exported headers
2016-07-05 11:15 ` [dpdk-dev] [PATCH v2 00/11] Fix build errors related to exported headers Jan Viktorin
@ 2016-07-05 11:35 ` Adrien Mazarguil
0 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-07-05 11:35 UTC (permalink / raw)
To: Jan Viktorin; +Cc: dev
Hi Jan,
On Tue, Jul 05, 2016 at 01:15:23PM +0200, Jan Viktorin wrote:
> Hi Adrien,
>
> I am the only one in CC and only in the 00/11 patch. Is it a mistake? Or what is the purpose?
It was on purpose to draw your attention to my comment regarding #includes
within extern "C" blocks.
> Regards
> Jan Viktorin
> RehiveTech
> Sent from a mobile device
> Původní zpráva
> Od: Adrien Mazarguil
> Odesláno: úterý, 5. července 2016 12:45
> Komu: dev@dpdk.org
> Kopie: Jan Viktorin
> Předmět: [PATCH v2 00/11] Fix build errors related to exported headers
>
> DPDK uses GNU C language extensions in most of its code base. This is fine
> for internal source files whose compilation flags are controlled by DPDK,
> however user applications that use exported "public" headers may experience
> compilation failures when enabling strict error/standard checks (-std and
> -pedantic for instance).
>
> Exported headers are installed system-wide and must be as clean as possible
> so applications do not have to resort to workarounds.
>
> This patchset affects exported headers only, compilation problems are
> addressed as follows:
>
> - Adding the __extension__ keyword to nonstandard constructs (same method
> as existing libraries when there is no other choice).
> - Adding the __extension__ keyword to C11 constructs to remain compatible
> with pure C99.
> - Adding missing includes so exported files can be included out of order
> and on their own.
> - Fixing GNU printf-like variadic macros as there is no magic keyword for
> these.
>
> Changes in v2:
>
> - Rebased on top of the current HEAD.
> - Added script to check headers automatically (check-includes.sh), for both
> C and C++ compilation.
> - Updated test-build.sh to use it.
> - Fixed consistency of new #include directives, now inside extern "C"
> blocks for files that already do that (Jan, fixing these was too much
> work for this patchset so I settled on this solution in the meantime).
> - Updated headlines to address check-git-log.sh complaints.
>
> Adrien Mazarguil (11):
> lib: work around braced-groups within expressions
> lib: work around large enum values
> lib: use C99 syntax for zero-size arrays
> lib: work around nonstandard bit-fields
> lib: work around structs with no members
> lib: work around unnamed structs/unions
> lib: add missing include dependencies
> lib: work around forward reference to enum types
> lib: remove named variadic macros in exported headers
> lib: hide static functions never defined
> scripts: check compilation of exported header files
>
> MAINTAINERS | 1 +
> lib/librte_acl/rte_acl.h | 2 +-
> lib/librte_cfgfile/rte_cfgfile.h | 2 +
> lib/librte_cmdline/cmdline.h | 1 +
> lib/librte_cmdline/cmdline_parse_portlist.h | 1 +
> lib/librte_cmdline/cmdline_socket.h | 3 +
> lib/librte_cryptodev/rte_crypto.h | 2 +
> lib/librte_cryptodev/rte_crypto_sym.h | 3 +
> lib/librte_cryptodev/rte_cryptodev.h | 40 ++-
> lib/librte_cryptodev/rte_cryptodev_pmd.h | 6 +-
> .../common/include/arch/arm/rte_byteorder.h | 2 +
> .../common/include/arch/arm/rte_memcpy_32.h | 3 +-
> .../common/include/arch/arm/rte_prefetch_32.h | 1 +
> .../common/include/arch/arm/rte_prefetch_64.h | 1 +
> .../common/include/arch/arm/rte_vect.h | 1 +
> .../common/include/arch/ppc_64/rte_atomic.h | 1 +
> .../common/include/arch/ppc_64/rte_byteorder.h | 1 +
> .../common/include/arch/ppc_64/rte_cycles.h | 2 +
> .../common/include/arch/ppc_64/rte_memcpy.h | 3 +-
> .../common/include/arch/ppc_64/rte_prefetch.h | 1 +
> .../common/include/arch/x86/rte_atomic.h | 2 +
> .../common/include/arch/x86/rte_atomic_32.h | 9 +
> .../common/include/arch/x86/rte_atomic_64.h | 8 +
> .../common/include/arch/x86/rte_byteorder.h | 2 +
> .../common/include/arch/x86/rte_byteorder_32.h | 7 +
> .../common/include/arch/x86/rte_byteorder_64.h | 7 +
> .../common/include/arch/x86/rte_cycles.h | 2 +
> .../common/include/arch/x86/rte_memcpy.h | 4 +-
> .../common/include/arch/x86/rte_prefetch.h | 1 +
> .../common/include/arch/x86/rte_rtm.h | 1 +
> .../common/include/arch/x86/rte_vect.h | 8 +-
> .../common/include/generic/rte_atomic.h | 1 +
> .../common/include/generic/rte_byteorder.h | 2 +
> .../common/include/generic/rte_cpuflags.h | 3 +
> .../common/include/generic/rte_memcpy.h | 4 +
> lib/librte_eal/common/include/rte_common.h | 22 +-
> lib/librte_eal/common/include/rte_devargs.h | 1 +
> lib/librte_eal/common/include/rte_eal.h | 1 +
> lib/librte_eal/common/include/rte_interrupts.h | 2 +
> lib/librte_eal/common/include/rte_memory.h | 4 +
> lib/librte_eal/common/include/rte_memzone.h | 2 +
> lib/librte_eal/common/include/rte_time.h | 8 +
> lib/librte_eal/common/include/rte_version.h | 1 +
> .../eal/include/exec-env/rte_interrupts.h | 1 +
> .../eal/include/exec-env/rte_kni_common.h | 6 +-
> lib/librte_ether/rte_dev_info.h | 2 +
> lib/librte_ether/rte_eth_ctrl.h | 4 +
> lib/librte_ether/rte_ethdev.h | 4 +
> lib/librte_hash/rte_fbk_hash.h | 2 +-
> lib/librte_hash/rte_thash.h | 3 +
> lib/librte_ip_frag/rte_ip_frag.h | 2 +-
> lib/librte_lpm/rte_lpm.h | 7 +-
> lib/librte_lpm/rte_lpm_neon.h | 1 +
> lib/librte_lpm/rte_lpm_sse.h | 1 +
> lib/librte_mbuf/rte_mbuf.h | 9 +
> lib/librte_mempool/rte_mempool.h | 3 +
> lib/librte_pdump/rte_pdump.h | 4 +
> lib/librte_pipeline/rte_pipeline.h | 4 +-
> lib/librte_reorder/rte_reorder.h | 2 +
> lib/librte_ring/rte_ring.h | 2 +-
> lib/librte_sched/rte_bitmap.h | 3 +-
> lib/librte_sched/rte_reciprocal.h | 2 +
> lib/librte_sched/rte_sched_common.h | 1 +
> lib/librte_timer/rte_timer.h | 2 +
> scripts/check-includes.sh | 286 +++++++++++++++++++
> scripts/test-build.sh | 14 +
> 66 files changed, 511 insertions(+), 33 deletions(-)
> create mode 100755 scripts/check-includes.sh
>
> --
> 2.1.4
>
--
Adrien Mazarguil
6WIND
^ permalink raw reply [flat|nested] 79+ messages in thread
* Re: [dpdk-dev] [PATCH v2 00/11] Fix build errors related to exported headers
2016-07-05 10:44 ` [dpdk-dev] [PATCH v2 00/11] Fix build errors related to exported headers Adrien Mazarguil
` (11 preceding siblings ...)
2016-07-05 11:15 ` [dpdk-dev] [PATCH v2 00/11] Fix build errors related to exported headers Jan Viktorin
@ 2016-07-05 11:27 ` Ferruh Yigit
2016-07-05 12:33 ` Thomas Monjalon
2016-07-05 12:37 ` Adrien Mazarguil
2016-07-06 16:34 ` Thomas Monjalon
2016-07-07 15:49 ` [dpdk-dev] [PATCH v3 " Adrien Mazarguil
14 siblings, 2 replies; 79+ messages in thread
From: Ferruh Yigit @ 2016-07-05 11:27 UTC (permalink / raw)
To: Adrien Mazarguil, dev; +Cc: Jan Viktorin
On 7/5/2016 11:44 AM, Adrien Mazarguil wrote:
> DPDK uses GNU C language extensions in most of its code base. This is fine
> for internal source files whose compilation flags are controlled by DPDK,
> however user applications that use exported "public" headers may experience
> compilation failures when enabling strict error/standard checks (-std and
> -pedantic for instance).
Out of curiosity, is there a specific standard version that is targeted?
^ permalink raw reply [flat|nested] 79+ messages in thread
* Re: [dpdk-dev] [PATCH v2 00/11] Fix build errors related to exported headers
2016-07-05 11:27 ` Ferruh Yigit
@ 2016-07-05 12:33 ` Thomas Monjalon
2016-07-05 12:37 ` Adrien Mazarguil
1 sibling, 0 replies; 79+ messages in thread
From: Thomas Monjalon @ 2016-07-05 12:33 UTC (permalink / raw)
To: Ferruh Yigit; +Cc: dev, Adrien Mazarguil
2016-07-05 12:27, Ferruh Yigit:
> On 7/5/2016 11:44 AM, Adrien Mazarguil wrote:
> > DPDK uses GNU C language extensions in most of its code base. This is fine
> > for internal source files whose compilation flags are controlled by DPDK,
> > however user applications that use exported "public" headers may experience
> > compilation failures when enabling strict error/standard checks (-std and
> > -pedantic for instance).
>
> Out of curiosity, is there a specific standard version that is targeted?
In the last patch (scripts/check-includes.sh), there is this:
+: ${PEDANTIC_CFLAGS=-std=c99 -pedantic -Wall -Wextra -Werror}
+: ${PEDANTIC_CXXFLAGS=}
+: ${PEDANTIC_CPPFLAGS=-D_XOPEN_SOURCE=600}
I guess it means that strict C99 is targeted and there is no standard
requirement for C++.
^ permalink raw reply [flat|nested] 79+ messages in thread
* Re: [dpdk-dev] [PATCH v2 00/11] Fix build errors related to exported headers
2016-07-05 11:27 ` Ferruh Yigit
2016-07-05 12:33 ` Thomas Monjalon
@ 2016-07-05 12:37 ` Adrien Mazarguil
1 sibling, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-07-05 12:37 UTC (permalink / raw)
To: Ferruh Yigit; +Cc: dev, Jan Viktorin
On Tue, Jul 05, 2016 at 12:27:06PM +0100, Ferruh Yigit wrote:
> On 7/5/2016 11:44 AM, Adrien Mazarguil wrote:
> > DPDK uses GNU C language extensions in most of its code base. This is fine
> > for internal source files whose compilation flags are controlled by DPDK,
> > however user applications that use exported "public" headers may experience
> > compilation failures when enabling strict error/standard checks (-std and
> > -pedantic for instance).
>
> Out of curiosity, is there a specific standard version that is targeted?
Considering past discussions on more or less related topics (such as [1]), I
think we target at least C99 compliance for exported headers only. It can be
even better if we manage to have them comply with C90 but I think it is not
worth the effort, as all the compilers we support do understand C99. C11
support is not widespread enough yet.
Note that even after applying this series, exported headers are not really
C99 compliant. Extensions are only made clear through the use of
__extension__ keywords (and a few minor changes) that non-compliant
statements are perfectly normal and compilers should not worry about them
when compiling user applications with stricter flags than usual (-pedantic).
Remember that the rest of DPDK can use whatever internally without explicit
keywords as long as it works with the default set of options and all
supported compiler versions for targetted platforms. This series does not
change anything in this regard.
Also C++ compat is on currently only on a best effort basis. Works as long
as -pedantic is not specified, that is a task for later if we really want
full compliance.
In short:
- Exported headers: C99, C++11 (best effort)
- Internally: GNU C99/C11, no C++ (but I guess it would be C++11 considering
the number of extensions we'd need otherwise).
[1] http://dpdk.org/ml/archives/dev/2015-November/027355.html
--
Adrien Mazarguil
6WIND
^ permalink raw reply [flat|nested] 79+ messages in thread
* Re: [dpdk-dev] [PATCH v2 00/11] Fix build errors related to exported headers
2016-07-05 10:44 ` [dpdk-dev] [PATCH v2 00/11] Fix build errors related to exported headers Adrien Mazarguil
` (12 preceding siblings ...)
2016-07-05 11:27 ` Ferruh Yigit
@ 2016-07-06 16:34 ` Thomas Monjalon
2016-07-07 15:49 ` [dpdk-dev] [PATCH v3 " Adrien Mazarguil
14 siblings, 0 replies; 79+ messages in thread
From: Thomas Monjalon @ 2016-07-06 16:34 UTC (permalink / raw)
To: Adrien Mazarguil; +Cc: dev, Jan Viktorin
2016-07-05 12:44, Adrien Mazarguil:
> This patchset affects exported headers only, compilation problems are
> addressed as follows:
I prefer postponing the headers changes to the very first days of
the 16.11 cycle.
^ permalink raw reply [flat|nested] 79+ messages in thread
* [dpdk-dev] [PATCH v3 00/11] Fix build errors related to exported headers
2016-07-05 10:44 ` [dpdk-dev] [PATCH v2 00/11] Fix build errors related to exported headers Adrien Mazarguil
` (13 preceding siblings ...)
2016-07-06 16:34 ` Thomas Monjalon
@ 2016-07-07 15:49 ` Adrien Mazarguil
2016-07-07 15:49 ` [dpdk-dev] [PATCH v3 01/11] lib: work around braced-groups within expressions Adrien Mazarguil
` (12 more replies)
14 siblings, 13 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-07-07 15:49 UTC (permalink / raw)
To: dev
DPDK uses GNU C language extensions in most of its code base. This is fine
for internal source files whose compilation flags are controlled by DPDK,
however user applications that use exported "public" headers may experience
compilation failures when enabling strict error/standard checks (-std and
-pedantic for instance).
Exported headers are installed system-wide and must be as clean as possible
so applications do not have to resort to workarounds.
This patchset affects exported headers only, compilation problems are
addressed as follows:
- Adding the __extension__ keyword to nonstandard constructs (same method
as existing libraries when there is no other choice).
- Adding the __extension__ keyword to C11 constructs to remain compatible
with pure C99.
- Adding missing includes so exported files can be included out of order
and on their own.
- Fixing GNU printf-like variadic macros as there is no magic keyword for
these.
Changes in v3:
- Fixed compilation issue on ARM and POWER8 due to missing parenthesis.
- Added bit-field fix for rte_kni.h.
Changes in v2:
- Rebased on top of the current HEAD.
- Added script to check headers automatically (check-includes.sh), for both
C and C++ compilation.
- Updated test-build.sh to use it.
- Fixed consistency of new #include directives, now inside extern "C"
blocks for files that already do that (Jan, fixing these was too much
work for this patchset so I settled on this solution in the meantime).
- Updated headlines to address check-git-log.sh complaints.
Adrien Mazarguil (11):
lib: work around braced-groups within expressions
lib: work around large enum values
lib: use C99 syntax for zero-size arrays
lib: work around nonstandard bit-fields
lib: work around structs with no members
lib: work around unnamed structs/unions
lib: add missing include dependencies
lib: work around forward reference to enum types
lib: remove named variadic macros in exported headers
lib: hide static functions never defined
scripts: check compilation of exported header files
MAINTAINERS | 1 +
lib/librte_acl/rte_acl.h | 2 +-
lib/librte_cfgfile/rte_cfgfile.h | 2 +
lib/librte_cmdline/cmdline.h | 1 +
lib/librte_cmdline/cmdline_parse_portlist.h | 1 +
lib/librte_cmdline/cmdline_socket.h | 3 +
lib/librte_cryptodev/rte_crypto.h | 2 +
lib/librte_cryptodev/rte_crypto_sym.h | 3 +
lib/librte_cryptodev/rte_cryptodev.h | 40 ++-
lib/librte_cryptodev/rte_cryptodev_pmd.h | 6 +-
.../common/include/arch/arm/rte_byteorder.h | 2 +
.../common/include/arch/arm/rte_memcpy_32.h | 3 +-
.../common/include/arch/arm/rte_prefetch_32.h | 1 +
.../common/include/arch/arm/rte_prefetch_64.h | 1 +
.../common/include/arch/arm/rte_vect.h | 1 +
.../common/include/arch/ppc_64/rte_atomic.h | 1 +
.../common/include/arch/ppc_64/rte_byteorder.h | 1 +
.../common/include/arch/ppc_64/rte_cycles.h | 2 +
.../common/include/arch/ppc_64/rte_memcpy.h | 3 +-
.../common/include/arch/ppc_64/rte_prefetch.h | 1 +
.../common/include/arch/x86/rte_atomic.h | 2 +
.../common/include/arch/x86/rte_atomic_32.h | 9 +
.../common/include/arch/x86/rte_atomic_64.h | 8 +
.../common/include/arch/x86/rte_byteorder.h | 2 +
.../common/include/arch/x86/rte_byteorder_32.h | 7 +
.../common/include/arch/x86/rte_byteorder_64.h | 7 +
.../common/include/arch/x86/rte_cycles.h | 2 +
.../common/include/arch/x86/rte_memcpy.h | 4 +-
.../common/include/arch/x86/rte_prefetch.h | 1 +
.../common/include/arch/x86/rte_rtm.h | 1 +
.../common/include/arch/x86/rte_vect.h | 8 +-
.../common/include/generic/rte_atomic.h | 1 +
.../common/include/generic/rte_byteorder.h | 2 +
.../common/include/generic/rte_cpuflags.h | 3 +
.../common/include/generic/rte_memcpy.h | 4 +
lib/librte_eal/common/include/rte_common.h | 22 +-
lib/librte_eal/common/include/rte_devargs.h | 1 +
lib/librte_eal/common/include/rte_eal.h | 1 +
lib/librte_eal/common/include/rte_interrupts.h | 2 +
lib/librte_eal/common/include/rte_memory.h | 4 +
lib/librte_eal/common/include/rte_memzone.h | 2 +
lib/librte_eal/common/include/rte_time.h | 8 +
lib/librte_eal/common/include/rte_version.h | 1 +
.../eal/include/exec-env/rte_interrupts.h | 1 +
.../eal/include/exec-env/rte_kni_common.h | 7 +-
lib/librte_ether/rte_dev_info.h | 2 +
lib/librte_ether/rte_eth_ctrl.h | 4 +
lib/librte_ether/rte_ethdev.h | 4 +
lib/librte_hash/rte_fbk_hash.h | 2 +-
lib/librte_hash/rte_thash.h | 3 +
lib/librte_ip_frag/rte_ip_frag.h | 2 +-
lib/librte_kni/rte_kni.h | 1 +
lib/librte_lpm/rte_lpm.h | 7 +-
lib/librte_lpm/rte_lpm_neon.h | 1 +
lib/librte_lpm/rte_lpm_sse.h | 1 +
lib/librte_mbuf/rte_mbuf.h | 9 +
lib/librte_mempool/rte_mempool.h | 3 +
lib/librte_pdump/rte_pdump.h | 4 +
lib/librte_pipeline/rte_pipeline.h | 4 +-
lib/librte_reorder/rte_reorder.h | 2 +
lib/librte_ring/rte_ring.h | 2 +-
lib/librte_sched/rte_bitmap.h | 3 +-
lib/librte_sched/rte_reciprocal.h | 2 +
lib/librte_sched/rte_sched_common.h | 1 +
lib/librte_timer/rte_timer.h | 2 +
scripts/check-includes.sh | 286 +++++++++++++++++++
scripts/test-build.sh | 14 +
67 files changed, 513 insertions(+), 33 deletions(-)
create mode 100755 scripts/check-includes.sh
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* [dpdk-dev] [PATCH v3 01/11] lib: work around braced-groups within expressions
2016-07-07 15:49 ` [dpdk-dev] [PATCH v3 " Adrien Mazarguil
@ 2016-07-07 15:49 ` Adrien Mazarguil
2016-07-07 15:49 ` [dpdk-dev] [PATCH v3 02/11] lib: work around large enum values Adrien Mazarguil
` (11 subsequent siblings)
12 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-07-07 15:49 UTC (permalink / raw)
To: dev
Exported header files used by applications should allow the strictest
compiler flags. Language extensions used in many places must be explicitly
marked or removed to avoid warnings and compilation failures.
This commit prevents the following errors:
error: ISO C forbids braced-groups within expressions
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
lib/librte_eal/common/include/arch/arm/rte_memcpy_32.h | 3 ++-
lib/librte_eal/common/include/arch/ppc_64/rte_memcpy.h | 3 ++-
lib/librte_eal/common/include/arch/x86/rte_memcpy.h | 4 ++--
lib/librte_eal/common/include/arch/x86/rte_vect.h | 6 ++++--
lib/librte_eal/common/include/rte_common.h | 6 ++++--
5 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/lib/librte_eal/common/include/arch/arm/rte_memcpy_32.h b/lib/librte_eal/common/include/arch/arm/rte_memcpy_32.h
index da6c233..c3a2619 100644
--- a/lib/librte_eal/common/include/arch/arm/rte_memcpy_32.h
+++ b/lib/librte_eal/common/include/arch/arm/rte_memcpy_32.h
@@ -148,7 +148,8 @@ rte_mov256(uint8_t *dst, const uint8_t *src)
}
#define rte_memcpy(dst, src, n) \
- ({ (__builtin_constant_p(n)) ? \
+ __extension__ ({ \
+ (__builtin_constant_p(n)) ? \
memcpy((dst), (src), (n)) : \
rte_memcpy_func((dst), (src), (n)); })
diff --git a/lib/librte_eal/common/include/arch/ppc_64/rte_memcpy.h b/lib/librte_eal/common/include/arch/ppc_64/rte_memcpy.h
index acf7aac..ca9d1dc 100644
--- a/lib/librte_eal/common/include/arch/ppc_64/rte_memcpy.h
+++ b/lib/librte_eal/common/include/arch/ppc_64/rte_memcpy.h
@@ -95,7 +95,8 @@ rte_mov256(uint8_t *dst, const uint8_t *src)
}
#define rte_memcpy(dst, src, n) \
- ({ (__builtin_constant_p(n)) ? \
+ __extension__ ({ \
+ (__builtin_constant_p(n)) ? \
memcpy((dst), (src), (n)) : \
rte_memcpy_func((dst), (src), (n)); })
diff --git a/lib/librte_eal/common/include/arch/x86/rte_memcpy.h b/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
index 413035e..b3bfc23 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
@@ -594,7 +594,7 @@ rte_mov256(uint8_t *dst, const uint8_t *src)
* - __m128i <xmm0> ~ <xmm8> must be pre-defined
*/
#define MOVEUNALIGNED_LEFT47_IMM(dst, src, len, offset) \
-({ \
+__extension__ ({ \
int tmp; \
while (len >= 128 + 16 - offset) { \
xmm0 = _mm_loadu_si128((const __m128i *)((const uint8_t *)src - offset + 0 * 16)); \
@@ -655,7 +655,7 @@ rte_mov256(uint8_t *dst, const uint8_t *src)
* - __m128i <xmm0> ~ <xmm8> used in MOVEUNALIGNED_LEFT47_IMM must be pre-defined
*/
#define MOVEUNALIGNED_LEFT47(dst, src, len, offset) \
-({ \
+__extension__ ({ \
switch (offset) { \
case 0x01: MOVEUNALIGNED_LEFT47_IMM(dst, src, n, 0x01); break; \
case 0x02: MOVEUNALIGNED_LEFT47_IMM(dst, src, n, 0x02); break; \
diff --git a/lib/librte_eal/common/include/arch/x86/rte_vect.h b/lib/librte_eal/common/include/arch/x86/rte_vect.h
index b698797..2836f2c 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_vect.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_vect.h
@@ -106,7 +106,8 @@ typedef union rte_ymm {
#endif /* __AVX__ */
#ifdef RTE_ARCH_I686
-#define _mm_cvtsi128_si64(a) ({ \
+#define _mm_cvtsi128_si64(a) \
+__extension__ ({ \
rte_xmm_t m; \
m.x = (a); \
(m.u64[0]); \
@@ -117,7 +118,8 @@ typedef union rte_ymm {
* Prior to version 12.1 icc doesn't support _mm_set_epi64x.
*/
#if (defined(__ICC) && __ICC < 1210)
-#define _mm_set_epi64x(a, b) ({ \
+#define _mm_set_epi64x(a, b) \
+__extension__ ({ \
rte_xmm_t m; \
m.u64[0] = b; \
m.u64[1] = a; \
diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h
index 332f2a4..477472b 100644
--- a/lib/librte_eal/common/include/rte_common.h
+++ b/lib/librte_eal/common/include/rte_common.h
@@ -268,7 +268,8 @@ rte_align64pow2(uint64_t v)
/**
* Macro to return the minimum of two numbers
*/
-#define RTE_MIN(a, b) ({ \
+#define RTE_MIN(a, b) \
+ __extension__ ({ \
typeof (a) _a = (a); \
typeof (b) _b = (b); \
_a < _b ? _a : _b; \
@@ -277,7 +278,8 @@ rte_align64pow2(uint64_t v)
/**
* Macro to return the maximum of two numbers
*/
-#define RTE_MAX(a, b) ({ \
+#define RTE_MAX(a, b) \
+ __extension__ ({ \
typeof (a) _a = (a); \
typeof (b) _b = (b); \
_a > _b ? _a : _b; \
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* [dpdk-dev] [PATCH v3 02/11] lib: work around large enum values
2016-07-07 15:49 ` [dpdk-dev] [PATCH v3 " Adrien Mazarguil
2016-07-07 15:49 ` [dpdk-dev] [PATCH v3 01/11] lib: work around braced-groups within expressions Adrien Mazarguil
@ 2016-07-07 15:49 ` Adrien Mazarguil
2016-07-07 15:49 ` [dpdk-dev] [PATCH v3 03/11] lib: use C99 syntax for zero-size arrays Adrien Mazarguil
` (10 subsequent siblings)
12 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-07-07 15:49 UTC (permalink / raw)
To: dev
Exported header files used by applications should allow the strictest
compiler flags. Language extensions used in many places must be explicitly
marked or removed to avoid warnings and compilation failures.
This commit prevents the following errors:
error: ISO C restricts enumerator values to range of `int'
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
lib/librte_eal/common/include/rte_memory.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/librte_eal/common/include/rte_memory.h b/lib/librte_eal/common/include/rte_memory.h
index 0661109..6a2b3f1 100644
--- a/lib/librte_eal/common/include/rte_memory.h
+++ b/lib/librte_eal/common/include/rte_memory.h
@@ -54,6 +54,7 @@ extern "C" {
#include <rte_common.h>
+__extension__
enum rte_page_sizes {
RTE_PGSIZE_4K = 1ULL << 12,
RTE_PGSIZE_64K = 1ULL << 16,
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* [dpdk-dev] [PATCH v3 03/11] lib: use C99 syntax for zero-size arrays
2016-07-07 15:49 ` [dpdk-dev] [PATCH v3 " Adrien Mazarguil
2016-07-07 15:49 ` [dpdk-dev] [PATCH v3 01/11] lib: work around braced-groups within expressions Adrien Mazarguil
2016-07-07 15:49 ` [dpdk-dev] [PATCH v3 02/11] lib: work around large enum values Adrien Mazarguil
@ 2016-07-07 15:49 ` Adrien Mazarguil
2016-07-07 15:49 ` [dpdk-dev] [PATCH v3 04/11] lib: work around nonstandard bit-fields Adrien Mazarguil
` (9 subsequent siblings)
12 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-07-07 15:49 UTC (permalink / raw)
To: dev
Exported header files used by applications should allow the strictest
compiler flags. Language extensions used in many places must be explicitly
marked or removed to avoid warnings and compilation failures.
The extension keyword is used whenever the C99 syntax cannot do it.
This commit prevents the following errors:
error: ISO C forbids zero-size array `[...]'
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
lib/librte_acl/rte_acl.h | 2 +-
lib/librte_cryptodev/rte_cryptodev.h | 2 +-
lib/librte_cryptodev/rte_cryptodev_pmd.h | 2 +-
lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h | 2 +-
lib/librte_hash/rte_fbk_hash.h | 2 +-
lib/librte_ip_frag/rte_ip_frag.h | 2 +-
lib/librte_lpm/rte_lpm.h | 2 +-
lib/librte_mbuf/rte_mbuf.h | 3 +++
lib/librte_pipeline/rte_pipeline.h | 2 +-
lib/librte_ring/rte_ring.h | 2 +-
lib/librte_sched/rte_bitmap.h | 2 +-
11 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/lib/librte_acl/rte_acl.h b/lib/librte_acl/rte_acl.h
index 0979a09..c059dc3 100644
--- a/lib/librte_acl/rte_acl.h
+++ b/lib/librte_acl/rte_acl.h
@@ -144,7 +144,7 @@ struct rte_acl_rule_data {
struct rte_acl_field field[fld_num]; \
}
-RTE_ACL_RULE_DEF(rte_acl_rule, 0);
+RTE_ACL_RULE_DEF(rte_acl_rule,);
#define RTE_ACL_RULE_SZ(fld_num) \
(sizeof(struct rte_acl_rule) + sizeof(struct rte_acl_field) * (fld_num))
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index 7768f0a..0123c24 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -759,7 +759,7 @@ struct rte_cryptodev_sym_session {
} __rte_aligned(8);
/**< Public symmetric session details */
- char _private[0];
+ char _private[];
/**< Private session material */
};
diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h b/lib/librte_cryptodev/rte_cryptodev_pmd.h
index 7d049ea..3a3845c 100644
--- a/lib/librte_cryptodev/rte_cryptodev_pmd.h
+++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h
@@ -71,7 +71,7 @@ struct rte_cryptodev_session {
struct rte_mempool *mp;
} __rte_aligned(8);
- char _private[0];
+ char _private[];
};
struct rte_cryptodev_driver;
diff --git a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
index 2acdfd9..7f458a3 100644
--- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
+++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
@@ -102,7 +102,7 @@ struct rte_kni_fifo {
volatile unsigned read; /**< Next position to be read */
unsigned len; /**< Circular buffer length */
unsigned elem_size; /**< Pointer size - for 32/64 bit OS */
- void * volatile buffer[0]; /**< The buffer contains mbuf pointers */
+ void *volatile buffer[]; /**< The buffer contains mbuf pointers */
};
/*
diff --git a/lib/librte_hash/rte_fbk_hash.h b/lib/librte_hash/rte_fbk_hash.h
index a430961..bd46048 100644
--- a/lib/librte_hash/rte_fbk_hash.h
+++ b/lib/librte_hash/rte_fbk_hash.h
@@ -115,7 +115,7 @@ struct rte_fbk_hash_table {
uint32_t init_val; /**< For initialising hash function. */
/** A flat table of all buckets. */
- union rte_fbk_hash_entry t[0];
+ union rte_fbk_hash_entry t[];
};
/**
diff --git a/lib/librte_ip_frag/rte_ip_frag.h b/lib/librte_ip_frag/rte_ip_frag.h
index 92cedf2..4c3faad 100644
--- a/lib/librte_ip_frag/rte_ip_frag.h
+++ b/lib/librte_ip_frag/rte_ip_frag.h
@@ -124,7 +124,7 @@ struct rte_ip_frag_tbl {
struct ip_frag_pkt *last; /**< last used entry. */
struct ip_pkt_list lru; /**< LRU list for table entries. */
struct ip_frag_tbl_stat stat; /**< statistics counters. */
- struct ip_frag_pkt pkt[0]; /**< hash table. */
+ struct ip_frag_pkt pkt[]; /**< hash table. */
};
/** IPv6 fragment extension header */
diff --git a/lib/librte_lpm/rte_lpm.h b/lib/librte_lpm/rte_lpm.h
index 2df1d67..79a4593 100644
--- a/lib/librte_lpm/rte_lpm.h
+++ b/lib/librte_lpm/rte_lpm.h
@@ -193,7 +193,7 @@ struct rte_lpm_v20 {
__rte_cache_aligned; /**< LPM tbl24 table. */
struct rte_lpm_tbl_entry_v20 tbl8[RTE_LPM_TBL8_NUM_ENTRIES]
__rte_cache_aligned; /**< LPM tbl8 table. */
- struct rte_lpm_rule_v20 rules_tbl[0] \
+ struct rte_lpm_rule_v20 rules_tbl[]
__rte_cache_aligned; /**< LPM rules. */
};
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 101485f..434ec31 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -756,8 +756,11 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask);
/* define a set of marker types that can be used to refer to set points in the
* mbuf */
+__extension__
typedef void *MARKER[0]; /**< generic marker for a point in a structure */
+__extension__
typedef uint8_t MARKER8[0]; /**< generic marker with 1B alignment */
+__extension__
typedef uint64_t MARKER64[0]; /**< marker that allows us to overwrite 8 bytes
* with a single assignment */
diff --git a/lib/librte_pipeline/rte_pipeline.h b/lib/librte_pipeline/rte_pipeline.h
index 84d1802..7736945 100644
--- a/lib/librte_pipeline/rte_pipeline.h
+++ b/lib/librte_pipeline/rte_pipeline.h
@@ -252,7 +252,7 @@ struct rte_pipeline_table_entry {
uint32_t table_id;
};
/** Start of table entry area for user defined actions and meta-data */
- uint8_t action_data[0];
+ uint8_t action_data[];
};
/**
diff --git a/lib/librte_ring/rte_ring.h b/lib/librte_ring/rte_ring.h
index eb45e41..12874f7 100644
--- a/lib/librte_ring/rte_ring.h
+++ b/lib/librte_ring/rte_ring.h
@@ -179,7 +179,7 @@ struct rte_ring {
struct rte_ring_debug_stats stats[RTE_MAX_LCORE];
#endif
- void * ring[0] __rte_cache_aligned; /**< Memory space of ring starts here.
+ void *ring[] __rte_cache_aligned; /**< Memory space of ring starts here.
* not volatile so need to be careful
* about compiler re-ordering */
};
diff --git a/lib/librte_sched/rte_bitmap.h b/lib/librte_sched/rte_bitmap.h
index ff675c5..1b5df02 100644
--- a/lib/librte_sched/rte_bitmap.h
+++ b/lib/librte_sched/rte_bitmap.h
@@ -103,7 +103,7 @@ struct rte_bitmap {
uint32_t go2; /**< Bitmap scan: Go/stop condition for current array2 cache line */
/* Storage space for array1 and array2 */
- uint8_t memory[0];
+ uint8_t memory[];
};
static inline void
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* [dpdk-dev] [PATCH v3 04/11] lib: work around nonstandard bit-fields
2016-07-07 15:49 ` [dpdk-dev] [PATCH v3 " Adrien Mazarguil
` (2 preceding siblings ...)
2016-07-07 15:49 ` [dpdk-dev] [PATCH v3 03/11] lib: use C99 syntax for zero-size arrays Adrien Mazarguil
@ 2016-07-07 15:49 ` Adrien Mazarguil
2016-07-07 15:49 ` [dpdk-dev] [PATCH v3 05/11] lib: work around structs with no members Adrien Mazarguil
` (8 subsequent siblings)
12 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-07-07 15:49 UTC (permalink / raw)
To: dev
Exported header files used by applications should allow the strictest
compiler flags. Language extensions used in many places must be explicitly
marked or removed to avoid warnings and compilation failures.
This commit prevents the following errors:
error: type of bit-field `[...]' is a GCC extension
Note: the standard does not require implementations to issue a diagnostic
message with these, and such errors do not occur with recent GCC or clang
versions. However, GCC 4.7 is still common and using the extension keyword
is easier than checking compiler version.
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
lib/librte_cryptodev/rte_cryptodev.h | 2 ++
lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h | 1 +
lib/librte_ether/rte_ethdev.h | 4 ++++
lib/librte_kni/rte_kni.h | 1 +
lib/librte_lpm/rte_lpm.h | 4 ++++
lib/librte_mbuf/rte_mbuf.h | 1 +
6 files changed, 13 insertions(+)
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index 0123c24..7991add 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -619,6 +619,7 @@ struct rte_cryptodev {
struct rte_cryptodev_cb_list link_intr_cbs;
/**< User application callback for interrupts if present */
+ __extension__
uint8_t attached : 1;
/**< Flag indicating the device is attached */
} __rte_cache_aligned;
@@ -642,6 +643,7 @@ struct rte_cryptodev_data {
char name[RTE_CRYPTODEV_NAME_MAX_LEN];
/**< Unique identifier name */
+ __extension__
uint8_t dev_started : 1;
/**< Device state: STARTED(1)/STOPPED(0) */
diff --git a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
index 7f458a3..2ef0506 100644
--- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
+++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
@@ -159,6 +159,7 @@ struct rte_kni_device_info {
uint16_t group_id; /**< Group ID */
uint32_t core_id; /**< core ID to bind for kernel thread */
+ __extension__
uint8_t force_bind : 1; /**< Flag for kernel thread binding */
/* mbuf size */
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 0f17323..755f150 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -255,6 +255,7 @@ struct rte_eth_stats {
/**
* A structure used to retrieve link-level information of an Ethernet port.
*/
+__extension__
struct rte_eth_link {
uint32_t link_speed; /**< ETH_SPEED_NUM_ */
uint16_t link_duplex : 1; /**< ETH_LINK_[HALF/FULL]_DUPLEX */
@@ -346,6 +347,7 @@ struct rte_eth_rxmode {
enum rte_eth_rx_mq_mode mq_mode;
uint32_t max_rx_pkt_len; /**< Only used if jumbo_frame enabled. */
uint16_t split_hdr_size; /**< hdr buf size (header_split enabled).*/
+ __extension__
uint16_t header_split : 1, /**< Header Split enable. */
hw_ip_checksum : 1, /**< IP/UDP/TCP checksum offload enable. */
hw_vlan_filter : 1, /**< VLAN filter enable. */
@@ -645,6 +647,7 @@ struct rte_eth_txmode {
/* For i40e specifically */
uint16_t pvid;
+ __extension__
uint8_t hw_vlan_reject_tagged : 1,
/**< If set, reject sending out tagged pkts */
hw_vlan_reject_untagged : 1,
@@ -1696,6 +1699,7 @@ struct rte_eth_dev_data {
struct ether_addr* hash_mac_addrs;
/** Device Ethernet MAC addresses of hash filtering. */
uint8_t port_id; /**< Device [external] port identifier. */
+ __extension__
uint8_t promiscuous : 1, /**< RX promiscuous mode ON(1) / OFF(0). */
scattered_rx : 1, /**< RX of scattered packets is ON(1) / OFF(0) */
all_multicast : 1, /**< RX all multicast mode ON(1) / OFF(0). */
diff --git a/lib/librte_kni/rte_kni.h b/lib/librte_kni/rte_kni.h
index 7363e6c..5f6f9e4 100644
--- a/lib/librte_kni/rte_kni.h
+++ b/lib/librte_kni/rte_kni.h
@@ -88,6 +88,7 @@ struct rte_kni_conf {
struct rte_pci_addr addr;
struct rte_pci_id id;
+ __extension__
uint8_t force_bind : 1; /* Flag to bind kernel thread */
};
diff --git a/lib/librte_lpm/rte_lpm.h b/lib/librte_lpm/rte_lpm.h
index 79a4593..28668a3 100644
--- a/lib/librte_lpm/rte_lpm.h
+++ b/lib/librte_lpm/rte_lpm.h
@@ -93,6 +93,7 @@ extern "C" {
#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
/** @internal Tbl24 entry structure. */
+__extension__
struct rte_lpm_tbl_entry_v20 {
/**
* Stores Next hop (tbl8 or tbl24 when valid_group is not set) or
@@ -116,6 +117,7 @@ struct rte_lpm_tbl_entry_v20 {
uint8_t depth :6; /**< Rule depth. */
};
+__extension__
struct rte_lpm_tbl_entry {
/**
* Stores Next hop (tbl8 or tbl24 when valid_group is not set) or
@@ -137,6 +139,7 @@ struct rte_lpm_tbl_entry {
};
#else
+__extension__
struct rte_lpm_tbl_entry_v20 {
uint8_t depth :6;
uint8_t valid_group :1;
@@ -147,6 +150,7 @@ struct rte_lpm_tbl_entry_v20 {
};
};
+__extension__
struct rte_lpm_tbl_entry {
uint32_t depth :6;
uint32_t valid_group :1;
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 434ec31..3d3e847 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -865,6 +865,7 @@ struct rte_mbuf {
/* fields to support TX offloads */
union {
uint64_t tx_offload; /**< combined for easy fetch */
+ __extension__
struct {
uint64_t l2_len:7; /**< L2 (MAC) Header Length. */
uint64_t l3_len:9; /**< L3 (IP) Header Length. */
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* [dpdk-dev] [PATCH v3 05/11] lib: work around structs with no members
2016-07-07 15:49 ` [dpdk-dev] [PATCH v3 " Adrien Mazarguil
` (3 preceding siblings ...)
2016-07-07 15:49 ` [dpdk-dev] [PATCH v3 04/11] lib: work around nonstandard bit-fields Adrien Mazarguil
@ 2016-07-07 15:49 ` Adrien Mazarguil
2016-07-07 15:49 ` [dpdk-dev] [PATCH v3 06/11] lib: work around unnamed structs/unions Adrien Mazarguil
` (7 subsequent siblings)
12 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-07-07 15:49 UTC (permalink / raw)
To: dev
Exported header files used by applications should allow the strictest
compiler flags. Language extensions used in many places must be explicitly
marked or removed to avoid warnings and compilation failures.
This commit prevents the following errors:
error: struct has no members
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
lib/librte_mempool/rte_mempool.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h
index fb7052e..fc33db8 100644
--- a/lib/librte_mempool/rte_mempool.h
+++ b/lib/librte_mempool/rte_mempool.h
@@ -169,6 +169,7 @@ STAILQ_HEAD(rte_mempool_objhdr_list, rte_mempool_objhdr);
* In debug mode, each object stored in mempools are suffixed by this
* trailer structure containing a cookie preventing memory corruptions.
*/
+__extension__
struct rte_mempool_objtlr {
#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
uint64_t cookie; /**< Debug cookie. */
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* [dpdk-dev] [PATCH v3 06/11] lib: work around unnamed structs/unions
2016-07-07 15:49 ` [dpdk-dev] [PATCH v3 " Adrien Mazarguil
` (4 preceding siblings ...)
2016-07-07 15:49 ` [dpdk-dev] [PATCH v3 05/11] lib: work around structs with no members Adrien Mazarguil
@ 2016-07-07 15:49 ` Adrien Mazarguil
2016-07-07 15:49 ` [dpdk-dev] [PATCH v3 07/11] lib: add missing include dependencies Adrien Mazarguil
` (6 subsequent siblings)
12 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-07-07 15:49 UTC (permalink / raw)
To: dev
Exported header files used by applications should allow the strictest
compiler flags. Language extensions used in many places must be explicitly
marked to avoid warnings and compilation failures.
Unnamed structs/unions are allowed since C11, however many compiler
versions do not use this mode by default.
This commit prevents the following errors:
error: ISO C99 doesn't support unnamed structs/unions
error: struct has no named members
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
lib/librte_cryptodev/rte_crypto.h | 2 ++
lib/librte_cryptodev/rte_crypto_sym.h | 3 +++
lib/librte_cryptodev/rte_cryptodev.h | 4 ++++
lib/librte_cryptodev/rte_cryptodev_pmd.h | 2 ++
lib/librte_eal/common/include/arch/ppc_64/rte_cycles.h | 2 ++
lib/librte_eal/common/include/arch/x86/rte_atomic_32.h | 3 +++
lib/librte_eal/common/include/arch/x86/rte_cycles.h | 2 ++
lib/librte_eal/common/include/rte_common.h | 7 +++++++
lib/librte_eal/common/include/rte_devargs.h | 1 +
lib/librte_eal/common/include/rte_interrupts.h | 2 ++
lib/librte_eal/common/include/rte_memory.h | 1 +
lib/librte_eal/common/include/rte_memzone.h | 2 ++
lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h | 1 +
lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h | 4 ++++
lib/librte_hash/rte_thash.h | 3 +++
lib/librte_lpm/rte_lpm.h | 1 +
lib/librte_mbuf/rte_mbuf.h | 5 +++++
lib/librte_mempool/rte_mempool.h | 2 ++
lib/librte_pipeline/rte_pipeline.h | 2 ++
lib/librte_timer/rte_timer.h | 2 ++
20 files changed, 51 insertions(+)
diff --git a/lib/librte_cryptodev/rte_crypto.h b/lib/librte_cryptodev/rte_crypto.h
index 5bc3eaa..9019518 100644
--- a/lib/librte_cryptodev/rte_crypto.h
+++ b/lib/librte_cryptodev/rte_crypto.h
@@ -48,6 +48,7 @@ extern "C" {
#include <rte_mbuf.h>
#include <rte_memory.h>
#include <rte_mempool.h>
+#include <rte_common.h>
#include "rte_crypto_sym.h"
@@ -111,6 +112,7 @@ struct rte_crypto_op {
void *opaque_data;
/**< Opaque pointer for user data */
+ RTE_STD_C11
union {
struct rte_crypto_sym_op *sym;
/**< Symmetric operation parameters */
diff --git a/lib/librte_cryptodev/rte_crypto_sym.h b/lib/librte_cryptodev/rte_crypto_sym.h
index d9bd821..8178e5a 100644
--- a/lib/librte_cryptodev/rte_crypto_sym.h
+++ b/lib/librte_cryptodev/rte_crypto_sym.h
@@ -51,6 +51,7 @@ extern "C" {
#include <rte_mbuf.h>
#include <rte_memory.h>
#include <rte_mempool.h>
+#include <rte_common.h>
/** Symmetric Cipher Algorithms */
@@ -333,6 +334,7 @@ struct rte_crypto_sym_xform {
/**< next xform in chain */
enum rte_crypto_sym_xform_type type
; /**< xform type */
+ RTE_STD_C11
union {
struct rte_crypto_auth_xform auth;
/**< Authentication / hash xform */
@@ -371,6 +373,7 @@ struct rte_crypto_sym_op {
enum rte_crypto_sym_op_sess_type sess_type;
+ RTE_STD_C11
union {
struct rte_cryptodev_sym_session *session;
/**< Handle for the initialised session context */
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index 7991add..be9a544 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -48,6 +48,7 @@ extern "C" {
#include "rte_kvargs.h"
#include "rte_crypto.h"
#include "rte_dev.h"
+#include <rte_common.h>
#define CRYPTODEV_NAME_NULL_PMD ("cryptodev_null_pmd")
/**< Null crypto PMD device name */
@@ -104,6 +105,7 @@ extern const char **rte_cyptodev_names;
struct rte_cryptodev_symmetric_capability {
enum rte_crypto_sym_xform_type xform_type;
/**< Transform type : Authentication / Cipher */
+ RTE_STD_C11
union {
struct {
enum rte_crypto_auth_algorithm algo;
@@ -177,6 +179,7 @@ struct rte_cryptodev_capabilities {
enum rte_crypto_op_type op;
/**< Operation type */
+ RTE_STD_C11
union {
struct rte_cryptodev_symmetric_capability sym;
/**< Symmetric operation capability parameters */
@@ -751,6 +754,7 @@ rte_cryptodev_enqueue_burst(uint8_t dev_id, uint16_t qp_id,
/** Cryptodev symmetric crypto session */
struct rte_cryptodev_sym_session {
+ RTE_STD_C11
struct {
uint8_t dev_id;
/**< Device Id */
diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h b/lib/librte_cryptodev/rte_cryptodev_pmd.h
index 3a3845c..cf08a50 100644
--- a/lib/librte_cryptodev/rte_cryptodev_pmd.h
+++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h
@@ -52,6 +52,7 @@ extern "C" {
#include <rte_mbuf.h>
#include <rte_mempool.h>
#include <rte_log.h>
+#include <rte_common.h>
#include "rte_crypto.h"
#include "rte_cryptodev.h"
@@ -65,6 +66,7 @@ extern "C" {
#endif
struct rte_cryptodev_session {
+ RTE_STD_C11
struct {
uint8_t dev_id;
enum rte_cryptodev_type type;
diff --git a/lib/librte_eal/common/include/arch/ppc_64/rte_cycles.h b/lib/librte_eal/common/include/arch/ppc_64/rte_cycles.h
index 64beddf..8fa6fc6 100644
--- a/lib/librte_eal/common/include/arch/ppc_64/rte_cycles.h
+++ b/lib/librte_eal/common/include/arch/ppc_64/rte_cycles.h
@@ -40,6 +40,7 @@ extern "C" {
#include "generic/rte_cycles.h"
#include <rte_byteorder.h>
+#include <rte_common.h>
/**
* Read the time base register.
@@ -52,6 +53,7 @@ rte_rdtsc(void)
{
union {
uint64_t tsc_64;
+ RTE_STD_C11
struct {
#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
uint32_t hi_32;
diff --git a/lib/librte_eal/common/include/arch/x86/rte_atomic_32.h b/lib/librte_eal/common/include/arch/x86/rte_atomic_32.h
index 400d8a9..5ce01b3 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_atomic_32.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_atomic_32.h
@@ -40,6 +40,8 @@
#ifndef _RTE_ATOMIC_I686_H_
#define _RTE_ATOMIC_I686_H_
+#include <rte_common.h>
+
/*------------------------- 64 bit atomic operations -------------------------*/
#ifndef RTE_FORCE_INTRINSICS
@@ -47,6 +49,7 @@ static inline int
rte_atomic64_cmpset(volatile uint64_t *dst, uint64_t exp, uint64_t src)
{
uint8_t res;
+ RTE_STD_C11
union {
struct {
uint32_t l32;
diff --git a/lib/librte_eal/common/include/arch/x86/rte_cycles.h b/lib/librte_eal/common/include/arch/x86/rte_cycles.h
index 6e3c7d8..5eb6ce9 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_cycles.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_cycles.h
@@ -75,12 +75,14 @@ extern "C" {
extern int rte_cycles_vmware_tsc_map;
#include <rte_branch_prediction.h>
#endif
+#include <rte_common.h>
static inline uint64_t
rte_rdtsc(void)
{
union {
uint64_t tsc_64;
+ RTE_STD_C11
struct {
uint32_t lo_32;
uint32_t hi_32;
diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h
index 477472b..98ecc1c 100644
--- a/lib/librte_eal/common/include/rte_common.h
+++ b/lib/librte_eal/common/include/rte_common.h
@@ -59,6 +59,13 @@ extern "C" {
#define asm __asm__
#endif
+/** C extension macro for environments lacking C11 features. */
+#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L
+#define RTE_STD_C11 __extension__
+#else
+#define RTE_STD_C11
+#endif
+
#ifdef RTE_ARCH_STRICT_ALIGN
typedef uint64_t unaligned_uint64_t __attribute__ ((aligned(1)));
typedef uint32_t unaligned_uint32_t __attribute__ ((aligned(1)));
diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h
index 53c59f5..c66895f 100644
--- a/lib/librte_eal/common/include/rte_devargs.h
+++ b/lib/librte_eal/common/include/rte_devargs.h
@@ -76,6 +76,7 @@ struct rte_devargs {
TAILQ_ENTRY(rte_devargs) next;
/** Type of device. */
enum rte_devtype type;
+ RTE_STD_C11
union {
/** Used if type is RTE_DEVTYPE_*_PCI. */
struct {
diff --git a/lib/librte_eal/common/include/rte_interrupts.h b/lib/librte_eal/common/include/rte_interrupts.h
index ff11ef3..fd3c6ef 100644
--- a/lib/librte_eal/common/include/rte_interrupts.h
+++ b/lib/librte_eal/common/include/rte_interrupts.h
@@ -34,6 +34,8 @@
#ifndef _RTE_INTERRUPTS_H_
#define _RTE_INTERRUPTS_H_
+#include <rte_common.h>
+
/**
* @file
*
diff --git a/lib/librte_eal/common/include/rte_memory.h b/lib/librte_eal/common/include/rte_memory.h
index 6a2b3f1..38fbe74 100644
--- a/lib/librte_eal/common/include/rte_memory.h
+++ b/lib/librte_eal/common/include/rte_memory.h
@@ -104,6 +104,7 @@ typedef uint64_t phys_addr_t; /**< Physical address definition. */
*/
struct rte_memseg {
phys_addr_t phys_addr; /**< Start physical address. */
+ RTE_STD_C11
union {
void *addr; /**< Start virtual address. */
uint64_t addr_64; /**< Makes sure addr is always 64 bits */
diff --git a/lib/librte_eal/common/include/rte_memzone.h b/lib/librte_eal/common/include/rte_memzone.h
index f69b5a8..c3caf6e 100644
--- a/lib/librte_eal/common/include/rte_memzone.h
+++ b/lib/librte_eal/common/include/rte_memzone.h
@@ -53,6 +53,7 @@
#include <stdio.h>
#include <rte_memory.h>
+#include <rte_common.h>
#ifdef __cplusplus
extern "C" {
@@ -78,6 +79,7 @@ struct rte_memzone {
char name[RTE_MEMZONE_NAMESIZE]; /**< Name of the memory zone. */
phys_addr_t phys_addr; /**< Start physical address. */
+ RTE_STD_C11
union {
void *addr; /**< Start virtual address. */
uint64_t addr_64; /**< Makes sure addr is always 64-bits */
diff --git a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h
index 3dacbff..d459bf4 100644
--- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h
+++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h
@@ -82,6 +82,7 @@ struct rte_epoll_event {
/** Handle for interrupts. */
struct rte_intr_handle {
+ RTE_STD_C11
union {
int vfio_dev_fd; /**< VFIO device file descriptor */
int uio_cfg_fd; /**< UIO config file descriptor
diff --git a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
index 2ef0506..164f127 100644
--- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
+++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
@@ -61,6 +61,9 @@
#ifdef __KERNEL__
#include <linux/if.h>
+#define RTE_STD_C11
+#else
+#include <rte_common.h>
#endif
/**
@@ -85,6 +88,7 @@ enum rte_kni_req_id {
*/
struct rte_kni_request {
uint32_t req_id; /**< Request id */
+ RTE_STD_C11
union {
uint32_t new_mtu; /**< New MTU */
uint8_t if_up; /**< 1: interface up, 0: interface down */
diff --git a/lib/librte_hash/rte_thash.h b/lib/librte_hash/rte_thash.h
index d98e98e..a4886a8 100644
--- a/lib/librte_hash/rte_thash.h
+++ b/lib/librte_hash/rte_thash.h
@@ -54,6 +54,7 @@ extern "C" {
#include <stdint.h>
#include <rte_byteorder.h>
#include <rte_ip.h>
+#include <rte_common.h>
#ifdef __SSE3__
#include <rte_vect.h>
@@ -102,6 +103,7 @@ static const __m128i rte_thash_ipv6_bswap_mask = {
struct rte_ipv4_tuple {
uint32_t src_addr;
uint32_t dst_addr;
+ RTE_STD_C11
union {
struct {
uint16_t dport;
@@ -119,6 +121,7 @@ struct rte_ipv4_tuple {
struct rte_ipv6_tuple {
uint8_t src_addr[16];
uint8_t dst_addr[16];
+ RTE_STD_C11
union {
struct {
uint16_t dport;
diff --git a/lib/librte_lpm/rte_lpm.h b/lib/librte_lpm/rte_lpm.h
index 28668a3..3ef4533 100644
--- a/lib/librte_lpm/rte_lpm.h
+++ b/lib/librte_lpm/rte_lpm.h
@@ -100,6 +100,7 @@ struct rte_lpm_tbl_entry_v20 {
* a group index pointing to a tbl8 structure (tbl24 only, when
* valid_group is set)
*/
+ RTE_STD_C11
union {
uint8_t next_hop;
uint8_t group_idx;
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 3d3e847..4b9eb93 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -787,6 +787,7 @@ struct rte_mbuf {
* or non-atomic) is controlled by the CONFIG_RTE_MBUF_REFCNT_ATOMIC
* config option.
*/
+ RTE_STD_C11
union {
rte_atomic16_t refcnt_atomic; /**< Atomically accessed refcnt */
uint16_t refcnt; /**< Non-atomically accessed refcnt */
@@ -806,6 +807,7 @@ struct rte_mbuf {
* would have RTE_PTYPE_L2_ETHER and not RTE_PTYPE_L2_VLAN because the
* vlan is stripped from the data.
*/
+ RTE_STD_C11
union {
uint32_t packet_type; /**< L2/L3/L4 and tunnel information. */
struct {
@@ -827,6 +829,7 @@ struct rte_mbuf {
union {
uint32_t rss; /**< RSS hash result if RSS enabled */
struct {
+ RTE_STD_C11
union {
struct {
uint16_t hash;
@@ -854,6 +857,7 @@ struct rte_mbuf {
/* second cache line - fields only used in slow path or on TX */
MARKER cacheline1 __rte_cache_min_aligned;
+ RTE_STD_C11
union {
void *userdata; /**< Can be used for external metadata */
uint64_t udata64; /**< Allow 8-byte userdata on 32-bit */
@@ -863,6 +867,7 @@ struct rte_mbuf {
struct rte_mbuf *next; /**< Next segment of scattered packet. */
/* fields to support TX offloads */
+ RTE_STD_C11
union {
uint64_t tx_offload; /**< combined for easy fetch */
__extension__
diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h
index fc33db8..70b3953 100644
--- a/lib/librte_mempool/rte_mempool.h
+++ b/lib/librte_mempool/rte_mempool.h
@@ -75,6 +75,7 @@
#include <rte_branch_prediction.h>
#include <rte_ring.h>
#include <rte_memcpy.h>
+#include <rte_common.h>
#ifdef __cplusplus
extern "C" {
@@ -208,6 +209,7 @@ struct rte_mempool_memhdr {
*/
struct rte_mempool {
char name[RTE_MEMPOOL_NAMESIZE]; /**< Name of mempool. */
+ RTE_STD_C11
union {
void *pool_data; /**< Ring or pool to store objects. */
uint64_t pool_id; /**< External mempool identifier. */
diff --git a/lib/librte_pipeline/rte_pipeline.h b/lib/librte_pipeline/rte_pipeline.h
index 7736945..b1193b4 100644
--- a/lib/librte_pipeline/rte_pipeline.h
+++ b/lib/librte_pipeline/rte_pipeline.h
@@ -87,6 +87,7 @@ extern "C" {
#include <rte_port.h>
#include <rte_table.h>
+#include <rte_common.h>
struct rte_mbuf;
@@ -244,6 +245,7 @@ struct rte_pipeline_table_entry {
/** Reserved action */
enum rte_pipeline_action action;
+ RTE_STD_C11
union {
/** Output port ID (meta-data for "Send packet to output port"
action) */
diff --git a/lib/librte_timer/rte_timer.h b/lib/librte_timer/rte_timer.h
index 77547c6..a276a73 100644
--- a/lib/librte_timer/rte_timer.h
+++ b/lib/librte_timer/rte_timer.h
@@ -66,6 +66,7 @@
#include <stdio.h>
#include <stdint.h>
#include <stddef.h>
+#include <rte_common.h>
#ifdef __cplusplus
extern "C" {
@@ -91,6 +92,7 @@ enum rte_timer_type {
* config) and an owner (the id of the lcore that owns the timer).
*/
union rte_timer_status {
+ RTE_STD_C11
struct {
uint16_t state; /**< Stop, pending, running, config. */
int16_t owner; /**< The lcore that owns the timer. */
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* [dpdk-dev] [PATCH v3 07/11] lib: add missing include dependencies
2016-07-07 15:49 ` [dpdk-dev] [PATCH v3 " Adrien Mazarguil
` (5 preceding siblings ...)
2016-07-07 15:49 ` [dpdk-dev] [PATCH v3 06/11] lib: work around unnamed structs/unions Adrien Mazarguil
@ 2016-07-07 15:49 ` Adrien Mazarguil
2016-07-07 15:49 ` [dpdk-dev] [PATCH v3 08/11] lib: work around forward reference to enum types Adrien Mazarguil
` (5 subsequent siblings)
12 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-07-07 15:49 UTC (permalink / raw)
To: dev
Exported header files for use by applications should be self sufficient and
allow out of order inclusion. Moreover, they must include all the system
headers they need for types and macros.
This commit prevents the following errors:
error: `RTE_MAX_LCORE' undeclared here (not in a function)
error: `RTE_LPM_VALID_EXT_ENTRY_BITMASK' undeclared
(first use in this function)
error: #error "Unsupported cache line size"
error: `asm' undeclared (first use in this function)
error: implicit declaration of function `[...]'
error: unknown type name `[...]'
error: field `mac_addr' has incomplete type
error: `CHAR_BIT' undeclared here (not in a function)
error: `struct [...]' declared inside parameter list
error: unknown type name `uint8_t'
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
lib/librte_cfgfile/rte_cfgfile.h | 2 ++
lib/librte_cmdline/cmdline.h | 1 +
lib/librte_cmdline/cmdline_parse_portlist.h | 1 +
lib/librte_cmdline/cmdline_socket.h | 3 +++
lib/librte_eal/common/include/arch/arm/rte_byteorder.h | 2 ++
lib/librte_eal/common/include/arch/arm/rte_prefetch_32.h | 1 +
lib/librte_eal/common/include/arch/arm/rte_prefetch_64.h | 1 +
lib/librte_eal/common/include/arch/arm/rte_vect.h | 1 +
lib/librte_eal/common/include/arch/ppc_64/rte_atomic.h | 1 +
lib/librte_eal/common/include/arch/ppc_64/rte_byteorder.h | 1 +
lib/librte_eal/common/include/arch/ppc_64/rte_prefetch.h | 1 +
lib/librte_eal/common/include/arch/x86/rte_atomic.h | 2 ++
lib/librte_eal/common/include/arch/x86/rte_atomic_32.h | 6 ++++++
lib/librte_eal/common/include/arch/x86/rte_atomic_64.h | 8 ++++++++
lib/librte_eal/common/include/arch/x86/rte_byteorder.h | 2 ++
lib/librte_eal/common/include/arch/x86/rte_byteorder_32.h | 7 +++++++
lib/librte_eal/common/include/arch/x86/rte_byteorder_64.h | 7 +++++++
lib/librte_eal/common/include/arch/x86/rte_prefetch.h | 1 +
lib/librte_eal/common/include/arch/x86/rte_rtm.h | 1 +
lib/librte_eal/common/include/arch/x86/rte_vect.h | 2 ++
lib/librte_eal/common/include/generic/rte_atomic.h | 1 +
lib/librte_eal/common/include/generic/rte_byteorder.h | 2 ++
lib/librte_eal/common/include/rte_eal.h | 1 +
lib/librte_eal/common/include/rte_memory.h | 2 ++
lib/librte_eal/common/include/rte_time.h | 8 ++++++++
lib/librte_eal/common/include/rte_version.h | 1 +
lib/librte_ether/rte_dev_info.h | 2 ++
lib/librte_ether/rte_eth_ctrl.h | 4 ++++
lib/librte_lpm/rte_lpm_neon.h | 1 +
lib/librte_lpm/rte_lpm_sse.h | 1 +
lib/librte_pdump/rte_pdump.h | 4 ++++
lib/librte_reorder/rte_reorder.h | 2 ++
lib/librte_sched/rte_bitmap.h | 1 +
lib/librte_sched/rte_reciprocal.h | 2 ++
lib/librte_sched/rte_sched_common.h | 1 +
35 files changed, 84 insertions(+)
diff --git a/lib/librte_cfgfile/rte_cfgfile.h b/lib/librte_cfgfile/rte_cfgfile.h
index f649836..e81a5a2 100644
--- a/lib/librte_cfgfile/rte_cfgfile.h
+++ b/lib/librte_cfgfile/rte_cfgfile.h
@@ -34,6 +34,8 @@
#ifndef __INCLUDE_RTE_CFGFILE_H__
#define __INCLUDE_RTE_CFGFILE_H__
+#include <stddef.h>
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/lib/librte_cmdline/cmdline.h b/lib/librte_cmdline/cmdline.h
index 2578ca8..65d73b0 100644
--- a/lib/librte_cmdline/cmdline.h
+++ b/lib/librte_cmdline/cmdline.h
@@ -63,6 +63,7 @@
#include <termios.h>
#include <cmdline_rdline.h>
+#include <cmdline_parse.h>
/**
* @file
diff --git a/lib/librte_cmdline/cmdline_parse_portlist.h b/lib/librte_cmdline/cmdline_parse_portlist.h
index 73d70e0..058df3e 100644
--- a/lib/librte_cmdline/cmdline_parse_portlist.h
+++ b/lib/librte_cmdline/cmdline_parse_portlist.h
@@ -61,6 +61,7 @@
#ifndef _PARSE_PORTLIST_H_
#define _PARSE_PORTLIST_H_
+#include <stdint.h>
#include <cmdline_parse.h>
#ifdef __cplusplus
diff --git a/lib/librte_cmdline/cmdline_socket.h b/lib/librte_cmdline/cmdline_socket.h
index 8cc2dfb..aa6068e 100644
--- a/lib/librte_cmdline/cmdline_socket.h
+++ b/lib/librte_cmdline/cmdline_socket.h
@@ -61,6 +61,9 @@
#ifndef _CMDLINE_SOCKET_H_
#define _CMDLINE_SOCKET_H_
+#include <cmdline_parse.h>
+#include <cmdline.h>
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/lib/librte_eal/common/include/arch/arm/rte_byteorder.h b/lib/librte_eal/common/include/arch/arm/rte_byteorder.h
index 3f2dd1f..1b312b3 100644
--- a/lib/librte_eal/common/include/arch/arm/rte_byteorder.h
+++ b/lib/librte_eal/common/include/arch/arm/rte_byteorder.h
@@ -41,6 +41,8 @@
extern "C" {
#endif
+#include <stdint.h>
+#include <rte_common.h>
#include "generic/rte_byteorder.h"
/* fix missing __builtin_bswap16 for gcc older then 4.8 */
diff --git a/lib/librte_eal/common/include/arch/arm/rte_prefetch_32.h b/lib/librte_eal/common/include/arch/arm/rte_prefetch_32.h
index 5aeed22..43cde17 100644
--- a/lib/librte_eal/common/include/arch/arm/rte_prefetch_32.h
+++ b/lib/librte_eal/common/include/arch/arm/rte_prefetch_32.h
@@ -37,6 +37,7 @@
extern "C" {
#endif
+#include <rte_common.h>
#include "generic/rte_prefetch.h"
static inline void rte_prefetch0(const volatile void *p)
diff --git a/lib/librte_eal/common/include/arch/arm/rte_prefetch_64.h b/lib/librte_eal/common/include/arch/arm/rte_prefetch_64.h
index 3ed46a4..0d077ea 100644
--- a/lib/librte_eal/common/include/arch/arm/rte_prefetch_64.h
+++ b/lib/librte_eal/common/include/arch/arm/rte_prefetch_64.h
@@ -37,6 +37,7 @@
extern "C" {
#endif
+#include <rte_common.h>
#include "generic/rte_prefetch.h"
static inline void rte_prefetch0(const volatile void *p)
diff --git a/lib/librte_eal/common/include/arch/arm/rte_vect.h b/lib/librte_eal/common/include/arch/arm/rte_vect.h
index a33c054..b86c2cf 100644
--- a/lib/librte_eal/common/include/arch/arm/rte_vect.h
+++ b/lib/librte_eal/common/include/arch/arm/rte_vect.h
@@ -33,6 +33,7 @@
#ifndef _RTE_VECT_ARM_H_
#define _RTE_VECT_ARM_H_
+#include <stdint.h>
#include "arm_neon.h"
#ifdef __cplusplus
diff --git a/lib/librte_eal/common/include/arch/ppc_64/rte_atomic.h b/lib/librte_eal/common/include/arch/ppc_64/rte_atomic.h
index feae486..3270fce 100644
--- a/lib/librte_eal/common/include/arch/ppc_64/rte_atomic.h
+++ b/lib/librte_eal/common/include/arch/ppc_64/rte_atomic.h
@@ -46,6 +46,7 @@
extern "C" {
#endif
+#include <stdint.h>
#include "generic/rte_atomic.h"
/**
diff --git a/lib/librte_eal/common/include/arch/ppc_64/rte_byteorder.h b/lib/librte_eal/common/include/arch/ppc_64/rte_byteorder.h
index 3c1734e..544de3c 100644
--- a/lib/librte_eal/common/include/arch/ppc_64/rte_byteorder.h
+++ b/lib/librte_eal/common/include/arch/ppc_64/rte_byteorder.h
@@ -42,6 +42,7 @@
extern "C" {
#endif
+#include <stdint.h>
#include "generic/rte_byteorder.h"
/*
diff --git a/lib/librte_eal/common/include/arch/ppc_64/rte_prefetch.h b/lib/librte_eal/common/include/arch/ppc_64/rte_prefetch.h
index 9a1995e..fd2e53b 100644
--- a/lib/librte_eal/common/include/arch/ppc_64/rte_prefetch.h
+++ b/lib/librte_eal/common/include/arch/ppc_64/rte_prefetch.h
@@ -37,6 +37,7 @@
extern "C" {
#endif
+#include <rte_common.h>
#include "generic/rte_prefetch.h"
static inline void rte_prefetch0(const volatile void *p)
diff --git a/lib/librte_eal/common/include/arch/x86/rte_atomic.h b/lib/librte_eal/common/include/arch/x86/rte_atomic.h
index b20056b..00b1cdf 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_atomic.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_atomic.h
@@ -38,6 +38,8 @@
extern "C" {
#endif
+#include <stdint.h>
+#include <rte_common.h>
#include <emmintrin.h>
#include "generic/rte_atomic.h"
diff --git a/lib/librte_eal/common/include/arch/x86/rte_atomic_32.h b/lib/librte_eal/common/include/arch/x86/rte_atomic_32.h
index 5ce01b3..2e04c75 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_atomic_32.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_atomic_32.h
@@ -37,10 +37,16 @@
* All rights reserved.
*/
+#ifndef _RTE_ATOMIC_X86_H_
+#error do not include this file directly, use <rte_atomic.h> instead
+#endif
+
#ifndef _RTE_ATOMIC_I686_H_
#define _RTE_ATOMIC_I686_H_
+#include <stdint.h>
#include <rte_common.h>
+#include <rte_atomic.h>
/*------------------------- 64 bit atomic operations -------------------------*/
diff --git a/lib/librte_eal/common/include/arch/x86/rte_atomic_64.h b/lib/librte_eal/common/include/arch/x86/rte_atomic_64.h
index 4de6600..1a53a76 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_atomic_64.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_atomic_64.h
@@ -37,9 +37,17 @@
* All rights reserved.
*/
+#ifndef _RTE_ATOMIC_X86_H_
+#error do not include this file directly, use <rte_atomic.h> instead
+#endif
+
#ifndef _RTE_ATOMIC_X86_64_H_
#define _RTE_ATOMIC_X86_64_H_
+#include <stdint.h>
+#include <rte_common.h>
+#include <rte_atomic.h>
+
/*------------------------- 64 bit atomic operations -------------------------*/
#ifndef RTE_FORCE_INTRINSICS
diff --git a/lib/librte_eal/common/include/arch/x86/rte_byteorder.h b/lib/librte_eal/common/include/arch/x86/rte_byteorder.h
index ffdb6ef..251f11b 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_byteorder.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_byteorder.h
@@ -38,6 +38,8 @@
extern "C" {
#endif
+#include <stdint.h>
+#include <rte_common.h>
#include "generic/rte_byteorder.h"
#ifndef RTE_BYTE_ORDER
diff --git a/lib/librte_eal/common/include/arch/x86/rte_byteorder_32.h b/lib/librte_eal/common/include/arch/x86/rte_byteorder_32.h
index 51c306f..14d6483 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_byteorder_32.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_byteorder_32.h
@@ -31,9 +31,16 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#ifndef _RTE_BYTEORDER_X86_H_
+#error do not include this file directly, use <rte_byteorder.h> instead
+#endif
+
#ifndef _RTE_BYTEORDER_I686_H_
#define _RTE_BYTEORDER_I686_H_
+#include <stdint.h>
+#include <rte_byteorder.h>
+
/*
* An architecture-optimized byte swap for a 64-bit value.
*
diff --git a/lib/librte_eal/common/include/arch/x86/rte_byteorder_64.h b/lib/librte_eal/common/include/arch/x86/rte_byteorder_64.h
index dda572b..516ac05 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_byteorder_64.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_byteorder_64.h
@@ -31,9 +31,16 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#ifndef _RTE_BYTEORDER_X86_H_
+#error do not include this file directly, use <rte_byteorder.h> instead
+#endif
+
#ifndef _RTE_BYTEORDER_X86_64_H_
#define _RTE_BYTEORDER_X86_64_H_
+#include <stdint.h>
+#include <rte_common.h>
+
/*
* An architecture-optimized byte swap for a 64-bit value.
*
diff --git a/lib/librte_eal/common/include/arch/x86/rte_prefetch.h b/lib/librte_eal/common/include/arch/x86/rte_prefetch.h
index 5dac47e..f464398 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_prefetch.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_prefetch.h
@@ -38,6 +38,7 @@
extern "C" {
#endif
+#include <rte_common.h>
#include "generic/rte_prefetch.h"
static inline void rte_prefetch0(const volatile void *p)
diff --git a/lib/librte_eal/common/include/arch/x86/rte_rtm.h b/lib/librte_eal/common/include/arch/x86/rte_rtm.h
index 0649f79..ab09995 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_rtm.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_rtm.h
@@ -20,6 +20,7 @@
/* Official RTM intrinsics interface matching gcc/icc, but works
on older gcc compatible compilers and binutils. */
+#include <rte_common.h>
#ifdef __cplusplus
extern "C" {
diff --git a/lib/librte_eal/common/include/arch/x86/rte_vect.h b/lib/librte_eal/common/include/arch/x86/rte_vect.h
index 2836f2c..77f2e25 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_vect.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_vect.h
@@ -40,6 +40,8 @@
* RTE SSE/AVX related header.
*/
+#include <stdint.h>
+
#if (defined(__ICC) || (__GNUC__ == 4 && __GNUC_MINOR__ < 4))
#ifdef __SSE__
diff --git a/lib/librte_eal/common/include/generic/rte_atomic.h b/lib/librte_eal/common/include/generic/rte_atomic.h
index bfb4fe4..43a704e 100644
--- a/lib/librte_eal/common/include/generic/rte_atomic.h
+++ b/lib/librte_eal/common/include/generic/rte_atomic.h
@@ -42,6 +42,7 @@
*/
#include <stdint.h>
+#include <rte_common.h>
#ifdef __DOXYGEN__
diff --git a/lib/librte_eal/common/include/generic/rte_byteorder.h b/lib/librte_eal/common/include/generic/rte_byteorder.h
index c46fdcf..e00bccb 100644
--- a/lib/librte_eal/common/include/generic/rte_byteorder.h
+++ b/lib/librte_eal/common/include/generic/rte_byteorder.h
@@ -50,6 +50,8 @@
#include <endian.h>
#endif
+#include <rte_common.h>
+
/*
* Compile-time endianness detection
*/
diff --git a/lib/librte_eal/common/include/rte_eal.h b/lib/librte_eal/common/include/rte_eal.h
index a71d6f5..98d20db 100644
--- a/lib/librte_eal/common/include/rte_eal.h
+++ b/lib/librte_eal/common/include/rte_eal.h
@@ -44,6 +44,7 @@
#include <sched.h>
#include <rte_per_lcore.h>
+#include <rte_config.h>
#ifdef __cplusplus
extern "C" {
diff --git a/lib/librte_eal/common/include/rte_memory.h b/lib/librte_eal/common/include/rte_memory.h
index 38fbe74..3b6b46b 100644
--- a/lib/librte_eal/common/include/rte_memory.h
+++ b/lib/librte_eal/common/include/rte_memory.h
@@ -44,6 +44,8 @@
#include <stddef.h>
#include <stdio.h>
+#include <rte_config.h>
+
#ifdef RTE_EXEC_ENV_LINUXAPP
#include <exec-env/rte_dom0_common.h>
#endif
diff --git a/lib/librte_eal/common/include/rte_time.h b/lib/librte_eal/common/include/rte_time.h
index 4b13b9c..28c6274 100644
--- a/lib/librte_eal/common/include/rte_time.h
+++ b/lib/librte_eal/common/include/rte_time.h
@@ -31,6 +31,12 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#ifndef _RTE_TIME_H_
+#define _RTE_TIME_H_
+
+#include <stdint.h>
+#include <time.h>
+
#define NSEC_PER_SEC 1000000000L
/**
@@ -120,3 +126,5 @@ rte_ns_to_timespec(uint64_t nsec)
return ts;
}
+
+#endif /* _RTE_TIME_H_ */
diff --git a/lib/librte_eal/common/include/rte_version.h b/lib/librte_eal/common/include/rte_version.h
index dbe0997..bcd7005 100644
--- a/lib/librte_eal/common/include/rte_version.h
+++ b/lib/librte_eal/common/include/rte_version.h
@@ -45,6 +45,7 @@ extern "C" {
#include <stdint.h>
#include <string.h>
+#include <stdio.h>
#include <rte_common.h>
/**
diff --git a/lib/librte_ether/rte_dev_info.h b/lib/librte_ether/rte_dev_info.h
index 291bd4d..64b1d18 100644
--- a/lib/librte_ether/rte_dev_info.h
+++ b/lib/librte_ether/rte_dev_info.h
@@ -34,6 +34,8 @@
#ifndef _RTE_DEV_INFO_H_
#define _RTE_DEV_INFO_H_
+#include <stdint.h>
+
/*
* Placeholder for accessing device registers
*/
diff --git a/lib/librte_ether/rte_eth_ctrl.h b/lib/librte_ether/rte_eth_ctrl.h
index c3a2c9e..fe80eb0 100644
--- a/lib/librte_ether/rte_eth_ctrl.h
+++ b/lib/librte_ether/rte_eth_ctrl.h
@@ -34,6 +34,10 @@
#ifndef _RTE_ETH_CTRL_H_
#define _RTE_ETH_CTRL_H_
+#include <stdint.h>
+#include <rte_common.h>
+#include "rte_ether.h"
+
/**
* @file
*
diff --git a/lib/librte_lpm/rte_lpm_neon.h b/lib/librte_lpm/rte_lpm_neon.h
index 7c64315..7efd9a0 100644
--- a/lib/librte_lpm/rte_lpm_neon.h
+++ b/lib/librte_lpm/rte_lpm_neon.h
@@ -43,6 +43,7 @@
#include <rte_byteorder.h>
#include <rte_common.h>
#include <rte_vect.h>
+#include <rte_lpm.h>
#ifdef __cplusplus
extern "C" {
diff --git a/lib/librte_lpm/rte_lpm_sse.h b/lib/librte_lpm/rte_lpm_sse.h
index da83099..ef33c6a 100644
--- a/lib/librte_lpm/rte_lpm_sse.h
+++ b/lib/librte_lpm/rte_lpm_sse.h
@@ -38,6 +38,7 @@
#include <rte_byteorder.h>
#include <rte_common.h>
#include <rte_vect.h>
+#include <rte_lpm.h>
#ifdef __cplusplus
extern "C" {
diff --git a/lib/librte_pdump/rte_pdump.h b/lib/librte_pdump/rte_pdump.h
index b5f4e2f..924b804 100644
--- a/lib/librte_pdump/rte_pdump.h
+++ b/lib/librte_pdump/rte_pdump.h
@@ -41,6 +41,10 @@
* packet dump library to provide packet capturing support on dpdk.
*/
+#include <stdint.h>
+#include <rte_mempool.h>
+#include <rte_ring.h>
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/lib/librte_reorder/rte_reorder.h b/lib/librte_reorder/rte_reorder.h
index c7a2934..737e055 100644
--- a/lib/librte_reorder/rte_reorder.h
+++ b/lib/librte_reorder/rte_reorder.h
@@ -44,6 +44,8 @@
*
*/
+#include <rte_mbuf.h>
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/lib/librte_sched/rte_bitmap.h b/lib/librte_sched/rte_bitmap.h
index 1b5df02..010d752 100644
--- a/lib/librte_sched/rte_bitmap.h
+++ b/lib/librte_sched/rte_bitmap.h
@@ -64,6 +64,7 @@ extern "C" {
*
***/
+#include <string.h>
#include <rte_common.h>
#include <rte_debug.h>
#include <rte_memory.h>
diff --git a/lib/librte_sched/rte_reciprocal.h b/lib/librte_sched/rte_reciprocal.h
index abd1525..5e21f09 100644
--- a/lib/librte_sched/rte_reciprocal.h
+++ b/lib/librte_sched/rte_reciprocal.h
@@ -22,6 +22,8 @@
#ifndef _RTE_RECIPROCAL_H_
#define _RTE_RECIPROCAL_H_
+#include <stdint.h>
+
struct rte_reciprocal {
uint32_t m;
uint8_t sh1, sh2;
diff --git a/lib/librte_sched/rte_sched_common.h b/lib/librte_sched/rte_sched_common.h
index 8920ade..aed144b 100644
--- a/lib/librte_sched/rte_sched_common.h
+++ b/lib/librte_sched/rte_sched_common.h
@@ -38,6 +38,7 @@
extern "C" {
#endif
+#include <stdint.h>
#include <sys/types.h>
#define __rte_aligned_16 __attribute__((__aligned__(16)))
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* [dpdk-dev] [PATCH v3 08/11] lib: work around forward reference to enum types
2016-07-07 15:49 ` [dpdk-dev] [PATCH v3 " Adrien Mazarguil
` (6 preceding siblings ...)
2016-07-07 15:49 ` [dpdk-dev] [PATCH v3 07/11] lib: add missing include dependencies Adrien Mazarguil
@ 2016-07-07 15:49 ` Adrien Mazarguil
2016-07-07 15:49 ` [dpdk-dev] [PATCH v3 09/11] lib: remove named variadic macros in exported headers Adrien Mazarguil
` (4 subsequent siblings)
12 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-07-07 15:49 UTC (permalink / raw)
To: dev
Exported header files used by applications should allow the strictest
compiler flags. Language extensions used in many places must be explicitly
marked or removed to avoid warnings and compilation failures.
This commit prevents the following errors:
error: ISO C forbids forward references to `enum' types
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
lib/librte_eal/common/include/generic/rte_cpuflags.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/librte_eal/common/include/generic/rte_cpuflags.h b/lib/librte_eal/common/include/generic/rte_cpuflags.h
index c1da357..71321f3 100644
--- a/lib/librte_eal/common/include/generic/rte_cpuflags.h
+++ b/lib/librte_eal/common/include/generic/rte_cpuflags.h
@@ -44,6 +44,7 @@
/**
* Enumeration of all CPU features supported
*/
+__extension__
enum rte_cpu_flag_t;
/**
@@ -55,6 +56,7 @@ enum rte_cpu_flag_t;
* flag name
* NULL if flag ID is invalid
*/
+__extension__
const char *
rte_cpu_get_flag_name(enum rte_cpu_flag_t feature);
@@ -68,6 +70,7 @@ rte_cpu_get_flag_name(enum rte_cpu_flag_t feature);
* 0 if flag is not available
* -ENOENT if flag is invalid
*/
+__extension__
int
rte_cpu_get_flag_enabled(enum rte_cpu_flag_t feature);
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* [dpdk-dev] [PATCH v3 09/11] lib: remove named variadic macros in exported headers
2016-07-07 15:49 ` [dpdk-dev] [PATCH v3 " Adrien Mazarguil
` (7 preceding siblings ...)
2016-07-07 15:49 ` [dpdk-dev] [PATCH v3 08/11] lib: work around forward reference to enum types Adrien Mazarguil
@ 2016-07-07 15:49 ` Adrien Mazarguil
2016-07-07 15:49 ` [dpdk-dev] [PATCH v3 10/11] lib: hide static functions never defined Adrien Mazarguil
` (3 subsequent siblings)
12 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-07-07 15:49 UTC (permalink / raw)
To: dev
Exported header files used by applications should allow the strictest
compiler flags. Language extensions used in many places must be explicitly
marked or removed to avoid warnings and compilation failures.
Since there is no way to force named variadic macros as extensions, use a
a standard __VA_ARGS__ with an extra dummy argument to format strings.
This commit prevents the following errors:
error: ISO C does not permit named variadic macros
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
lib/librte_cryptodev/rte_cryptodev.h | 32 ++++++++++++++-----------
lib/librte_cryptodev/rte_cryptodev_pmd.h | 2 +-
lib/librte_eal/common/include/rte_common.h | 9 +++++++
3 files changed, 28 insertions(+), 15 deletions(-)
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index be9a544..febea9b 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -77,26 +77,30 @@ extern const char **rte_cyptodev_names;
/* Logging Macros */
-#define CDEV_LOG_ERR(fmt, args...) \
- RTE_LOG(ERR, CRYPTODEV, "%s() line %u: " fmt "\n", \
- __func__, __LINE__, ## args)
+#define CDEV_LOG_ERR(...) \
+ RTE_LOG(ERR, CRYPTODEV, \
+ RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
+ __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__,)))
-#define CDEV_PMD_LOG_ERR(dev, fmt, args...) \
- RTE_LOG(ERR, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \
- dev, __func__, __LINE__, ## args)
+#define CDEV_PMD_LOG_ERR(dev, ...) \
+ RTE_LOG(ERR, CRYPTODEV, \
+ RTE_FMT("[%s] %s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
+ dev, __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__,)))
#ifdef RTE_LIBRTE_CRYPTODEV_DEBUG
-#define CDEV_LOG_DEBUG(fmt, args...) \
- RTE_LOG(DEBUG, CRYPTODEV, "%s() line %u: " fmt "\n", \
- __func__, __LINE__, ## args) \
+#define CDEV_LOG_DEBUG(...) \
+ RTE_LOG(DEBUG, CRYPTODEV, \
+ RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
+ __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__,)))
-#define CDEV_PMD_TRACE(fmt, args...) \
- RTE_LOG(DEBUG, CRYPTODEV, "[%s] %s: " fmt "\n", \
- dev, __func__, ## args)
+#define CDEV_PMD_TRACE(...) \
+ RTE_LOG(DEBUG, CRYPTODEV, \
+ RTE_FMT("[%s] %s: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
+ dev, __func__, RTE_FMT_TAIL(__VA_ARGS__,)))
#else
-#define CDEV_LOG_DEBUG(fmt, args...)
-#define CDEV_PMD_TRACE(fmt, args...)
+#define CDEV_LOG_DEBUG(...) (void)0
+#define CDEV_PMD_TRACE(...) (void)0
#endif
/**
diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h b/lib/librte_cryptodev/rte_cryptodev_pmd.h
index cf08a50..4a07362 100644
--- a/lib/librte_cryptodev/rte_cryptodev_pmd.h
+++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h
@@ -62,7 +62,7 @@ extern "C" {
#define RTE_PMD_DEBUG_TRACE(...) \
rte_pmd_debug_trace(__func__, __VA_ARGS__)
#else
-#define RTE_PMD_DEBUG_TRACE(fmt, args...)
+#define RTE_PMD_DEBUG_TRACE(...)
#endif
struct rte_cryptodev_session {
diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h
index 98ecc1c..db5ac91 100644
--- a/lib/librte_eal/common/include/rte_common.h
+++ b/lib/librte_eal/common/include/rte_common.h
@@ -335,6 +335,15 @@ rte_bsf32(uint32_t v)
/** Take a macro value and get a string version of it */
#define RTE_STR(x) _RTE_STR(x)
+/**
+ * ISO C helpers to modify format strings using variadic macros.
+ * This is a replacement for the ", ## __VA_ARGS__" GNU extension.
+ * An empty %s argument is appended to avoid a dangling comma.
+ */
+#define RTE_FMT(fmt, ...) fmt "%.0s", __VA_ARGS__ ""
+#define RTE_FMT_HEAD(fmt, ...) fmt
+#define RTE_FMT_TAIL(fmt, ...) __VA_ARGS__
+
/** Mask value of type "tp" for the first "ln" bit set. */
#define RTE_LEN2MASK(ln, tp) \
((tp)((uint64_t)-1 >> (sizeof(uint64_t) * CHAR_BIT - (ln))))
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* [dpdk-dev] [PATCH v3 10/11] lib: hide static functions never defined
2016-07-07 15:49 ` [dpdk-dev] [PATCH v3 " Adrien Mazarguil
` (8 preceding siblings ...)
2016-07-07 15:49 ` [dpdk-dev] [PATCH v3 09/11] lib: remove named variadic macros in exported headers Adrien Mazarguil
@ 2016-07-07 15:49 ` Adrien Mazarguil
2016-07-07 15:49 ` [dpdk-dev] [PATCH v3 11/11] scripts: check compilation of exported header files Adrien Mazarguil
` (2 subsequent siblings)
12 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-07-07 15:49 UTC (permalink / raw)
To: dev
Arch-specific functions not defined for all architectures (missing on x86
in this case) and not used anywhere should not expose a prototype.
This commit prevents the following error:
error: `rte_mov48' declared `static' but never defined
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
lib/librte_eal/common/include/generic/rte_memcpy.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lib/librte_eal/common/include/generic/rte_memcpy.h b/lib/librte_eal/common/include/generic/rte_memcpy.h
index afb0afe..4e9d879 100644
--- a/lib/librte_eal/common/include/generic/rte_memcpy.h
+++ b/lib/librte_eal/common/include/generic/rte_memcpy.h
@@ -64,6 +64,8 @@ rte_mov16(uint8_t *dst, const uint8_t *src);
static inline void
rte_mov32(uint8_t *dst, const uint8_t *src);
+#ifdef __DOXYGEN__
+
/**
* Copy 48 bytes from one location to another using optimised
* instructions. The locations should not overlap.
@@ -76,6 +78,8 @@ rte_mov32(uint8_t *dst, const uint8_t *src);
static inline void
rte_mov48(uint8_t *dst, const uint8_t *src);
+#endif /* __DOXYGEN__ */
+
/**
* Copy 64 bytes from one location to another using optimised
* instructions. The locations should not overlap.
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* [dpdk-dev] [PATCH v3 11/11] scripts: check compilation of exported header files
2016-07-07 15:49 ` [dpdk-dev] [PATCH v3 " Adrien Mazarguil
` (9 preceding siblings ...)
2016-07-07 15:49 ` [dpdk-dev] [PATCH v3 10/11] lib: hide static functions never defined Adrien Mazarguil
@ 2016-07-07 15:49 ` Adrien Mazarguil
2016-07-07 18:33 ` [dpdk-dev] [PATCH v3 00/11] Fix build errors related to exported headers Wiles, Keith
2016-07-13 13:02 ` [dpdk-dev] [PATCH v4 00/10] " Adrien Mazarguil
12 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-07-07 15:49 UTC (permalink / raw)
To: dev
This script checks that header files in a given directory do not miss
dependencies when included on their own, do not conflict and accept being
compiled with the strictest possible flags.
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
MAINTAINERS | 1 +
scripts/check-includes.sh | 286 +++++++++++++++++++++++++++++++++++++++++
scripts/test-build.sh | 14 ++
3 files changed, 301 insertions(+)
diff --git a/MAINTAINERS b/MAINTAINERS
index a59191e..c12db3d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -26,6 +26,7 @@ T: git://dpdk.org/dpdk
F: MAINTAINERS
F: scripts/check-maintainers.sh
F: scripts/check-git-log.sh
+F: scripts/check-includes.sh
F: scripts/checkpatches.sh
F: scripts/load-devel-config.sh
F: scripts/test-build.sh
diff --git a/scripts/check-includes.sh b/scripts/check-includes.sh
new file mode 100755
index 0000000..d65adc6
--- /dev/null
+++ b/scripts/check-includes.sh
@@ -0,0 +1,286 @@
+#!/bin/sh -e
+#
+# BSD LICENSE
+#
+# Copyright 2016 6WIND S.A.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of 6WIND S.A. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# This script checks that header files in a given directory do not miss
+# dependencies when included on their own, do not conflict and accept being
+# compiled with the strictest possible flags.
+#
+# Files are looked up in the directory provided as the first argument,
+# otherwise build/include by default.
+#
+# Recognized environment variables:
+#
+# VERBOSE=1 is the same as -v.
+#
+# QUIET=1 is the same as -q.
+#
+# SUMMARY=1 is the same as -s.
+#
+# CC, CPPFLAGS, CFLAGS, EXTRA_CPPFLAGS, EXTRA_CFLAGS, CXX, CXXFLAGS and
+# EXTRA_CXXFLAGS are taken into account.
+#
+# PEDANTIC_CFLAGS, PEDANTIC_CXXFLAGS and PEDANTIC_CPPFLAGS provide strict
+# C/C++ compilation flags.
+#
+# IGNORE contains a list of shell patterns matching files (relative to the
+# include directory) to avoid. It is set by default to known DPDK headers
+# which must not be included on their own.
+#
+# IGNORE_CXX provides additional files for C++.
+
+while getopts hqvs arg; do
+ case $arg in
+ h)
+ cat <<EOF
+usage: $0 [-h] [-q] [-v] [-s] [DIR]
+
+This script checks that header files in a given directory do not miss
+dependencies when included on their own, do not conflict and accept being
+compiled with the strictest possible flags.
+
+ -h display this help and exit
+ -q quiet mode, disable normal output
+ -v show command lines being executed
+ -s show summary
+
+With no DIR, default to build/include.
+
+Any failed header check yields a nonzero exit status.
+EOF
+ exit
+ ;;
+ q)
+ QUIET=1
+ ;;
+ v)
+ VERBOSE=1
+ ;;
+ s)
+ SUMMARY=1
+ ;;
+ *)
+ exit 1
+ ;;
+ esac
+done
+
+shift $(($OPTIND - 1))
+
+include_dir=${1:-build/include}
+
+: ${PEDANTIC_CFLAGS=-std=c99 -pedantic -Wall -Wextra -Werror}
+: ${PEDANTIC_CXXFLAGS=}
+: ${PEDANTIC_CPPFLAGS=-D_XOPEN_SOURCE=600}
+: ${CC:=cc}
+: ${CXX:=c++}
+: ${IGNORE= \
+ 'rte_atomic_32.h' \
+ 'rte_atomic_64.h' \
+ 'rte_byteorder_32.h' \
+ 'rte_byteorder_64.h' \
+ 'generic/*' \
+ 'exec-env/*' \
+}
+: ${IGNORE_CXX= \
+ 'rte_eth_vhost.h' \
+ 'rte_virtio_net.h' \
+}
+
+temp_cc=/tmp/${0##*/}.$$.c
+pass_cc=
+failures_cc=0
+
+temp_cxx=/tmp/${0##*/}.$$.cc
+pass_cxx=
+failures_cxx=0
+
+# Process output parameters.
+
+[ "$QUIET" = 1 ] &&
+exec 1> /dev/null
+
+[ "$VERBOSE" = 1 ] &&
+output ()
+{
+ local CCV
+ local CXXV
+
+ shift
+ CCV=$CC
+ CXXV=$CXX
+ CC="echo $CC" CXX="echo $CXX" "$@"
+ CC=$CCV
+ CXX=$CXXV
+
+ "$@"
+} ||
+output ()
+{
+
+ printf ' %s\n' "$1"
+ shift
+ "$@"
+}
+
+trap 'rm -f "$temp_cc" "$temp_cxx"' EXIT
+
+compile_cc ()
+{
+ ${CC} -I"$include_dir" \
+ ${PEDANTIC_CPPFLAGS} ${CPPFLAGS} ${EXTRA_CPPFLAGS} \
+ ${PEDANTIC_CFLAGS} ${CFLAGS} ${EXTRA_CFLAGS} \
+ -c -o /dev/null "${temp_cc}"
+}
+
+compile_cxx ()
+{
+ ${CXX} -I"$include_dir" \
+ ${PEDANTIC_CPPFLAGS} ${CPPFLAGS} ${EXTRA_CPPFLAGS} \
+ ${PEDANTIC_CXXFLAGS} ${CXXFLAGS} ${EXTRA_CXXFLAGS} \
+ -c -o /dev/null "${temp_cxx}"
+}
+
+ignore ()
+{
+ file="$1"
+ shift
+ while [ $# -ne 0 ]; do
+ case "$file" in
+ $1)
+ return 0
+ ;;
+ esac
+ shift
+ done
+ return 1
+}
+
+# Check C/C++ compilation for each header file.
+
+while read -r path
+do
+ file=${path#$include_dir}
+ file=${file##/}
+ if ignore "$file" $IGNORE; then
+ output "SKIP $file" :
+ continue
+ fi
+ if printf "\
+#include <%s>
+
+int main(void)
+{
+ return 0;
+}
+" "$file" > "$temp_cc" &&
+ output "CC $file" compile_cc
+ then
+ pass_cc="$pass_cc $file"
+ else
+ failures_cc=$(($failures_cc + 1))
+ fi
+ if ignore "$file" $IGNORE_CXX; then
+ output "SKIP CXX $file" :
+ continue
+ fi
+ if printf "\
+#include <%s>
+
+int main()
+{
+}
+" "$file" > "$temp_cxx" &&
+ output "CXX $file" compile_cxx
+ then
+ pass_cxx="$pass_cxx $file"
+ else
+ failures_cxx=$(($failures_cxx + 1))
+ fi
+done <<EOF
+$(find "$include_dir" -name '*.h')
+EOF
+
+# Check C compilation with all includes.
+
+: > "$temp_cc" &&
+for file in $pass_cc; do
+ printf "\
+#include <%s>
+" "$file" >> $temp_cc
+done
+if printf "\
+int main(void)
+{
+ return 0;
+}
+" >> "$temp_cc" &&
+ output "CC (all includes that did not fail)" compile_cc
+then
+ :
+else
+ failures_cc=$(($failures_cc + 1))
+fi
+
+# Check C++ compilation with all includes.
+
+: > "$temp_cxx" &&
+for file in $pass_cxx; do
+ printf "\
+#include <%s>
+" "$file" >> $temp_cxx
+done
+if printf "\
+int main()
+{
+}
+" >> "$temp_cxx" &&
+ output "CXX (all includes that did not fail)" compile_cxx
+then
+ :
+else
+ failures_cxx=$(($failures_cxx + 1))
+fi
+
+# Report results.
+
+if [ "$SUMMARY" = 1 ]; then
+ printf "\
+Summary:
+ %u failure(s) for C using '%s'.
+ %u failure(s) for C++ using '%s'.
+" $failures_cc "$CC" $failures_cxx "$CXX" 1>&2
+fi
+
+# Exit with nonzero status if there are failures.
+
+[ $failures_cc -eq 0 ] &&
+[ $failures_cxx -eq 0 ]
diff --git a/scripts/test-build.sh b/scripts/test-build.sh
index 5bcecfc..b2ea602 100755
--- a/scripts/test-build.sh
+++ b/scripts/test-build.sh
@@ -229,6 +229,20 @@ for conf in $configs ; do
make -j$J -sC examples/performance-thread \
EXTRA_LDFLAGS="$DPDK_DEP_LDFLAGS" $verbose \
O=$(readlink -m $dir/examples/performance-thread)
+ echo "================== Check includes in $dir"
+ if echo $target | grep -q 'gcc'; then
+ CC=gcc
+ CXX=g++
+ elif echo $target | grep -q 'clang'; then
+ CC=clang
+ CXX=clang++
+ else
+ CXX=$CC
+ fi
+ CC=$CROSS$CC CXX=$CROSS$CXX \
+ VERBOSE="$((! ! ${#verbose}))" \
+ QUIET="$((! ${#verbose}))" \
+ scripts/check-includes.sh "$dir/include"
unset RTE_TARGET
echo "################## $dir done."
done
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* Re: [dpdk-dev] [PATCH v3 00/11] Fix build errors related to exported headers
2016-07-07 15:49 ` [dpdk-dev] [PATCH v3 " Adrien Mazarguil
` (10 preceding siblings ...)
2016-07-07 15:49 ` [dpdk-dev] [PATCH v3 11/11] scripts: check compilation of exported header files Adrien Mazarguil
@ 2016-07-07 18:33 ` Wiles, Keith
2016-07-08 8:05 ` Adrien Mazarguil
2016-07-13 13:02 ` [dpdk-dev] [PATCH v4 00/10] " Adrien Mazarguil
12 siblings, 1 reply; 79+ messages in thread
From: Wiles, Keith @ 2016-07-07 18:33 UTC (permalink / raw)
To: Adrien Mazarguil; +Cc: dev
> On Jul 7, 2016, at 10:49 AM, Adrien Mazarguil <adrien.mazarguil@6wind.com> wrote:
>
> DPDK uses GNU C language extensions in most of its code base. This is fine
> for internal source files whose compilation flags are controlled by DPDK,
> however user applications that use exported "public" headers may experience
> compilation failures when enabling strict error/standard checks (-std and
> -pedantic for instance).
Do you try compiling these changes with CLANG and/or ICC compilers?
^ permalink raw reply [flat|nested] 79+ messages in thread
* Re: [dpdk-dev] [PATCH v3 00/11] Fix build errors related to exported headers
2016-07-07 18:33 ` [dpdk-dev] [PATCH v3 00/11] Fix build errors related to exported headers Wiles, Keith
@ 2016-07-08 8:05 ` Adrien Mazarguil
2016-07-08 9:56 ` Ferruh Yigit
0 siblings, 1 reply; 79+ messages in thread
From: Adrien Mazarguil @ 2016-07-08 8:05 UTC (permalink / raw)
To: Wiles, Keith; +Cc: dev
On Thu, Jul 07, 2016 at 06:33:17PM +0000, Wiles, Keith wrote:
>
> > On Jul 7, 2016, at 10:49 AM, Adrien Mazarguil <adrien.mazarguil@6wind.com> wrote:
> >
> > DPDK uses GNU C language extensions in most of its code base. This is fine
> > for internal source files whose compilation flags are controlled by DPDK,
> > however user applications that use exported "public" headers may experience
> > compilation failures when enabling strict error/standard checks (-std and
> > -pedantic for instance).
>
> Do you try compiling these changes with CLANG and/or ICC compilers?
clang/clang++ yes, works fine. I did not try with ICC however.
Note that considering "({ ... })" is a GNU extension, compilers that do
support this syntax also support the GNU __extension__ keyword. As a result,
those that do not support this keyword most likely already cannot compile
DPDK at all.
--
Adrien Mazarguil
6WIND
^ permalink raw reply [flat|nested] 79+ messages in thread
* Re: [dpdk-dev] [PATCH v3 00/11] Fix build errors related to exported headers
2016-07-08 8:05 ` Adrien Mazarguil
@ 2016-07-08 9:56 ` Ferruh Yigit
2016-07-08 14:15 ` Wiles, Keith
0 siblings, 1 reply; 79+ messages in thread
From: Ferruh Yigit @ 2016-07-08 9:56 UTC (permalink / raw)
To: Wiles, Keith, dev
On 7/8/2016 9:05 AM, Adrien Mazarguil wrote:
> On Thu, Jul 07, 2016 at 06:33:17PM +0000, Wiles, Keith wrote:
>>
>>> On Jul 7, 2016, at 10:49 AM, Adrien Mazarguil <adrien.mazarguil@6wind.com> wrote:
>>>
>>> DPDK uses GNU C language extensions in most of its code base. This is fine
>>> for internal source files whose compilation flags are controlled by DPDK,
>>> however user applications that use exported "public" headers may experience
>>> compilation failures when enabling strict error/standard checks (-std and
>>> -pedantic for instance).
>>
>> Do you try compiling these changes with CLANG and/or ICC compilers?
>
> clang/clang++ yes, works fine. I did not try with ICC however.
I tested with icc, getting following error [1], compiler warning seems
valid, but didn't investigate what in your patch cause this.
[1]
.../app/test/test_table_acl.c(487): error #2405: array of elements
containing a flexible array member is nonstandard
struct rte_pipeline_table_entry entries[5];
^
.../app/test/test_table_acl.c(492): error #2405: array of elements
containing a flexible array member is nonstandard
struct rte_pipeline_table_entry entries_ptr[5];
>
> Note that considering "({ ... })" is a GNU extension, compilers that do
> support this syntax also support the GNU __extension__ keyword. As a result,
> those that do not support this keyword most likely already cannot compile
> DPDK at all.
>
^ permalink raw reply [flat|nested] 79+ messages in thread
* Re: [dpdk-dev] [PATCH v3 00/11] Fix build errors related to exported headers
2016-07-08 9:56 ` Ferruh Yigit
@ 2016-07-08 14:15 ` Wiles, Keith
2016-07-08 14:35 ` Adrien Mazarguil
0 siblings, 1 reply; 79+ messages in thread
From: Wiles, Keith @ 2016-07-08 14:15 UTC (permalink / raw)
To: Yigit, Ferruh; +Cc: dev
> On Jul 8, 2016, at 4:56 AM, Yigit, Ferruh <ferruh.yigit@intel.com> wrote:
>
> On 7/8/2016 9:05 AM, Adrien Mazarguil wrote:
>> On Thu, Jul 07, 2016 at 06:33:17PM +0000, Wiles, Keith wrote:
>>>
>>>> On Jul 7, 2016, at 10:49 AM, Adrien Mazarguil <adrien.mazarguil@6wind.com> wrote:
>>>>
>>>> DPDK uses GNU C language extensions in most of its code base. This is fine
>>>> for internal source files whose compilation flags are controlled by DPDK,
>>>> however user applications that use exported "public" headers may experience
>>>> compilation failures when enabling strict error/standard checks (-std and
>>>> -pedantic for instance).
>>>
>>> Do you try compiling these changes with CLANG and/or ICC compilers?
>>
>> clang/clang++ yes, works fine. I did not try with ICC however.
>
> I tested with icc, getting following error [1], compiler warning seems
> valid, but didn't investigate what in your patch cause this.
>
> [1]
> .../app/test/test_table_acl.c(487): error #2405: array of elements
> containing a flexible array member is nonstandard
> struct rte_pipeline_table_entry entries[5];
> ^
>
> .../app/test/test_table_acl.c(492): error #2405: array of elements
> containing a flexible array member is nonstandard
> struct rte_pipeline_table_entry entries_ptr[5];
I am guessing it does not like the uint8_t action_data[0] in the rte_pipeline_table_entry structure. I can see why it would be non-standard allocated on the stack in this case. Maybe a keyword like __extension__ needs to be added or pragma.
>
>>
>> Note that considering "({ ... })" is a GNU extension, compilers that do
>> support this syntax also support the GNU __extension__ keyword. As a result,
>> those that do not support this keyword most likely already cannot compile
>> DPDK at all.
>>
>
^ permalink raw reply [flat|nested] 79+ messages in thread
* Re: [dpdk-dev] [PATCH v3 00/11] Fix build errors related to exported headers
2016-07-08 14:15 ` Wiles, Keith
@ 2016-07-08 14:35 ` Adrien Mazarguil
2016-07-08 14:45 ` Ferruh Yigit
0 siblings, 1 reply; 79+ messages in thread
From: Adrien Mazarguil @ 2016-07-08 14:35 UTC (permalink / raw)
To: Wiles, Keith; +Cc: Yigit, Ferruh, dev
On Fri, Jul 08, 2016 at 02:15:37PM +0000, Wiles, Keith wrote:
>
> > On Jul 8, 2016, at 4:56 AM, Yigit, Ferruh <ferruh.yigit@intel.com> wrote:
> >
> > On 7/8/2016 9:05 AM, Adrien Mazarguil wrote:
> >> On Thu, Jul 07, 2016 at 06:33:17PM +0000, Wiles, Keith wrote:
> >>>
> >>>> On Jul 7, 2016, at 10:49 AM, Adrien Mazarguil <adrien.mazarguil@6wind.com> wrote:
> >>>>
> >>>> DPDK uses GNU C language extensions in most of its code base. This is fine
> >>>> for internal source files whose compilation flags are controlled by DPDK,
> >>>> however user applications that use exported "public" headers may experience
> >>>> compilation failures when enabling strict error/standard checks (-std and
> >>>> -pedantic for instance).
> >>>
> >>> Do you try compiling these changes with CLANG and/or ICC compilers?
> >>
> >> clang/clang++ yes, works fine. I did not try with ICC however.
> >
> > I tested with icc, getting following error [1], compiler warning seems
> > valid, but didn't investigate what in your patch cause this.
> >
> > [1]
> > .../app/test/test_table_acl.c(487): error #2405: array of elements
> > containing a flexible array member is nonstandard
> > struct rte_pipeline_table_entry entries[5];
> > ^
> >
> > .../app/test/test_table_acl.c(492): error #2405: array of elements
> > containing a flexible array member is nonstandard
> > struct rte_pipeline_table_entry entries_ptr[5];
>
> I am guessing it does not like the uint8_t action_data[0] in the rte_pipeline_table_entry structure. I can see why it would be non-standard allocated on the stack in this case. Maybe a keyword like __extension__ needs to be added or pragma.
Hmmm, right, a variable array cannot be embedded like that. I think a change
in test_table_acl.c would be better. I guess I missed a compilation check on
these tests programs. Is that the only issue you saw?
> >> Note that considering "({ ... })" is a GNU extension, compilers that do
> >> support this syntax also support the GNU __extension__ keyword. As a result,
> >> those that do not support this keyword most likely already cannot compile
> >> DPDK at all.
--
Adrien Mazarguil
6WIND
^ permalink raw reply [flat|nested] 79+ messages in thread
* Re: [dpdk-dev] [PATCH v3 00/11] Fix build errors related to exported headers
2016-07-08 14:35 ` Adrien Mazarguil
@ 2016-07-08 14:45 ` Ferruh Yigit
2016-07-08 15:23 ` Adrien Mazarguil
0 siblings, 1 reply; 79+ messages in thread
From: Ferruh Yigit @ 2016-07-08 14:45 UTC (permalink / raw)
To: Wiles, Keith, dev
On 7/8/2016 3:35 PM, Adrien Mazarguil wrote:
> On Fri, Jul 08, 2016 at 02:15:37PM +0000, Wiles, Keith wrote:
>>
>>> On Jul 8, 2016, at 4:56 AM, Yigit, Ferruh <ferruh.yigit@intel.com> wrote:
>>>
>>> On 7/8/2016 9:05 AM, Adrien Mazarguil wrote:
>>>> On Thu, Jul 07, 2016 at 06:33:17PM +0000, Wiles, Keith wrote:
>>>>>
>>>>>> On Jul 7, 2016, at 10:49 AM, Adrien Mazarguil <adrien.mazarguil@6wind.com> wrote:
>>>>>>
>>>>>> DPDK uses GNU C language extensions in most of its code base. This is fine
>>>>>> for internal source files whose compilation flags are controlled by DPDK,
>>>>>> however user applications that use exported "public" headers may experience
>>>>>> compilation failures when enabling strict error/standard checks (-std and
>>>>>> -pedantic for instance).
>>>>>
>>>>> Do you try compiling these changes with CLANG and/or ICC compilers?
>>>>
>>>> clang/clang++ yes, works fine. I did not try with ICC however.
>>>
>>> I tested with icc, getting following error [1], compiler warning seems
>>> valid, but didn't investigate what in your patch cause this.
>>>
>>> [1]
>>> .../app/test/test_table_acl.c(487): error #2405: array of elements
>>> containing a flexible array member is nonstandard
>>> struct rte_pipeline_table_entry entries[5];
>>> ^
>>>
>>> .../app/test/test_table_acl.c(492): error #2405: array of elements
>>> containing a flexible array member is nonstandard
>>> struct rte_pipeline_table_entry entries_ptr[5];
>>
>> I am guessing it does not like the uint8_t action_data[0] in the rte_pipeline_table_entry structure. I can see why it would be non-standard allocated on the stack in this case. Maybe a keyword like __extension__ needs to be added or pragma.
>
> Hmmm, right, a variable array cannot be embedded like that. I think a change
> in test_table_acl.c would be better.
Correct, I just wonder why not getting this same compiler warning before
your changes.
...
> Is that the only issue you saw?
>
Yes.
>>>> Note that considering "({ ... })" is a GNU extension, compilers that do
>>>> support this syntax also support the GNU __extension__ keyword. As a result,
>>>> those that do not support this keyword most likely already cannot compile
>>>> DPDK at all.
>
^ permalink raw reply [flat|nested] 79+ messages in thread
* Re: [dpdk-dev] [PATCH v3 00/11] Fix build errors related to exported headers
2016-07-08 14:45 ` Ferruh Yigit
@ 2016-07-08 15:23 ` Adrien Mazarguil
0 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-07-08 15:23 UTC (permalink / raw)
To: Ferruh Yigit; +Cc: Wiles, Keith, dev
On Fri, Jul 08, 2016 at 03:45:50PM +0100, Ferruh Yigit wrote:
> On 7/8/2016 3:35 PM, Adrien Mazarguil wrote:
> > On Fri, Jul 08, 2016 at 02:15:37PM +0000, Wiles, Keith wrote:
> >>
> >>> On Jul 8, 2016, at 4:56 AM, Yigit, Ferruh <ferruh.yigit@intel.com> wrote:
> >>>
> >>> On 7/8/2016 9:05 AM, Adrien Mazarguil wrote:
> >>>> On Thu, Jul 07, 2016 at 06:33:17PM +0000, Wiles, Keith wrote:
> >>>>>
> >>>>>> On Jul 7, 2016, at 10:49 AM, Adrien Mazarguil <adrien.mazarguil@6wind.com> wrote:
> >>>>>>
> >>>>>> DPDK uses GNU C language extensions in most of its code base. This is fine
> >>>>>> for internal source files whose compilation flags are controlled by DPDK,
> >>>>>> however user applications that use exported "public" headers may experience
> >>>>>> compilation failures when enabling strict error/standard checks (-std and
> >>>>>> -pedantic for instance).
> >>>>>
> >>>>> Do you try compiling these changes with CLANG and/or ICC compilers?
> >>>>
> >>>> clang/clang++ yes, works fine. I did not try with ICC however.
> >>>
> >>> I tested with icc, getting following error [1], compiler warning seems
> >>> valid, but didn't investigate what in your patch cause this.
> >>>
> >>> [1]
> >>> .../app/test/test_table_acl.c(487): error #2405: array of elements
> >>> containing a flexible array member is nonstandard
> >>> struct rte_pipeline_table_entry entries[5];
> >>> ^
> >>>
> >>> .../app/test/test_table_acl.c(492): error #2405: array of elements
> >>> containing a flexible array member is nonstandard
> >>> struct rte_pipeline_table_entry entries_ptr[5];
> >>
> >> I am guessing it does not like the uint8_t action_data[0] in the rte_pipeline_table_entry structure. I can see why it would be non-standard allocated on the stack in this case. Maybe a keyword like __extension__ needs to be added or pragma.
> >
> > Hmmm, right, a variable array cannot be embedded like that. I think a change
> > in test_table_acl.c would be better.
> Correct, I just wonder why not getting this same compiler warning before
> your changes.
>
> ...
I guess declaring a zero-sized array does not give the same compiler
constraints as declaring a variable-sized one even though the structure has
the same size in both cases. C99 does not allow it. This is probably the
only difference.
>
> > Is that the only issue you saw?
> >
> Yes.
OK then, prepare for v4.
> >>>> Note that considering "({ ... })" is a GNU extension, compilers that do
> >>>> support this syntax also support the GNU __extension__ keyword. As a result,
> >>>> those that do not support this keyword most likely already cannot compile
> >>>> DPDK at all.
--
Adrien Mazarguil
6WIND
^ permalink raw reply [flat|nested] 79+ messages in thread
* [dpdk-dev] [PATCH v4 00/10] Fix build errors related to exported headers
2016-07-07 15:49 ` [dpdk-dev] [PATCH v3 " Adrien Mazarguil
` (11 preceding siblings ...)
2016-07-07 18:33 ` [dpdk-dev] [PATCH v3 00/11] Fix build errors related to exported headers Wiles, Keith
@ 2016-07-13 13:02 ` Adrien Mazarguil
2016-07-13 13:02 ` [dpdk-dev] [PATCH v4 01/10] lib: work around braced-groups within expressions Adrien Mazarguil
` (12 more replies)
12 siblings, 13 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-07-13 13:02 UTC (permalink / raw)
To: dev; +Cc: Ferruh Yigit
DPDK uses GNU C language extensions in most of its code base. This is fine
for internal source files whose compilation flags are controlled by DPDK,
however user applications that use exported "public" headers may experience
compilation failures when enabling strict error/standard checks (-std and
-pedantic for instance).
Exported headers are installed system-wide and must be as clean as possible
so applications do not have to resort to workarounds.
This patchset affects exported headers only, compilation problems are
addressed as follows:
- Adding the __extension__ keyword to nonstandard constructs (same method
as existing libraries when there is no other choice).
- Adding the __extension__ keyword to C11 constructs to remain compatible
with pure C99.
- Adding missing includes so exported files can be included out of order
and on their own.
- Fixing GNU printf-like variadic macros as there is no magic keyword for
these.
Changes in v4:
- Dropped "lib: work around structs with no members" patch, now addressed as
a separate issue outside of this patchset by "mempool: fix empty structure
definition".
- Fixed remaining compilation error with ICC reported by Ferruh. Finally
settled on using the __extension__ keyword directly in struct
rte_pipeline_table_entry as converting it to a standard flexible array may
break existing programs.
Changes in v3:
- Fixed compilation issue on ARM and POWER8 due to missing parenthesis.
- Added bit-field fix for rte_kni.h.
Changes in v2:
- Rebased on top of the current HEAD.
- Added script to check headers automatically (check-includes.sh), for both
C and C++ compilation.
- Updated test-build.sh to use it.
- Fixed consistency of new #include directives, now inside extern "C"
blocks for files that already do that (Jan, fixing these was too much
work for this patchset so I settled on this solution in the meantime).
- Updated headlines to address check-git-log.sh complaints.
Adrien Mazarguil (10):
lib: work around braced-groups within expressions
lib: work around large enum values
lib: use C99 syntax for zero-size arrays
lib: work around nonstandard bit-fields
lib: work around unnamed structs/unions
lib: add missing include dependencies
lib: work around forward reference to enum types
lib: remove named variadic macros in exported headers
lib: hide static functions never defined
scripts: check compilation of exported header files
MAINTAINERS | 1 +
lib/librte_acl/rte_acl.h | 2 +-
lib/librte_cfgfile/rte_cfgfile.h | 2 +
lib/librte_cmdline/cmdline.h | 1 +
lib/librte_cmdline/cmdline_parse_portlist.h | 1 +
lib/librte_cmdline/cmdline_socket.h | 3 +
lib/librte_cryptodev/rte_crypto.h | 2 +
lib/librte_cryptodev/rte_crypto_sym.h | 3 +
lib/librte_cryptodev/rte_cryptodev.h | 40 ++-
lib/librte_cryptodev/rte_cryptodev_pmd.h | 6 +-
.../common/include/arch/arm/rte_byteorder.h | 2 +
.../common/include/arch/arm/rte_memcpy_32.h | 3 +-
.../common/include/arch/arm/rte_prefetch_32.h | 1 +
.../common/include/arch/arm/rte_prefetch_64.h | 1 +
.../common/include/arch/arm/rte_vect.h | 1 +
.../common/include/arch/ppc_64/rte_atomic.h | 1 +
.../common/include/arch/ppc_64/rte_byteorder.h | 1 +
.../common/include/arch/ppc_64/rte_cycles.h | 2 +
.../common/include/arch/ppc_64/rte_memcpy.h | 3 +-
.../common/include/arch/ppc_64/rte_prefetch.h | 1 +
.../common/include/arch/x86/rte_atomic.h | 2 +
.../common/include/arch/x86/rte_atomic_32.h | 9 +
.../common/include/arch/x86/rte_atomic_64.h | 8 +
.../common/include/arch/x86/rte_byteorder.h | 2 +
.../common/include/arch/x86/rte_byteorder_32.h | 7 +
.../common/include/arch/x86/rte_byteorder_64.h | 7 +
.../common/include/arch/x86/rte_cycles.h | 2 +
.../common/include/arch/x86/rte_memcpy.h | 4 +-
.../common/include/arch/x86/rte_prefetch.h | 1 +
.../common/include/arch/x86/rte_rtm.h | 1 +
.../common/include/arch/x86/rte_vect.h | 8 +-
.../common/include/generic/rte_atomic.h | 1 +
.../common/include/generic/rte_byteorder.h | 2 +
.../common/include/generic/rte_cpuflags.h | 3 +
.../common/include/generic/rte_memcpy.h | 4 +
lib/librte_eal/common/include/rte_common.h | 22 +-
lib/librte_eal/common/include/rte_devargs.h | 1 +
lib/librte_eal/common/include/rte_eal.h | 1 +
lib/librte_eal/common/include/rte_interrupts.h | 2 +
lib/librte_eal/common/include/rte_memory.h | 4 +
lib/librte_eal/common/include/rte_memzone.h | 2 +
lib/librte_eal/common/include/rte_time.h | 8 +
lib/librte_eal/common/include/rte_version.h | 1 +
.../eal/include/exec-env/rte_interrupts.h | 1 +
.../eal/include/exec-env/rte_kni_common.h | 7 +-
lib/librte_ether/rte_dev_info.h | 2 +
lib/librte_ether/rte_eth_ctrl.h | 4 +
lib/librte_ether/rte_ethdev.h | 4 +
lib/librte_hash/rte_fbk_hash.h | 2 +-
lib/librte_hash/rte_thash.h | 3 +
lib/librte_ip_frag/rte_ip_frag.h | 2 +-
lib/librte_kni/rte_kni.h | 1 +
lib/librte_lpm/rte_lpm.h | 7 +-
lib/librte_lpm/rte_lpm_neon.h | 1 +
lib/librte_lpm/rte_lpm_sse.h | 1 +
lib/librte_mbuf/rte_mbuf.h | 9 +
lib/librte_mempool/rte_mempool.h | 2 +
lib/librte_pdump/rte_pdump.h | 4 +
lib/librte_pipeline/rte_pipeline.h | 4 +-
lib/librte_reorder/rte_reorder.h | 2 +
lib/librte_ring/rte_ring.h | 2 +-
lib/librte_sched/rte_bitmap.h | 3 +-
lib/librte_sched/rte_reciprocal.h | 2 +
lib/librte_sched/rte_sched_common.h | 1 +
lib/librte_timer/rte_timer.h | 2 +
scripts/check-includes.sh | 286 +++++++++++++++++++
scripts/test-build.sh | 14 +
67 files changed, 512 insertions(+), 33 deletions(-)
create mode 100755 scripts/check-includes.sh
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* [dpdk-dev] [PATCH v4 01/10] lib: work around braced-groups within expressions
2016-07-13 13:02 ` [dpdk-dev] [PATCH v4 00/10] " Adrien Mazarguil
@ 2016-07-13 13:02 ` Adrien Mazarguil
2016-07-13 13:02 ` [dpdk-dev] [PATCH v4 02/10] lib: work around large enum values Adrien Mazarguil
` (11 subsequent siblings)
12 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-07-13 13:02 UTC (permalink / raw)
To: dev
Exported header files used by applications should allow the strictest
compiler flags. Language extensions used in many places must be explicitly
marked or removed to avoid warnings and compilation failures.
This commit prevents the following errors:
error: ISO C forbids braced-groups within expressions
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
lib/librte_eal/common/include/arch/arm/rte_memcpy_32.h | 3 ++-
lib/librte_eal/common/include/arch/ppc_64/rte_memcpy.h | 3 ++-
lib/librte_eal/common/include/arch/x86/rte_memcpy.h | 4 ++--
lib/librte_eal/common/include/arch/x86/rte_vect.h | 6 ++++--
lib/librte_eal/common/include/rte_common.h | 6 ++++--
5 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/lib/librte_eal/common/include/arch/arm/rte_memcpy_32.h b/lib/librte_eal/common/include/arch/arm/rte_memcpy_32.h
index da6c233..c3a2619 100644
--- a/lib/librte_eal/common/include/arch/arm/rte_memcpy_32.h
+++ b/lib/librte_eal/common/include/arch/arm/rte_memcpy_32.h
@@ -148,7 +148,8 @@ rte_mov256(uint8_t *dst, const uint8_t *src)
}
#define rte_memcpy(dst, src, n) \
- ({ (__builtin_constant_p(n)) ? \
+ __extension__ ({ \
+ (__builtin_constant_p(n)) ? \
memcpy((dst), (src), (n)) : \
rte_memcpy_func((dst), (src), (n)); })
diff --git a/lib/librte_eal/common/include/arch/ppc_64/rte_memcpy.h b/lib/librte_eal/common/include/arch/ppc_64/rte_memcpy.h
index acf7aac..ca9d1dc 100644
--- a/lib/librte_eal/common/include/arch/ppc_64/rte_memcpy.h
+++ b/lib/librte_eal/common/include/arch/ppc_64/rte_memcpy.h
@@ -95,7 +95,8 @@ rte_mov256(uint8_t *dst, const uint8_t *src)
}
#define rte_memcpy(dst, src, n) \
- ({ (__builtin_constant_p(n)) ? \
+ __extension__ ({ \
+ (__builtin_constant_p(n)) ? \
memcpy((dst), (src), (n)) : \
rte_memcpy_func((dst), (src), (n)); })
diff --git a/lib/librte_eal/common/include/arch/x86/rte_memcpy.h b/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
index 413035e..b3bfc23 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
@@ -594,7 +594,7 @@ rte_mov256(uint8_t *dst, const uint8_t *src)
* - __m128i <xmm0> ~ <xmm8> must be pre-defined
*/
#define MOVEUNALIGNED_LEFT47_IMM(dst, src, len, offset) \
-({ \
+__extension__ ({ \
int tmp; \
while (len >= 128 + 16 - offset) { \
xmm0 = _mm_loadu_si128((const __m128i *)((const uint8_t *)src - offset + 0 * 16)); \
@@ -655,7 +655,7 @@ rte_mov256(uint8_t *dst, const uint8_t *src)
* - __m128i <xmm0> ~ <xmm8> used in MOVEUNALIGNED_LEFT47_IMM must be pre-defined
*/
#define MOVEUNALIGNED_LEFT47(dst, src, len, offset) \
-({ \
+__extension__ ({ \
switch (offset) { \
case 0x01: MOVEUNALIGNED_LEFT47_IMM(dst, src, n, 0x01); break; \
case 0x02: MOVEUNALIGNED_LEFT47_IMM(dst, src, n, 0x02); break; \
diff --git a/lib/librte_eal/common/include/arch/x86/rte_vect.h b/lib/librte_eal/common/include/arch/x86/rte_vect.h
index b698797..2836f2c 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_vect.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_vect.h
@@ -106,7 +106,8 @@ typedef union rte_ymm {
#endif /* __AVX__ */
#ifdef RTE_ARCH_I686
-#define _mm_cvtsi128_si64(a) ({ \
+#define _mm_cvtsi128_si64(a) \
+__extension__ ({ \
rte_xmm_t m; \
m.x = (a); \
(m.u64[0]); \
@@ -117,7 +118,8 @@ typedef union rte_ymm {
* Prior to version 12.1 icc doesn't support _mm_set_epi64x.
*/
#if (defined(__ICC) && __ICC < 1210)
-#define _mm_set_epi64x(a, b) ({ \
+#define _mm_set_epi64x(a, b) \
+__extension__ ({ \
rte_xmm_t m; \
m.u64[0] = b; \
m.u64[1] = a; \
diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h
index 332f2a4..477472b 100644
--- a/lib/librte_eal/common/include/rte_common.h
+++ b/lib/librte_eal/common/include/rte_common.h
@@ -268,7 +268,8 @@ rte_align64pow2(uint64_t v)
/**
* Macro to return the minimum of two numbers
*/
-#define RTE_MIN(a, b) ({ \
+#define RTE_MIN(a, b) \
+ __extension__ ({ \
typeof (a) _a = (a); \
typeof (b) _b = (b); \
_a < _b ? _a : _b; \
@@ -277,7 +278,8 @@ rte_align64pow2(uint64_t v)
/**
* Macro to return the maximum of two numbers
*/
-#define RTE_MAX(a, b) ({ \
+#define RTE_MAX(a, b) \
+ __extension__ ({ \
typeof (a) _a = (a); \
typeof (b) _b = (b); \
_a > _b ? _a : _b; \
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* [dpdk-dev] [PATCH v4 02/10] lib: work around large enum values
2016-07-13 13:02 ` [dpdk-dev] [PATCH v4 00/10] " Adrien Mazarguil
2016-07-13 13:02 ` [dpdk-dev] [PATCH v4 01/10] lib: work around braced-groups within expressions Adrien Mazarguil
@ 2016-07-13 13:02 ` Adrien Mazarguil
2016-07-13 13:02 ` [dpdk-dev] [PATCH v4 03/10] lib: use C99 syntax for zero-size arrays Adrien Mazarguil
` (10 subsequent siblings)
12 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-07-13 13:02 UTC (permalink / raw)
To: dev
Exported header files used by applications should allow the strictest
compiler flags. Language extensions used in many places must be explicitly
marked or removed to avoid warnings and compilation failures.
This commit prevents the following errors:
error: ISO C restricts enumerator values to range of `int'
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
lib/librte_eal/common/include/rte_memory.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/librte_eal/common/include/rte_memory.h b/lib/librte_eal/common/include/rte_memory.h
index 0661109..6a2b3f1 100644
--- a/lib/librte_eal/common/include/rte_memory.h
+++ b/lib/librte_eal/common/include/rte_memory.h
@@ -54,6 +54,7 @@ extern "C" {
#include <rte_common.h>
+__extension__
enum rte_page_sizes {
RTE_PGSIZE_4K = 1ULL << 12,
RTE_PGSIZE_64K = 1ULL << 16,
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* [dpdk-dev] [PATCH v4 03/10] lib: use C99 syntax for zero-size arrays
2016-07-13 13:02 ` [dpdk-dev] [PATCH v4 00/10] " Adrien Mazarguil
2016-07-13 13:02 ` [dpdk-dev] [PATCH v4 01/10] lib: work around braced-groups within expressions Adrien Mazarguil
2016-07-13 13:02 ` [dpdk-dev] [PATCH v4 02/10] lib: work around large enum values Adrien Mazarguil
@ 2016-07-13 13:02 ` Adrien Mazarguil
2016-07-13 13:02 ` [dpdk-dev] [PATCH v4 04/10] lib: work around nonstandard bit-fields Adrien Mazarguil
` (9 subsequent siblings)
12 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-07-13 13:02 UTC (permalink / raw)
To: dev
Exported header files used by applications should allow the strictest
compiler flags. Language extensions used in many places must be explicitly
marked or removed to avoid warnings and compilation failures.
The extension keyword is used whenever the C99 syntax cannot do it.
This commit prevents the following errors:
error: ISO C forbids zero-size array `[...]'
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
lib/librte_acl/rte_acl.h | 2 +-
lib/librte_cryptodev/rte_cryptodev.h | 2 +-
lib/librte_cryptodev/rte_cryptodev_pmd.h | 2 +-
lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h | 2 +-
lib/librte_hash/rte_fbk_hash.h | 2 +-
lib/librte_ip_frag/rte_ip_frag.h | 2 +-
lib/librte_lpm/rte_lpm.h | 2 +-
lib/librte_mbuf/rte_mbuf.h | 3 +++
lib/librte_pipeline/rte_pipeline.h | 2 +-
lib/librte_ring/rte_ring.h | 2 +-
lib/librte_sched/rte_bitmap.h | 2 +-
11 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/lib/librte_acl/rte_acl.h b/lib/librte_acl/rte_acl.h
index 0979a09..c059dc3 100644
--- a/lib/librte_acl/rte_acl.h
+++ b/lib/librte_acl/rte_acl.h
@@ -144,7 +144,7 @@ struct rte_acl_rule_data {
struct rte_acl_field field[fld_num]; \
}
-RTE_ACL_RULE_DEF(rte_acl_rule, 0);
+RTE_ACL_RULE_DEF(rte_acl_rule,);
#define RTE_ACL_RULE_SZ(fld_num) \
(sizeof(struct rte_acl_rule) + sizeof(struct rte_acl_field) * (fld_num))
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index affbdec..1e30a19 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -759,7 +759,7 @@ struct rte_cryptodev_sym_session {
} __rte_aligned(8);
/**< Public symmetric session details */
- char _private[0];
+ char _private[];
/**< Private session material */
};
diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h b/lib/librte_cryptodev/rte_cryptodev_pmd.h
index 7d049ea..3a3845c 100644
--- a/lib/librte_cryptodev/rte_cryptodev_pmd.h
+++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h
@@ -71,7 +71,7 @@ struct rte_cryptodev_session {
struct rte_mempool *mp;
} __rte_aligned(8);
- char _private[0];
+ char _private[];
};
struct rte_cryptodev_driver;
diff --git a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
index 2acdfd9..7f458a3 100644
--- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
+++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
@@ -102,7 +102,7 @@ struct rte_kni_fifo {
volatile unsigned read; /**< Next position to be read */
unsigned len; /**< Circular buffer length */
unsigned elem_size; /**< Pointer size - for 32/64 bit OS */
- void * volatile buffer[0]; /**< The buffer contains mbuf pointers */
+ void *volatile buffer[]; /**< The buffer contains mbuf pointers */
};
/*
diff --git a/lib/librte_hash/rte_fbk_hash.h b/lib/librte_hash/rte_fbk_hash.h
index a430961..bd46048 100644
--- a/lib/librte_hash/rte_fbk_hash.h
+++ b/lib/librte_hash/rte_fbk_hash.h
@@ -115,7 +115,7 @@ struct rte_fbk_hash_table {
uint32_t init_val; /**< For initialising hash function. */
/** A flat table of all buckets. */
- union rte_fbk_hash_entry t[0];
+ union rte_fbk_hash_entry t[];
};
/**
diff --git a/lib/librte_ip_frag/rte_ip_frag.h b/lib/librte_ip_frag/rte_ip_frag.h
index 92cedf2..4c3faad 100644
--- a/lib/librte_ip_frag/rte_ip_frag.h
+++ b/lib/librte_ip_frag/rte_ip_frag.h
@@ -124,7 +124,7 @@ struct rte_ip_frag_tbl {
struct ip_frag_pkt *last; /**< last used entry. */
struct ip_pkt_list lru; /**< LRU list for table entries. */
struct ip_frag_tbl_stat stat; /**< statistics counters. */
- struct ip_frag_pkt pkt[0]; /**< hash table. */
+ struct ip_frag_pkt pkt[]; /**< hash table. */
};
/** IPv6 fragment extension header */
diff --git a/lib/librte_lpm/rte_lpm.h b/lib/librte_lpm/rte_lpm.h
index 2df1d67..79a4593 100644
--- a/lib/librte_lpm/rte_lpm.h
+++ b/lib/librte_lpm/rte_lpm.h
@@ -193,7 +193,7 @@ struct rte_lpm_v20 {
__rte_cache_aligned; /**< LPM tbl24 table. */
struct rte_lpm_tbl_entry_v20 tbl8[RTE_LPM_TBL8_NUM_ENTRIES]
__rte_cache_aligned; /**< LPM tbl8 table. */
- struct rte_lpm_rule_v20 rules_tbl[0] \
+ struct rte_lpm_rule_v20 rules_tbl[]
__rte_cache_aligned; /**< LPM rules. */
};
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 101485f..434ec31 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -756,8 +756,11 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask);
/* define a set of marker types that can be used to refer to set points in the
* mbuf */
+__extension__
typedef void *MARKER[0]; /**< generic marker for a point in a structure */
+__extension__
typedef uint8_t MARKER8[0]; /**< generic marker with 1B alignment */
+__extension__
typedef uint64_t MARKER64[0]; /**< marker that allows us to overwrite 8 bytes
* with a single assignment */
diff --git a/lib/librte_pipeline/rte_pipeline.h b/lib/librte_pipeline/rte_pipeline.h
index 84d1802..b0b4615 100644
--- a/lib/librte_pipeline/rte_pipeline.h
+++ b/lib/librte_pipeline/rte_pipeline.h
@@ -252,7 +252,7 @@ struct rte_pipeline_table_entry {
uint32_t table_id;
};
/** Start of table entry area for user defined actions and meta-data */
- uint8_t action_data[0];
+ __extension__ uint8_t action_data[0];
};
/**
diff --git a/lib/librte_ring/rte_ring.h b/lib/librte_ring/rte_ring.h
index eb45e41..12874f7 100644
--- a/lib/librte_ring/rte_ring.h
+++ b/lib/librte_ring/rte_ring.h
@@ -179,7 +179,7 @@ struct rte_ring {
struct rte_ring_debug_stats stats[RTE_MAX_LCORE];
#endif
- void * ring[0] __rte_cache_aligned; /**< Memory space of ring starts here.
+ void *ring[] __rte_cache_aligned; /**< Memory space of ring starts here.
* not volatile so need to be careful
* about compiler re-ordering */
};
diff --git a/lib/librte_sched/rte_bitmap.h b/lib/librte_sched/rte_bitmap.h
index ff675c5..1b5df02 100644
--- a/lib/librte_sched/rte_bitmap.h
+++ b/lib/librte_sched/rte_bitmap.h
@@ -103,7 +103,7 @@ struct rte_bitmap {
uint32_t go2; /**< Bitmap scan: Go/stop condition for current array2 cache line */
/* Storage space for array1 and array2 */
- uint8_t memory[0];
+ uint8_t memory[];
};
static inline void
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* [dpdk-dev] [PATCH v4 04/10] lib: work around nonstandard bit-fields
2016-07-13 13:02 ` [dpdk-dev] [PATCH v4 00/10] " Adrien Mazarguil
` (2 preceding siblings ...)
2016-07-13 13:02 ` [dpdk-dev] [PATCH v4 03/10] lib: use C99 syntax for zero-size arrays Adrien Mazarguil
@ 2016-07-13 13:02 ` Adrien Mazarguil
2016-07-13 13:02 ` [dpdk-dev] [PATCH v4 05/10] lib: work around unnamed structs/unions Adrien Mazarguil
` (8 subsequent siblings)
12 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-07-13 13:02 UTC (permalink / raw)
To: dev
Exported header files used by applications should allow the strictest
compiler flags. Language extensions used in many places must be explicitly
marked or removed to avoid warnings and compilation failures.
This commit prevents the following errors:
error: type of bit-field `[...]' is a GCC extension
Note: the standard does not require implementations to issue a diagnostic
message with these, and such errors do not occur with recent GCC or clang
versions. However, GCC 4.7 is still common and using the extension keyword
is easier than checking compiler version.
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
lib/librte_cryptodev/rte_cryptodev.h | 2 ++
lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h | 1 +
lib/librte_ether/rte_ethdev.h | 4 ++++
lib/librte_kni/rte_kni.h | 1 +
lib/librte_lpm/rte_lpm.h | 4 ++++
lib/librte_mbuf/rte_mbuf.h | 1 +
6 files changed, 13 insertions(+)
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index 1e30a19..957bdd7 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -619,6 +619,7 @@ struct rte_cryptodev {
struct rte_cryptodev_cb_list link_intr_cbs;
/**< User application callback for interrupts if present */
+ __extension__
uint8_t attached : 1;
/**< Flag indicating the device is attached */
} __rte_cache_aligned;
@@ -642,6 +643,7 @@ struct rte_cryptodev_data {
char name[RTE_CRYPTODEV_NAME_MAX_LEN];
/**< Unique identifier name */
+ __extension__
uint8_t dev_started : 1;
/**< Device state: STARTED(1)/STOPPED(0) */
diff --git a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
index 7f458a3..2ef0506 100644
--- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
+++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
@@ -159,6 +159,7 @@ struct rte_kni_device_info {
uint16_t group_id; /**< Group ID */
uint32_t core_id; /**< core ID to bind for kernel thread */
+ __extension__
uint8_t force_bind : 1; /**< Flag for kernel thread binding */
/* mbuf size */
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 4dac364..6059dd5 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -255,6 +255,7 @@ struct rte_eth_stats {
/**
* A structure used to retrieve link-level information of an Ethernet port.
*/
+__extension__
struct rte_eth_link {
uint32_t link_speed; /**< ETH_SPEED_NUM_ */
uint16_t link_duplex : 1; /**< ETH_LINK_[HALF/FULL]_DUPLEX */
@@ -346,6 +347,7 @@ struct rte_eth_rxmode {
enum rte_eth_rx_mq_mode mq_mode;
uint32_t max_rx_pkt_len; /**< Only used if jumbo_frame enabled. */
uint16_t split_hdr_size; /**< hdr buf size (header_split enabled).*/
+ __extension__
uint16_t header_split : 1, /**< Header Split enable. */
hw_ip_checksum : 1, /**< IP/UDP/TCP checksum offload enable. */
hw_vlan_filter : 1, /**< VLAN filter enable. */
@@ -645,6 +647,7 @@ struct rte_eth_txmode {
/* For i40e specifically */
uint16_t pvid;
+ __extension__
uint8_t hw_vlan_reject_tagged : 1,
/**< If set, reject sending out tagged pkts */
hw_vlan_reject_untagged : 1,
@@ -1691,6 +1694,7 @@ struct rte_eth_dev_data {
struct ether_addr* hash_mac_addrs;
/** Device Ethernet MAC addresses of hash filtering. */
uint8_t port_id; /**< Device [external] port identifier. */
+ __extension__
uint8_t promiscuous : 1, /**< RX promiscuous mode ON(1) / OFF(0). */
scattered_rx : 1, /**< RX of scattered packets is ON(1) / OFF(0) */
all_multicast : 1, /**< RX all multicast mode ON(1) / OFF(0). */
diff --git a/lib/librte_kni/rte_kni.h b/lib/librte_kni/rte_kni.h
index 7363e6c..5f6f9e4 100644
--- a/lib/librte_kni/rte_kni.h
+++ b/lib/librte_kni/rte_kni.h
@@ -88,6 +88,7 @@ struct rte_kni_conf {
struct rte_pci_addr addr;
struct rte_pci_id id;
+ __extension__
uint8_t force_bind : 1; /* Flag to bind kernel thread */
};
diff --git a/lib/librte_lpm/rte_lpm.h b/lib/librte_lpm/rte_lpm.h
index 79a4593..28668a3 100644
--- a/lib/librte_lpm/rte_lpm.h
+++ b/lib/librte_lpm/rte_lpm.h
@@ -93,6 +93,7 @@ extern "C" {
#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
/** @internal Tbl24 entry structure. */
+__extension__
struct rte_lpm_tbl_entry_v20 {
/**
* Stores Next hop (tbl8 or tbl24 when valid_group is not set) or
@@ -116,6 +117,7 @@ struct rte_lpm_tbl_entry_v20 {
uint8_t depth :6; /**< Rule depth. */
};
+__extension__
struct rte_lpm_tbl_entry {
/**
* Stores Next hop (tbl8 or tbl24 when valid_group is not set) or
@@ -137,6 +139,7 @@ struct rte_lpm_tbl_entry {
};
#else
+__extension__
struct rte_lpm_tbl_entry_v20 {
uint8_t depth :6;
uint8_t valid_group :1;
@@ -147,6 +150,7 @@ struct rte_lpm_tbl_entry_v20 {
};
};
+__extension__
struct rte_lpm_tbl_entry {
uint32_t depth :6;
uint32_t valid_group :1;
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 434ec31..3d3e847 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -865,6 +865,7 @@ struct rte_mbuf {
/* fields to support TX offloads */
union {
uint64_t tx_offload; /**< combined for easy fetch */
+ __extension__
struct {
uint64_t l2_len:7; /**< L2 (MAC) Header Length. */
uint64_t l3_len:9; /**< L3 (IP) Header Length. */
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* [dpdk-dev] [PATCH v4 05/10] lib: work around unnamed structs/unions
2016-07-13 13:02 ` [dpdk-dev] [PATCH v4 00/10] " Adrien Mazarguil
` (3 preceding siblings ...)
2016-07-13 13:02 ` [dpdk-dev] [PATCH v4 04/10] lib: work around nonstandard bit-fields Adrien Mazarguil
@ 2016-07-13 13:02 ` Adrien Mazarguil
2016-07-13 13:02 ` [dpdk-dev] [PATCH v4 06/10] lib: add missing include dependencies Adrien Mazarguil
` (7 subsequent siblings)
12 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-07-13 13:02 UTC (permalink / raw)
To: dev
Exported header files used by applications should allow the strictest
compiler flags. Language extensions used in many places must be explicitly
marked to avoid warnings and compilation failures.
Unnamed structs/unions are allowed since C11, however many compiler
versions do not use this mode by default.
This commit prevents the following errors:
error: ISO C99 doesn't support unnamed structs/unions
error: struct has no named members
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
lib/librte_cryptodev/rte_crypto.h | 2 ++
lib/librte_cryptodev/rte_crypto_sym.h | 3 +++
lib/librte_cryptodev/rte_cryptodev.h | 4 ++++
lib/librte_cryptodev/rte_cryptodev_pmd.h | 2 ++
lib/librte_eal/common/include/arch/ppc_64/rte_cycles.h | 2 ++
lib/librte_eal/common/include/arch/x86/rte_atomic_32.h | 3 +++
lib/librte_eal/common/include/arch/x86/rte_cycles.h | 2 ++
lib/librte_eal/common/include/rte_common.h | 7 +++++++
lib/librte_eal/common/include/rte_devargs.h | 1 +
lib/librte_eal/common/include/rte_interrupts.h | 2 ++
lib/librte_eal/common/include/rte_memory.h | 1 +
lib/librte_eal/common/include/rte_memzone.h | 2 ++
lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h | 1 +
lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h | 4 ++++
lib/librte_hash/rte_thash.h | 3 +++
lib/librte_lpm/rte_lpm.h | 1 +
lib/librte_mbuf/rte_mbuf.h | 5 +++++
lib/librte_mempool/rte_mempool.h | 2 ++
lib/librte_pipeline/rte_pipeline.h | 2 ++
lib/librte_timer/rte_timer.h | 2 ++
20 files changed, 51 insertions(+)
diff --git a/lib/librte_cryptodev/rte_crypto.h b/lib/librte_cryptodev/rte_crypto.h
index 5bc3eaa..9019518 100644
--- a/lib/librte_cryptodev/rte_crypto.h
+++ b/lib/librte_cryptodev/rte_crypto.h
@@ -48,6 +48,7 @@ extern "C" {
#include <rte_mbuf.h>
#include <rte_memory.h>
#include <rte_mempool.h>
+#include <rte_common.h>
#include "rte_crypto_sym.h"
@@ -111,6 +112,7 @@ struct rte_crypto_op {
void *opaque_data;
/**< Opaque pointer for user data */
+ RTE_STD_C11
union {
struct rte_crypto_sym_op *sym;
/**< Symmetric operation parameters */
diff --git a/lib/librte_cryptodev/rte_crypto_sym.h b/lib/librte_cryptodev/rte_crypto_sym.h
index d9bd821..8178e5a 100644
--- a/lib/librte_cryptodev/rte_crypto_sym.h
+++ b/lib/librte_cryptodev/rte_crypto_sym.h
@@ -51,6 +51,7 @@ extern "C" {
#include <rte_mbuf.h>
#include <rte_memory.h>
#include <rte_mempool.h>
+#include <rte_common.h>
/** Symmetric Cipher Algorithms */
@@ -333,6 +334,7 @@ struct rte_crypto_sym_xform {
/**< next xform in chain */
enum rte_crypto_sym_xform_type type
; /**< xform type */
+ RTE_STD_C11
union {
struct rte_crypto_auth_xform auth;
/**< Authentication / hash xform */
@@ -371,6 +373,7 @@ struct rte_crypto_sym_op {
enum rte_crypto_sym_op_sess_type sess_type;
+ RTE_STD_C11
union {
struct rte_cryptodev_sym_session *session;
/**< Handle for the initialised session context */
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index 957bdd7..cf28541 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -48,6 +48,7 @@ extern "C" {
#include "rte_kvargs.h"
#include "rte_crypto.h"
#include "rte_dev.h"
+#include <rte_common.h>
#define CRYPTODEV_NAME_NULL_PMD cryptodev_null_pmd
/**< Null crypto PMD device name */
@@ -104,6 +105,7 @@ extern const char **rte_cyptodev_names;
struct rte_cryptodev_symmetric_capability {
enum rte_crypto_sym_xform_type xform_type;
/**< Transform type : Authentication / Cipher */
+ RTE_STD_C11
union {
struct {
enum rte_crypto_auth_algorithm algo;
@@ -177,6 +179,7 @@ struct rte_cryptodev_capabilities {
enum rte_crypto_op_type op;
/**< Operation type */
+ RTE_STD_C11
union {
struct rte_cryptodev_symmetric_capability sym;
/**< Symmetric operation capability parameters */
@@ -751,6 +754,7 @@ rte_cryptodev_enqueue_burst(uint8_t dev_id, uint16_t qp_id,
/** Cryptodev symmetric crypto session */
struct rte_cryptodev_sym_session {
+ RTE_STD_C11
struct {
uint8_t dev_id;
/**< Device Id */
diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h b/lib/librte_cryptodev/rte_cryptodev_pmd.h
index 3a3845c..cf08a50 100644
--- a/lib/librte_cryptodev/rte_cryptodev_pmd.h
+++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h
@@ -52,6 +52,7 @@ extern "C" {
#include <rte_mbuf.h>
#include <rte_mempool.h>
#include <rte_log.h>
+#include <rte_common.h>
#include "rte_crypto.h"
#include "rte_cryptodev.h"
@@ -65,6 +66,7 @@ extern "C" {
#endif
struct rte_cryptodev_session {
+ RTE_STD_C11
struct {
uint8_t dev_id;
enum rte_cryptodev_type type;
diff --git a/lib/librte_eal/common/include/arch/ppc_64/rte_cycles.h b/lib/librte_eal/common/include/arch/ppc_64/rte_cycles.h
index 64beddf..8fa6fc6 100644
--- a/lib/librte_eal/common/include/arch/ppc_64/rte_cycles.h
+++ b/lib/librte_eal/common/include/arch/ppc_64/rte_cycles.h
@@ -40,6 +40,7 @@ extern "C" {
#include "generic/rte_cycles.h"
#include <rte_byteorder.h>
+#include <rte_common.h>
/**
* Read the time base register.
@@ -52,6 +53,7 @@ rte_rdtsc(void)
{
union {
uint64_t tsc_64;
+ RTE_STD_C11
struct {
#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
uint32_t hi_32;
diff --git a/lib/librte_eal/common/include/arch/x86/rte_atomic_32.h b/lib/librte_eal/common/include/arch/x86/rte_atomic_32.h
index 400d8a9..5ce01b3 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_atomic_32.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_atomic_32.h
@@ -40,6 +40,8 @@
#ifndef _RTE_ATOMIC_I686_H_
#define _RTE_ATOMIC_I686_H_
+#include <rte_common.h>
+
/*------------------------- 64 bit atomic operations -------------------------*/
#ifndef RTE_FORCE_INTRINSICS
@@ -47,6 +49,7 @@ static inline int
rte_atomic64_cmpset(volatile uint64_t *dst, uint64_t exp, uint64_t src)
{
uint8_t res;
+ RTE_STD_C11
union {
struct {
uint32_t l32;
diff --git a/lib/librte_eal/common/include/arch/x86/rte_cycles.h b/lib/librte_eal/common/include/arch/x86/rte_cycles.h
index 6e3c7d8..5eb6ce9 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_cycles.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_cycles.h
@@ -75,12 +75,14 @@ extern "C" {
extern int rte_cycles_vmware_tsc_map;
#include <rte_branch_prediction.h>
#endif
+#include <rte_common.h>
static inline uint64_t
rte_rdtsc(void)
{
union {
uint64_t tsc_64;
+ RTE_STD_C11
struct {
uint32_t lo_32;
uint32_t hi_32;
diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h
index 477472b..98ecc1c 100644
--- a/lib/librte_eal/common/include/rte_common.h
+++ b/lib/librte_eal/common/include/rte_common.h
@@ -59,6 +59,13 @@ extern "C" {
#define asm __asm__
#endif
+/** C extension macro for environments lacking C11 features. */
+#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L
+#define RTE_STD_C11 __extension__
+#else
+#define RTE_STD_C11
+#endif
+
#ifdef RTE_ARCH_STRICT_ALIGN
typedef uint64_t unaligned_uint64_t __attribute__ ((aligned(1)));
typedef uint32_t unaligned_uint32_t __attribute__ ((aligned(1)));
diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h
index 53c59f5..c66895f 100644
--- a/lib/librte_eal/common/include/rte_devargs.h
+++ b/lib/librte_eal/common/include/rte_devargs.h
@@ -76,6 +76,7 @@ struct rte_devargs {
TAILQ_ENTRY(rte_devargs) next;
/** Type of device. */
enum rte_devtype type;
+ RTE_STD_C11
union {
/** Used if type is RTE_DEVTYPE_*_PCI. */
struct {
diff --git a/lib/librte_eal/common/include/rte_interrupts.h b/lib/librte_eal/common/include/rte_interrupts.h
index ff11ef3..fd3c6ef 100644
--- a/lib/librte_eal/common/include/rte_interrupts.h
+++ b/lib/librte_eal/common/include/rte_interrupts.h
@@ -34,6 +34,8 @@
#ifndef _RTE_INTERRUPTS_H_
#define _RTE_INTERRUPTS_H_
+#include <rte_common.h>
+
/**
* @file
*
diff --git a/lib/librte_eal/common/include/rte_memory.h b/lib/librte_eal/common/include/rte_memory.h
index 6a2b3f1..38fbe74 100644
--- a/lib/librte_eal/common/include/rte_memory.h
+++ b/lib/librte_eal/common/include/rte_memory.h
@@ -104,6 +104,7 @@ typedef uint64_t phys_addr_t; /**< Physical address definition. */
*/
struct rte_memseg {
phys_addr_t phys_addr; /**< Start physical address. */
+ RTE_STD_C11
union {
void *addr; /**< Start virtual address. */
uint64_t addr_64; /**< Makes sure addr is always 64 bits */
diff --git a/lib/librte_eal/common/include/rte_memzone.h b/lib/librte_eal/common/include/rte_memzone.h
index f69b5a8..c3caf6e 100644
--- a/lib/librte_eal/common/include/rte_memzone.h
+++ b/lib/librte_eal/common/include/rte_memzone.h
@@ -53,6 +53,7 @@
#include <stdio.h>
#include <rte_memory.h>
+#include <rte_common.h>
#ifdef __cplusplus
extern "C" {
@@ -78,6 +79,7 @@ struct rte_memzone {
char name[RTE_MEMZONE_NAMESIZE]; /**< Name of the memory zone. */
phys_addr_t phys_addr; /**< Start physical address. */
+ RTE_STD_C11
union {
void *addr; /**< Start virtual address. */
uint64_t addr_64; /**< Makes sure addr is always 64-bits */
diff --git a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h
index 3dacbff..d459bf4 100644
--- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h
+++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h
@@ -82,6 +82,7 @@ struct rte_epoll_event {
/** Handle for interrupts. */
struct rte_intr_handle {
+ RTE_STD_C11
union {
int vfio_dev_fd; /**< VFIO device file descriptor */
int uio_cfg_fd; /**< UIO config file descriptor
diff --git a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
index 2ef0506..164f127 100644
--- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
+++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
@@ -61,6 +61,9 @@
#ifdef __KERNEL__
#include <linux/if.h>
+#define RTE_STD_C11
+#else
+#include <rte_common.h>
#endif
/**
@@ -85,6 +88,7 @@ enum rte_kni_req_id {
*/
struct rte_kni_request {
uint32_t req_id; /**< Request id */
+ RTE_STD_C11
union {
uint32_t new_mtu; /**< New MTU */
uint8_t if_up; /**< 1: interface up, 0: interface down */
diff --git a/lib/librte_hash/rte_thash.h b/lib/librte_hash/rte_thash.h
index d98e98e..a4886a8 100644
--- a/lib/librte_hash/rte_thash.h
+++ b/lib/librte_hash/rte_thash.h
@@ -54,6 +54,7 @@ extern "C" {
#include <stdint.h>
#include <rte_byteorder.h>
#include <rte_ip.h>
+#include <rte_common.h>
#ifdef __SSE3__
#include <rte_vect.h>
@@ -102,6 +103,7 @@ static const __m128i rte_thash_ipv6_bswap_mask = {
struct rte_ipv4_tuple {
uint32_t src_addr;
uint32_t dst_addr;
+ RTE_STD_C11
union {
struct {
uint16_t dport;
@@ -119,6 +121,7 @@ struct rte_ipv4_tuple {
struct rte_ipv6_tuple {
uint8_t src_addr[16];
uint8_t dst_addr[16];
+ RTE_STD_C11
union {
struct {
uint16_t dport;
diff --git a/lib/librte_lpm/rte_lpm.h b/lib/librte_lpm/rte_lpm.h
index 28668a3..3ef4533 100644
--- a/lib/librte_lpm/rte_lpm.h
+++ b/lib/librte_lpm/rte_lpm.h
@@ -100,6 +100,7 @@ struct rte_lpm_tbl_entry_v20 {
* a group index pointing to a tbl8 structure (tbl24 only, when
* valid_group is set)
*/
+ RTE_STD_C11
union {
uint8_t next_hop;
uint8_t group_idx;
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 3d3e847..4b9eb93 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -787,6 +787,7 @@ struct rte_mbuf {
* or non-atomic) is controlled by the CONFIG_RTE_MBUF_REFCNT_ATOMIC
* config option.
*/
+ RTE_STD_C11
union {
rte_atomic16_t refcnt_atomic; /**< Atomically accessed refcnt */
uint16_t refcnt; /**< Non-atomically accessed refcnt */
@@ -806,6 +807,7 @@ struct rte_mbuf {
* would have RTE_PTYPE_L2_ETHER and not RTE_PTYPE_L2_VLAN because the
* vlan is stripped from the data.
*/
+ RTE_STD_C11
union {
uint32_t packet_type; /**< L2/L3/L4 and tunnel information. */
struct {
@@ -827,6 +829,7 @@ struct rte_mbuf {
union {
uint32_t rss; /**< RSS hash result if RSS enabled */
struct {
+ RTE_STD_C11
union {
struct {
uint16_t hash;
@@ -854,6 +857,7 @@ struct rte_mbuf {
/* second cache line - fields only used in slow path or on TX */
MARKER cacheline1 __rte_cache_min_aligned;
+ RTE_STD_C11
union {
void *userdata; /**< Can be used for external metadata */
uint64_t udata64; /**< Allow 8-byte userdata on 32-bit */
@@ -863,6 +867,7 @@ struct rte_mbuf {
struct rte_mbuf *next; /**< Next segment of scattered packet. */
/* fields to support TX offloads */
+ RTE_STD_C11
union {
uint64_t tx_offload; /**< combined for easy fetch */
__extension__
diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h
index 4a8fbb1..0ed8170 100644
--- a/lib/librte_mempool/rte_mempool.h
+++ b/lib/librte_mempool/rte_mempool.h
@@ -75,6 +75,7 @@
#include <rte_branch_prediction.h>
#include <rte_ring.h>
#include <rte_memcpy.h>
+#include <rte_common.h>
#ifdef __cplusplus
extern "C" {
@@ -209,6 +210,7 @@ struct rte_mempool_memhdr {
*/
struct rte_mempool {
char name[RTE_MEMPOOL_NAMESIZE]; /**< Name of mempool. */
+ RTE_STD_C11
union {
void *pool_data; /**< Ring or pool to store objects. */
uint64_t pool_id; /**< External mempool identifier. */
diff --git a/lib/librte_pipeline/rte_pipeline.h b/lib/librte_pipeline/rte_pipeline.h
index b0b4615..f366348 100644
--- a/lib/librte_pipeline/rte_pipeline.h
+++ b/lib/librte_pipeline/rte_pipeline.h
@@ -87,6 +87,7 @@ extern "C" {
#include <rte_port.h>
#include <rte_table.h>
+#include <rte_common.h>
struct rte_mbuf;
@@ -244,6 +245,7 @@ struct rte_pipeline_table_entry {
/** Reserved action */
enum rte_pipeline_action action;
+ RTE_STD_C11
union {
/** Output port ID (meta-data for "Send packet to output port"
action) */
diff --git a/lib/librte_timer/rte_timer.h b/lib/librte_timer/rte_timer.h
index 77547c6..a276a73 100644
--- a/lib/librte_timer/rte_timer.h
+++ b/lib/librte_timer/rte_timer.h
@@ -66,6 +66,7 @@
#include <stdio.h>
#include <stdint.h>
#include <stddef.h>
+#include <rte_common.h>
#ifdef __cplusplus
extern "C" {
@@ -91,6 +92,7 @@ enum rte_timer_type {
* config) and an owner (the id of the lcore that owns the timer).
*/
union rte_timer_status {
+ RTE_STD_C11
struct {
uint16_t state; /**< Stop, pending, running, config. */
int16_t owner; /**< The lcore that owns the timer. */
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* [dpdk-dev] [PATCH v4 06/10] lib: add missing include dependencies
2016-07-13 13:02 ` [dpdk-dev] [PATCH v4 00/10] " Adrien Mazarguil
` (4 preceding siblings ...)
2016-07-13 13:02 ` [dpdk-dev] [PATCH v4 05/10] lib: work around unnamed structs/unions Adrien Mazarguil
@ 2016-07-13 13:02 ` Adrien Mazarguil
2016-07-13 13:02 ` [dpdk-dev] [PATCH v4 07/10] lib: work around forward reference to enum types Adrien Mazarguil
` (6 subsequent siblings)
12 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-07-13 13:02 UTC (permalink / raw)
To: dev
Exported header files for use by applications should be self sufficient and
allow out of order inclusion. Moreover, they must include all the system
headers they need for types and macros.
This commit prevents the following errors:
error: `RTE_MAX_LCORE' undeclared here (not in a function)
error: `RTE_LPM_VALID_EXT_ENTRY_BITMASK' undeclared
(first use in this function)
error: #error "Unsupported cache line size"
error: `asm' undeclared (first use in this function)
error: implicit declaration of function `[...]'
error: unknown type name `[...]'
error: field `mac_addr' has incomplete type
error: `CHAR_BIT' undeclared here (not in a function)
error: `struct [...]' declared inside parameter list
error: unknown type name `uint8_t'
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
lib/librte_cfgfile/rte_cfgfile.h | 2 ++
lib/librte_cmdline/cmdline.h | 1 +
lib/librte_cmdline/cmdline_parse_portlist.h | 1 +
lib/librte_cmdline/cmdline_socket.h | 3 +++
lib/librte_eal/common/include/arch/arm/rte_byteorder.h | 2 ++
lib/librte_eal/common/include/arch/arm/rte_prefetch_32.h | 1 +
lib/librte_eal/common/include/arch/arm/rte_prefetch_64.h | 1 +
lib/librte_eal/common/include/arch/arm/rte_vect.h | 1 +
lib/librte_eal/common/include/arch/ppc_64/rte_atomic.h | 1 +
lib/librte_eal/common/include/arch/ppc_64/rte_byteorder.h | 1 +
lib/librte_eal/common/include/arch/ppc_64/rte_prefetch.h | 1 +
lib/librte_eal/common/include/arch/x86/rte_atomic.h | 2 ++
lib/librte_eal/common/include/arch/x86/rte_atomic_32.h | 6 ++++++
lib/librte_eal/common/include/arch/x86/rte_atomic_64.h | 8 ++++++++
lib/librte_eal/common/include/arch/x86/rte_byteorder.h | 2 ++
lib/librte_eal/common/include/arch/x86/rte_byteorder_32.h | 7 +++++++
lib/librte_eal/common/include/arch/x86/rte_byteorder_64.h | 7 +++++++
lib/librte_eal/common/include/arch/x86/rte_prefetch.h | 1 +
lib/librte_eal/common/include/arch/x86/rte_rtm.h | 1 +
lib/librte_eal/common/include/arch/x86/rte_vect.h | 2 ++
lib/librte_eal/common/include/generic/rte_atomic.h | 1 +
lib/librte_eal/common/include/generic/rte_byteorder.h | 2 ++
lib/librte_eal/common/include/rte_eal.h | 1 +
lib/librte_eal/common/include/rte_memory.h | 2 ++
lib/librte_eal/common/include/rte_time.h | 8 ++++++++
lib/librte_eal/common/include/rte_version.h | 1 +
lib/librte_ether/rte_dev_info.h | 2 ++
lib/librte_ether/rte_eth_ctrl.h | 4 ++++
lib/librte_lpm/rte_lpm_neon.h | 1 +
lib/librte_lpm/rte_lpm_sse.h | 1 +
lib/librte_pdump/rte_pdump.h | 4 ++++
lib/librte_reorder/rte_reorder.h | 2 ++
lib/librte_sched/rte_bitmap.h | 1 +
lib/librte_sched/rte_reciprocal.h | 2 ++
lib/librte_sched/rte_sched_common.h | 1 +
35 files changed, 84 insertions(+)
diff --git a/lib/librte_cfgfile/rte_cfgfile.h b/lib/librte_cfgfile/rte_cfgfile.h
index f649836..e81a5a2 100644
--- a/lib/librte_cfgfile/rte_cfgfile.h
+++ b/lib/librte_cfgfile/rte_cfgfile.h
@@ -34,6 +34,8 @@
#ifndef __INCLUDE_RTE_CFGFILE_H__
#define __INCLUDE_RTE_CFGFILE_H__
+#include <stddef.h>
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/lib/librte_cmdline/cmdline.h b/lib/librte_cmdline/cmdline.h
index 2578ca8..65d73b0 100644
--- a/lib/librte_cmdline/cmdline.h
+++ b/lib/librte_cmdline/cmdline.h
@@ -63,6 +63,7 @@
#include <termios.h>
#include <cmdline_rdline.h>
+#include <cmdline_parse.h>
/**
* @file
diff --git a/lib/librte_cmdline/cmdline_parse_portlist.h b/lib/librte_cmdline/cmdline_parse_portlist.h
index 73d70e0..058df3e 100644
--- a/lib/librte_cmdline/cmdline_parse_portlist.h
+++ b/lib/librte_cmdline/cmdline_parse_portlist.h
@@ -61,6 +61,7 @@
#ifndef _PARSE_PORTLIST_H_
#define _PARSE_PORTLIST_H_
+#include <stdint.h>
#include <cmdline_parse.h>
#ifdef __cplusplus
diff --git a/lib/librte_cmdline/cmdline_socket.h b/lib/librte_cmdline/cmdline_socket.h
index 8cc2dfb..aa6068e 100644
--- a/lib/librte_cmdline/cmdline_socket.h
+++ b/lib/librte_cmdline/cmdline_socket.h
@@ -61,6 +61,9 @@
#ifndef _CMDLINE_SOCKET_H_
#define _CMDLINE_SOCKET_H_
+#include <cmdline_parse.h>
+#include <cmdline.h>
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/lib/librte_eal/common/include/arch/arm/rte_byteorder.h b/lib/librte_eal/common/include/arch/arm/rte_byteorder.h
index 3f2dd1f..1b312b3 100644
--- a/lib/librte_eal/common/include/arch/arm/rte_byteorder.h
+++ b/lib/librte_eal/common/include/arch/arm/rte_byteorder.h
@@ -41,6 +41,8 @@
extern "C" {
#endif
+#include <stdint.h>
+#include <rte_common.h>
#include "generic/rte_byteorder.h"
/* fix missing __builtin_bswap16 for gcc older then 4.8 */
diff --git a/lib/librte_eal/common/include/arch/arm/rte_prefetch_32.h b/lib/librte_eal/common/include/arch/arm/rte_prefetch_32.h
index 5aeed22..43cde17 100644
--- a/lib/librte_eal/common/include/arch/arm/rte_prefetch_32.h
+++ b/lib/librte_eal/common/include/arch/arm/rte_prefetch_32.h
@@ -37,6 +37,7 @@
extern "C" {
#endif
+#include <rte_common.h>
#include "generic/rte_prefetch.h"
static inline void rte_prefetch0(const volatile void *p)
diff --git a/lib/librte_eal/common/include/arch/arm/rte_prefetch_64.h b/lib/librte_eal/common/include/arch/arm/rte_prefetch_64.h
index 3ed46a4..0d077ea 100644
--- a/lib/librte_eal/common/include/arch/arm/rte_prefetch_64.h
+++ b/lib/librte_eal/common/include/arch/arm/rte_prefetch_64.h
@@ -37,6 +37,7 @@
extern "C" {
#endif
+#include <rte_common.h>
#include "generic/rte_prefetch.h"
static inline void rte_prefetch0(const volatile void *p)
diff --git a/lib/librte_eal/common/include/arch/arm/rte_vect.h b/lib/librte_eal/common/include/arch/arm/rte_vect.h
index a33c054..b86c2cf 100644
--- a/lib/librte_eal/common/include/arch/arm/rte_vect.h
+++ b/lib/librte_eal/common/include/arch/arm/rte_vect.h
@@ -33,6 +33,7 @@
#ifndef _RTE_VECT_ARM_H_
#define _RTE_VECT_ARM_H_
+#include <stdint.h>
#include "arm_neon.h"
#ifdef __cplusplus
diff --git a/lib/librte_eal/common/include/arch/ppc_64/rte_atomic.h b/lib/librte_eal/common/include/arch/ppc_64/rte_atomic.h
index feae486..3270fce 100644
--- a/lib/librte_eal/common/include/arch/ppc_64/rte_atomic.h
+++ b/lib/librte_eal/common/include/arch/ppc_64/rte_atomic.h
@@ -46,6 +46,7 @@
extern "C" {
#endif
+#include <stdint.h>
#include "generic/rte_atomic.h"
/**
diff --git a/lib/librte_eal/common/include/arch/ppc_64/rte_byteorder.h b/lib/librte_eal/common/include/arch/ppc_64/rte_byteorder.h
index 3c1734e..544de3c 100644
--- a/lib/librte_eal/common/include/arch/ppc_64/rte_byteorder.h
+++ b/lib/librte_eal/common/include/arch/ppc_64/rte_byteorder.h
@@ -42,6 +42,7 @@
extern "C" {
#endif
+#include <stdint.h>
#include "generic/rte_byteorder.h"
/*
diff --git a/lib/librte_eal/common/include/arch/ppc_64/rte_prefetch.h b/lib/librte_eal/common/include/arch/ppc_64/rte_prefetch.h
index 9a1995e..fd2e53b 100644
--- a/lib/librte_eal/common/include/arch/ppc_64/rte_prefetch.h
+++ b/lib/librte_eal/common/include/arch/ppc_64/rte_prefetch.h
@@ -37,6 +37,7 @@
extern "C" {
#endif
+#include <rte_common.h>
#include "generic/rte_prefetch.h"
static inline void rte_prefetch0(const volatile void *p)
diff --git a/lib/librte_eal/common/include/arch/x86/rte_atomic.h b/lib/librte_eal/common/include/arch/x86/rte_atomic.h
index b20056b..00b1cdf 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_atomic.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_atomic.h
@@ -38,6 +38,8 @@
extern "C" {
#endif
+#include <stdint.h>
+#include <rte_common.h>
#include <emmintrin.h>
#include "generic/rte_atomic.h"
diff --git a/lib/librte_eal/common/include/arch/x86/rte_atomic_32.h b/lib/librte_eal/common/include/arch/x86/rte_atomic_32.h
index 5ce01b3..2e04c75 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_atomic_32.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_atomic_32.h
@@ -37,10 +37,16 @@
* All rights reserved.
*/
+#ifndef _RTE_ATOMIC_X86_H_
+#error do not include this file directly, use <rte_atomic.h> instead
+#endif
+
#ifndef _RTE_ATOMIC_I686_H_
#define _RTE_ATOMIC_I686_H_
+#include <stdint.h>
#include <rte_common.h>
+#include <rte_atomic.h>
/*------------------------- 64 bit atomic operations -------------------------*/
diff --git a/lib/librte_eal/common/include/arch/x86/rte_atomic_64.h b/lib/librte_eal/common/include/arch/x86/rte_atomic_64.h
index 4de6600..1a53a76 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_atomic_64.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_atomic_64.h
@@ -37,9 +37,17 @@
* All rights reserved.
*/
+#ifndef _RTE_ATOMIC_X86_H_
+#error do not include this file directly, use <rte_atomic.h> instead
+#endif
+
#ifndef _RTE_ATOMIC_X86_64_H_
#define _RTE_ATOMIC_X86_64_H_
+#include <stdint.h>
+#include <rte_common.h>
+#include <rte_atomic.h>
+
/*------------------------- 64 bit atomic operations -------------------------*/
#ifndef RTE_FORCE_INTRINSICS
diff --git a/lib/librte_eal/common/include/arch/x86/rte_byteorder.h b/lib/librte_eal/common/include/arch/x86/rte_byteorder.h
index ffdb6ef..251f11b 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_byteorder.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_byteorder.h
@@ -38,6 +38,8 @@
extern "C" {
#endif
+#include <stdint.h>
+#include <rte_common.h>
#include "generic/rte_byteorder.h"
#ifndef RTE_BYTE_ORDER
diff --git a/lib/librte_eal/common/include/arch/x86/rte_byteorder_32.h b/lib/librte_eal/common/include/arch/x86/rte_byteorder_32.h
index 51c306f..14d6483 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_byteorder_32.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_byteorder_32.h
@@ -31,9 +31,16 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#ifndef _RTE_BYTEORDER_X86_H_
+#error do not include this file directly, use <rte_byteorder.h> instead
+#endif
+
#ifndef _RTE_BYTEORDER_I686_H_
#define _RTE_BYTEORDER_I686_H_
+#include <stdint.h>
+#include <rte_byteorder.h>
+
/*
* An architecture-optimized byte swap for a 64-bit value.
*
diff --git a/lib/librte_eal/common/include/arch/x86/rte_byteorder_64.h b/lib/librte_eal/common/include/arch/x86/rte_byteorder_64.h
index dda572b..516ac05 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_byteorder_64.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_byteorder_64.h
@@ -31,9 +31,16 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#ifndef _RTE_BYTEORDER_X86_H_
+#error do not include this file directly, use <rte_byteorder.h> instead
+#endif
+
#ifndef _RTE_BYTEORDER_X86_64_H_
#define _RTE_BYTEORDER_X86_64_H_
+#include <stdint.h>
+#include <rte_common.h>
+
/*
* An architecture-optimized byte swap for a 64-bit value.
*
diff --git a/lib/librte_eal/common/include/arch/x86/rte_prefetch.h b/lib/librte_eal/common/include/arch/x86/rte_prefetch.h
index 5dac47e..f464398 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_prefetch.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_prefetch.h
@@ -38,6 +38,7 @@
extern "C" {
#endif
+#include <rte_common.h>
#include "generic/rte_prefetch.h"
static inline void rte_prefetch0(const volatile void *p)
diff --git a/lib/librte_eal/common/include/arch/x86/rte_rtm.h b/lib/librte_eal/common/include/arch/x86/rte_rtm.h
index 0649f79..ab09995 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_rtm.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_rtm.h
@@ -20,6 +20,7 @@
/* Official RTM intrinsics interface matching gcc/icc, but works
on older gcc compatible compilers and binutils. */
+#include <rte_common.h>
#ifdef __cplusplus
extern "C" {
diff --git a/lib/librte_eal/common/include/arch/x86/rte_vect.h b/lib/librte_eal/common/include/arch/x86/rte_vect.h
index 2836f2c..77f2e25 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_vect.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_vect.h
@@ -40,6 +40,8 @@
* RTE SSE/AVX related header.
*/
+#include <stdint.h>
+
#if (defined(__ICC) || (__GNUC__ == 4 && __GNUC_MINOR__ < 4))
#ifdef __SSE__
diff --git a/lib/librte_eal/common/include/generic/rte_atomic.h b/lib/librte_eal/common/include/generic/rte_atomic.h
index bfb4fe4..43a704e 100644
--- a/lib/librte_eal/common/include/generic/rte_atomic.h
+++ b/lib/librte_eal/common/include/generic/rte_atomic.h
@@ -42,6 +42,7 @@
*/
#include <stdint.h>
+#include <rte_common.h>
#ifdef __DOXYGEN__
diff --git a/lib/librte_eal/common/include/generic/rte_byteorder.h b/lib/librte_eal/common/include/generic/rte_byteorder.h
index c46fdcf..e00bccb 100644
--- a/lib/librte_eal/common/include/generic/rte_byteorder.h
+++ b/lib/librte_eal/common/include/generic/rte_byteorder.h
@@ -50,6 +50,8 @@
#include <endian.h>
#endif
+#include <rte_common.h>
+
/*
* Compile-time endianness detection
*/
diff --git a/lib/librte_eal/common/include/rte_eal.h b/lib/librte_eal/common/include/rte_eal.h
index a71d6f5..98d20db 100644
--- a/lib/librte_eal/common/include/rte_eal.h
+++ b/lib/librte_eal/common/include/rte_eal.h
@@ -44,6 +44,7 @@
#include <sched.h>
#include <rte_per_lcore.h>
+#include <rte_config.h>
#ifdef __cplusplus
extern "C" {
diff --git a/lib/librte_eal/common/include/rte_memory.h b/lib/librte_eal/common/include/rte_memory.h
index 38fbe74..3b6b46b 100644
--- a/lib/librte_eal/common/include/rte_memory.h
+++ b/lib/librte_eal/common/include/rte_memory.h
@@ -44,6 +44,8 @@
#include <stddef.h>
#include <stdio.h>
+#include <rte_config.h>
+
#ifdef RTE_EXEC_ENV_LINUXAPP
#include <exec-env/rte_dom0_common.h>
#endif
diff --git a/lib/librte_eal/common/include/rte_time.h b/lib/librte_eal/common/include/rte_time.h
index 4b13b9c..28c6274 100644
--- a/lib/librte_eal/common/include/rte_time.h
+++ b/lib/librte_eal/common/include/rte_time.h
@@ -31,6 +31,12 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#ifndef _RTE_TIME_H_
+#define _RTE_TIME_H_
+
+#include <stdint.h>
+#include <time.h>
+
#define NSEC_PER_SEC 1000000000L
/**
@@ -120,3 +126,5 @@ rte_ns_to_timespec(uint64_t nsec)
return ts;
}
+
+#endif /* _RTE_TIME_H_ */
diff --git a/lib/librte_eal/common/include/rte_version.h b/lib/librte_eal/common/include/rte_version.h
index 3710222..ab80c93 100644
--- a/lib/librte_eal/common/include/rte_version.h
+++ b/lib/librte_eal/common/include/rte_version.h
@@ -45,6 +45,7 @@ extern "C" {
#include <stdint.h>
#include <string.h>
+#include <stdio.h>
#include <rte_common.h>
/**
diff --git a/lib/librte_ether/rte_dev_info.h b/lib/librte_ether/rte_dev_info.h
index 574683d..aab6d1a 100644
--- a/lib/librte_ether/rte_dev_info.h
+++ b/lib/librte_ether/rte_dev_info.h
@@ -34,6 +34,8 @@
#ifndef _RTE_DEV_INFO_H_
#define _RTE_DEV_INFO_H_
+#include <stdint.h>
+
/*
* Placeholder for accessing device registers
*/
diff --git a/lib/librte_ether/rte_eth_ctrl.h b/lib/librte_ether/rte_eth_ctrl.h
index c3a2c9e..fe80eb0 100644
--- a/lib/librte_ether/rte_eth_ctrl.h
+++ b/lib/librte_ether/rte_eth_ctrl.h
@@ -34,6 +34,10 @@
#ifndef _RTE_ETH_CTRL_H_
#define _RTE_ETH_CTRL_H_
+#include <stdint.h>
+#include <rte_common.h>
+#include "rte_ether.h"
+
/**
* @file
*
diff --git a/lib/librte_lpm/rte_lpm_neon.h b/lib/librte_lpm/rte_lpm_neon.h
index 7c64315..7efd9a0 100644
--- a/lib/librte_lpm/rte_lpm_neon.h
+++ b/lib/librte_lpm/rte_lpm_neon.h
@@ -43,6 +43,7 @@
#include <rte_byteorder.h>
#include <rte_common.h>
#include <rte_vect.h>
+#include <rte_lpm.h>
#ifdef __cplusplus
extern "C" {
diff --git a/lib/librte_lpm/rte_lpm_sse.h b/lib/librte_lpm/rte_lpm_sse.h
index da83099..ef33c6a 100644
--- a/lib/librte_lpm/rte_lpm_sse.h
+++ b/lib/librte_lpm/rte_lpm_sse.h
@@ -38,6 +38,7 @@
#include <rte_byteorder.h>
#include <rte_common.h>
#include <rte_vect.h>
+#include <rte_lpm.h>
#ifdef __cplusplus
extern "C" {
diff --git a/lib/librte_pdump/rte_pdump.h b/lib/librte_pdump/rte_pdump.h
index b5f4e2f..924b804 100644
--- a/lib/librte_pdump/rte_pdump.h
+++ b/lib/librte_pdump/rte_pdump.h
@@ -41,6 +41,10 @@
* packet dump library to provide packet capturing support on dpdk.
*/
+#include <stdint.h>
+#include <rte_mempool.h>
+#include <rte_ring.h>
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/lib/librte_reorder/rte_reorder.h b/lib/librte_reorder/rte_reorder.h
index c7a2934..737e055 100644
--- a/lib/librte_reorder/rte_reorder.h
+++ b/lib/librte_reorder/rte_reorder.h
@@ -44,6 +44,8 @@
*
*/
+#include <rte_mbuf.h>
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/lib/librte_sched/rte_bitmap.h b/lib/librte_sched/rte_bitmap.h
index 1b5df02..010d752 100644
--- a/lib/librte_sched/rte_bitmap.h
+++ b/lib/librte_sched/rte_bitmap.h
@@ -64,6 +64,7 @@ extern "C" {
*
***/
+#include <string.h>
#include <rte_common.h>
#include <rte_debug.h>
#include <rte_memory.h>
diff --git a/lib/librte_sched/rte_reciprocal.h b/lib/librte_sched/rte_reciprocal.h
index abd1525..5e21f09 100644
--- a/lib/librte_sched/rte_reciprocal.h
+++ b/lib/librte_sched/rte_reciprocal.h
@@ -22,6 +22,8 @@
#ifndef _RTE_RECIPROCAL_H_
#define _RTE_RECIPROCAL_H_
+#include <stdint.h>
+
struct rte_reciprocal {
uint32_t m;
uint8_t sh1, sh2;
diff --git a/lib/librte_sched/rte_sched_common.h b/lib/librte_sched/rte_sched_common.h
index 8920ade..aed144b 100644
--- a/lib/librte_sched/rte_sched_common.h
+++ b/lib/librte_sched/rte_sched_common.h
@@ -38,6 +38,7 @@
extern "C" {
#endif
+#include <stdint.h>
#include <sys/types.h>
#define __rte_aligned_16 __attribute__((__aligned__(16)))
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* [dpdk-dev] [PATCH v4 07/10] lib: work around forward reference to enum types
2016-07-13 13:02 ` [dpdk-dev] [PATCH v4 00/10] " Adrien Mazarguil
` (5 preceding siblings ...)
2016-07-13 13:02 ` [dpdk-dev] [PATCH v4 06/10] lib: add missing include dependencies Adrien Mazarguil
@ 2016-07-13 13:02 ` Adrien Mazarguil
2016-07-13 13:02 ` [dpdk-dev] [PATCH v4 08/10] lib: remove named variadic macros in exported headers Adrien Mazarguil
` (5 subsequent siblings)
12 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-07-13 13:02 UTC (permalink / raw)
To: dev
Exported header files used by applications should allow the strictest
compiler flags. Language extensions used in many places must be explicitly
marked or removed to avoid warnings and compilation failures.
This commit prevents the following errors:
error: ISO C forbids forward references to `enum' types
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
lib/librte_eal/common/include/generic/rte_cpuflags.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/librte_eal/common/include/generic/rte_cpuflags.h b/lib/librte_eal/common/include/generic/rte_cpuflags.h
index c1da357..71321f3 100644
--- a/lib/librte_eal/common/include/generic/rte_cpuflags.h
+++ b/lib/librte_eal/common/include/generic/rte_cpuflags.h
@@ -44,6 +44,7 @@
/**
* Enumeration of all CPU features supported
*/
+__extension__
enum rte_cpu_flag_t;
/**
@@ -55,6 +56,7 @@ enum rte_cpu_flag_t;
* flag name
* NULL if flag ID is invalid
*/
+__extension__
const char *
rte_cpu_get_flag_name(enum rte_cpu_flag_t feature);
@@ -68,6 +70,7 @@ rte_cpu_get_flag_name(enum rte_cpu_flag_t feature);
* 0 if flag is not available
* -ENOENT if flag is invalid
*/
+__extension__
int
rte_cpu_get_flag_enabled(enum rte_cpu_flag_t feature);
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* [dpdk-dev] [PATCH v4 08/10] lib: remove named variadic macros in exported headers
2016-07-13 13:02 ` [dpdk-dev] [PATCH v4 00/10] " Adrien Mazarguil
` (6 preceding siblings ...)
2016-07-13 13:02 ` [dpdk-dev] [PATCH v4 07/10] lib: work around forward reference to enum types Adrien Mazarguil
@ 2016-07-13 13:02 ` Adrien Mazarguil
2016-07-13 13:02 ` [dpdk-dev] [PATCH v4 09/10] lib: hide static functions never defined Adrien Mazarguil
` (4 subsequent siblings)
12 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-07-13 13:02 UTC (permalink / raw)
To: dev
Exported header files used by applications should allow the strictest
compiler flags. Language extensions used in many places must be explicitly
marked or removed to avoid warnings and compilation failures.
Since there is no way to force named variadic macros as extensions, use a
a standard __VA_ARGS__ with an extra dummy argument to format strings.
This commit prevents the following errors:
error: ISO C does not permit named variadic macros
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
lib/librte_cryptodev/rte_cryptodev.h | 32 ++++++++++++++-----------
lib/librte_cryptodev/rte_cryptodev_pmd.h | 2 +-
lib/librte_eal/common/include/rte_common.h | 9 +++++++
3 files changed, 28 insertions(+), 15 deletions(-)
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index cf28541..d047ba8 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -77,26 +77,30 @@ extern const char **rte_cyptodev_names;
/* Logging Macros */
-#define CDEV_LOG_ERR(fmt, args...) \
- RTE_LOG(ERR, CRYPTODEV, "%s() line %u: " fmt "\n", \
- __func__, __LINE__, ## args)
+#define CDEV_LOG_ERR(...) \
+ RTE_LOG(ERR, CRYPTODEV, \
+ RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
+ __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__,)))
-#define CDEV_PMD_LOG_ERR(dev, fmt, args...) \
- RTE_LOG(ERR, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \
- dev, __func__, __LINE__, ## args)
+#define CDEV_PMD_LOG_ERR(dev, ...) \
+ RTE_LOG(ERR, CRYPTODEV, \
+ RTE_FMT("[%s] %s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
+ dev, __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__,)))
#ifdef RTE_LIBRTE_CRYPTODEV_DEBUG
-#define CDEV_LOG_DEBUG(fmt, args...) \
- RTE_LOG(DEBUG, CRYPTODEV, "%s() line %u: " fmt "\n", \
- __func__, __LINE__, ## args) \
+#define CDEV_LOG_DEBUG(...) \
+ RTE_LOG(DEBUG, CRYPTODEV, \
+ RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
+ __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__,)))
-#define CDEV_PMD_TRACE(fmt, args...) \
- RTE_LOG(DEBUG, CRYPTODEV, "[%s] %s: " fmt "\n", \
- dev, __func__, ## args)
+#define CDEV_PMD_TRACE(...) \
+ RTE_LOG(DEBUG, CRYPTODEV, \
+ RTE_FMT("[%s] %s: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
+ dev, __func__, RTE_FMT_TAIL(__VA_ARGS__,)))
#else
-#define CDEV_LOG_DEBUG(fmt, args...)
-#define CDEV_PMD_TRACE(fmt, args...)
+#define CDEV_LOG_DEBUG(...) (void)0
+#define CDEV_PMD_TRACE(...) (void)0
#endif
/**
diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h b/lib/librte_cryptodev/rte_cryptodev_pmd.h
index cf08a50..4a07362 100644
--- a/lib/librte_cryptodev/rte_cryptodev_pmd.h
+++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h
@@ -62,7 +62,7 @@ extern "C" {
#define RTE_PMD_DEBUG_TRACE(...) \
rte_pmd_debug_trace(__func__, __VA_ARGS__)
#else
-#define RTE_PMD_DEBUG_TRACE(fmt, args...)
+#define RTE_PMD_DEBUG_TRACE(...)
#endif
struct rte_cryptodev_session {
diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h
index 98ecc1c..db5ac91 100644
--- a/lib/librte_eal/common/include/rte_common.h
+++ b/lib/librte_eal/common/include/rte_common.h
@@ -335,6 +335,15 @@ rte_bsf32(uint32_t v)
/** Take a macro value and get a string version of it */
#define RTE_STR(x) _RTE_STR(x)
+/**
+ * ISO C helpers to modify format strings using variadic macros.
+ * This is a replacement for the ", ## __VA_ARGS__" GNU extension.
+ * An empty %s argument is appended to avoid a dangling comma.
+ */
+#define RTE_FMT(fmt, ...) fmt "%.0s", __VA_ARGS__ ""
+#define RTE_FMT_HEAD(fmt, ...) fmt
+#define RTE_FMT_TAIL(fmt, ...) __VA_ARGS__
+
/** Mask value of type "tp" for the first "ln" bit set. */
#define RTE_LEN2MASK(ln, tp) \
((tp)((uint64_t)-1 >> (sizeof(uint64_t) * CHAR_BIT - (ln))))
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* [dpdk-dev] [PATCH v4 09/10] lib: hide static functions never defined
2016-07-13 13:02 ` [dpdk-dev] [PATCH v4 00/10] " Adrien Mazarguil
` (7 preceding siblings ...)
2016-07-13 13:02 ` [dpdk-dev] [PATCH v4 08/10] lib: remove named variadic macros in exported headers Adrien Mazarguil
@ 2016-07-13 13:02 ` Adrien Mazarguil
2016-07-13 13:02 ` [dpdk-dev] [PATCH v4 10/10] scripts: check compilation of exported header files Adrien Mazarguil
` (3 subsequent siblings)
12 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-07-13 13:02 UTC (permalink / raw)
To: dev
Arch-specific functions not defined for all architectures (missing on x86
in this case) and not used anywhere should not expose a prototype.
This commit prevents the following error:
error: `rte_mov48' declared `static' but never defined
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
lib/librte_eal/common/include/generic/rte_memcpy.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lib/librte_eal/common/include/generic/rte_memcpy.h b/lib/librte_eal/common/include/generic/rte_memcpy.h
index afb0afe..4e9d879 100644
--- a/lib/librte_eal/common/include/generic/rte_memcpy.h
+++ b/lib/librte_eal/common/include/generic/rte_memcpy.h
@@ -64,6 +64,8 @@ rte_mov16(uint8_t *dst, const uint8_t *src);
static inline void
rte_mov32(uint8_t *dst, const uint8_t *src);
+#ifdef __DOXYGEN__
+
/**
* Copy 48 bytes from one location to another using optimised
* instructions. The locations should not overlap.
@@ -76,6 +78,8 @@ rte_mov32(uint8_t *dst, const uint8_t *src);
static inline void
rte_mov48(uint8_t *dst, const uint8_t *src);
+#endif /* __DOXYGEN__ */
+
/**
* Copy 64 bytes from one location to another using optimised
* instructions. The locations should not overlap.
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* [dpdk-dev] [PATCH v4 10/10] scripts: check compilation of exported header files
2016-07-13 13:02 ` [dpdk-dev] [PATCH v4 00/10] " Adrien Mazarguil
` (8 preceding siblings ...)
2016-07-13 13:02 ` [dpdk-dev] [PATCH v4 09/10] lib: hide static functions never defined Adrien Mazarguil
@ 2016-07-13 13:02 ` Adrien Mazarguil
2016-07-15 21:03 ` [dpdk-dev] [PATCH v4 00/10] Fix build errors related to exported headers Bruce Richardson
` (2 subsequent siblings)
12 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-07-13 13:02 UTC (permalink / raw)
To: dev
This script checks that header files in a given directory do not miss
dependencies when included on their own, do not conflict and accept being
compiled with the strictest possible flags.
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
MAINTAINERS | 1 +
scripts/check-includes.sh | 286 +++++++++++++++++++++++++++++++++++++++++
scripts/test-build.sh | 14 ++
3 files changed, 301 insertions(+)
diff --git a/MAINTAINERS b/MAINTAINERS
index f996c2e..e2933c4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -26,6 +26,7 @@ T: git://dpdk.org/dpdk
F: MAINTAINERS
F: scripts/check-maintainers.sh
F: scripts/check-git-log.sh
+F: scripts/check-includes.sh
F: scripts/checkpatches.sh
F: scripts/load-devel-config.sh
F: scripts/test-build.sh
diff --git a/scripts/check-includes.sh b/scripts/check-includes.sh
new file mode 100755
index 0000000..d65adc6
--- /dev/null
+++ b/scripts/check-includes.sh
@@ -0,0 +1,286 @@
+#!/bin/sh -e
+#
+# BSD LICENSE
+#
+# Copyright 2016 6WIND S.A.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of 6WIND S.A. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# This script checks that header files in a given directory do not miss
+# dependencies when included on their own, do not conflict and accept being
+# compiled with the strictest possible flags.
+#
+# Files are looked up in the directory provided as the first argument,
+# otherwise build/include by default.
+#
+# Recognized environment variables:
+#
+# VERBOSE=1 is the same as -v.
+#
+# QUIET=1 is the same as -q.
+#
+# SUMMARY=1 is the same as -s.
+#
+# CC, CPPFLAGS, CFLAGS, EXTRA_CPPFLAGS, EXTRA_CFLAGS, CXX, CXXFLAGS and
+# EXTRA_CXXFLAGS are taken into account.
+#
+# PEDANTIC_CFLAGS, PEDANTIC_CXXFLAGS and PEDANTIC_CPPFLAGS provide strict
+# C/C++ compilation flags.
+#
+# IGNORE contains a list of shell patterns matching files (relative to the
+# include directory) to avoid. It is set by default to known DPDK headers
+# which must not be included on their own.
+#
+# IGNORE_CXX provides additional files for C++.
+
+while getopts hqvs arg; do
+ case $arg in
+ h)
+ cat <<EOF
+usage: $0 [-h] [-q] [-v] [-s] [DIR]
+
+This script checks that header files in a given directory do not miss
+dependencies when included on their own, do not conflict and accept being
+compiled with the strictest possible flags.
+
+ -h display this help and exit
+ -q quiet mode, disable normal output
+ -v show command lines being executed
+ -s show summary
+
+With no DIR, default to build/include.
+
+Any failed header check yields a nonzero exit status.
+EOF
+ exit
+ ;;
+ q)
+ QUIET=1
+ ;;
+ v)
+ VERBOSE=1
+ ;;
+ s)
+ SUMMARY=1
+ ;;
+ *)
+ exit 1
+ ;;
+ esac
+done
+
+shift $(($OPTIND - 1))
+
+include_dir=${1:-build/include}
+
+: ${PEDANTIC_CFLAGS=-std=c99 -pedantic -Wall -Wextra -Werror}
+: ${PEDANTIC_CXXFLAGS=}
+: ${PEDANTIC_CPPFLAGS=-D_XOPEN_SOURCE=600}
+: ${CC:=cc}
+: ${CXX:=c++}
+: ${IGNORE= \
+ 'rte_atomic_32.h' \
+ 'rte_atomic_64.h' \
+ 'rte_byteorder_32.h' \
+ 'rte_byteorder_64.h' \
+ 'generic/*' \
+ 'exec-env/*' \
+}
+: ${IGNORE_CXX= \
+ 'rte_eth_vhost.h' \
+ 'rte_virtio_net.h' \
+}
+
+temp_cc=/tmp/${0##*/}.$$.c
+pass_cc=
+failures_cc=0
+
+temp_cxx=/tmp/${0##*/}.$$.cc
+pass_cxx=
+failures_cxx=0
+
+# Process output parameters.
+
+[ "$QUIET" = 1 ] &&
+exec 1> /dev/null
+
+[ "$VERBOSE" = 1 ] &&
+output ()
+{
+ local CCV
+ local CXXV
+
+ shift
+ CCV=$CC
+ CXXV=$CXX
+ CC="echo $CC" CXX="echo $CXX" "$@"
+ CC=$CCV
+ CXX=$CXXV
+
+ "$@"
+} ||
+output ()
+{
+
+ printf ' %s\n' "$1"
+ shift
+ "$@"
+}
+
+trap 'rm -f "$temp_cc" "$temp_cxx"' EXIT
+
+compile_cc ()
+{
+ ${CC} -I"$include_dir" \
+ ${PEDANTIC_CPPFLAGS} ${CPPFLAGS} ${EXTRA_CPPFLAGS} \
+ ${PEDANTIC_CFLAGS} ${CFLAGS} ${EXTRA_CFLAGS} \
+ -c -o /dev/null "${temp_cc}"
+}
+
+compile_cxx ()
+{
+ ${CXX} -I"$include_dir" \
+ ${PEDANTIC_CPPFLAGS} ${CPPFLAGS} ${EXTRA_CPPFLAGS} \
+ ${PEDANTIC_CXXFLAGS} ${CXXFLAGS} ${EXTRA_CXXFLAGS} \
+ -c -o /dev/null "${temp_cxx}"
+}
+
+ignore ()
+{
+ file="$1"
+ shift
+ while [ $# -ne 0 ]; do
+ case "$file" in
+ $1)
+ return 0
+ ;;
+ esac
+ shift
+ done
+ return 1
+}
+
+# Check C/C++ compilation for each header file.
+
+while read -r path
+do
+ file=${path#$include_dir}
+ file=${file##/}
+ if ignore "$file" $IGNORE; then
+ output "SKIP $file" :
+ continue
+ fi
+ if printf "\
+#include <%s>
+
+int main(void)
+{
+ return 0;
+}
+" "$file" > "$temp_cc" &&
+ output "CC $file" compile_cc
+ then
+ pass_cc="$pass_cc $file"
+ else
+ failures_cc=$(($failures_cc + 1))
+ fi
+ if ignore "$file" $IGNORE_CXX; then
+ output "SKIP CXX $file" :
+ continue
+ fi
+ if printf "\
+#include <%s>
+
+int main()
+{
+}
+" "$file" > "$temp_cxx" &&
+ output "CXX $file" compile_cxx
+ then
+ pass_cxx="$pass_cxx $file"
+ else
+ failures_cxx=$(($failures_cxx + 1))
+ fi
+done <<EOF
+$(find "$include_dir" -name '*.h')
+EOF
+
+# Check C compilation with all includes.
+
+: > "$temp_cc" &&
+for file in $pass_cc; do
+ printf "\
+#include <%s>
+" "$file" >> $temp_cc
+done
+if printf "\
+int main(void)
+{
+ return 0;
+}
+" >> "$temp_cc" &&
+ output "CC (all includes that did not fail)" compile_cc
+then
+ :
+else
+ failures_cc=$(($failures_cc + 1))
+fi
+
+# Check C++ compilation with all includes.
+
+: > "$temp_cxx" &&
+for file in $pass_cxx; do
+ printf "\
+#include <%s>
+" "$file" >> $temp_cxx
+done
+if printf "\
+int main()
+{
+}
+" >> "$temp_cxx" &&
+ output "CXX (all includes that did not fail)" compile_cxx
+then
+ :
+else
+ failures_cxx=$(($failures_cxx + 1))
+fi
+
+# Report results.
+
+if [ "$SUMMARY" = 1 ]; then
+ printf "\
+Summary:
+ %u failure(s) for C using '%s'.
+ %u failure(s) for C++ using '%s'.
+" $failures_cc "$CC" $failures_cxx "$CXX" 1>&2
+fi
+
+# Exit with nonzero status if there are failures.
+
+[ $failures_cc -eq 0 ] &&
+[ $failures_cxx -eq 0 ]
diff --git a/scripts/test-build.sh b/scripts/test-build.sh
index 5bcecfc..b2ea602 100755
--- a/scripts/test-build.sh
+++ b/scripts/test-build.sh
@@ -229,6 +229,20 @@ for conf in $configs ; do
make -j$J -sC examples/performance-thread \
EXTRA_LDFLAGS="$DPDK_DEP_LDFLAGS" $verbose \
O=$(readlink -m $dir/examples/performance-thread)
+ echo "================== Check includes in $dir"
+ if echo $target | grep -q 'gcc'; then
+ CC=gcc
+ CXX=g++
+ elif echo $target | grep -q 'clang'; then
+ CC=clang
+ CXX=clang++
+ else
+ CXX=$CC
+ fi
+ CC=$CROSS$CC CXX=$CROSS$CXX \
+ VERBOSE="$((! ! ${#verbose}))" \
+ QUIET="$((! ${#verbose}))" \
+ scripts/check-includes.sh "$dir/include"
unset RTE_TARGET
echo "################## $dir done."
done
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* Re: [dpdk-dev] [PATCH v4 00/10] Fix build errors related to exported headers
2016-07-13 13:02 ` [dpdk-dev] [PATCH v4 00/10] " Adrien Mazarguil
` (9 preceding siblings ...)
2016-07-13 13:02 ` [dpdk-dev] [PATCH v4 10/10] scripts: check compilation of exported header files Adrien Mazarguil
@ 2016-07-15 21:03 ` Bruce Richardson
2016-07-18 10:47 ` Adrien Mazarguil
2016-07-20 9:55 ` Thomas Monjalon
2016-08-23 16:36 ` Thomas Monjalon
2016-09-08 12:25 ` [dpdk-dev] [PATCH v5 " Adrien Mazarguil
12 siblings, 2 replies; 79+ messages in thread
From: Bruce Richardson @ 2016-07-15 21:03 UTC (permalink / raw)
To: Adrien Mazarguil; +Cc: dev, Ferruh Yigit
On Wed, Jul 13, 2016 at 03:02:37PM +0200, Adrien Mazarguil wrote:
> DPDK uses GNU C language extensions in most of its code base. This is fine
> for internal source files whose compilation flags are controlled by DPDK,
> however user applications that use exported "public" headers may experience
> compilation failures when enabling strict error/standard checks (-std and
> -pedantic for instance).
>
> Exported headers are installed system-wide and must be as clean as possible
> so applications do not have to resort to workarounds.
>
> This patchset affects exported headers only, compilation problems are
> addressed as follows:
>
> - Adding the __extension__ keyword to nonstandard constructs (same method
> as existing libraries when there is no other choice).
> - Adding the __extension__ keyword to C11 constructs to remain compatible
> with pure C99.
> - Adding missing includes so exported files can be included out of order
> and on their own.
> - Fixing GNU printf-like variadic macros as there is no magic keyword for
> these.
>
Having upgraded to Fedora 24, I'm seeing quite a few errors compiling with gcc
6.1.1 in debug mode. Applying this patchset seems to really cut down on those
errors, so may need to be applied for 16.07 release.
The remaining error I'm seeing is, in mlx drivers, complaints about the
pedantic flag (the flag which I think was causing all the other errors to be
triggered too):
error: `-pedantic' is not an option that controls warnings
For this set though, I don't see any new errors introduced into gcc or clang
builds for the libs or drivers, and a number of errors cleared, so:
Tested-by: Bruce Richardson <bruce.richardson@intel.com>
Regards,
/Bruce
^ permalink raw reply [flat|nested] 79+ messages in thread
* Re: [dpdk-dev] [PATCH v4 00/10] Fix build errors related to exported headers
2016-07-15 21:03 ` [dpdk-dev] [PATCH v4 00/10] Fix build errors related to exported headers Bruce Richardson
@ 2016-07-18 10:47 ` Adrien Mazarguil
2016-07-20 9:55 ` Thomas Monjalon
1 sibling, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-07-18 10:47 UTC (permalink / raw)
To: Bruce Richardson; +Cc: dev, Ferruh Yigit
On Fri, Jul 15, 2016 at 10:03:02PM +0100, Bruce Richardson wrote:
> On Wed, Jul 13, 2016 at 03:02:37PM +0200, Adrien Mazarguil wrote:
> > DPDK uses GNU C language extensions in most of its code base. This is fine
> > for internal source files whose compilation flags are controlled by DPDK,
> > however user applications that use exported "public" headers may experience
> > compilation failures when enabling strict error/standard checks (-std and
> > -pedantic for instance).
> >
> > Exported headers are installed system-wide and must be as clean as possible
> > so applications do not have to resort to workarounds.
> >
> > This patchset affects exported headers only, compilation problems are
> > addressed as follows:
> >
> > - Adding the __extension__ keyword to nonstandard constructs (same method
> > as existing libraries when there is no other choice).
> > - Adding the __extension__ keyword to C11 constructs to remain compatible
> > with pure C99.
> > - Adding missing includes so exported files can be included out of order
> > and on their own.
> > - Fixing GNU printf-like variadic macros as there is no magic keyword for
> > these.
> >
>
> Having upgraded to Fedora 24, I'm seeing quite a few errors compiling with gcc
> 6.1.1 in debug mode. Applying this patchset seems to really cut down on those
> errors, so may need to be applied for 16.07 release.
>
> The remaining error I'm seeing is, in mlx drivers, complaints about the
> pedantic flag (the flag which I think was causing all the other errors to be
> triggered too):
>
> error: `-pedantic' is not an option that controls warnings
Saw this as well with GCC 6, I've planned to drop these #pragmas as soon as
possible after this series is applied, however there is some work left to do
on the libibverbs side before that.
> For this set though, I don't see any new errors introduced into gcc or clang
> builds for the libs or drivers, and a number of errors cleared, so:
>
> Tested-by: Bruce Richardson <bruce.richardson@intel.com>
Thanks for testing.
--
Adrien Mazarguil
6WIND
^ permalink raw reply [flat|nested] 79+ messages in thread
* Re: [dpdk-dev] [PATCH v4 00/10] Fix build errors related to exported headers
2016-07-15 21:03 ` [dpdk-dev] [PATCH v4 00/10] Fix build errors related to exported headers Bruce Richardson
2016-07-18 10:47 ` Adrien Mazarguil
@ 2016-07-20 9:55 ` Thomas Monjalon
1 sibling, 0 replies; 79+ messages in thread
From: Thomas Monjalon @ 2016-07-20 9:55 UTC (permalink / raw)
To: Bruce Richardson; +Cc: dev, Adrien Mazarguil, Ferruh Yigit
2016-07-15 22:03, Bruce Richardson:
> On Wed, Jul 13, 2016 at 03:02:37PM +0200, Adrien Mazarguil wrote:
> > DPDK uses GNU C language extensions in most of its code base. This is fine
> > for internal source files whose compilation flags are controlled by DPDK,
> > however user applications that use exported "public" headers may experience
> > compilation failures when enabling strict error/standard checks (-std and
> > -pedantic for instance).
> >
> > Exported headers are installed system-wide and must be as clean as possible
> > so applications do not have to resort to workarounds.
> >
> > This patchset affects exported headers only, compilation problems are
> > addressed as follows:
> >
> > - Adding the __extension__ keyword to nonstandard constructs (same method
> > as existing libraries when there is no other choice).
> > - Adding the __extension__ keyword to C11 constructs to remain compatible
> > with pure C99.
> > - Adding missing includes so exported files can be included out of order
> > and on their own.
> > - Fixing GNU printf-like variadic macros as there is no magic keyword for
> > these.
> >
>
> Having upgraded to Fedora 24, I'm seeing quite a few errors compiling with gcc
> 6.1.1 in debug mode. Applying this patchset seems to really cut down on those
> errors, so may need to be applied for 16.07 release.
It is reducing the number of warnings but do not completely solve it, right?
It is a very good patchset but it needs to be validated with a large number
of compilers and options. That's why I think it is too late for 16.07.
^ permalink raw reply [flat|nested] 79+ messages in thread
* Re: [dpdk-dev] [PATCH v4 00/10] Fix build errors related to exported headers
2016-07-13 13:02 ` [dpdk-dev] [PATCH v4 00/10] " Adrien Mazarguil
` (10 preceding siblings ...)
2016-07-15 21:03 ` [dpdk-dev] [PATCH v4 00/10] Fix build errors related to exported headers Bruce Richardson
@ 2016-08-23 16:36 ` Thomas Monjalon
2016-09-08 12:39 ` Adrien Mazarguil
2016-09-08 12:25 ` [dpdk-dev] [PATCH v5 " Adrien Mazarguil
12 siblings, 1 reply; 79+ messages in thread
From: Thomas Monjalon @ 2016-08-23 16:36 UTC (permalink / raw)
To: Adrien Mazarguil; +Cc: dev
After rebasing the patchset, the compilation of each patch seems good.
But the new checks fail with clang:
rte_memcpy.h:814:2: error:
implicit declaration of function '_mm_alignr_epi8' is invalid in C99
Other comments about the script:
- it is too long (can it be parallelized?)
- it does not stop printing errors after the first one
^ permalink raw reply [flat|nested] 79+ messages in thread
* Re: [dpdk-dev] [PATCH v4 00/10] Fix build errors related to exported headers
2016-08-23 16:36 ` Thomas Monjalon
@ 2016-09-08 12:39 ` Adrien Mazarguil
0 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-09-08 12:39 UTC (permalink / raw)
To: Thomas Monjalon; +Cc: dev
On Tue, Aug 23, 2016 at 06:36:57PM +0200, Thomas Monjalon wrote:
> After rebasing the patchset, the compilation of each patch seems good.
> But the new checks fail with clang:
> rte_memcpy.h:814:2: error:
> implicit declaration of function '_mm_alignr_epi8' is invalid in C99
This is an unfortunate false positive. mmintrin.h and other x86 intrinsics
headers files define their macros and types only if compiled with the right
-march or CPU flags options. check-includes.sh does not provide any of
those and relies on whatever the C compiler falls back to by default.
The problem is actually that we haven't implemented any fallback in DPDK for
such cases. In the meantime it can be worked around like this:
EXTRA_CFLAGS=-march=core2 EXTRA_CXXFLAGS=-march=core2 ./scripts/check-includes.sh
> Other comments about the script:
> - it is too long (can it be parallelized?)
> - it does not stop printing errors after the first one
Addressing these concerns would require a complete redesign of that script
as a Makefile, and even then it would most likely end up taking too long
when there are no errors (all headers end up being checked).
I've removed it from test-build.sh, people will have to run it manually like
check-git-log.sh, updated v5 accordingly.
--
Adrien Mazarguil
6WIND
^ permalink raw reply [flat|nested] 79+ messages in thread
* [dpdk-dev] [PATCH v5 00/10] Fix build errors related to exported headers
2016-07-13 13:02 ` [dpdk-dev] [PATCH v4 00/10] " Adrien Mazarguil
` (11 preceding siblings ...)
2016-08-23 16:36 ` Thomas Monjalon
@ 2016-09-08 12:25 ` Adrien Mazarguil
2016-09-08 12:25 ` [dpdk-dev] [PATCH v5 01/10] lib: work around braced-groups within expressions Adrien Mazarguil
` (10 more replies)
12 siblings, 11 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-09-08 12:25 UTC (permalink / raw)
To: dev
DPDK uses GNU C language extensions in most of its code base. This is fine
for internal source files whose compilation flags are controlled by DPDK,
however user applications that use exported "public" headers may experience
compilation failures when enabling strict error/standard checks (-std and
-pedantic for instance).
Exported headers are installed system-wide and must be as clean as possible
so applications do not have to resort to workarounds.
This patchset affects exported headers only, compilation problems are
addressed as follows:
- Adding the __extension__ keyword to nonstandard constructs (same method
as existing libraries when there is no other choice).
- Adding the __extension__ keyword to C11 constructs to remain compatible
with pure C99.
- Adding missing includes so exported files can be included out of order
and on their own.
- Fixing GNU printf-like variadic macros as there is no magic keyword for
these.
Changes in v5:
- Fixed compilation error (RH 6.7) in struct rte_cryptodev_session by using
the extension keyword instead of the C99 syntax.
- Removed call to check-includes.sh from test-build.sh as it takes too long
to complete. This script should be run voluntarily like check-git-log.sh
and friends.
Changes in v4:
- Dropped "lib: work around structs with no members" patch, now addressed
as a separate issue outside of this patchset by "mempool: fix empty
structure definition".
- Fixed remaining compilation error with ICC reported by Ferruh. Finally
settled on using the __extension__ keyword directly in struct
rte_pipeline_table_entry as converting it to a standard flexible array
may break existing programs.
Changes in v3:
- Fixed compilation issue on ARM and POWER8 due to missing parenthesis.
- Added bit-field fix for rte_kni.h.
Changes in v2:
- Rebased on top of the current HEAD.
- Added script to check headers automatically (check-includes.sh), for both
C and C++ compilation.
- Updated test-build.sh to use it.
- Fixed consistency of new #include directives, now inside extern "C"
blocks for files that already do that (Jan, fixing these was too much
work for this patchset so I settled on this solution in the meantime).
- Updated headlines to address check-git-log.sh complaints.
Adrien Mazarguil (10):
lib: work around braced-groups within expressions
lib: work around large enum values
lib: use C99 syntax for zero-size arrays
lib: work around nonstandard bit-fields
lib: work around unnamed structs/unions
lib: add missing include dependencies
lib: work around forward reference to enum types
lib: remove named variadic macros in exported headers
lib: hide static functions never defined
scripts: check compilation of exported header files
MAINTAINERS | 1 +
lib/librte_acl/rte_acl.h | 2 +-
lib/librte_cfgfile/rte_cfgfile.h | 2 +
lib/librte_cmdline/cmdline.h | 1 +
lib/librte_cmdline/cmdline_parse_portlist.h | 1 +
lib/librte_cmdline/cmdline_socket.h | 3 +
lib/librte_cryptodev/rte_crypto.h | 2 +
lib/librte_cryptodev/rte_crypto_sym.h | 3 +
lib/librte_cryptodev/rte_cryptodev.h | 40 ++-
lib/librte_cryptodev/rte_cryptodev_pmd.h | 6 +-
.../common/include/arch/arm/rte_byteorder.h | 2 +
.../common/include/arch/arm/rte_memcpy_32.h | 3 +-
.../common/include/arch/arm/rte_prefetch_32.h | 1 +
.../common/include/arch/arm/rte_prefetch_64.h | 1 +
.../common/include/arch/arm/rte_vect.h | 1 +
.../common/include/arch/ppc_64/rte_atomic.h | 1 +
.../common/include/arch/ppc_64/rte_byteorder.h | 1 +
.../common/include/arch/ppc_64/rte_cycles.h | 2 +
.../common/include/arch/ppc_64/rte_memcpy.h | 3 +-
.../common/include/arch/ppc_64/rte_prefetch.h | 1 +
.../common/include/arch/x86/rte_atomic.h | 2 +
.../common/include/arch/x86/rte_atomic_32.h | 9 +
.../common/include/arch/x86/rte_atomic_64.h | 8 +
.../common/include/arch/x86/rte_byteorder.h | 2 +
.../common/include/arch/x86/rte_byteorder_32.h | 7 +
.../common/include/arch/x86/rte_byteorder_64.h | 7 +
.../common/include/arch/x86/rte_cycles.h | 2 +
.../common/include/arch/x86/rte_memcpy.h | 4 +-
.../common/include/arch/x86/rte_prefetch.h | 1 +
.../common/include/arch/x86/rte_rtm.h | 1 +
.../common/include/arch/x86/rte_vect.h | 8 +-
.../common/include/generic/rte_atomic.h | 1 +
.../common/include/generic/rte_byteorder.h | 2 +
.../common/include/generic/rte_cpuflags.h | 3 +
.../common/include/generic/rte_memcpy.h | 4 +
lib/librte_eal/common/include/rte_common.h | 22 +-
lib/librte_eal/common/include/rte_devargs.h | 1 +
lib/librte_eal/common/include/rte_eal.h | 1 +
lib/librte_eal/common/include/rte_interrupts.h | 2 +
lib/librte_eal/common/include/rte_memory.h | 4 +
lib/librte_eal/common/include/rte_memzone.h | 2 +
lib/librte_eal/common/include/rte_time.h | 8 +
lib/librte_eal/common/include/rte_version.h | 1 +
.../eal/include/exec-env/rte_interrupts.h | 1 +
.../eal/include/exec-env/rte_kni_common.h | 7 +-
lib/librte_ether/rte_dev_info.h | 2 +
lib/librte_ether/rte_eth_ctrl.h | 4 +
lib/librte_ether/rte_ethdev.h | 4 +
lib/librte_hash/rte_fbk_hash.h | 2 +-
lib/librte_hash/rte_thash.h | 3 +
lib/librte_ip_frag/rte_ip_frag.h | 2 +-
lib/librte_kni/rte_kni.h | 1 +
lib/librte_lpm/rte_lpm.h | 7 +-
lib/librte_lpm/rte_lpm_neon.h | 1 +
lib/librte_lpm/rte_lpm_sse.h | 1 +
lib/librte_mbuf/rte_mbuf.h | 9 +
lib/librte_mempool/rte_mempool.h | 2 +
lib/librte_pdump/rte_pdump.h | 4 +
lib/librte_pipeline/rte_pipeline.h | 4 +-
lib/librte_reorder/rte_reorder.h | 2 +
lib/librte_ring/rte_ring.h | 2 +-
lib/librte_sched/rte_bitmap.h | 3 +-
lib/librte_sched/rte_reciprocal.h | 2 +
lib/librte_sched/rte_sched_common.h | 1 +
lib/librte_timer/rte_timer.h | 2 +
scripts/check-includes.sh | 286 +++++++++++++++++++
66 files changed, 498 insertions(+), 33 deletions(-)
create mode 100755 scripts/check-includes.sh
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* [dpdk-dev] [PATCH v5 01/10] lib: work around braced-groups within expressions
2016-09-08 12:25 ` [dpdk-dev] [PATCH v5 " Adrien Mazarguil
@ 2016-09-08 12:25 ` Adrien Mazarguil
2016-09-08 12:25 ` [dpdk-dev] [PATCH v5 02/10] lib: work around large enum values Adrien Mazarguil
` (9 subsequent siblings)
10 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-09-08 12:25 UTC (permalink / raw)
To: dev
Exported header files used by applications should allow the strictest
compiler flags. Language extensions used in many places must be explicitly
marked or removed to avoid warnings and compilation failures.
This commit prevents the following errors:
error: ISO C forbids braced-groups within expressions
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
lib/librte_eal/common/include/arch/arm/rte_memcpy_32.h | 3 ++-
lib/librte_eal/common/include/arch/ppc_64/rte_memcpy.h | 3 ++-
lib/librte_eal/common/include/arch/x86/rte_memcpy.h | 4 ++--
lib/librte_eal/common/include/arch/x86/rte_vect.h | 6 ++++--
lib/librte_eal/common/include/rte_common.h | 6 ++++--
5 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/lib/librte_eal/common/include/arch/arm/rte_memcpy_32.h b/lib/librte_eal/common/include/arch/arm/rte_memcpy_32.h
index da6c233..c3a2619 100644
--- a/lib/librte_eal/common/include/arch/arm/rte_memcpy_32.h
+++ b/lib/librte_eal/common/include/arch/arm/rte_memcpy_32.h
@@ -148,7 +148,8 @@ rte_mov256(uint8_t *dst, const uint8_t *src)
}
#define rte_memcpy(dst, src, n) \
- ({ (__builtin_constant_p(n)) ? \
+ __extension__ ({ \
+ (__builtin_constant_p(n)) ? \
memcpy((dst), (src), (n)) : \
rte_memcpy_func((dst), (src), (n)); })
diff --git a/lib/librte_eal/common/include/arch/ppc_64/rte_memcpy.h b/lib/librte_eal/common/include/arch/ppc_64/rte_memcpy.h
index acf7aac..ca9d1dc 100644
--- a/lib/librte_eal/common/include/arch/ppc_64/rte_memcpy.h
+++ b/lib/librte_eal/common/include/arch/ppc_64/rte_memcpy.h
@@ -95,7 +95,8 @@ rte_mov256(uint8_t *dst, const uint8_t *src)
}
#define rte_memcpy(dst, src, n) \
- ({ (__builtin_constant_p(n)) ? \
+ __extension__ ({ \
+ (__builtin_constant_p(n)) ? \
memcpy((dst), (src), (n)) : \
rte_memcpy_func((dst), (src), (n)); })
diff --git a/lib/librte_eal/common/include/arch/x86/rte_memcpy.h b/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
index 413035e..b3bfc23 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
@@ -594,7 +594,7 @@ rte_mov256(uint8_t *dst, const uint8_t *src)
* - __m128i <xmm0> ~ <xmm8> must be pre-defined
*/
#define MOVEUNALIGNED_LEFT47_IMM(dst, src, len, offset) \
-({ \
+__extension__ ({ \
int tmp; \
while (len >= 128 + 16 - offset) { \
xmm0 = _mm_loadu_si128((const __m128i *)((const uint8_t *)src - offset + 0 * 16)); \
@@ -655,7 +655,7 @@ rte_mov256(uint8_t *dst, const uint8_t *src)
* - __m128i <xmm0> ~ <xmm8> used in MOVEUNALIGNED_LEFT47_IMM must be pre-defined
*/
#define MOVEUNALIGNED_LEFT47(dst, src, len, offset) \
-({ \
+__extension__ ({ \
switch (offset) { \
case 0x01: MOVEUNALIGNED_LEFT47_IMM(dst, src, n, 0x01); break; \
case 0x02: MOVEUNALIGNED_LEFT47_IMM(dst, src, n, 0x02); break; \
diff --git a/lib/librte_eal/common/include/arch/x86/rte_vect.h b/lib/librte_eal/common/include/arch/x86/rte_vect.h
index b698797..2836f2c 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_vect.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_vect.h
@@ -106,7 +106,8 @@ typedef union rte_ymm {
#endif /* __AVX__ */
#ifdef RTE_ARCH_I686
-#define _mm_cvtsi128_si64(a) ({ \
+#define _mm_cvtsi128_si64(a) \
+__extension__ ({ \
rte_xmm_t m; \
m.x = (a); \
(m.u64[0]); \
@@ -117,7 +118,8 @@ typedef union rte_ymm {
* Prior to version 12.1 icc doesn't support _mm_set_epi64x.
*/
#if (defined(__ICC) && __ICC < 1210)
-#define _mm_set_epi64x(a, b) ({ \
+#define _mm_set_epi64x(a, b) \
+__extension__ ({ \
rte_xmm_t m; \
m.u64[0] = b; \
m.u64[1] = a; \
diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h
index 332f2a4..477472b 100644
--- a/lib/librte_eal/common/include/rte_common.h
+++ b/lib/librte_eal/common/include/rte_common.h
@@ -268,7 +268,8 @@ rte_align64pow2(uint64_t v)
/**
* Macro to return the minimum of two numbers
*/
-#define RTE_MIN(a, b) ({ \
+#define RTE_MIN(a, b) \
+ __extension__ ({ \
typeof (a) _a = (a); \
typeof (b) _b = (b); \
_a < _b ? _a : _b; \
@@ -277,7 +278,8 @@ rte_align64pow2(uint64_t v)
/**
* Macro to return the maximum of two numbers
*/
-#define RTE_MAX(a, b) ({ \
+#define RTE_MAX(a, b) \
+ __extension__ ({ \
typeof (a) _a = (a); \
typeof (b) _b = (b); \
_a > _b ? _a : _b; \
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* [dpdk-dev] [PATCH v5 02/10] lib: work around large enum values
2016-09-08 12:25 ` [dpdk-dev] [PATCH v5 " Adrien Mazarguil
2016-09-08 12:25 ` [dpdk-dev] [PATCH v5 01/10] lib: work around braced-groups within expressions Adrien Mazarguil
@ 2016-09-08 12:25 ` Adrien Mazarguil
2016-09-08 12:25 ` [dpdk-dev] [PATCH v5 03/10] lib: use C99 syntax for zero-size arrays Adrien Mazarguil
` (8 subsequent siblings)
10 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-09-08 12:25 UTC (permalink / raw)
To: dev
Exported header files used by applications should allow the strictest
compiler flags. Language extensions used in many places must be explicitly
marked or removed to avoid warnings and compilation failures.
This commit prevents the following errors:
error: ISO C restricts enumerator values to range of `int'
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
lib/librte_eal/common/include/rte_memory.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/librte_eal/common/include/rte_memory.h b/lib/librte_eal/common/include/rte_memory.h
index d9e8c21..12e0ebb 100644
--- a/lib/librte_eal/common/include/rte_memory.h
+++ b/lib/librte_eal/common/include/rte_memory.h
@@ -54,6 +54,7 @@ extern "C" {
#include <rte_common.h>
+__extension__
enum rte_page_sizes {
RTE_PGSIZE_4K = 1ULL << 12,
RTE_PGSIZE_64K = 1ULL << 16,
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* [dpdk-dev] [PATCH v5 03/10] lib: use C99 syntax for zero-size arrays
2016-09-08 12:25 ` [dpdk-dev] [PATCH v5 " Adrien Mazarguil
2016-09-08 12:25 ` [dpdk-dev] [PATCH v5 01/10] lib: work around braced-groups within expressions Adrien Mazarguil
2016-09-08 12:25 ` [dpdk-dev] [PATCH v5 02/10] lib: work around large enum values Adrien Mazarguil
@ 2016-09-08 12:25 ` Adrien Mazarguil
2016-09-08 12:25 ` [dpdk-dev] [PATCH v5 04/10] lib: work around nonstandard bit-fields Adrien Mazarguil
` (7 subsequent siblings)
10 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-09-08 12:25 UTC (permalink / raw)
To: dev
Exported header files used by applications should allow the strictest
compiler flags. Language extensions used in many places must be explicitly
marked or removed to avoid warnings and compilation failures.
The extension keyword is used whenever the C99 syntax cannot do it.
This commit prevents the following errors:
error: ISO C forbids zero-size array `[...]'
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
lib/librte_acl/rte_acl.h | 2 +-
lib/librte_cryptodev/rte_cryptodev.h | 2 +-
lib/librte_cryptodev/rte_cryptodev_pmd.h | 2 +-
lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h | 2 +-
lib/librte_hash/rte_fbk_hash.h | 2 +-
lib/librte_ip_frag/rte_ip_frag.h | 2 +-
lib/librte_lpm/rte_lpm.h | 2 +-
lib/librte_mbuf/rte_mbuf.h | 3 +++
lib/librte_pipeline/rte_pipeline.h | 2 +-
lib/librte_ring/rte_ring.h | 2 +-
lib/librte_sched/rte_bitmap.h | 2 +-
11 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/lib/librte_acl/rte_acl.h b/lib/librte_acl/rte_acl.h
index 0979a09..c059dc3 100644
--- a/lib/librte_acl/rte_acl.h
+++ b/lib/librte_acl/rte_acl.h
@@ -144,7 +144,7 @@ struct rte_acl_rule_data {
struct rte_acl_field field[fld_num]; \
}
-RTE_ACL_RULE_DEF(rte_acl_rule, 0);
+RTE_ACL_RULE_DEF(rte_acl_rule,);
#define RTE_ACL_RULE_SZ(fld_num) \
(sizeof(struct rte_acl_rule) + sizeof(struct rte_acl_field) * (fld_num))
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index affbdec..1e30a19 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -759,7 +759,7 @@ struct rte_cryptodev_sym_session {
} __rte_aligned(8);
/**< Public symmetric session details */
- char _private[0];
+ char _private[];
/**< Private session material */
};
diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h b/lib/librte_cryptodev/rte_cryptodev_pmd.h
index 7d049ea..42e7b79 100644
--- a/lib/librte_cryptodev/rte_cryptodev_pmd.h
+++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h
@@ -71,7 +71,7 @@ struct rte_cryptodev_session {
struct rte_mempool *mp;
} __rte_aligned(8);
- char _private[0];
+ __extension__ char _private[0];
};
struct rte_cryptodev_driver;
diff --git a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
index 2acdfd9..7f458a3 100644
--- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
+++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
@@ -102,7 +102,7 @@ struct rte_kni_fifo {
volatile unsigned read; /**< Next position to be read */
unsigned len; /**< Circular buffer length */
unsigned elem_size; /**< Pointer size - for 32/64 bit OS */
- void * volatile buffer[0]; /**< The buffer contains mbuf pointers */
+ void *volatile buffer[]; /**< The buffer contains mbuf pointers */
};
/*
diff --git a/lib/librte_hash/rte_fbk_hash.h b/lib/librte_hash/rte_fbk_hash.h
index a430961..bd46048 100644
--- a/lib/librte_hash/rte_fbk_hash.h
+++ b/lib/librte_hash/rte_fbk_hash.h
@@ -115,7 +115,7 @@ struct rte_fbk_hash_table {
uint32_t init_val; /**< For initialising hash function. */
/** A flat table of all buckets. */
- union rte_fbk_hash_entry t[0];
+ union rte_fbk_hash_entry t[];
};
/**
diff --git a/lib/librte_ip_frag/rte_ip_frag.h b/lib/librte_ip_frag/rte_ip_frag.h
index 9ac7081..69596ab 100644
--- a/lib/librte_ip_frag/rte_ip_frag.h
+++ b/lib/librte_ip_frag/rte_ip_frag.h
@@ -124,7 +124,7 @@ struct rte_ip_frag_tbl {
struct ip_frag_pkt *last; /**< last used entry. */
struct ip_pkt_list lru; /**< LRU list for table entries. */
struct ip_frag_tbl_stat stat; /**< statistics counters. */
- struct ip_frag_pkt pkt[0]; /**< hash table. */
+ struct ip_frag_pkt pkt[]; /**< hash table. */
};
/** IPv6 fragment extension header */
diff --git a/lib/librte_lpm/rte_lpm.h b/lib/librte_lpm/rte_lpm.h
index 2df1d67..79a4593 100644
--- a/lib/librte_lpm/rte_lpm.h
+++ b/lib/librte_lpm/rte_lpm.h
@@ -193,7 +193,7 @@ struct rte_lpm_v20 {
__rte_cache_aligned; /**< LPM tbl24 table. */
struct rte_lpm_tbl_entry_v20 tbl8[RTE_LPM_TBL8_NUM_ENTRIES]
__rte_cache_aligned; /**< LPM tbl8 table. */
- struct rte_lpm_rule_v20 rules_tbl[0] \
+ struct rte_lpm_rule_v20 rules_tbl[]
__rte_cache_aligned; /**< LPM rules. */
};
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 7ea66ed..7ae6554 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -756,8 +756,11 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask);
/* define a set of marker types that can be used to refer to set points in the
* mbuf */
+__extension__
typedef void *MARKER[0]; /**< generic marker for a point in a structure */
+__extension__
typedef uint8_t MARKER8[0]; /**< generic marker with 1B alignment */
+__extension__
typedef uint64_t MARKER64[0]; /**< marker that allows us to overwrite 8 bytes
* with a single assignment */
diff --git a/lib/librte_pipeline/rte_pipeline.h b/lib/librte_pipeline/rte_pipeline.h
index 84d1802..b0b4615 100644
--- a/lib/librte_pipeline/rte_pipeline.h
+++ b/lib/librte_pipeline/rte_pipeline.h
@@ -252,7 +252,7 @@ struct rte_pipeline_table_entry {
uint32_t table_id;
};
/** Start of table entry area for user defined actions and meta-data */
- uint8_t action_data[0];
+ __extension__ uint8_t action_data[0];
};
/**
diff --git a/lib/librte_ring/rte_ring.h b/lib/librte_ring/rte_ring.h
index 0e22e69..dfe07a2 100644
--- a/lib/librte_ring/rte_ring.h
+++ b/lib/librte_ring/rte_ring.h
@@ -187,7 +187,7 @@ struct rte_ring {
struct rte_ring_debug_stats stats[RTE_MAX_LCORE];
#endif
- void * ring[0] __rte_cache_aligned; /**< Memory space of ring starts here.
+ void *ring[] __rte_cache_aligned; /**< Memory space of ring starts here.
* not volatile so need to be careful
* about compiler re-ordering */
};
diff --git a/lib/librte_sched/rte_bitmap.h b/lib/librte_sched/rte_bitmap.h
index ff675c5..1b5df02 100644
--- a/lib/librte_sched/rte_bitmap.h
+++ b/lib/librte_sched/rte_bitmap.h
@@ -103,7 +103,7 @@ struct rte_bitmap {
uint32_t go2; /**< Bitmap scan: Go/stop condition for current array2 cache line */
/* Storage space for array1 and array2 */
- uint8_t memory[0];
+ uint8_t memory[];
};
static inline void
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* [dpdk-dev] [PATCH v5 04/10] lib: work around nonstandard bit-fields
2016-09-08 12:25 ` [dpdk-dev] [PATCH v5 " Adrien Mazarguil
` (2 preceding siblings ...)
2016-09-08 12:25 ` [dpdk-dev] [PATCH v5 03/10] lib: use C99 syntax for zero-size arrays Adrien Mazarguil
@ 2016-09-08 12:25 ` Adrien Mazarguil
2016-09-08 12:25 ` [dpdk-dev] [PATCH v5 05/10] lib: work around unnamed structs/unions Adrien Mazarguil
` (6 subsequent siblings)
10 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-09-08 12:25 UTC (permalink / raw)
To: dev
Exported header files used by applications should allow the strictest
compiler flags. Language extensions used in many places must be explicitly
marked or removed to avoid warnings and compilation failures.
This commit prevents the following errors:
error: type of bit-field `[...]' is a GCC extension
Note: the standard does not require implementations to issue a diagnostic
message with these, and such errors do not occur with recent GCC or clang
versions. However, GCC 4.7 is still common and using the extension keyword
is easier than checking compiler version.
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
lib/librte_cryptodev/rte_cryptodev.h | 2 ++
lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h | 1 +
lib/librte_ether/rte_ethdev.h | 4 ++++
lib/librte_kni/rte_kni.h | 1 +
lib/librte_lpm/rte_lpm.h | 4 ++++
lib/librte_mbuf/rte_mbuf.h | 1 +
6 files changed, 13 insertions(+)
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index 1e30a19..957bdd7 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -619,6 +619,7 @@ struct rte_cryptodev {
struct rte_cryptodev_cb_list link_intr_cbs;
/**< User application callback for interrupts if present */
+ __extension__
uint8_t attached : 1;
/**< Flag indicating the device is attached */
} __rte_cache_aligned;
@@ -642,6 +643,7 @@ struct rte_cryptodev_data {
char name[RTE_CRYPTODEV_NAME_MAX_LEN];
/**< Unique identifier name */
+ __extension__
uint8_t dev_started : 1;
/**< Device state: STARTED(1)/STOPPED(0) */
diff --git a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
index 7f458a3..2ef0506 100644
--- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
+++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
@@ -159,6 +159,7 @@ struct rte_kni_device_info {
uint16_t group_id; /**< Group ID */
uint32_t core_id; /**< core ID to bind for kernel thread */
+ __extension__
uint8_t force_bind : 1; /**< Flag for kernel thread binding */
/* mbuf size */
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index b0fe033..96575e8 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -255,6 +255,7 @@ struct rte_eth_stats {
/**
* A structure used to retrieve link-level information of an Ethernet port.
*/
+__extension__
struct rte_eth_link {
uint32_t link_speed; /**< ETH_SPEED_NUM_ */
uint16_t link_duplex : 1; /**< ETH_LINK_[HALF/FULL]_DUPLEX */
@@ -346,6 +347,7 @@ struct rte_eth_rxmode {
enum rte_eth_rx_mq_mode mq_mode;
uint32_t max_rx_pkt_len; /**< Only used if jumbo_frame enabled. */
uint16_t split_hdr_size; /**< hdr buf size (header_split enabled).*/
+ __extension__
uint16_t header_split : 1, /**< Header Split enable. */
hw_ip_checksum : 1, /**< IP/UDP/TCP checksum offload enable. */
hw_vlan_filter : 1, /**< VLAN filter enable. */
@@ -645,6 +647,7 @@ struct rte_eth_txmode {
/* For i40e specifically */
uint16_t pvid;
+ __extension__
uint8_t hw_vlan_reject_tagged : 1,
/**< If set, reject sending out tagged pkts */
hw_vlan_reject_untagged : 1,
@@ -1691,6 +1694,7 @@ struct rte_eth_dev_data {
struct ether_addr* hash_mac_addrs;
/** Device Ethernet MAC addresses of hash filtering. */
uint8_t port_id; /**< Device [external] port identifier. */
+ __extension__
uint8_t promiscuous : 1, /**< RX promiscuous mode ON(1) / OFF(0). */
scattered_rx : 1, /**< RX of scattered packets is ON(1) / OFF(0) */
all_multicast : 1, /**< RX all multicast mode ON(1) / OFF(0). */
diff --git a/lib/librte_kni/rte_kni.h b/lib/librte_kni/rte_kni.h
index 7363e6c..5f6f9e4 100644
--- a/lib/librte_kni/rte_kni.h
+++ b/lib/librte_kni/rte_kni.h
@@ -88,6 +88,7 @@ struct rte_kni_conf {
struct rte_pci_addr addr;
struct rte_pci_id id;
+ __extension__
uint8_t force_bind : 1; /* Flag to bind kernel thread */
};
diff --git a/lib/librte_lpm/rte_lpm.h b/lib/librte_lpm/rte_lpm.h
index 79a4593..28668a3 100644
--- a/lib/librte_lpm/rte_lpm.h
+++ b/lib/librte_lpm/rte_lpm.h
@@ -93,6 +93,7 @@ extern "C" {
#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
/** @internal Tbl24 entry structure. */
+__extension__
struct rte_lpm_tbl_entry_v20 {
/**
* Stores Next hop (tbl8 or tbl24 when valid_group is not set) or
@@ -116,6 +117,7 @@ struct rte_lpm_tbl_entry_v20 {
uint8_t depth :6; /**< Rule depth. */
};
+__extension__
struct rte_lpm_tbl_entry {
/**
* Stores Next hop (tbl8 or tbl24 when valid_group is not set) or
@@ -137,6 +139,7 @@ struct rte_lpm_tbl_entry {
};
#else
+__extension__
struct rte_lpm_tbl_entry_v20 {
uint8_t depth :6;
uint8_t valid_group :1;
@@ -147,6 +150,7 @@ struct rte_lpm_tbl_entry_v20 {
};
};
+__extension__
struct rte_lpm_tbl_entry {
uint32_t depth :6;
uint32_t valid_group :1;
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 7ae6554..c6cb299 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -865,6 +865,7 @@ struct rte_mbuf {
/* fields to support TX offloads */
union {
uint64_t tx_offload; /**< combined for easy fetch */
+ __extension__
struct {
uint64_t l2_len:7; /**< L2 (MAC) Header Length. */
uint64_t l3_len:9; /**< L3 (IP) Header Length. */
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* [dpdk-dev] [PATCH v5 05/10] lib: work around unnamed structs/unions
2016-09-08 12:25 ` [dpdk-dev] [PATCH v5 " Adrien Mazarguil
` (3 preceding siblings ...)
2016-09-08 12:25 ` [dpdk-dev] [PATCH v5 04/10] lib: work around nonstandard bit-fields Adrien Mazarguil
@ 2016-09-08 12:25 ` Adrien Mazarguil
2016-09-08 12:25 ` [dpdk-dev] [PATCH v5 06/10] lib: add missing include dependencies Adrien Mazarguil
` (5 subsequent siblings)
10 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-09-08 12:25 UTC (permalink / raw)
To: dev
Exported header files used by applications should allow the strictest
compiler flags. Language extensions used in many places must be explicitly
marked to avoid warnings and compilation failures.
Unnamed structs/unions are allowed since C11, however many compiler
versions do not use this mode by default.
This commit prevents the following errors:
error: ISO C99 doesn't support unnamed structs/unions
error: struct has no named members
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
lib/librte_cryptodev/rte_crypto.h | 2 ++
lib/librte_cryptodev/rte_crypto_sym.h | 3 +++
lib/librte_cryptodev/rte_cryptodev.h | 4 ++++
lib/librte_cryptodev/rte_cryptodev_pmd.h | 2 ++
lib/librte_eal/common/include/arch/ppc_64/rte_cycles.h | 2 ++
lib/librte_eal/common/include/arch/x86/rte_atomic_32.h | 3 +++
lib/librte_eal/common/include/arch/x86/rte_cycles.h | 2 ++
lib/librte_eal/common/include/rte_common.h | 7 +++++++
lib/librte_eal/common/include/rte_devargs.h | 1 +
lib/librte_eal/common/include/rte_interrupts.h | 2 ++
lib/librte_eal/common/include/rte_memory.h | 1 +
lib/librte_eal/common/include/rte_memzone.h | 2 ++
lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h | 1 +
lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h | 4 ++++
lib/librte_hash/rte_thash.h | 3 +++
lib/librte_lpm/rte_lpm.h | 1 +
lib/librte_mbuf/rte_mbuf.h | 5 +++++
lib/librte_mempool/rte_mempool.h | 2 ++
lib/librte_pipeline/rte_pipeline.h | 2 ++
lib/librte_timer/rte_timer.h | 2 ++
20 files changed, 51 insertions(+)
diff --git a/lib/librte_cryptodev/rte_crypto.h b/lib/librte_cryptodev/rte_crypto.h
index 5bc3eaa..9019518 100644
--- a/lib/librte_cryptodev/rte_crypto.h
+++ b/lib/librte_cryptodev/rte_crypto.h
@@ -48,6 +48,7 @@ extern "C" {
#include <rte_mbuf.h>
#include <rte_memory.h>
#include <rte_mempool.h>
+#include <rte_common.h>
#include "rte_crypto_sym.h"
@@ -111,6 +112,7 @@ struct rte_crypto_op {
void *opaque_data;
/**< Opaque pointer for user data */
+ RTE_STD_C11
union {
struct rte_crypto_sym_op *sym;
/**< Symmetric operation parameters */
diff --git a/lib/librte_cryptodev/rte_crypto_sym.h b/lib/librte_cryptodev/rte_crypto_sym.h
index d9bd821..8178e5a 100644
--- a/lib/librte_cryptodev/rte_crypto_sym.h
+++ b/lib/librte_cryptodev/rte_crypto_sym.h
@@ -51,6 +51,7 @@ extern "C" {
#include <rte_mbuf.h>
#include <rte_memory.h>
#include <rte_mempool.h>
+#include <rte_common.h>
/** Symmetric Cipher Algorithms */
@@ -333,6 +334,7 @@ struct rte_crypto_sym_xform {
/**< next xform in chain */
enum rte_crypto_sym_xform_type type
; /**< xform type */
+ RTE_STD_C11
union {
struct rte_crypto_auth_xform auth;
/**< Authentication / hash xform */
@@ -371,6 +373,7 @@ struct rte_crypto_sym_op {
enum rte_crypto_sym_op_sess_type sess_type;
+ RTE_STD_C11
union {
struct rte_cryptodev_sym_session *session;
/**< Handle for the initialised session context */
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index 957bdd7..cf28541 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -48,6 +48,7 @@ extern "C" {
#include "rte_kvargs.h"
#include "rte_crypto.h"
#include "rte_dev.h"
+#include <rte_common.h>
#define CRYPTODEV_NAME_NULL_PMD cryptodev_null_pmd
/**< Null crypto PMD device name */
@@ -104,6 +105,7 @@ extern const char **rte_cyptodev_names;
struct rte_cryptodev_symmetric_capability {
enum rte_crypto_sym_xform_type xform_type;
/**< Transform type : Authentication / Cipher */
+ RTE_STD_C11
union {
struct {
enum rte_crypto_auth_algorithm algo;
@@ -177,6 +179,7 @@ struct rte_cryptodev_capabilities {
enum rte_crypto_op_type op;
/**< Operation type */
+ RTE_STD_C11
union {
struct rte_cryptodev_symmetric_capability sym;
/**< Symmetric operation capability parameters */
@@ -751,6 +754,7 @@ rte_cryptodev_enqueue_burst(uint8_t dev_id, uint16_t qp_id,
/** Cryptodev symmetric crypto session */
struct rte_cryptodev_sym_session {
+ RTE_STD_C11
struct {
uint8_t dev_id;
/**< Device Id */
diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h b/lib/librte_cryptodev/rte_cryptodev_pmd.h
index 42e7b79..a929ef1 100644
--- a/lib/librte_cryptodev/rte_cryptodev_pmd.h
+++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h
@@ -52,6 +52,7 @@ extern "C" {
#include <rte_mbuf.h>
#include <rte_mempool.h>
#include <rte_log.h>
+#include <rte_common.h>
#include "rte_crypto.h"
#include "rte_cryptodev.h"
@@ -65,6 +66,7 @@ extern "C" {
#endif
struct rte_cryptodev_session {
+ RTE_STD_C11
struct {
uint8_t dev_id;
enum rte_cryptodev_type type;
diff --git a/lib/librte_eal/common/include/arch/ppc_64/rte_cycles.h b/lib/librte_eal/common/include/arch/ppc_64/rte_cycles.h
index 64beddf..8fa6fc6 100644
--- a/lib/librte_eal/common/include/arch/ppc_64/rte_cycles.h
+++ b/lib/librte_eal/common/include/arch/ppc_64/rte_cycles.h
@@ -40,6 +40,7 @@ extern "C" {
#include "generic/rte_cycles.h"
#include <rte_byteorder.h>
+#include <rte_common.h>
/**
* Read the time base register.
@@ -52,6 +53,7 @@ rte_rdtsc(void)
{
union {
uint64_t tsc_64;
+ RTE_STD_C11
struct {
#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
uint32_t hi_32;
diff --git a/lib/librte_eal/common/include/arch/x86/rte_atomic_32.h b/lib/librte_eal/common/include/arch/x86/rte_atomic_32.h
index 400d8a9..5ce01b3 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_atomic_32.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_atomic_32.h
@@ -40,6 +40,8 @@
#ifndef _RTE_ATOMIC_I686_H_
#define _RTE_ATOMIC_I686_H_
+#include <rte_common.h>
+
/*------------------------- 64 bit atomic operations -------------------------*/
#ifndef RTE_FORCE_INTRINSICS
@@ -47,6 +49,7 @@ static inline int
rte_atomic64_cmpset(volatile uint64_t *dst, uint64_t exp, uint64_t src)
{
uint8_t res;
+ RTE_STD_C11
union {
struct {
uint32_t l32;
diff --git a/lib/librte_eal/common/include/arch/x86/rte_cycles.h b/lib/librte_eal/common/include/arch/x86/rte_cycles.h
index 6e3c7d8..5eb6ce9 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_cycles.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_cycles.h
@@ -75,12 +75,14 @@ extern "C" {
extern int rte_cycles_vmware_tsc_map;
#include <rte_branch_prediction.h>
#endif
+#include <rte_common.h>
static inline uint64_t
rte_rdtsc(void)
{
union {
uint64_t tsc_64;
+ RTE_STD_C11
struct {
uint32_t lo_32;
uint32_t hi_32;
diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h
index 477472b..98ecc1c 100644
--- a/lib/librte_eal/common/include/rte_common.h
+++ b/lib/librte_eal/common/include/rte_common.h
@@ -59,6 +59,13 @@ extern "C" {
#define asm __asm__
#endif
+/** C extension macro for environments lacking C11 features. */
+#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L
+#define RTE_STD_C11 __extension__
+#else
+#define RTE_STD_C11
+#endif
+
#ifdef RTE_ARCH_STRICT_ALIGN
typedef uint64_t unaligned_uint64_t __attribute__ ((aligned(1)));
typedef uint32_t unaligned_uint32_t __attribute__ ((aligned(1)));
diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h
index 53c59f5..c66895f 100644
--- a/lib/librte_eal/common/include/rte_devargs.h
+++ b/lib/librte_eal/common/include/rte_devargs.h
@@ -76,6 +76,7 @@ struct rte_devargs {
TAILQ_ENTRY(rte_devargs) next;
/** Type of device. */
enum rte_devtype type;
+ RTE_STD_C11
union {
/** Used if type is RTE_DEVTYPE_*_PCI. */
struct {
diff --git a/lib/librte_eal/common/include/rte_interrupts.h b/lib/librte_eal/common/include/rte_interrupts.h
index ff11ef3..fd3c6ef 100644
--- a/lib/librte_eal/common/include/rte_interrupts.h
+++ b/lib/librte_eal/common/include/rte_interrupts.h
@@ -34,6 +34,8 @@
#ifndef _RTE_INTERRUPTS_H_
#define _RTE_INTERRUPTS_H_
+#include <rte_common.h>
+
/**
* @file
*
diff --git a/lib/librte_eal/common/include/rte_memory.h b/lib/librte_eal/common/include/rte_memory.h
index 12e0ebb..06b6596 100644
--- a/lib/librte_eal/common/include/rte_memory.h
+++ b/lib/librte_eal/common/include/rte_memory.h
@@ -104,6 +104,7 @@ typedef uint64_t phys_addr_t; /**< Physical address definition. */
*/
struct rte_memseg {
phys_addr_t phys_addr; /**< Start physical address. */
+ RTE_STD_C11
union {
void *addr; /**< Start virtual address. */
uint64_t addr_64; /**< Makes sure addr is always 64 bits */
diff --git a/lib/librte_eal/common/include/rte_memzone.h b/lib/librte_eal/common/include/rte_memzone.h
index dae98f5..8e42cae 100644
--- a/lib/librte_eal/common/include/rte_memzone.h
+++ b/lib/librte_eal/common/include/rte_memzone.h
@@ -53,6 +53,7 @@
#include <stdio.h>
#include <rte_memory.h>
+#include <rte_common.h>
#ifdef __cplusplus
extern "C" {
@@ -78,6 +79,7 @@ struct rte_memzone {
char name[RTE_MEMZONE_NAMESIZE]; /**< Name of the memory zone. */
phys_addr_t phys_addr; /**< Start physical address. */
+ RTE_STD_C11
union {
void *addr; /**< Start virtual address. */
uint64_t addr_64; /**< Makes sure addr is always 64-bits */
diff --git a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h
index 3dacbff..d459bf4 100644
--- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h
+++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h
@@ -82,6 +82,7 @@ struct rte_epoll_event {
/** Handle for interrupts. */
struct rte_intr_handle {
+ RTE_STD_C11
union {
int vfio_dev_fd; /**< VFIO device file descriptor */
int uio_cfg_fd; /**< UIO config file descriptor
diff --git a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
index 2ef0506..164f127 100644
--- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
+++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
@@ -61,6 +61,9 @@
#ifdef __KERNEL__
#include <linux/if.h>
+#define RTE_STD_C11
+#else
+#include <rte_common.h>
#endif
/**
@@ -85,6 +88,7 @@ enum rte_kni_req_id {
*/
struct rte_kni_request {
uint32_t req_id; /**< Request id */
+ RTE_STD_C11
union {
uint32_t new_mtu; /**< New MTU */
uint8_t if_up; /**< 1: interface up, 0: interface down */
diff --git a/lib/librte_hash/rte_thash.h b/lib/librte_hash/rte_thash.h
index d98e98e..a4886a8 100644
--- a/lib/librte_hash/rte_thash.h
+++ b/lib/librte_hash/rte_thash.h
@@ -54,6 +54,7 @@ extern "C" {
#include <stdint.h>
#include <rte_byteorder.h>
#include <rte_ip.h>
+#include <rte_common.h>
#ifdef __SSE3__
#include <rte_vect.h>
@@ -102,6 +103,7 @@ static const __m128i rte_thash_ipv6_bswap_mask = {
struct rte_ipv4_tuple {
uint32_t src_addr;
uint32_t dst_addr;
+ RTE_STD_C11
union {
struct {
uint16_t dport;
@@ -119,6 +121,7 @@ struct rte_ipv4_tuple {
struct rte_ipv6_tuple {
uint8_t src_addr[16];
uint8_t dst_addr[16];
+ RTE_STD_C11
union {
struct {
uint16_t dport;
diff --git a/lib/librte_lpm/rte_lpm.h b/lib/librte_lpm/rte_lpm.h
index 28668a3..3ef4533 100644
--- a/lib/librte_lpm/rte_lpm.h
+++ b/lib/librte_lpm/rte_lpm.h
@@ -100,6 +100,7 @@ struct rte_lpm_tbl_entry_v20 {
* a group index pointing to a tbl8 structure (tbl24 only, when
* valid_group is set)
*/
+ RTE_STD_C11
union {
uint8_t next_hop;
uint8_t group_idx;
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index c6cb299..23b7bf8 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -787,6 +787,7 @@ struct rte_mbuf {
* or non-atomic) is controlled by the CONFIG_RTE_MBUF_REFCNT_ATOMIC
* config option.
*/
+ RTE_STD_C11
union {
rte_atomic16_t refcnt_atomic; /**< Atomically accessed refcnt */
uint16_t refcnt; /**< Non-atomically accessed refcnt */
@@ -806,6 +807,7 @@ struct rte_mbuf {
* would have RTE_PTYPE_L2_ETHER and not RTE_PTYPE_L2_VLAN because the
* vlan is stripped from the data.
*/
+ RTE_STD_C11
union {
uint32_t packet_type; /**< L2/L3/L4 and tunnel information. */
struct {
@@ -827,6 +829,7 @@ struct rte_mbuf {
union {
uint32_t rss; /**< RSS hash result if RSS enabled */
struct {
+ RTE_STD_C11
union {
struct {
uint16_t hash;
@@ -854,6 +857,7 @@ struct rte_mbuf {
/* second cache line - fields only used in slow path or on TX */
MARKER cacheline1 __rte_cache_min_aligned;
+ RTE_STD_C11
union {
void *userdata; /**< Can be used for external metadata */
uint64_t udata64; /**< Allow 8-byte userdata on 32-bit */
@@ -863,6 +867,7 @@ struct rte_mbuf {
struct rte_mbuf *next; /**< Next segment of scattered packet. */
/* fields to support TX offloads */
+ RTE_STD_C11
union {
uint64_t tx_offload; /**< combined for easy fetch */
__extension__
diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h
index 059ad9e..0243f9e 100644
--- a/lib/librte_mempool/rte_mempool.h
+++ b/lib/librte_mempool/rte_mempool.h
@@ -75,6 +75,7 @@
#include <rte_branch_prediction.h>
#include <rte_ring.h>
#include <rte_memcpy.h>
+#include <rte_common.h>
#ifdef __cplusplus
extern "C" {
@@ -216,6 +217,7 @@ struct rte_mempool {
* RTE_MEMPOOL_NAMESIZE next time the ABI changes
*/
char name[RTE_MEMZONE_NAMESIZE]; /**< Name of mempool. */
+ RTE_STD_C11
union {
void *pool_data; /**< Ring or pool to store objects. */
uint64_t pool_id; /**< External mempool identifier. */
diff --git a/lib/librte_pipeline/rte_pipeline.h b/lib/librte_pipeline/rte_pipeline.h
index b0b4615..f366348 100644
--- a/lib/librte_pipeline/rte_pipeline.h
+++ b/lib/librte_pipeline/rte_pipeline.h
@@ -87,6 +87,7 @@ extern "C" {
#include <rte_port.h>
#include <rte_table.h>
+#include <rte_common.h>
struct rte_mbuf;
@@ -244,6 +245,7 @@ struct rte_pipeline_table_entry {
/** Reserved action */
enum rte_pipeline_action action;
+ RTE_STD_C11
union {
/** Output port ID (meta-data for "Send packet to output port"
action) */
diff --git a/lib/librte_timer/rte_timer.h b/lib/librte_timer/rte_timer.h
index 77547c6..a276a73 100644
--- a/lib/librte_timer/rte_timer.h
+++ b/lib/librte_timer/rte_timer.h
@@ -66,6 +66,7 @@
#include <stdio.h>
#include <stdint.h>
#include <stddef.h>
+#include <rte_common.h>
#ifdef __cplusplus
extern "C" {
@@ -91,6 +92,7 @@ enum rte_timer_type {
* config) and an owner (the id of the lcore that owns the timer).
*/
union rte_timer_status {
+ RTE_STD_C11
struct {
uint16_t state; /**< Stop, pending, running, config. */
int16_t owner; /**< The lcore that owns the timer. */
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* [dpdk-dev] [PATCH v5 06/10] lib: add missing include dependencies
2016-09-08 12:25 ` [dpdk-dev] [PATCH v5 " Adrien Mazarguil
` (4 preceding siblings ...)
2016-09-08 12:25 ` [dpdk-dev] [PATCH v5 05/10] lib: work around unnamed structs/unions Adrien Mazarguil
@ 2016-09-08 12:25 ` Adrien Mazarguil
2016-09-08 12:25 ` [dpdk-dev] [PATCH v5 07/10] lib: work around forward reference to enum types Adrien Mazarguil
` (4 subsequent siblings)
10 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-09-08 12:25 UTC (permalink / raw)
To: dev
Exported header files for use by applications should be self sufficient and
allow out of order inclusion. Moreover, they must include all the system
headers they need for types and macros.
This commit prevents the following errors:
error: `RTE_MAX_LCORE' undeclared here (not in a function)
error: `RTE_LPM_VALID_EXT_ENTRY_BITMASK' undeclared
(first use in this function)
error: #error "Unsupported cache line size"
error: `asm' undeclared (first use in this function)
error: implicit declaration of function `[...]'
error: unknown type name `[...]'
error: field `mac_addr' has incomplete type
error: `CHAR_BIT' undeclared here (not in a function)
error: `struct [...]' declared inside parameter list
error: unknown type name `uint8_t'
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
lib/librte_cfgfile/rte_cfgfile.h | 2 ++
lib/librte_cmdline/cmdline.h | 1 +
lib/librte_cmdline/cmdline_parse_portlist.h | 1 +
lib/librte_cmdline/cmdline_socket.h | 3 +++
lib/librte_eal/common/include/arch/arm/rte_byteorder.h | 2 ++
lib/librte_eal/common/include/arch/arm/rte_prefetch_32.h | 1 +
lib/librte_eal/common/include/arch/arm/rte_prefetch_64.h | 1 +
lib/librte_eal/common/include/arch/arm/rte_vect.h | 1 +
lib/librte_eal/common/include/arch/ppc_64/rte_atomic.h | 1 +
lib/librte_eal/common/include/arch/ppc_64/rte_byteorder.h | 1 +
lib/librte_eal/common/include/arch/ppc_64/rte_prefetch.h | 1 +
lib/librte_eal/common/include/arch/x86/rte_atomic.h | 2 ++
lib/librte_eal/common/include/arch/x86/rte_atomic_32.h | 6 ++++++
lib/librte_eal/common/include/arch/x86/rte_atomic_64.h | 8 ++++++++
lib/librte_eal/common/include/arch/x86/rte_byteorder.h | 2 ++
lib/librte_eal/common/include/arch/x86/rte_byteorder_32.h | 7 +++++++
lib/librte_eal/common/include/arch/x86/rte_byteorder_64.h | 7 +++++++
lib/librte_eal/common/include/arch/x86/rte_prefetch.h | 1 +
lib/librte_eal/common/include/arch/x86/rte_rtm.h | 1 +
lib/librte_eal/common/include/arch/x86/rte_vect.h | 2 ++
lib/librte_eal/common/include/generic/rte_atomic.h | 1 +
lib/librte_eal/common/include/generic/rte_byteorder.h | 2 ++
lib/librte_eal/common/include/rte_eal.h | 1 +
lib/librte_eal/common/include/rte_memory.h | 2 ++
lib/librte_eal/common/include/rte_time.h | 8 ++++++++
lib/librte_eal/common/include/rte_version.h | 1 +
lib/librte_ether/rte_dev_info.h | 2 ++
lib/librte_ether/rte_eth_ctrl.h | 4 ++++
lib/librte_lpm/rte_lpm_neon.h | 1 +
lib/librte_lpm/rte_lpm_sse.h | 1 +
lib/librte_pdump/rte_pdump.h | 4 ++++
lib/librte_reorder/rte_reorder.h | 2 ++
lib/librte_sched/rte_bitmap.h | 1 +
lib/librte_sched/rte_reciprocal.h | 2 ++
lib/librte_sched/rte_sched_common.h | 1 +
35 files changed, 84 insertions(+)
diff --git a/lib/librte_cfgfile/rte_cfgfile.h b/lib/librte_cfgfile/rte_cfgfile.h
index f649836..e81a5a2 100644
--- a/lib/librte_cfgfile/rte_cfgfile.h
+++ b/lib/librte_cfgfile/rte_cfgfile.h
@@ -34,6 +34,8 @@
#ifndef __INCLUDE_RTE_CFGFILE_H__
#define __INCLUDE_RTE_CFGFILE_H__
+#include <stddef.h>
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/lib/librte_cmdline/cmdline.h b/lib/librte_cmdline/cmdline.h
index 2578ca8..65d73b0 100644
--- a/lib/librte_cmdline/cmdline.h
+++ b/lib/librte_cmdline/cmdline.h
@@ -63,6 +63,7 @@
#include <termios.h>
#include <cmdline_rdline.h>
+#include <cmdline_parse.h>
/**
* @file
diff --git a/lib/librte_cmdline/cmdline_parse_portlist.h b/lib/librte_cmdline/cmdline_parse_portlist.h
index 73d70e0..058df3e 100644
--- a/lib/librte_cmdline/cmdline_parse_portlist.h
+++ b/lib/librte_cmdline/cmdline_parse_portlist.h
@@ -61,6 +61,7 @@
#ifndef _PARSE_PORTLIST_H_
#define _PARSE_PORTLIST_H_
+#include <stdint.h>
#include <cmdline_parse.h>
#ifdef __cplusplus
diff --git a/lib/librte_cmdline/cmdline_socket.h b/lib/librte_cmdline/cmdline_socket.h
index 8cc2dfb..aa6068e 100644
--- a/lib/librte_cmdline/cmdline_socket.h
+++ b/lib/librte_cmdline/cmdline_socket.h
@@ -61,6 +61,9 @@
#ifndef _CMDLINE_SOCKET_H_
#define _CMDLINE_SOCKET_H_
+#include <cmdline_parse.h>
+#include <cmdline.h>
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/lib/librte_eal/common/include/arch/arm/rte_byteorder.h b/lib/librte_eal/common/include/arch/arm/rte_byteorder.h
index 3f2dd1f..1b312b3 100644
--- a/lib/librte_eal/common/include/arch/arm/rte_byteorder.h
+++ b/lib/librte_eal/common/include/arch/arm/rte_byteorder.h
@@ -41,6 +41,8 @@
extern "C" {
#endif
+#include <stdint.h>
+#include <rte_common.h>
#include "generic/rte_byteorder.h"
/* fix missing __builtin_bswap16 for gcc older then 4.8 */
diff --git a/lib/librte_eal/common/include/arch/arm/rte_prefetch_32.h b/lib/librte_eal/common/include/arch/arm/rte_prefetch_32.h
index 5aeed22..43cde17 100644
--- a/lib/librte_eal/common/include/arch/arm/rte_prefetch_32.h
+++ b/lib/librte_eal/common/include/arch/arm/rte_prefetch_32.h
@@ -37,6 +37,7 @@
extern "C" {
#endif
+#include <rte_common.h>
#include "generic/rte_prefetch.h"
static inline void rte_prefetch0(const volatile void *p)
diff --git a/lib/librte_eal/common/include/arch/arm/rte_prefetch_64.h b/lib/librte_eal/common/include/arch/arm/rte_prefetch_64.h
index 3ed46a4..0d077ea 100644
--- a/lib/librte_eal/common/include/arch/arm/rte_prefetch_64.h
+++ b/lib/librte_eal/common/include/arch/arm/rte_prefetch_64.h
@@ -37,6 +37,7 @@
extern "C" {
#endif
+#include <rte_common.h>
#include "generic/rte_prefetch.h"
static inline void rte_prefetch0(const volatile void *p)
diff --git a/lib/librte_eal/common/include/arch/arm/rte_vect.h b/lib/librte_eal/common/include/arch/arm/rte_vect.h
index a33c054..b86c2cf 100644
--- a/lib/librte_eal/common/include/arch/arm/rte_vect.h
+++ b/lib/librte_eal/common/include/arch/arm/rte_vect.h
@@ -33,6 +33,7 @@
#ifndef _RTE_VECT_ARM_H_
#define _RTE_VECT_ARM_H_
+#include <stdint.h>
#include "arm_neon.h"
#ifdef __cplusplus
diff --git a/lib/librte_eal/common/include/arch/ppc_64/rte_atomic.h b/lib/librte_eal/common/include/arch/ppc_64/rte_atomic.h
index 924e894..fb4fccb 100644
--- a/lib/librte_eal/common/include/arch/ppc_64/rte_atomic.h
+++ b/lib/librte_eal/common/include/arch/ppc_64/rte_atomic.h
@@ -46,6 +46,7 @@
extern "C" {
#endif
+#include <stdint.h>
#include "generic/rte_atomic.h"
/**
diff --git a/lib/librte_eal/common/include/arch/ppc_64/rte_byteorder.h b/lib/librte_eal/common/include/arch/ppc_64/rte_byteorder.h
index 3c1734e..544de3c 100644
--- a/lib/librte_eal/common/include/arch/ppc_64/rte_byteorder.h
+++ b/lib/librte_eal/common/include/arch/ppc_64/rte_byteorder.h
@@ -42,6 +42,7 @@
extern "C" {
#endif
+#include <stdint.h>
#include "generic/rte_byteorder.h"
/*
diff --git a/lib/librte_eal/common/include/arch/ppc_64/rte_prefetch.h b/lib/librte_eal/common/include/arch/ppc_64/rte_prefetch.h
index 9a1995e..fd2e53b 100644
--- a/lib/librte_eal/common/include/arch/ppc_64/rte_prefetch.h
+++ b/lib/librte_eal/common/include/arch/ppc_64/rte_prefetch.h
@@ -37,6 +37,7 @@
extern "C" {
#endif
+#include <rte_common.h>
#include "generic/rte_prefetch.h"
static inline void rte_prefetch0(const volatile void *p)
diff --git a/lib/librte_eal/common/include/arch/x86/rte_atomic.h b/lib/librte_eal/common/include/arch/x86/rte_atomic.h
index b20056b..00b1cdf 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_atomic.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_atomic.h
@@ -38,6 +38,8 @@
extern "C" {
#endif
+#include <stdint.h>
+#include <rte_common.h>
#include <emmintrin.h>
#include "generic/rte_atomic.h"
diff --git a/lib/librte_eal/common/include/arch/x86/rte_atomic_32.h b/lib/librte_eal/common/include/arch/x86/rte_atomic_32.h
index 5ce01b3..2e04c75 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_atomic_32.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_atomic_32.h
@@ -37,10 +37,16 @@
* All rights reserved.
*/
+#ifndef _RTE_ATOMIC_X86_H_
+#error do not include this file directly, use <rte_atomic.h> instead
+#endif
+
#ifndef _RTE_ATOMIC_I686_H_
#define _RTE_ATOMIC_I686_H_
+#include <stdint.h>
#include <rte_common.h>
+#include <rte_atomic.h>
/*------------------------- 64 bit atomic operations -------------------------*/
diff --git a/lib/librte_eal/common/include/arch/x86/rte_atomic_64.h b/lib/librte_eal/common/include/arch/x86/rte_atomic_64.h
index 4de6600..1a53a76 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_atomic_64.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_atomic_64.h
@@ -37,9 +37,17 @@
* All rights reserved.
*/
+#ifndef _RTE_ATOMIC_X86_H_
+#error do not include this file directly, use <rte_atomic.h> instead
+#endif
+
#ifndef _RTE_ATOMIC_X86_64_H_
#define _RTE_ATOMIC_X86_64_H_
+#include <stdint.h>
+#include <rte_common.h>
+#include <rte_atomic.h>
+
/*------------------------- 64 bit atomic operations -------------------------*/
#ifndef RTE_FORCE_INTRINSICS
diff --git a/lib/librte_eal/common/include/arch/x86/rte_byteorder.h b/lib/librte_eal/common/include/arch/x86/rte_byteorder.h
index ffdb6ef..251f11b 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_byteorder.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_byteorder.h
@@ -38,6 +38,8 @@
extern "C" {
#endif
+#include <stdint.h>
+#include <rte_common.h>
#include "generic/rte_byteorder.h"
#ifndef RTE_BYTE_ORDER
diff --git a/lib/librte_eal/common/include/arch/x86/rte_byteorder_32.h b/lib/librte_eal/common/include/arch/x86/rte_byteorder_32.h
index 51c306f..14d6483 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_byteorder_32.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_byteorder_32.h
@@ -31,9 +31,16 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#ifndef _RTE_BYTEORDER_X86_H_
+#error do not include this file directly, use <rte_byteorder.h> instead
+#endif
+
#ifndef _RTE_BYTEORDER_I686_H_
#define _RTE_BYTEORDER_I686_H_
+#include <stdint.h>
+#include <rte_byteorder.h>
+
/*
* An architecture-optimized byte swap for a 64-bit value.
*
diff --git a/lib/librte_eal/common/include/arch/x86/rte_byteorder_64.h b/lib/librte_eal/common/include/arch/x86/rte_byteorder_64.h
index dda572b..516ac05 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_byteorder_64.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_byteorder_64.h
@@ -31,9 +31,16 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#ifndef _RTE_BYTEORDER_X86_H_
+#error do not include this file directly, use <rte_byteorder.h> instead
+#endif
+
#ifndef _RTE_BYTEORDER_X86_64_H_
#define _RTE_BYTEORDER_X86_64_H_
+#include <stdint.h>
+#include <rte_common.h>
+
/*
* An architecture-optimized byte swap for a 64-bit value.
*
diff --git a/lib/librte_eal/common/include/arch/x86/rte_prefetch.h b/lib/librte_eal/common/include/arch/x86/rte_prefetch.h
index 5dac47e..f464398 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_prefetch.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_prefetch.h
@@ -38,6 +38,7 @@
extern "C" {
#endif
+#include <rte_common.h>
#include "generic/rte_prefetch.h"
static inline void rte_prefetch0(const volatile void *p)
diff --git a/lib/librte_eal/common/include/arch/x86/rte_rtm.h b/lib/librte_eal/common/include/arch/x86/rte_rtm.h
index 0649f79..ab09995 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_rtm.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_rtm.h
@@ -20,6 +20,7 @@
/* Official RTM intrinsics interface matching gcc/icc, but works
on older gcc compatible compilers and binutils. */
+#include <rte_common.h>
#ifdef __cplusplus
extern "C" {
diff --git a/lib/librte_eal/common/include/arch/x86/rte_vect.h b/lib/librte_eal/common/include/arch/x86/rte_vect.h
index 2836f2c..77f2e25 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_vect.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_vect.h
@@ -40,6 +40,8 @@
* RTE SSE/AVX related header.
*/
+#include <stdint.h>
+
#if (defined(__ICC) || (__GNUC__ == 4 && __GNUC_MINOR__ < 4))
#ifdef __SSE__
diff --git a/lib/librte_eal/common/include/generic/rte_atomic.h b/lib/librte_eal/common/include/generic/rte_atomic.h
index bfb4fe4..43a704e 100644
--- a/lib/librte_eal/common/include/generic/rte_atomic.h
+++ b/lib/librte_eal/common/include/generic/rte_atomic.h
@@ -42,6 +42,7 @@
*/
#include <stdint.h>
+#include <rte_common.h>
#ifdef __DOXYGEN__
diff --git a/lib/librte_eal/common/include/generic/rte_byteorder.h b/lib/librte_eal/common/include/generic/rte_byteorder.h
index c46fdcf..e00bccb 100644
--- a/lib/librte_eal/common/include/generic/rte_byteorder.h
+++ b/lib/librte_eal/common/include/generic/rte_byteorder.h
@@ -50,6 +50,8 @@
#include <endian.h>
#endif
+#include <rte_common.h>
+
/*
* Compile-time endianness detection
*/
diff --git a/lib/librte_eal/common/include/rte_eal.h b/lib/librte_eal/common/include/rte_eal.h
index a71d6f5..98d20db 100644
--- a/lib/librte_eal/common/include/rte_eal.h
+++ b/lib/librte_eal/common/include/rte_eal.h
@@ -44,6 +44,7 @@
#include <sched.h>
#include <rte_per_lcore.h>
+#include <rte_config.h>
#ifdef __cplusplus
extern "C" {
diff --git a/lib/librte_eal/common/include/rte_memory.h b/lib/librte_eal/common/include/rte_memory.h
index 06b6596..2e69821 100644
--- a/lib/librte_eal/common/include/rte_memory.h
+++ b/lib/librte_eal/common/include/rte_memory.h
@@ -44,6 +44,8 @@
#include <stddef.h>
#include <stdio.h>
+#include <rte_config.h>
+
#ifdef RTE_EXEC_ENV_LINUXAPP
#include <exec-env/rte_dom0_common.h>
#endif
diff --git a/lib/librte_eal/common/include/rte_time.h b/lib/librte_eal/common/include/rte_time.h
index 4b13b9c..28c6274 100644
--- a/lib/librte_eal/common/include/rte_time.h
+++ b/lib/librte_eal/common/include/rte_time.h
@@ -31,6 +31,12 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#ifndef _RTE_TIME_H_
+#define _RTE_TIME_H_
+
+#include <stdint.h>
+#include <time.h>
+
#define NSEC_PER_SEC 1000000000L
/**
@@ -120,3 +126,5 @@ rte_ns_to_timespec(uint64_t nsec)
return ts;
}
+
+#endif /* _RTE_TIME_H_ */
diff --git a/lib/librte_eal/common/include/rte_version.h b/lib/librte_eal/common/include/rte_version.h
index 2c20cb3..844e40c 100644
--- a/lib/librte_eal/common/include/rte_version.h
+++ b/lib/librte_eal/common/include/rte_version.h
@@ -45,6 +45,7 @@ extern "C" {
#include <stdint.h>
#include <string.h>
+#include <stdio.h>
#include <rte_common.h>
/**
diff --git a/lib/librte_ether/rte_dev_info.h b/lib/librte_ether/rte_dev_info.h
index 574683d..aab6d1a 100644
--- a/lib/librte_ether/rte_dev_info.h
+++ b/lib/librte_ether/rte_dev_info.h
@@ -34,6 +34,8 @@
#ifndef _RTE_DEV_INFO_H_
#define _RTE_DEV_INFO_H_
+#include <stdint.h>
+
/*
* Placeholder for accessing device registers
*/
diff --git a/lib/librte_ether/rte_eth_ctrl.h b/lib/librte_ether/rte_eth_ctrl.h
index c3a2c9e..fe80eb0 100644
--- a/lib/librte_ether/rte_eth_ctrl.h
+++ b/lib/librte_ether/rte_eth_ctrl.h
@@ -34,6 +34,10 @@
#ifndef _RTE_ETH_CTRL_H_
#define _RTE_ETH_CTRL_H_
+#include <stdint.h>
+#include <rte_common.h>
+#include "rte_ether.h"
+
/**
* @file
*
diff --git a/lib/librte_lpm/rte_lpm_neon.h b/lib/librte_lpm/rte_lpm_neon.h
index 7c64315..7efd9a0 100644
--- a/lib/librte_lpm/rte_lpm_neon.h
+++ b/lib/librte_lpm/rte_lpm_neon.h
@@ -43,6 +43,7 @@
#include <rte_byteorder.h>
#include <rte_common.h>
#include <rte_vect.h>
+#include <rte_lpm.h>
#ifdef __cplusplus
extern "C" {
diff --git a/lib/librte_lpm/rte_lpm_sse.h b/lib/librte_lpm/rte_lpm_sse.h
index da83099..ef33c6a 100644
--- a/lib/librte_lpm/rte_lpm_sse.h
+++ b/lib/librte_lpm/rte_lpm_sse.h
@@ -38,6 +38,7 @@
#include <rte_byteorder.h>
#include <rte_common.h>
#include <rte_vect.h>
+#include <rte_lpm.h>
#ifdef __cplusplus
extern "C" {
diff --git a/lib/librte_pdump/rte_pdump.h b/lib/librte_pdump/rte_pdump.h
index b5f4e2f..924b804 100644
--- a/lib/librte_pdump/rte_pdump.h
+++ b/lib/librte_pdump/rte_pdump.h
@@ -41,6 +41,10 @@
* packet dump library to provide packet capturing support on dpdk.
*/
+#include <stdint.h>
+#include <rte_mempool.h>
+#include <rte_ring.h>
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/lib/librte_reorder/rte_reorder.h b/lib/librte_reorder/rte_reorder.h
index c7a2934..737e055 100644
--- a/lib/librte_reorder/rte_reorder.h
+++ b/lib/librte_reorder/rte_reorder.h
@@ -44,6 +44,8 @@
*
*/
+#include <rte_mbuf.h>
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/lib/librte_sched/rte_bitmap.h b/lib/librte_sched/rte_bitmap.h
index 1b5df02..010d752 100644
--- a/lib/librte_sched/rte_bitmap.h
+++ b/lib/librte_sched/rte_bitmap.h
@@ -64,6 +64,7 @@ extern "C" {
*
***/
+#include <string.h>
#include <rte_common.h>
#include <rte_debug.h>
#include <rte_memory.h>
diff --git a/lib/librte_sched/rte_reciprocal.h b/lib/librte_sched/rte_reciprocal.h
index abd1525..5e21f09 100644
--- a/lib/librte_sched/rte_reciprocal.h
+++ b/lib/librte_sched/rte_reciprocal.h
@@ -22,6 +22,8 @@
#ifndef _RTE_RECIPROCAL_H_
#define _RTE_RECIPROCAL_H_
+#include <stdint.h>
+
struct rte_reciprocal {
uint32_t m;
uint8_t sh1, sh2;
diff --git a/lib/librte_sched/rte_sched_common.h b/lib/librte_sched/rte_sched_common.h
index 8920ade..aed144b 100644
--- a/lib/librte_sched/rte_sched_common.h
+++ b/lib/librte_sched/rte_sched_common.h
@@ -38,6 +38,7 @@
extern "C" {
#endif
+#include <stdint.h>
#include <sys/types.h>
#define __rte_aligned_16 __attribute__((__aligned__(16)))
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* [dpdk-dev] [PATCH v5 07/10] lib: work around forward reference to enum types
2016-09-08 12:25 ` [dpdk-dev] [PATCH v5 " Adrien Mazarguil
` (5 preceding siblings ...)
2016-09-08 12:25 ` [dpdk-dev] [PATCH v5 06/10] lib: add missing include dependencies Adrien Mazarguil
@ 2016-09-08 12:25 ` Adrien Mazarguil
2016-09-08 12:25 ` [dpdk-dev] [PATCH v5 08/10] lib: remove named variadic macros in exported headers Adrien Mazarguil
` (3 subsequent siblings)
10 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-09-08 12:25 UTC (permalink / raw)
To: dev
Exported header files used by applications should allow the strictest
compiler flags. Language extensions used in many places must be explicitly
marked or removed to avoid warnings and compilation failures.
This commit prevents the following errors:
error: ISO C forbids forward references to `enum' types
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
lib/librte_eal/common/include/generic/rte_cpuflags.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/librte_eal/common/include/generic/rte_cpuflags.h b/lib/librte_eal/common/include/generic/rte_cpuflags.h
index c1da357..71321f3 100644
--- a/lib/librte_eal/common/include/generic/rte_cpuflags.h
+++ b/lib/librte_eal/common/include/generic/rte_cpuflags.h
@@ -44,6 +44,7 @@
/**
* Enumeration of all CPU features supported
*/
+__extension__
enum rte_cpu_flag_t;
/**
@@ -55,6 +56,7 @@ enum rte_cpu_flag_t;
* flag name
* NULL if flag ID is invalid
*/
+__extension__
const char *
rte_cpu_get_flag_name(enum rte_cpu_flag_t feature);
@@ -68,6 +70,7 @@ rte_cpu_get_flag_name(enum rte_cpu_flag_t feature);
* 0 if flag is not available
* -ENOENT if flag is invalid
*/
+__extension__
int
rte_cpu_get_flag_enabled(enum rte_cpu_flag_t feature);
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* [dpdk-dev] [PATCH v5 08/10] lib: remove named variadic macros in exported headers
2016-09-08 12:25 ` [dpdk-dev] [PATCH v5 " Adrien Mazarguil
` (6 preceding siblings ...)
2016-09-08 12:25 ` [dpdk-dev] [PATCH v5 07/10] lib: work around forward reference to enum types Adrien Mazarguil
@ 2016-09-08 12:25 ` Adrien Mazarguil
2016-09-08 12:25 ` [dpdk-dev] [PATCH v5 09/10] lib: hide static functions never defined Adrien Mazarguil
` (2 subsequent siblings)
10 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-09-08 12:25 UTC (permalink / raw)
To: dev
Exported header files used by applications should allow the strictest
compiler flags. Language extensions used in many places must be explicitly
marked or removed to avoid warnings and compilation failures.
Since there is no way to force named variadic macros as extensions, use a
a standard __VA_ARGS__ with an extra dummy argument to format strings.
This commit prevents the following errors:
error: ISO C does not permit named variadic macros
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
lib/librte_cryptodev/rte_cryptodev.h | 32 ++++++++++++++-----------
lib/librte_cryptodev/rte_cryptodev_pmd.h | 2 +-
lib/librte_eal/common/include/rte_common.h | 9 +++++++
3 files changed, 28 insertions(+), 15 deletions(-)
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index cf28541..d047ba8 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -77,26 +77,30 @@ extern const char **rte_cyptodev_names;
/* Logging Macros */
-#define CDEV_LOG_ERR(fmt, args...) \
- RTE_LOG(ERR, CRYPTODEV, "%s() line %u: " fmt "\n", \
- __func__, __LINE__, ## args)
+#define CDEV_LOG_ERR(...) \
+ RTE_LOG(ERR, CRYPTODEV, \
+ RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
+ __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__,)))
-#define CDEV_PMD_LOG_ERR(dev, fmt, args...) \
- RTE_LOG(ERR, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \
- dev, __func__, __LINE__, ## args)
+#define CDEV_PMD_LOG_ERR(dev, ...) \
+ RTE_LOG(ERR, CRYPTODEV, \
+ RTE_FMT("[%s] %s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
+ dev, __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__,)))
#ifdef RTE_LIBRTE_CRYPTODEV_DEBUG
-#define CDEV_LOG_DEBUG(fmt, args...) \
- RTE_LOG(DEBUG, CRYPTODEV, "%s() line %u: " fmt "\n", \
- __func__, __LINE__, ## args) \
+#define CDEV_LOG_DEBUG(...) \
+ RTE_LOG(DEBUG, CRYPTODEV, \
+ RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
+ __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__,)))
-#define CDEV_PMD_TRACE(fmt, args...) \
- RTE_LOG(DEBUG, CRYPTODEV, "[%s] %s: " fmt "\n", \
- dev, __func__, ## args)
+#define CDEV_PMD_TRACE(...) \
+ RTE_LOG(DEBUG, CRYPTODEV, \
+ RTE_FMT("[%s] %s: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
+ dev, __func__, RTE_FMT_TAIL(__VA_ARGS__,)))
#else
-#define CDEV_LOG_DEBUG(fmt, args...)
-#define CDEV_PMD_TRACE(fmt, args...)
+#define CDEV_LOG_DEBUG(...) (void)0
+#define CDEV_PMD_TRACE(...) (void)0
#endif
/**
diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h b/lib/librte_cryptodev/rte_cryptodev_pmd.h
index a929ef1..cd46674 100644
--- a/lib/librte_cryptodev/rte_cryptodev_pmd.h
+++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h
@@ -62,7 +62,7 @@ extern "C" {
#define RTE_PMD_DEBUG_TRACE(...) \
rte_pmd_debug_trace(__func__, __VA_ARGS__)
#else
-#define RTE_PMD_DEBUG_TRACE(fmt, args...)
+#define RTE_PMD_DEBUG_TRACE(...)
#endif
struct rte_cryptodev_session {
diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h
index 98ecc1c..db5ac91 100644
--- a/lib/librte_eal/common/include/rte_common.h
+++ b/lib/librte_eal/common/include/rte_common.h
@@ -335,6 +335,15 @@ rte_bsf32(uint32_t v)
/** Take a macro value and get a string version of it */
#define RTE_STR(x) _RTE_STR(x)
+/**
+ * ISO C helpers to modify format strings using variadic macros.
+ * This is a replacement for the ", ## __VA_ARGS__" GNU extension.
+ * An empty %s argument is appended to avoid a dangling comma.
+ */
+#define RTE_FMT(fmt, ...) fmt "%.0s", __VA_ARGS__ ""
+#define RTE_FMT_HEAD(fmt, ...) fmt
+#define RTE_FMT_TAIL(fmt, ...) __VA_ARGS__
+
/** Mask value of type "tp" for the first "ln" bit set. */
#define RTE_LEN2MASK(ln, tp) \
((tp)((uint64_t)-1 >> (sizeof(uint64_t) * CHAR_BIT - (ln))))
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* [dpdk-dev] [PATCH v5 09/10] lib: hide static functions never defined
2016-09-08 12:25 ` [dpdk-dev] [PATCH v5 " Adrien Mazarguil
` (7 preceding siblings ...)
2016-09-08 12:25 ` [dpdk-dev] [PATCH v5 08/10] lib: remove named variadic macros in exported headers Adrien Mazarguil
@ 2016-09-08 12:25 ` Adrien Mazarguil
2016-09-08 12:25 ` [dpdk-dev] [PATCH v5 10/10] scripts: check compilation of exported header files Adrien Mazarguil
2016-09-13 13:38 ` [dpdk-dev] [PATCH v5 00/10] Fix build errors related to exported headers Thomas Monjalon
10 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-09-08 12:25 UTC (permalink / raw)
To: dev
Arch-specific functions not defined for all architectures (missing on x86
in this case) and not used anywhere should not expose a prototype.
This commit prevents the following error:
error: `rte_mov48' declared `static' but never defined
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
lib/librte_eal/common/include/generic/rte_memcpy.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lib/librte_eal/common/include/generic/rte_memcpy.h b/lib/librte_eal/common/include/generic/rte_memcpy.h
index afb0afe..4e9d879 100644
--- a/lib/librte_eal/common/include/generic/rte_memcpy.h
+++ b/lib/librte_eal/common/include/generic/rte_memcpy.h
@@ -64,6 +64,8 @@ rte_mov16(uint8_t *dst, const uint8_t *src);
static inline void
rte_mov32(uint8_t *dst, const uint8_t *src);
+#ifdef __DOXYGEN__
+
/**
* Copy 48 bytes from one location to another using optimised
* instructions. The locations should not overlap.
@@ -76,6 +78,8 @@ rte_mov32(uint8_t *dst, const uint8_t *src);
static inline void
rte_mov48(uint8_t *dst, const uint8_t *src);
+#endif /* __DOXYGEN__ */
+
/**
* Copy 64 bytes from one location to another using optimised
* instructions. The locations should not overlap.
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* [dpdk-dev] [PATCH v5 10/10] scripts: check compilation of exported header files
2016-09-08 12:25 ` [dpdk-dev] [PATCH v5 " Adrien Mazarguil
` (8 preceding siblings ...)
2016-09-08 12:25 ` [dpdk-dev] [PATCH v5 09/10] lib: hide static functions never defined Adrien Mazarguil
@ 2016-09-08 12:25 ` Adrien Mazarguil
2016-09-13 13:38 ` [dpdk-dev] [PATCH v5 00/10] Fix build errors related to exported headers Thomas Monjalon
10 siblings, 0 replies; 79+ messages in thread
From: Adrien Mazarguil @ 2016-09-08 12:25 UTC (permalink / raw)
To: dev
This script checks that header files in a given directory do not miss
dependencies when included on their own, do not conflict and accept being
compiled with the strictest possible flags.
It is too slow at the moment to be automatically executed by test-build.sh
and should be run voluntarily (like check-git-log.sh and friends) after
making changes to exported header files.
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
MAINTAINERS | 1 +
scripts/check-includes.sh | 286 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 287 insertions(+)
diff --git a/MAINTAINERS b/MAINTAINERS
index bc9aa02..0e78941 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -26,6 +26,7 @@ T: git://dpdk.org/dpdk
F: MAINTAINERS
F: scripts/check-maintainers.sh
F: scripts/check-git-log.sh
+F: scripts/check-includes.sh
F: scripts/checkpatches.sh
F: scripts/load-devel-config
F: scripts/test-build.sh
diff --git a/scripts/check-includes.sh b/scripts/check-includes.sh
new file mode 100755
index 0000000..d65adc6
--- /dev/null
+++ b/scripts/check-includes.sh
@@ -0,0 +1,286 @@
+#!/bin/sh -e
+#
+# BSD LICENSE
+#
+# Copyright 2016 6WIND S.A.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of 6WIND S.A. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# This script checks that header files in a given directory do not miss
+# dependencies when included on their own, do not conflict and accept being
+# compiled with the strictest possible flags.
+#
+# Files are looked up in the directory provided as the first argument,
+# otherwise build/include by default.
+#
+# Recognized environment variables:
+#
+# VERBOSE=1 is the same as -v.
+#
+# QUIET=1 is the same as -q.
+#
+# SUMMARY=1 is the same as -s.
+#
+# CC, CPPFLAGS, CFLAGS, EXTRA_CPPFLAGS, EXTRA_CFLAGS, CXX, CXXFLAGS and
+# EXTRA_CXXFLAGS are taken into account.
+#
+# PEDANTIC_CFLAGS, PEDANTIC_CXXFLAGS and PEDANTIC_CPPFLAGS provide strict
+# C/C++ compilation flags.
+#
+# IGNORE contains a list of shell patterns matching files (relative to the
+# include directory) to avoid. It is set by default to known DPDK headers
+# which must not be included on their own.
+#
+# IGNORE_CXX provides additional files for C++.
+
+while getopts hqvs arg; do
+ case $arg in
+ h)
+ cat <<EOF
+usage: $0 [-h] [-q] [-v] [-s] [DIR]
+
+This script checks that header files in a given directory do not miss
+dependencies when included on their own, do not conflict and accept being
+compiled with the strictest possible flags.
+
+ -h display this help and exit
+ -q quiet mode, disable normal output
+ -v show command lines being executed
+ -s show summary
+
+With no DIR, default to build/include.
+
+Any failed header check yields a nonzero exit status.
+EOF
+ exit
+ ;;
+ q)
+ QUIET=1
+ ;;
+ v)
+ VERBOSE=1
+ ;;
+ s)
+ SUMMARY=1
+ ;;
+ *)
+ exit 1
+ ;;
+ esac
+done
+
+shift $(($OPTIND - 1))
+
+include_dir=${1:-build/include}
+
+: ${PEDANTIC_CFLAGS=-std=c99 -pedantic -Wall -Wextra -Werror}
+: ${PEDANTIC_CXXFLAGS=}
+: ${PEDANTIC_CPPFLAGS=-D_XOPEN_SOURCE=600}
+: ${CC:=cc}
+: ${CXX:=c++}
+: ${IGNORE= \
+ 'rte_atomic_32.h' \
+ 'rte_atomic_64.h' \
+ 'rte_byteorder_32.h' \
+ 'rte_byteorder_64.h' \
+ 'generic/*' \
+ 'exec-env/*' \
+}
+: ${IGNORE_CXX= \
+ 'rte_eth_vhost.h' \
+ 'rte_virtio_net.h' \
+}
+
+temp_cc=/tmp/${0##*/}.$$.c
+pass_cc=
+failures_cc=0
+
+temp_cxx=/tmp/${0##*/}.$$.cc
+pass_cxx=
+failures_cxx=0
+
+# Process output parameters.
+
+[ "$QUIET" = 1 ] &&
+exec 1> /dev/null
+
+[ "$VERBOSE" = 1 ] &&
+output ()
+{
+ local CCV
+ local CXXV
+
+ shift
+ CCV=$CC
+ CXXV=$CXX
+ CC="echo $CC" CXX="echo $CXX" "$@"
+ CC=$CCV
+ CXX=$CXXV
+
+ "$@"
+} ||
+output ()
+{
+
+ printf ' %s\n' "$1"
+ shift
+ "$@"
+}
+
+trap 'rm -f "$temp_cc" "$temp_cxx"' EXIT
+
+compile_cc ()
+{
+ ${CC} -I"$include_dir" \
+ ${PEDANTIC_CPPFLAGS} ${CPPFLAGS} ${EXTRA_CPPFLAGS} \
+ ${PEDANTIC_CFLAGS} ${CFLAGS} ${EXTRA_CFLAGS} \
+ -c -o /dev/null "${temp_cc}"
+}
+
+compile_cxx ()
+{
+ ${CXX} -I"$include_dir" \
+ ${PEDANTIC_CPPFLAGS} ${CPPFLAGS} ${EXTRA_CPPFLAGS} \
+ ${PEDANTIC_CXXFLAGS} ${CXXFLAGS} ${EXTRA_CXXFLAGS} \
+ -c -o /dev/null "${temp_cxx}"
+}
+
+ignore ()
+{
+ file="$1"
+ shift
+ while [ $# -ne 0 ]; do
+ case "$file" in
+ $1)
+ return 0
+ ;;
+ esac
+ shift
+ done
+ return 1
+}
+
+# Check C/C++ compilation for each header file.
+
+while read -r path
+do
+ file=${path#$include_dir}
+ file=${file##/}
+ if ignore "$file" $IGNORE; then
+ output "SKIP $file" :
+ continue
+ fi
+ if printf "\
+#include <%s>
+
+int main(void)
+{
+ return 0;
+}
+" "$file" > "$temp_cc" &&
+ output "CC $file" compile_cc
+ then
+ pass_cc="$pass_cc $file"
+ else
+ failures_cc=$(($failures_cc + 1))
+ fi
+ if ignore "$file" $IGNORE_CXX; then
+ output "SKIP CXX $file" :
+ continue
+ fi
+ if printf "\
+#include <%s>
+
+int main()
+{
+}
+" "$file" > "$temp_cxx" &&
+ output "CXX $file" compile_cxx
+ then
+ pass_cxx="$pass_cxx $file"
+ else
+ failures_cxx=$(($failures_cxx + 1))
+ fi
+done <<EOF
+$(find "$include_dir" -name '*.h')
+EOF
+
+# Check C compilation with all includes.
+
+: > "$temp_cc" &&
+for file in $pass_cc; do
+ printf "\
+#include <%s>
+" "$file" >> $temp_cc
+done
+if printf "\
+int main(void)
+{
+ return 0;
+}
+" >> "$temp_cc" &&
+ output "CC (all includes that did not fail)" compile_cc
+then
+ :
+else
+ failures_cc=$(($failures_cc + 1))
+fi
+
+# Check C++ compilation with all includes.
+
+: > "$temp_cxx" &&
+for file in $pass_cxx; do
+ printf "\
+#include <%s>
+" "$file" >> $temp_cxx
+done
+if printf "\
+int main()
+{
+}
+" >> "$temp_cxx" &&
+ output "CXX (all includes that did not fail)" compile_cxx
+then
+ :
+else
+ failures_cxx=$(($failures_cxx + 1))
+fi
+
+# Report results.
+
+if [ "$SUMMARY" = 1 ]; then
+ printf "\
+Summary:
+ %u failure(s) for C using '%s'.
+ %u failure(s) for C++ using '%s'.
+" $failures_cc "$CC" $failures_cxx "$CXX" 1>&2
+fi
+
+# Exit with nonzero status if there are failures.
+
+[ $failures_cc -eq 0 ] &&
+[ $failures_cxx -eq 0 ]
--
2.1.4
^ permalink raw reply [flat|nested] 79+ messages in thread
* Re: [dpdk-dev] [PATCH v5 00/10] Fix build errors related to exported headers
2016-09-08 12:25 ` [dpdk-dev] [PATCH v5 " Adrien Mazarguil
` (9 preceding siblings ...)
2016-09-08 12:25 ` [dpdk-dev] [PATCH v5 10/10] scripts: check compilation of exported header files Adrien Mazarguil
@ 2016-09-13 13:38 ` Thomas Monjalon
10 siblings, 0 replies; 79+ messages in thread
From: Thomas Monjalon @ 2016-09-13 13:38 UTC (permalink / raw)
To: Adrien Mazarguil; +Cc: dev
2016-09-08 14:25, Adrien Mazarguil:
> DPDK uses GNU C language extensions in most of its code base. This is fine
> for internal source files whose compilation flags are controlled by DPDK,
> however user applications that use exported "public" headers may experience
> compilation failures when enabling strict error/standard checks (-std and
> -pedantic for instance).
>
> Exported headers are installed system-wide and must be as clean as possible
> so applications do not have to resort to workarounds.
>
> This patchset affects exported headers only, compilation problems are
> addressed as follows:
>
> - Adding the __extension__ keyword to nonstandard constructs (same method
> as existing libraries when there is no other choice).
> - Adding the __extension__ keyword to C11 constructs to remain compatible
> with pure C99.
> - Adding missing includes so exported files can be included out of order
> and on their own.
> - Fixing GNU printf-like variadic macros as there is no magic keyword for
> these.
Applied, thanks
The script is a bit slow so it is not integrated in test-build.sh yet.
But it should allow us to take care of our exported headers in the future.
Adrien, you'll be welcome to remind us how to keep things standard :)
^ permalink raw reply [flat|nested] 79+ messages in thread