From nobody Wed Feb 11 00:55:55 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1559310951; cv=none; d=zoho.com; s=zohoarc; b=EC+Gvzbnh0E0qd+QBcqPxkQNC9B6tfWAIDbb9p6blPvbNxMPRUdEIbTNunuiDa4T3mTQIFNTYZgJS5lH1saluO1Zy5fx3F4D2RMXDvrIbMcWQAh60Gkgc5UjMw1Orr4RZAVbI2b+zdCS2GEBfIw2gMcMKPzrtBR6aHtQQI1nJ1w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559310951; 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:ARC-Authentication-Results; bh=cN7HSsTir9LPfFs0tqL8Rk/5kniGhoqrSHsDQ6DZZvw=; b=jQ9XXh11/1b669F8V7OznYCywXT1rnoOd49lhfmXDlDw0AHtTqM5RDLHQuifE0AMugN63ZZRFBsfyRPEjQZQPDQQCresdMCKaZh0sOmxSUakw3cvAgY7q+QVNR9Ub38yabVA8NzyL4A4VkPU7OIIblsF/n0IPYlsUTWDTghvEFA= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1559310951356943.6596388456262; Fri, 31 May 2019 06:55:51 -0700 (PDT) Received: from localhost ([127.0.0.1]:43960 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hWi0R-0007vN-An for importer@patchew.org; Fri, 31 May 2019 09:55:39 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34468) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hWhom-0007Tl-1X for qemu-devel@nongnu.org; Fri, 31 May 2019 09:43:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hWhok-0000HJ-SN for qemu-devel@nongnu.org; Fri, 31 May 2019 09:43:35 -0400 Received: from mail-oi1-x243.google.com ([2607:f8b0:4864:20::243]:36234) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hWhok-0000FU-Mh for qemu-devel@nongnu.org; Fri, 31 May 2019 09:43:34 -0400 Received: by mail-oi1-x243.google.com with SMTP id y124so7752210oiy.3 for ; Fri, 31 May 2019 06:43:34 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id r23sm2391176otg.49.2019.05.31.06.43.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 31 May 2019 06:43:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cN7HSsTir9LPfFs0tqL8Rk/5kniGhoqrSHsDQ6DZZvw=; b=DPDEOcIQZsvsE3Agtlz272WzH7Upsh/iMUqZTXtAdyG3dVnE0Rx1Bl9Zgg5I5XDSRB QwXfEgPV+i/IqPGs07yul+xBXzPdr/p/pnAlP8tx9FnZOm/o7Q8+WT1gEpSIsov29IbT JUQSdpGX73Id/8Uc3DZG0s9WPd1f/GQDrqxF4nRRIncTTWWh+jDWf9FFi5e7Uxdc1OsI ncnlbYB6zuuPz/uw7+kyzJZkgEFlAy82FFnAv2CSt1n9602QlaqQY6uI4iSGoK0RdXRa g6bKwNQprF83lTwZ5wvbr4Al9ScDn95la+ISHL3pJVY7YM6xd+9RDqliFPvkmYPOhuAT mpKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cN7HSsTir9LPfFs0tqL8Rk/5kniGhoqrSHsDQ6DZZvw=; b=pmfuRMtt2iAmf2TYQORCCp4QQhCz/iEwrgXJUo05kVK1Mfbzj1M0pbyqv4YaNRXBye reo9Bhtar6hmRAYoTFPGoMJbykp9Gon9vCcJ6vmtIakhUZT7kfo+Na6DY+DwdIsGnhd9 9lp7f2Xnm6/aM0/cFLj7WHv4MrATJ1Ga05Jxt+4XW/CaOocKn6/RiGeZkCOFKzLWj9Vw uFh1gFmd1Kv1GqOHqmzjux9nM0rsiKrsDsnGd+vZpqjWTEmFdVYA9XaB6plq/qP4M2BD hXSO6lEmC4PEriSv5idiBhUXLN93gOchZIQvKN0XhQSxbA1OhmD8YPvx4sYFuYE5MUJ3 WbGg== X-Gm-Message-State: APjAAAVwh8coMZMwBX+ExX1GbYOBoRd2eXUD9uf/lc+IImzd4Zunbrym fuaezG9ln+RNb45rlrO+X1CNFj3T8l94FA== X-Google-Smtp-Source: APXvYqxg0Zb/G54tQ/KXwUNKB771Qn+AU+xOOSqkhmQUCCzlI8T33lZbtps2AuAKBiuALwEbCxQPbg== X-Received: by 2002:aca:d607:: with SMTP id n7mr51941oig.150.1559310213745; Fri, 31 May 2019 06:43:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 31 May 2019 08:43:01 -0500 Message-Id: <20190531134315.4109-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190531134315.4109-1-richard.henderson@linaro.org> References: <20190531134315.4109-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::243 Subject: [Qemu-devel] [PATCH v16 09/23] qemu/bitops.h: Add extract8 and extract16 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: philmd@redhat.com, ysato@users.sourceforge.jp Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Yoshinori Sato Signed-off-by: Yoshinori Sato Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20190516055244.95559-12-ysato@users.sourceforge.jp> 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 3f0926cf40..764f9d1ea0 100644 --- a/include/qemu/bitops.h +++ b/include/qemu/bitops.h @@ -300,6 +300,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.17.1