From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:60918) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UFRbn-00016Z-Vs for qemu-devel@nongnu.org; Tue, 12 Mar 2013 11:59:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UFRbc-00060Z-0u for qemu-devel@nongnu.org; Tue, 12 Mar 2013 11:59:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:63148) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UFRbb-00060L-Ng for qemu-devel@nongnu.org; Tue, 12 Mar 2013 11:59:11 -0400 Message-ID: <513F50CB.1050701@redhat.com> Date: Tue, 12 Mar 2013 09:59:07 -0600 From: Eric Blake MIME-Version: 1.0 References: <513F4E68.2060005@dlhnet.de> In-Reply-To: <513F4E68.2060005@dlhnet.de> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="----enig2CUIWPCLSVCNHKLTECGCH" Subject: Re: [Qemu-devel] [RFC][PATCH 2/9] add a function to find non-zero content in a buffer List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Lieven Cc: Kevin Wolf , Paolo Bonzini , Stefan Hajnoczi , "qemu-devel@nongnu.org" , Orit Wasserman This is an OpenPGP/MIME signed message (RFC 4880 and 3156) ------enig2CUIWPCLSVCNHKLTECGCH Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 03/12/2013 09:48 AM, Peter Lieven wrote: > Signed-off-by: Peter Lieven > --- > include/qemu-common.h | 1 + > util/cutils.c | 30 ++++++++++++++++++++++++++++++ > 2 files changed, 31 insertions(+) >=20 >=20 > /* > + * Searches for an area with non-zero content in a buffer > + * > + * Attention! The len must be a multiple of 8 * sizeof(VECTYPE) > + * and addr must bedue to restriction of optimizations in this functio= n. s/bedue/be XXX due/ don't know what XXX is supposed to be. Instead of stating this in a comment... > + * > + * The return value is the offset of the non-zero area rounded > + * down to 8 * sizeof(VECTYPE). If the buffer is all zero > + * the return value is equal to len. > + */ > + > +size_t buffer_find_nonzero_offset(const void *buf, size_t len) > +{ =2E..why not instead assert() it as part of the contract? > + VECTYPE *p =3D (VECTYPE *)buf; > + VECTYPE zero =3D ZERO_SPLAT; > + size_t i; > + for (i =3D 0; i < len / sizeof(VECTYPE); i +=3D 8) { > + VECTYPE tmp0 =3D p[i+0] | p[i+1]; > + VECTYPE tmp1 =3D p[i+2] | p[i+3]; > + VECTYPE tmp2 =3D p[i+4] | p[i+5]; > + VECTYPE tmp3 =3D p[i+6] | p[i+7]; > + VECTYPE tmp01 =3D tmp0 | tmp1; > + VECTYPE tmp23 =3D tmp2 | tmp3; > + if (!ALL_EQ(tmp01 | tmp23, zero)) { > + break; > + } > + } > + return i * sizeof(VECTYPE); > +} > + > +/* > * Checks if a buffer is all zeroes > * > * Attention! The len must be a multiple of 4 * sizeof(long) due to oh, probably because of copy and paste. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org ------enig2CUIWPCLSVCNHKLTECGCH Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.13 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJRP1DLAAoJEKeha0olJ0Nq9XUIAJ7eRY9npTrBlXPS6a3CHGqr Sod1R1uqAZY+/u9UUSRfQLfcUL1GtZt5vAhqpN39K8XBpMSYNRvmO2BPsOFLGYUC CrmSb0FpFGA/xZJE0AYN4kOr3j+Ow67mdHV6tqeVVQSjdQPMEAD77HJffG0BG/xL guatGi1EzhxCm+NkMqoD2WcZlS7lc1ItFJ3dnkw15qfoCjMV0uJon3HdEWwda9lo MgOjmAICAo4QZfOAuRRbITIAlL29cyRZrJ/v55v7vskxigOAeHTJ9v3MT9Nb9M+4 ECcfvNUoEq3L+cnv2zKCYPimTODhKbU69k7/i5P5OcsOTwXIaG4aSQRs2Mnd03M= =7hFk -----END PGP SIGNATURE----- ------enig2CUIWPCLSVCNHKLTECGCH--