From owner-freebsd-hackers@FreeBSD.ORG Mon Aug 20 19:26:00 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C43DD106564A; Mon, 20 Aug 2012 19:26:00 +0000 (UTC) (envelope-from bakul@bitblocks.com) Received: from mail.bitblocks.com (ns1.bitblocks.com [173.228.5.8]) by mx1.freebsd.org (Postfix) with ESMTP id A5EC68FC12; Mon, 20 Aug 2012 19:26:00 +0000 (UTC) Received: from bitblocks.com (localhost [127.0.0.1]) by mail.bitblocks.com (Postfix) with ESMTP id C8F24B827; Mon, 20 Aug 2012 12:20:32 -0700 (PDT) To: Warner Losh In-reply-to: Your message of "Mon, 20 Aug 2012 13:05:51 MDT." References: <50324DB4.6080905@cabletv.dp.ua> Comments: In-reply-to Warner Losh message dated "Mon, 20 Aug 2012 13:05:51 -0600." Date: Mon, 20 Aug 2012 12:20:32 -0700 From: Bakul Shah Message-Id: <20120820192032.C8F24B827@mail.bitblocks.com> Cc: freebsd-hackers@freebsd.org, freebsd-net@freebsd.org Subject: Re: Replace bcopy() to update ether_addr X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Aug 2012 19:26:00 -0000 On Mon, 20 Aug 2012 13:05:51 MDT Warner Losh 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?