From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id AE8335698 for ; Fri, 27 Feb 2015 17:25:12 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP; 27 Feb 2015 08:19:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,660,1418112000"; d="scan'208";a="658154347" Received: from irsmsx103.ger.corp.intel.com ([163.33.3.157]) by orsmga001.jf.intel.com with ESMTP; 27 Feb 2015 08:24:24 -0800 Received: from irsmsx105.ger.corp.intel.com ([169.254.7.117]) by IRSMSX103.ger.corp.intel.com ([169.254.3.247]) with mapi id 14.03.0195.001; Fri, 27 Feb 2015 16:24:23 +0000 From: "Ananyev, Konstantin" To: Simon Kagstrom , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] headers: typeof -> __typeof__ to unbreak C++11 code Thread-Index: AQHQUP8dWp2hI9i9MUiaptxSRhE5oJ0ErTqg Date: Fri, 27 Feb 2015 16:24:22 +0000 Message-ID: <2601191342CEEE43887BDE71AB977258213F3012@irsmsx105.ger.corp.intel.com> References: <20150225142851.55406347@miho> In-Reply-To: <20150225142851.55406347@miho> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.180] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] headers: typeof -> __typeof__ to unbreak C++11 code 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: Fri, 27 Feb 2015 16:25:13 -0000 > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Simon Kagstrom > Sent: Wednesday, February 25, 2015 1:29 PM > To: dev@dpdk.org > Subject: [dpdk-dev] [PATCH] headers: typeof -> __typeof__ to unbreak C++1= 1 code >=20 > When compiling C++11-code or above (--std=3Dc++11), the build fails with > lots of >=20 > rte_eth_ctrl.h:517:3: note: in expansion of macro RTE_ALIGN > (RTE_ALIGN(RTE_ETH_FLOW_MAX, UINT32_BIT)/UINT32_BIT) > ^ >=20 > When reading the GCC info pages, I get the feeling that __typeof__ is > a better choice, and that indeed works when including the headers in > C++ files (--std=3Dc++11). >=20 > There are some typeof()s left in C files, the patch only touches the > public API. >=20 > Signed-off-by: Simon Kagstrom > --- > lib/librte_acl/acl_vect.h | 8 ++++---- > lib/librte_eal/common/include/rte_common.h | 17 +++++++++-------- > lib/librte_eal/common/include/rte_pci.h | 2 +- > 3 files changed, 14 insertions(+), 13 deletions(-) >=20 > diff --git a/lib/librte_acl/acl_vect.h b/lib/librte_acl/acl_vect.h > index 6cc1999..de47071 100644 > --- a/lib/librte_acl/acl_vect.h > +++ b/lib/librte_acl/acl_vect.h > @@ -52,8 +52,8 @@ extern "C" { > * hi - contains high 32 bits of given N transitions. > */ > #define ACL_TR_HILO(P, TC, tr0, tr1, lo, hi) do {= \ > - lo =3D (typeof(lo))_##P##_shuffle_ps((TC)(tr0), (TC)(tr1), 0x88); \ > - hi =3D (typeof(hi))_##P##_shuffle_ps((TC)(tr0), (TC)(tr1), 0xdd); \ > + lo =3D (__typeof__(lo))_##P##_shuffle_ps((TC)(tr0), (TC)(tr1), 0x88); = \ > + hi =3D (__typeof__(hi))_##P##_shuffle_ps((TC)(tr0), (TC)(tr1), 0xdd); = \ > } while (0) >=20 >=20 > @@ -74,8 +74,8 @@ extern "C" { > addr, index_mask, next_input, shuffle_input, \ > ones_16, range_base, tr_lo, tr_hi) do { \ > \ > - typeof(addr) in, node_type, r, t; \ > - typeof(addr) dfa_msk, dfa_ofs, quad_ofs; \ > + __typeof__(addr) in, node_type, r, t; \ > + __typeof__(addr) dfa_msk, dfa_ofs, quad_ofs; \ > \ > t =3D _##P##_xor_si##S(index_mask, index_mask); \ > in =3D _##P##_shuffle_epi8(next_input, shuffle_input); \ > diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/= common/include/rte_common.h > index 8ac940c..40c2603 100644 > --- a/lib/librte_eal/common/include/rte_common.h > +++ b/lib/librte_eal/common/include/rte_common.h > @@ -43,6 +43,7 @@ >=20 > #ifdef __cplusplus > extern "C" { > + > #endif >=20 > #include > @@ -112,7 +113,7 @@ rte_align_floor_int(uintptr_t ptr, uintptr_t align) > * must be a power-of-two value. > */ > #define RTE_PTR_ALIGN_FLOOR(ptr, align) \ > - (typeof(ptr))rte_align_floor_int((uintptr_t)ptr, align) > + (__typeof__(ptr))rte_align_floor_int((uintptr_t)ptr, align) >=20 > /** > * Macro to align a value to a given power-of-two. The resultant value > @@ -121,7 +122,7 @@ rte_align_floor_int(uintptr_t ptr, uintptr_t align) > * power-of-two value. > */ > #define RTE_ALIGN_FLOOR(val, align) \ > - (typeof(val))((val) & (~((typeof(val))((align) - 1)))) > + (__typeof__(val))((val) & (~((__typeof__(val))((align) - 1)))) >=20 > /** > * Macro to align a pointer to a given power-of-two. The resultant > @@ -130,7 +131,7 @@ rte_align_floor_int(uintptr_t ptr, uintptr_t align) > * must be a power-of-two value. > */ > #define RTE_PTR_ALIGN_CEIL(ptr, align) \ > - RTE_PTR_ALIGN_FLOOR((typeof(ptr))RTE_PTR_ADD(ptr, (align) - 1), align) > + RTE_PTR_ALIGN_FLOOR((__typeof__(ptr))RTE_PTR_ADD(ptr, (align) - 1), ali= gn) >=20 > /** > * Macro to align a value to a given power-of-two. The resultant value > @@ -139,7 +140,7 @@ rte_align_floor_int(uintptr_t ptr, uintptr_t align) > * value. > */ > #define RTE_ALIGN_CEIL(val, align) \ > - RTE_ALIGN_FLOOR(((val) + ((typeof(val)) (align) - 1)), align) > + RTE_ALIGN_FLOOR(((val) + ((__typeof__(val)) (align) - 1)), align) >=20 > /** > * Macro to align a pointer to a given power-of-two. The resultant > @@ -257,8 +258,8 @@ rte_align64pow2(uint64_t v) > * Macro to return the minimum of two numbers > */ > #define RTE_MIN(a, b) ({ \ > - typeof (a) _a =3D (a); \ > - typeof (b) _b =3D (b); \ > + __typeof__ (a) _a =3D (a); \ > + __typeof__ (b) _b =3D (b); \ > _a < _b ? _a : _b; \ > }) >=20 > @@ -266,8 +267,8 @@ rte_align64pow2(uint64_t v) > * Macro to return the maximum of two numbers > */ > #define RTE_MAX(a, b) ({ \ > - typeof (a) _a =3D (a); \ > - typeof (b) _b =3D (b); \ > + __typeof__ (a) _a =3D (a); \ > + __typeof__ (b) _b =3D (b); \ > _a > _b ? _a : _b; \ > }) >=20 > diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/com= mon/include/rte_pci.h > index 3df07e8..bc065d4 100644 > --- a/lib/librte_eal/common/include/rte_pci.h > +++ b/lib/librte_eal/common/include/rte_pci.h > @@ -212,7 +212,7 @@ do { = \ > val =3D strtoul((in), &end, 16); \ > if (errno !=3D 0 || end[0] !=3D (dlm) || val > (lim)) \ > return (-EINVAL); \ > - (fd) =3D (typeof (fd))val; \ > + (fd) =3D (__typeof__ (fd))val; \ > (in) =3D end + 1; \ > } while(0) >=20 > -- Actually, I wonder wouldn't something like the one below be sufficient? Konstantin diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/co= mmon/ index 8ac940c..1867692 100644 --- a/lib/librte_eal/common/include/rte_common.h +++ b/lib/librte_eal/common/include/rte_common.h @@ -51,6 +51,15 @@ extern "C" { #include #include +#ifndef typeof +#define typeof __typeof__ +#endif + +#ifndef asm +#define asm __asm__ +#endif + + /*********** Macros to eliminate unused variable warnings ********/ /**