From nobody Thu Nov 6 14:12:54 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1489415666517793.6923514844115; Mon, 13 Mar 2017 07:34:26 -0700 (PDT) Received: from localhost ([::1]:52438 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnR3G-0002Nt-S6 for importer@patchew.org; Mon, 13 Mar 2017 10:34:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58809) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnR2l-0002Mp-9e for qemu-devel@nongnu.org; Mon, 13 Mar 2017 10:33:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cnR2i-0000pr-6v for qemu-devel@nongnu.org; Mon, 13 Mar 2017 10:33:51 -0400 Received: from 8.mo1.mail-out.ovh.net ([178.33.110.239]:48343) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cnR2i-0000of-0b for qemu-devel@nongnu.org; Mon, 13 Mar 2017 10:33:48 -0400 Received: from player730.ha.ovh.net (b7.ovh.net [213.186.33.57]) by mo1.mail-out.ovh.net (Postfix) with ESMTP id D872461374 for ; Mon, 13 Mar 2017 15:33:43 +0100 (CET) Received: from zorba.kaod.org.com (LFbn-1-10647-27.w90-89.abo.wanadoo.fr [90.89.233.27]) (Authenticated sender: clg@kaod.org) by player730.ha.ovh.net (Postfix) with ESMTPSA id A308B440085; Mon, 13 Mar 2017 15:33:37 +0100 (CET) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org Date: Mon, 13 Mar 2017 15:33:25 +0100 Message-Id: <1489415605-13105-1-git-send-email-clg@kaod.org> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Ovh-Tracer-Id: 12521977291870079808 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelhedrheeggdeihecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 178.33.110.239 Subject: [Qemu-devel] [PATCH] vnc: replace hweight_long() with ctpopl() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Gerd Hoffmann , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" ctpopl() has a better implementation than hweight_long() and ui/vnc.c being the last user of hweight_long(), we can simply remove it. Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: Peter Maydell --- include/qemu/bitops.h | 10 ---------- ui/vnc.c | 6 +++--- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/include/qemu/bitops.h b/include/qemu/bitops.h index 1881284cb5f3..3f0926cf40ca 100644 --- a/include/qemu/bitops.h +++ b/include/qemu/bitops.h @@ -201,16 +201,6 @@ static inline unsigned long find_first_zero_bit(const = unsigned long *addr, return find_next_zero_bit(addr, size, 0); } =20 -static inline unsigned long hweight_long(unsigned long w) -{ - unsigned long count; - - for (count =3D 0; w; w >>=3D 1) { - count +=3D w & 1; - } - return count; -} - /** * rol8 - rotate an 8-bit value left * @word: value to rotate diff --git a/ui/vnc.c b/ui/vnc.c index 51f4b309596e..8a2789a8c26b 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -2154,15 +2154,15 @@ static void set_pixel_format(VncState *vs, int bits= _per_pixel, } =20 vs->client_pf.rmax =3D red_max ? red_max : 0xFF; - vs->client_pf.rbits =3D hweight_long(red_max); + vs->client_pf.rbits =3D ctpopl(red_max); vs->client_pf.rshift =3D red_shift; vs->client_pf.rmask =3D red_max << red_shift; vs->client_pf.gmax =3D green_max ? green_max : 0xFF; - vs->client_pf.gbits =3D hweight_long(green_max); + vs->client_pf.gbits =3D ctpopl(green_max); vs->client_pf.gshift =3D green_shift; vs->client_pf.gmask =3D green_max << green_shift; vs->client_pf.bmax =3D blue_max ? blue_max : 0xFF; - vs->client_pf.bbits =3D hweight_long(blue_max); + vs->client_pf.bbits =3D ctpopl(blue_max); vs->client_pf.bshift =3D blue_shift; vs->client_pf.bmask =3D blue_max << blue_shift; vs->client_pf.bits_per_pixel =3D bits_per_pixel; --=20 2.7.4