From nobody Mon Feb 9 16:45:08 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1626199595355187.45605229525393; Tue, 13 Jul 2021 11:06:35 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.155538.287124 (Exim 4.92) (envelope-from ) id 1m3MnV-000332-Hz; Tue, 13 Jul 2021 18:06:21 +0000 Received: by outflank-mailman (output) from mailman id 155538.287124; Tue, 13 Jul 2021 18:06:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1m3MnV-00032r-Et; Tue, 13 Jul 2021 18:06:21 +0000 Received: by outflank-mailman (input) for mailman id 155538; Tue, 13 Jul 2021 18:06:19 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1m3MnT-0002UL-Fo for xen-devel@lists.xenproject.org; Tue, 13 Jul 2021 18:06:19 +0000 Received: from mo4-p01-ob.smtp.rzone.de (unknown [85.215.255.50]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id b883459d-473c-4d3c-a22e-a01fa3628ede; Tue, 13 Jul 2021 18:06:17 +0000 (UTC) Received: from sender by smtp.strato.de (RZmta 47.28.1 AUTH) with ESMTPSA id 30791cx6DI6CtAk (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Tue, 13 Jul 2021 20:06:12 +0200 (CEST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: b883459d-473c-4d3c-a22e-a01fa3628ede DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1626199572; s=strato-dkim-0002; d=aepfle.de; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=4WYZHRcGpgtt0AApxzyOy4HkByS6ppN/3uviqFvGNT0=; b=gtSK6ABErb1YI8s+5/58wut9xJISpnDjs25U6sS+QGQDeyPNXkZ2MM7VY3ekmJt/uC 22VYTQ7goGuzoXZTubM2lITtegcQrARH5NGJjB4y2OZRCzsvWozHG1MrMkNzEvkhaYZG nAhHQb6CquW7HEh+HiwJ+9u0UaT9AF7pOuOJ34r94KSsnCq8YK2mN7zXNrh8abNFPP/l j1iLhqTykQ0MSmpJRpVgFUzDOC5kgKb2EkgXmb3E9bqg2mQ0LOU0/XygzaaTQj/hnmDz gtG/FG+CGug5iv5YyOxWtbDwXjTFlgsmULXQDowbOx9qUkpuFfLABMmSiqlAguK0hHFM lGdg== Authentication-Results: strato.com; dkim=none X-RZG-AUTH: ":P2EQZWCpfu+qG7CngxMFH1J+3q8wa/QXkBR9MXjAuzpIG0mv9coXAgthqlagRsstpH9XYEN5v9xf7dypFU9ge5p0Oi0V" X-RZG-CLASS-ID: mo00 From: Olaf Hering To: xen-devel@lists.xenproject.org Cc: Olaf Hering , Ian Jackson , Wei Liu , Juergen Gross Subject: [PATCH v20210713 03/31] tools: add API to work with sevaral bits at once Date: Tue, 13 Jul 2021 20:05:37 +0200 Message-Id: <20210713180605.12096-4-olaf@aepfle.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210713180605.12096-1-olaf@aepfle.de> References: <20210713180605.12096-1-olaf@aepfle.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1626199598640100005 Content-Type: text/plain; charset="utf-8" Introduce new API to test if a fixed number of bits is clear or set, and clear or set them all at once. The caller has to make sure the input bitnumber is a multiple of BITS_PER_L= ONG. This API avoids the loop over each bit in a known range just to see if all of them are either clear or set. Signed-off-by: Olaf Hering --- v02: - change return type from int to bool (jgross) --- tools/libs/ctrl/xc_bitops.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tools/libs/ctrl/xc_bitops.h b/tools/libs/ctrl/xc_bitops.h index f0bac4a071..8e8c6efb45 100644 --- a/tools/libs/ctrl/xc_bitops.h +++ b/tools/libs/ctrl/xc_bitops.h @@ -3,6 +3,7 @@ =20 /* bitmap operations for single threaded access */ =20 +#include #include #include =20 @@ -77,4 +78,31 @@ static inline void bitmap_or(void *_dst, const void *_ot= her, dst[i] |=3D other[i]; } =20 +static inline bool test_bit_long_set(unsigned long nr_base, const void *_a= ddr) +{ + const unsigned long *addr =3D _addr; + unsigned long val =3D addr[nr_base / BITS_PER_LONG]; + + return val =3D=3D ~0; +} + +static inline bool test_bit_long_clear(unsigned long nr_base, const void *= _addr) +{ + const unsigned long *addr =3D _addr; + unsigned long val =3D addr[nr_base / BITS_PER_LONG]; + + return val =3D=3D 0; +} + +static inline void clear_bit_long(unsigned long nr_base, void *_addr) +{ + unsigned long *addr =3D _addr; + addr[nr_base / BITS_PER_LONG] =3D 0; +} + +static inline void set_bit_long(unsigned long nr_base, void *_addr) +{ + unsigned long *addr =3D _addr; + addr[nr_base / BITS_PER_LONG] =3D ~0; +} #endif /* XC_BITOPS_H */