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 42CBC5ABA for ; Mon, 9 Mar 2015 07:14:47 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP; 08 Mar 2015 23:12:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,365,1422950400"; d="scan'208";a="464462292" Received: from pgsmsx106.gar.corp.intel.com ([10.221.44.98]) by FMSMGA003.fm.intel.com with ESMTP; 08 Mar 2015 23:08:08 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by PGSMSX106.gar.corp.intel.com (10.221.44.98) with Microsoft SMTP Server (TLS) id 14.3.195.1; Mon, 9 Mar 2015 14:14:37 +0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.192]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.234]) with mapi id 14.03.0195.001; Mon, 9 Mar 2015 14:14:36 +0800 From: "Qiu, Michael" To: "Wang, Zhihong" , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] A fix to work around strict-aliasing rules breaking Thread-Index: AQHQVMfleUkCb5bpL0e1Da5GxIVHqQ== Date: Mon, 9 Mar 2015 06:14:36 +0000 Message-ID: <533710CFB86FA344BFBF2D6802E60286CF0632@SHSMSX101.ccr.corp.intel.com> References: <1425287030-18225-1-git-send-email-zhihong.wang@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] A fix to work around strict-aliasing rules breaking 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: Mon, 09 Mar 2015 06:14:48 -0000 On 3/2/2015 5:04 PM, zhihong.wang@intel.com wrote:=0A= > Fixed strict-aliasing rules breaking errors for some GCC version.=0A= >=0A= > Signed-off-by: Zhihong Wang =0A= > ---=0A= =0A= As this should be a quick fix, this workaround is workable.=0A= Acked-by: Michael Qiu =0A= =0A= > .../common/include/arch/x86/rte_memcpy.h | 44 ++++++++++++----= ------=0A= > 1 file changed, 24 insertions(+), 20 deletions(-)=0A= >=0A= > diff --git a/lib/librte_eal/common/include/arch/x86/rte_memcpy.h b/lib/li= brte_eal/common/include/arch/x86/rte_memcpy.h=0A= > index 69a5c6f..f412099 100644=0A= > --- a/lib/librte_eal/common/include/arch/x86/rte_memcpy.h=0A= > +++ b/lib/librte_eal/common/include/arch/x86/rte_memcpy.h=0A= > @@ -195,6 +195,8 @@ rte_mov256blocks(uint8_t *dst, const uint8_t *src, si= ze_t n)=0A= > static inline void *=0A= > rte_memcpy(void *dst, const void *src, size_t n)=0A= > {=0A= > + uintptr_t dstu =3D (uintptr_t)dst;=0A= > + uintptr_t srcu =3D (uintptr_t)src;=0A= > void *ret =3D dst;=0A= > int dstofss;=0A= > int bits;=0A= > @@ -204,22 +206,22 @@ rte_memcpy(void *dst, const void *src, size_t n)=0A= > */=0A= > if (n < 16) {=0A= > if (n & 0x01) {=0A= > - *(uint8_t *)dst =3D *(const uint8_t *)src;=0A= > - src =3D (const uint8_t *)src + 1;=0A= > - dst =3D (uint8_t *)dst + 1;=0A= > + *(uint8_t *)dstu =3D *(const uint8_t *)srcu;=0A= > + srcu =3D (uintptr_t)((const uint8_t *)srcu + 1);=0A= > + dstu =3D (uintptr_t)((uint8_t *)dstu + 1);=0A= > }=0A= > if (n & 0x02) {=0A= > - *(uint16_t *)dst =3D *(const uint16_t *)src;=0A= > - src =3D (const uint16_t *)src + 1;=0A= > - dst =3D (uint16_t *)dst + 1;=0A= > + *(uint16_t *)dstu =3D *(const uint16_t *)srcu;=0A= > + srcu =3D (uintptr_t)((const uint16_t *)srcu + 1);=0A= > + dstu =3D (uintptr_t)((uint16_t *)dstu + 1);=0A= > }=0A= > if (n & 0x04) {=0A= > - *(uint32_t *)dst =3D *(const uint32_t *)src;=0A= > - src =3D (const uint32_t *)src + 1;=0A= > - dst =3D (uint32_t *)dst + 1;=0A= > + *(uint32_t *)dstu =3D *(const uint32_t *)srcu;=0A= > + srcu =3D (uintptr_t)((const uint32_t *)srcu + 1);=0A= > + dstu =3D (uintptr_t)((uint32_t *)dstu + 1);=0A= > }=0A= > if (n & 0x08) {=0A= > - *(uint64_t *)dst =3D *(const uint64_t *)src;=0A= > + *(uint64_t *)dstu =3D *(const uint64_t *)srcu;=0A= > }=0A= > return ret;=0A= > }=0A= > @@ -458,6 +460,8 @@ static inline void *=0A= > rte_memcpy(void *dst, const void *src, size_t n)=0A= > {=0A= > __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, xmm8;=0A= > + uintptr_t dstu =3D (uintptr_t)dst;=0A= > + uintptr_t srcu =3D (uintptr_t)src;=0A= > void *ret =3D dst;=0A= > int dstofss;=0A= > int srcofs;=0A= > @@ -467,22 +471,22 @@ rte_memcpy(void *dst, const void *src, size_t n)=0A= > */=0A= > if (n < 16) {=0A= > if (n & 0x01) {=0A= > - *(uint8_t *)dst =3D *(const uint8_t *)src;=0A= > - src =3D (const uint8_t *)src + 1;=0A= > - dst =3D (uint8_t *)dst + 1;=0A= > + *(uint8_t *)dstu =3D *(const uint8_t *)srcu;=0A= > + srcu =3D (uintptr_t)((const uint8_t *)srcu + 1);=0A= > + dstu =3D (uintptr_t)((uint8_t *)dstu + 1);=0A= > }=0A= > if (n & 0x02) {=0A= > - *(uint16_t *)dst =3D *(const uint16_t *)src;=0A= > - src =3D (const uint16_t *)src + 1;=0A= > - dst =3D (uint16_t *)dst + 1;=0A= > + *(uint16_t *)dstu =3D *(const uint16_t *)srcu;=0A= > + srcu =3D (uintptr_t)((const uint16_t *)srcu + 1);=0A= > + dstu =3D (uintptr_t)((uint16_t *)dstu + 1);=0A= > }=0A= > if (n & 0x04) {=0A= > - *(uint32_t *)dst =3D *(const uint32_t *)src;=0A= > - src =3D (const uint32_t *)src + 1;=0A= > - dst =3D (uint32_t *)dst + 1;=0A= > + *(uint32_t *)dstu =3D *(const uint32_t *)srcu;=0A= > + srcu =3D (uintptr_t)((const uint32_t *)srcu + 1);=0A= > + dstu =3D (uintptr_t)((uint32_t *)dstu + 1);=0A= > }=0A= > if (n & 0x08) {=0A= > - *(uint64_t *)dst =3D *(const uint64_t *)src;=0A= > + *(uint64_t *)dstu =3D *(const uint64_t *)srcu;=0A= > }=0A= > return ret;=0A= > }=0A= =0A=