From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Monjalon Subject: Re: [PATCH] A fix to work around strict-aliasing rules breaking Date: Thu, 05 Mar 2015 18:33:46 +0100 Message-ID: <1492500.Ex1SnWRXJA@xps13> References: <1425287030-18225-1-git-send-email-zhihong.wang@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit To: dev-VfR2kkLFssw@public.gmane.org Return-path: In-Reply-To: <1425287030-18225-1-git-send-email-zhihong.wang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-VfR2kkLFssw@public.gmane.org Sender: "dev" 2015-03-02 17:03, zhihong.wang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org: > 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); [...] Is there another solution? Are we going to acknowledge this fix?