From owner-svn-src-all@freebsd.org Sun Aug 7 19:31:06 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 79C65BB174A; Sun, 7 Aug 2016 19:31:06 +0000 (UTC) (envelope-from peter@rulingia.com) Received: from vps.rulingia.com (vps.rulingia.com [103.243.244.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "rulingia.com", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0BAD411F5; Sun, 7 Aug 2016 19:31:05 +0000 (UTC) (envelope-from peter@rulingia.com) Received: from server.rulingia.com (ppp59-167-167-3.static.internode.on.net [59.167.167.3]) by vps.rulingia.com (8.15.2/8.15.2) with ESMTPS id u77JNeN2061333 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 8 Aug 2016 05:23:50 +1000 (AEST) (envelope-from peter@rulingia.com) X-Bogosity: Ham, spamicity=0.000000 Received: from server.rulingia.com (localhost.rulingia.com [127.0.0.1]) by server.rulingia.com (8.15.2/8.15.2) with ESMTPS id u77JNYTN067240 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 8 Aug 2016 05:23:34 +1000 (AEST) (envelope-from peter@server.rulingia.com) Received: (from peter@localhost) by server.rulingia.com (8.15.2/8.15.2/Submit) id u77JNXF0067239; Mon, 8 Aug 2016 05:23:33 +1000 (AEST) (envelope-from peter) Date: Mon, 8 Aug 2016 05:23:33 +1000 From: Peter Jeremy To: Hans Petter Selasky Cc: Adrian Chadd , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r303811 - in head/sys: net net80211 Message-ID: <20160807192333.GA79784@server.rulingia.com> References: <201608070348.u773mXXt030939@repo.freebsd.org> <46183559-343f-401b-6471-3822e3383a50@selasky.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="a8Wt8u1KmwUX3Y2C" Content-Disposition: inline In-Reply-To: <46183559-343f-401b-6471-3822e3383a50@selasky.org> X-PGP-Key: http://www.rulingia.com/keys/peter.pgp User-Agent: Mutt/1.6.1 (2016-04-27) X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Aug 2016 19:31:06 -0000 --a8Wt8u1KmwUX3Y2C Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2016-Aug-07 11:03:23 +0200, Hans Petter Selasky wrote: >On 08/07/16 05:48, Adrian Chadd wrote: >> +#define ETHER_IS_BROADCAST(addr) \ >> + (((addr)[0] & (addr)[1] & (addr)[2] & \ >> + (addr)[3] & (addr)[4] & (addr)[5]) =3D=3D 0xff) >> >The compiler might be able to produce more optimal code if you use "+"=20 >instead of "&", because there are instructions on x86, that can add=20 >multiple variables at the same time. With "&" you need to process every=20 >one as a single instructions usually I think. > > > +#define ETHER_IS_BROADCAST(addr) \ > > + (((addr)[0] + (addr)[1] + (addr)[2] + \ > > + (addr)[3] + (addr)[4] + (addr)[5]) =3D=3D (6*0xff)) IMHO, Adrian's code is clearer and micro-optimisations like this belong in the complier, not the code. There are lots of alternative ways you could write the macro and, unless you can demonstrate that the micro- optimisation is worthwhile, you should pick the one that is clearer to the software maintainer. If you want to make a few more assumptions (64-bit unaligned little-endian architecture with at least 2 accessible bytes beyond the address), the following has the added advantage of only referencing (addr) once. (I'm not suggesting it as a replacement though). #define ETHER_IS_BROADCAST(addr) \ ((*(const long *)(addr) & 0x00ffffffl) =3D=3D 0x00ffffffl) --=20 Peter Jeremy --a8Wt8u1KmwUX3Y2C Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQJ8BAEBCgBmBQJXp4q1XxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXRFRUIyOTg2QzMwNjcxRTc0RTY1QzIyN0Ux NkE1OTdBMEU0QTIwQjM0AAoJEBall6Dkogs0a4YP/jMIA7H+af/LRfWjZDnxNyRq Kk0nMu+H4yfXmmYrw42UW4MqM2YkNpjw9cJ/x1fb9Vm1hKK9y7Z3Yx23QlX/Ffd5 g7YQrlTDBgtbmtzMknyJ4yWO6Z5fESMj3Kndxcwg1fUBppow/Zzri2j0mkWSKlHb b8jXecifM1QqxBfVz3ePhHJ5I7GtNmYn3mDO29TqLsjRTto5jp9jGnKDOQkyBcV0 kc6wICXZ8PcIuteHmxQcoNXEktYzhoTxJWd/pS01pMZK6ZcvIzZQKEayCmVVML0Y jLzrLcTzLYK/+z54e4XW77uPNPNj1CuEUOvTO4hUeMM/HJ3GwbZxG8hZnO4hMBdx hhQzTqIeNv3irlI5lJKrU6Ezf7N3Q5Zpf+X33D6uiEJ631380SID/e23ExzO5C8G uTirWxZrEAAyN+puyAJDz4Bzoo87U4VwsdbHBPlD4k6rSwz/PSdjVDBQZjoK0uKI cN+Fnw3YZImrgj/UDMtDlXpmgBvjpxzp9ycejZ+ejhg9cnv1bC57jNcgAua2aH5a 6gmYcWfkiUJ1Fx8KHxMy4yMqgX+UPmVLtR0i9h3F/Qk3wEsrhOqc7bolsw/gAIAT w3N4IJw+go8Kdao+Yxt6GO+hBBcOixxuS2Q1hlC5IwfISxUUwv0sPFWBUJJu6w84 iv/5Y3ILXpBievwymsIB =7NB+ -----END PGP SIGNATURE----- --a8Wt8u1KmwUX3Y2C--