Replace bcopy() to update ether_addr

Bakul Shah bakul at bitblocks.com
Mon Aug 20 19:26:00 UTC 2012


On Mon, 20 Aug 2012 13:05:51 MDT Warner Losh <imp at bsdimp.com>  wrote:
> 
> On Aug 20, 2012, at 10:48 AM, Wojciech Puchar wrote:
> 
> >> #if defined(__i386__) || defined(__amd64__)
> >>   *dst =3D *src;
> >> #else
> >>   bcopy(src, dst, ETHER_ADDR_LEN);
> > #else
> > short *tmp1=3D((*short)src),*tmp2=3D((*short)dst);
> > *tmp2=3D*tmp1; *(tmp2+1)=3D*(tmp1+1); *(tmp2+2)=3D*(tmp1+2);
> >
> > 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.

Doesn't gcc inline memcpy these days? 


More information about the freebsd-hackers mailing list