Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 21 Aug 2012 09:29:44 +0300
From:      Mitya <mitya@cabletv.dp.ua>
To:        freebsd-net@freebsd.org, freebsd-hackers@freebsd.org
Subject:   Re: Replace bcopy() to update ether_addr
Message-ID:  <50332AD8.6020800@cabletv.dp.ua>
In-Reply-To: <5452BF37-3658-4C1F-B965-CE3EA28B6EA5@bsdimp.com>
References:  <50324DB4.6080905@cabletv.dp.ua> <alpine.BSF.2.00.1208201844220.35173@wojtek.tensor.gdynia.pl> <B2BB7724-57A9-40C9-AE9F-FFEC83D9DE9A@bsdimp.com> <alpine.BSF.2.00.1208202117230.19372@wojtek.tensor.gdynia.pl> <5452BF37-3658-4C1F-B965-CE3EA28B6EA5@bsdimp.com>

next in thread | previous in thread | raw e-mail | index | archive | help
20.08.2012 22:20, Warner Losh написал:
> On Aug 20, 2012, at 1:17 PM, Wojciech Puchar wrote:
>
>>>> or use ++.
>>>>
>>>> i think it is always aligned to 2 bytes and this should produce usable code on any CPU? should be 6 instructions on MIPS and PPC IMHO.
>>> We should tag it as __aligned(2) then, no?  If so, then the compiler should generate the code you posted.
>> should is the most important word in Your post. what it actually do - i don't know.
> If we are requiring this to be __aligned(2), we should tag it as such to enforce this.
>
> Even without this tagging, the code to do a structure level copy of 6 bytes is going to be tiny...
>
> Warner
>
I try some times different algorithms. This is one of thees:
*(u_int32_t *)(dst) = *(u_int32_t *)(src);
*(u_int16_t *)&(dst->octet[4]) = *(u_int16_t *)&(src->octet[4]);

But, internal gcc and clang optimisations are much better, than my attempt.
For aligned platforms (2 bytes aligned) best choice is *dst = *src;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?50332AD8.6020800>