From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id EBD2C11C5 for ; Fri, 6 Mar 2015 08:36:31 +0100 (CET) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP; 05 Mar 2015 23:36:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,351,1422950400"; d="scan'208,217";a="536949904" Received: from shwdeisgchi017.ccr.corp.intel.com (HELO [10.239.66.47]) ([10.239.66.47]) by orsmga003.jf.intel.com with ESMTP; 05 Mar 2015 23:35:58 -0800 Message-ID: <54F958ED.4070800@intel.com> Date: Fri, 06 Mar 2015 15:36:13 +0800 From: "Liang, Cunming" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: zhihong.wang@intel.com, dev@dpdk.org References: <1425287030-18225-1-git-send-email-zhihong.wang@intel.com> In-Reply-To: <1425287030-18225-1-git-send-email-zhihong.wang@intel.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.15 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: Fri, 06 Mar 2015 07:36:33 -0000 Hi, On 3/2/2015 5:03 PM, zhihong.wang@intel.com wrote: > Fixed strict-aliasing rules breaking errors for some GCC version. > > Signed-off-by: Zhihong Wang > --- > .../common/include/arch/x86/rte_memcpy.h | 44 ++++++++++++---------- > 1 file changed, 24 insertions(+), 20 deletions(-) > > 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 69a5c6f..f412099 100644 > --- a/lib/librte_eal/common/include/arch/x86/rte_memcpy.h > +++ b/lib/librte_eal/common/include/arch/x86/rte_memcpy.h > @@ -195,6 +195,8 @@ rte_mov256blocks(uint8_t *dst, const uint8_t *src, size_t n) > static inline void * > rte_memcpy(void *dst, const void *src, size_t n) > { > + uintptr_t dstu = (uintptr_t)dst; > + uintptr_t srcu = (uintptr_t)src; > void *ret = dst; > int dstofss; > int bits; > @@ -204,22 +206,22 @@ rte_memcpy(void *dst, const void *src, size_t n) > */ > if (n < 16) { > if (n & 0x01) { > - *(uint8_t *)dst = *(const uint8_t *)src; > - src = (const uint8_t *)src + 1; > - dst = (uint8_t *)dst + 1; > + *(uint8_t *)dstu = *(const uint8_t *)srcu; > + srcu = (uintptr_t)((const uint8_t *)srcu + 1); > + dstu = (uintptr_t)((uint8_t *)dstu + 1); > } > if (n & 0x02) { > - *(uint16_t *)dst = *(const uint16_t *)src; > - src = (const uint16_t *)src + 1; > - dst = (uint16_t *)dst + 1; > + *(uint16_t *)dstu = *(const uint16_t *)srcu; > + srcu = (uintptr_t)((const uint16_t *)srcu + 1); > + dstu = (uintptr_t)((uint16_t *)dstu + 1); > } > if (n & 0x04) { > - *(uint32_t *)dst = *(const uint32_t *)src; > - src = (const uint32_t *)src + 1; > - dst = (uint32_t *)dst + 1; > + *(uint32_t *)dstu = *(const uint32_t *)srcu; > + srcu = (uintptr_t)((const uint32_t *)srcu + 1); > + dstu = (uintptr_t)((uint32_t *)dstu + 1); > } > if (n & 0x08) { > - *(uint64_t *)dst = *(const uint64_t *)src; > + *(uint64_t *)dstu = *(const uint64_t *)srcu; > } > return ret; > } > @@ -458,6 +460,8 @@ static inline void * > rte_memcpy(void *dst, const void *src, size_t n) > { > __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, xmm8; > + uintptr_t dstu = (uintptr_t)dst; > + uintptr_t srcu = (uintptr_t)src; > void *ret = dst; > int dstofss; > int srcofs; > @@ -467,22 +471,22 @@ rte_memcpy(void *dst, const void *src, size_t n) > */ > if (n < 16) { > if (n & 0x01) { > - *(uint8_t *)dst = *(const uint8_t *)src; > - src = (const uint8_t *)src + 1; > - dst = (uint8_t *)dst + 1; > + *(uint8_t *)dstu = *(const uint8_t *)srcu; > + srcu = (uintptr_t)((const uint8_t *)srcu + 1); > + dstu = (uintptr_t)((uint8_t *)dstu + 1); > } > if (n & 0x02) { > - *(uint16_t *)dst = *(const uint16_t *)src; > - src = (const uint16_t *)src + 1; > - dst = (uint16_t *)dst + 1; > + *(uint16_t *)dstu = *(const uint16_t *)srcu; > + srcu = (uintptr_t)((const uint16_t *)srcu + 1); > + dstu = (uintptr_t)((uint16_t *)dstu + 1); > } > if (n & 0x04) { > - *(uint32_t *)dst = *(const uint32_t *)src; > - src = (const uint32_t *)src + 1; > - dst = (uint32_t *)dst + 1; > + *(uint32_t *)dstu = *(const uint32_t *)srcu; > + srcu = (uintptr_t)((const uint32_t *)srcu + 1); > + dstu = (uintptr_t)((uint32_t *)dstu + 1); > } > if (n & 0x08) { > - *(uint64_t *)dst = *(const uint64_t *)src; > + *(uint64_t *)dstu = *(const uint64_t *)srcu; > } > return ret; > } Acked-by:Cunming Liang >