All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Qiu, Michael" <michael.qiu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
To: "Wang,
	Zhihong" <zhihong.wang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	"dev-VfR2kkLFssw@public.gmane.org"
	<dev-VfR2kkLFssw@public.gmane.org>
Subject: Re: [PATCH] A fix to work around strict-aliasing rules	breaking
Date: Mon, 9 Mar 2015 06:14:36 +0000	[thread overview]
Message-ID: <533710CFB86FA344BFBF2D6802E60286CF0632@SHSMSX101.ccr.corp.intel.com> (raw)
In-Reply-To: 1425287030-18225-1-git-send-email-zhihong.wang@intel.com

On 3/2/2015 5:04 PM, zhihong.wang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org wrote:
> Fixed strict-aliasing rules breaking errors for some GCC version.
>
> Signed-off-by: Zhihong Wang <zhihong.wang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> ---

As this should be a quick fix, this workaround is workable.
Acked-by: Michael Qiu <michael.qiu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

>  .../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;
>  	}


      parent reply	other threads:[~2015-03-09  6:14 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-02  9:03 [PATCH] A fix to work around strict-aliasing rules breaking zhihong.wang-ral2JQCrhuEAvxtiuMwx3w
     [not found] ` <1425287030-18225-1-git-send-email-zhihong.wang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2015-03-02 10:32   ` Bruce Richardson
2015-03-02 12:32     ` Pawel Wodkowski
     [not found]       ` <54F4584B.5090507-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2015-03-04  5:57         ` Wang, Zhihong
2015-03-04  2:07     ` Wang, Zhihong
     [not found]       ` <F60F360A2500CD45ACDB1D700268892D0E790DF6-0J0gbvR4kThpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2015-03-04 10:18         ` Bruce Richardson
2015-03-05 17:33   ` Thomas Monjalon
2015-03-06  7:36   ` Liang, Cunming
     [not found]     ` <54F958ED.4070800-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2015-03-09 11:44       ` Thomas Monjalon
2015-03-09  6:14 ` Qiu, Michael [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=533710CFB86FA344BFBF2D6802E60286CF0632@SHSMSX101.ccr.corp.intel.com \
    --to=michael.qiu-ral2jqcrhueavxtiumwx3w@public.gmane.org \
    --cc=dev-VfR2kkLFssw@public.gmane.org \
    --cc=zhihong.wang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.