From nobody Mon Feb 9 02:12:38 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1579791408; cv=none; d=zohomail.com; s=zohoarc; b=kodfZRisznOWNExkmODORfyCbB1FsWpOs40Uxq1sy7BTGv4SORk7r0r61DaKmkVAJ6zjShGYcuFbO2c70w8NwP0RSX/Di1CkMTJE6gm2JBaImVaQ+5ynYBnG3RFyZGD6pZOKzYxfzlwjB23ZXlim8/jzqC5ovxe1E25XR0wqiEg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579791408; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XVZ8XdFIGuowGCWpjVAm+O46E6p3sc4YJXzqrD7PID4=; b=depCRBNFo/CDjSRFJWIToPTEp5KC626gVVd8hm3tovboKwerxFtOyspmytB8zYNEamt1DvIOJuYm/e1sitAScRn3mkzSuEO3fg7GqqXLhsCs2YkaEPwJGjZibYjhEVNn/1hAI/jgNgYYp1SZNo2RsgYpqyiMDsCtGgH3huwqpRw= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579791408981141.70610978520529; Thu, 23 Jan 2020 06:56:48 -0800 (PST) Received: from localhost ([::1]:58600 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuduZ-0002V0-K8 for importer@patchew.org; Thu, 23 Jan 2020 09:56:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46043) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iucUL-0001C5-SN for qemu-devel@nongnu.org; Thu, 23 Jan 2020 08:25:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iucUK-0000lI-Eu for qemu-devel@nongnu.org; Thu, 23 Jan 2020 08:25:37 -0500 Received: from mail03.asahi-net.or.jp ([202.224.55.15]:36677) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1iucUK-0000fU-5Q for qemu-devel@nongnu.org; Thu, 23 Jan 2020 08:25:36 -0500 Received: from h61-195-96-97.vps.ablenet.jp (h61-195-96-97.ablenetvps.ne.jp [61.195.96.97]) (Authenticated sender: PQ4Y-STU) by mail03.asahi-net.or.jp (Postfix) with ESMTPA id 2932FB9C44; Thu, 23 Jan 2020 22:25:32 +0900 (JST) Received: from yo-satoh-debian.localdomain (v046114.dynamic.ppp.asahi-net.or.jp [124.155.46.114]) by h61-195-96-97.vps.ablenet.jp (Postfix) with ESMTPSA id 9F963240090; Thu, 23 Jan 2020 22:25:31 +0900 (JST) From: Yoshinori Sato To: qemu-devel@nongnu.org Subject: [PATCH v29 02/22] qemu/bitops.h: Add extract8 and extract16 Date: Thu, 23 Jan 2020 22:25:05 +0900 Message-Id: <20200123132525.80891-3-ysato@users.sourceforge.jp> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200123132525.80891-1-ysato@users.sourceforge.jp> References: <20200123132525.80891-1-ysato@users.sourceforge.jp> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 202.224.55.15 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: richard.henderson@linaro.org, philmd@redhat.com, Yoshinori Sato Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Signed-off-by: Yoshinori Sato Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20190607091116.49044-10-ysato@users.sourceforge.jp> Tested-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- include/qemu/bitops.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/include/qemu/bitops.h b/include/qemu/bitops.h index 02c1ce6a5d..f55ce8b320 100644 --- a/include/qemu/bitops.h +++ b/include/qemu/bitops.h @@ -301,6 +301,44 @@ static inline uint32_t extract32(uint32_t value, int s= tart, int length) return (value >> start) & (~0U >> (32 - length)); } =20 +/** + * extract8: + * @value: the value to extract the bit field from + * @start: the lowest bit in the bit field (numbered from 0) + * @length: the length of the bit field + * + * Extract from the 8 bit input @value the bit field specified by the + * @start and @length parameters, and return it. The bit field must + * lie entirely within the 8 bit word. It is valid to request that + * all 8 bits are returned (ie @length 8 and @start 0). + * + * Returns: the value of the bit field extracted from the input value. + */ +static inline uint8_t extract8(uint8_t value, int start, int length) +{ + assert(start >=3D 0 && length > 0 && length <=3D 8 - start); + return extract32(value, start, length); +} + +/** + * extract16: + * @value: the value to extract the bit field from + * @start: the lowest bit in the bit field (numbered from 0) + * @length: the length of the bit field + * + * Extract from the 16 bit input @value the bit field specified by the + * @start and @length parameters, and return it. The bit field must + * lie entirely within the 16 bit word. It is valid to request that + * all 16 bits are returned (ie @length 16 and @start 0). + * + * Returns: the value of the bit field extracted from the input value. + */ +static inline uint16_t extract16(uint16_t value, int start, int length) +{ + assert(start >=3D 0 && length > 0 && length <=3D 16 - start); + return extract32(value, start, length); +} + /** * extract64: * @value: the value to extract the bit field from --=20 2.20.1