From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f48.google.com (mail-wm0-f48.google.com [74.125.82.48]) by dpdk.org (Postfix) with ESMTP id E6420568B for ; Tue, 5 Jul 2016 12:45:19 +0200 (CEST) Received: by mail-wm0-f48.google.com with SMTP id r201so146821549wme.1 for ; Tue, 05 Jul 2016 03:45:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=5+e/+CDDsz5iHQ+2QEpmejLMO/QGf20uhSE5onRLqsc=; b=kNqdxxMZz/43Y5m8sbx43XlrJORVrTF5zDSJdc//uu6uKpb3msfqbLuOrKV6D+Wgg+ sOX496JkP771DuB4IsNjzmUAFatP6BPFsnqK+8neRBcZ1ZGfDY25wv9crq+8NXINeuHy pF7JUXZ0tfQDdemG32UKhYFkRp2zDLn0ETV75tKIn4xx0J+Cp2OMc0LvyFns5DJI9wsB NCtI4HNgrkybJJSp3D3QWymKCo20AjFBndFBLDJolEtPF/O4DOldVoSq9W81Kod7Y8g0 xathv59rkXQsrUc3BQJHj7YGC5Ayjwj/Gd3oadUZ4UoYYak8gJmvGzpD7Z1S6/w6/hBs BiQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=5+e/+CDDsz5iHQ+2QEpmejLMO/QGf20uhSE5onRLqsc=; b=ahrb0Kx/vR6xK8VrImAYZKdwGBjd0uVNGZ6+ETwTFDfohxf8tLaZXtZ9Yc9W6klmEg dlSkYIxzavEezkq6YK5FHDwlku5bTHNNADlzmqkkqnR1LbU+w+qDGRHVdUSSl4zPxx+r TjfOYF7/UJT52qxcnO/+5FnxeyQKNTPRT0sSelgvDHCl6OpUiqQtnMaGp9drDDF78cB0 UPLpfOvzAPJXEgW54FwM2YZyq5QIRh6Xww25VjHAxWfdt+eHZwkSFWeBxuN4vc3D5/1P iAatCATk7vF7i8fDBHhZh6OQJMAY5OiBFeS3CzAXu03HtfvU0ywTJwBTLaqlDvOSjdQ9 zDpA== X-Gm-Message-State: ALyK8tLf/gCd9w7dnXbAPp+xd1wPiNSijaBDpbXfypCzmIlJ4fF/bIR1s2JK6SbYl1ne4lQb X-Received: by 10.194.8.38 with SMTP id o6mr14567667wja.13.1467715519298; Tue, 05 Jul 2016 03:45:19 -0700 (PDT) Received: from 6wind.com (guy78-3-82-239-227-177.fbx.proxad.net. [82.239.227.177]) by smtp.gmail.com with ESMTPSA id f196sm2326610wmg.15.2016.07.05.03.45.17 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Tue, 05 Jul 2016 03:45:18 -0700 (PDT) From: Adrien Mazarguil To: dev@dpdk.org Date: Tue, 5 Jul 2016 12:44:52 +0200 Message-Id: <49ea2103b93c079df1266ceefdfcfbb6a6fb7066.1467715254.git.adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: <1459865290-10248-1-git-send-email-adrien.mazarguil@6wind.com> Subject: [dpdk-dev] [PATCH v2 06/11] lib: work around unnamed structs/unions X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Jul 2016 10:45:20 -0000 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 --- 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 #include #include +#include #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 #include #include +#include /** 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 #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 #include #include +#include #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 +#include /** * 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 + /*------------------------- 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 #endif +#include 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 + /** * @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 #include +#include #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 +#define RTE_STD_C11 +#else +#include #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 #include #include +#include #ifdef __SSE3__ #include @@ -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 #include #include +#include #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 #include +#include 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 #include #include +#include #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