[dpdk-dev] [PATCH] A fix to work around strict-aliasing rules breaking

Thomas Monjalon thomas.monjalon at 6wind.com
Thu Mar 5 18:33:46 CET 2015


2015-03-02 17:03, zhihong.wang at intel.com:
> Fixed strict-aliasing rules breaking errors for some GCC version.
> 
> Signed-off-by: Zhihong Wang <zhihong.wang at intel.com>
> ---
>  .../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?



More information about the dev mailing list