From patchwork Wed Sep 11 12:13:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 827430 Delivered-To: patch@linaro.org Received: by 2002:adf:ab1c:0:b0:367:895a:4699 with SMTP id q28csp767781wrc; Wed, 11 Sep 2024 05:29:56 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUExAY8HcPxkvWOP79mJZA96hymAjEK0u3tOc8joqXsvVPVo57wcwSIyCAOfhQzO+mUX6w9QQ==@linaro.org X-Google-Smtp-Source: AGHT+IHDR56vZXyNb1VtU5HfNUJa76TNiHGZxW8IUiiU2UU9/zLHMoYexQvEdL6OF8ZFlgfxtqN9 X-Received: by 2002:a05:6214:2c13:b0:6c3:52ef:3012 with SMTP id 6a1803df08f44-6c528517684mr269875686d6.34.1726057796071; Wed, 11 Sep 2024 05:29:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1726057796; cv=none; d=google.com; s=arc-20240605; b=MaE58pHR0bbSuszRI1AvSLjdaaW+uYFIIlIqoConUok8aXI3AUKAjRiQorzrnW40dE 0GXT/jSm+GCVdyAiqT5w5c6ttIdlV0vVkHraGNVOMb6SL5I64w1jSt1hO+jOJ7Wo8awx RRfc/DaJw0hRfeSVC355s9q5knamT76ITFwhSJaVL57MEbORJxItyLHTTrPHOd7UM8+u P2IXlrVykVIwyPCVyEp/9hA6APZ6LNO2dzfiNGXFZaQdyMUNpm8RAziiwELvtQrSI241 mubuPYCzrDvnnmTWz3AgriaRkDIwV07XkKuY7pSKFrfxwlDrNwJcqH1mlzIlOvTwd6fM VKYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=IjC/62EZVazJYeQw2M6RGzr8NQkf0Ibb5BD/Lj2iJ4w=; fh=/9cz0zv9u/ptCvwYMcD3chx+MwYwmNFWtCWoZlabT74=; b=kJetNuLIQMpXhlyYqnEYWobVyCYantSaWDPEVGJSPyiOdZWnHQEFIhqLl+DgmAg+l/ H+/y+MGahJ4M2yTj7OeusKxqNeCaOwrKwPA8A4psjQavLERA6EMWXyYEgao9Fyp3k5Id nw2xdYxNiTxLvyBuRQZSxKE5SRgWSB3R0amAgf1OiMen84IIPaTkrKVEGYcU8aAy7UlC KNqMe7WfZC/8AY24TLqXGl39Bh63Q3751nz++U8+xI5tOmCZzb38TJgu2Qq+ef1I3o4V twTdD1acVjW9G8ww7fdsvZ6TaksDb7oE1O/O2j2v0Jo9/FgGAwX7zZGdsJedNiUWQniO 6eMA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uVKStR93; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6c53476f61fsi100847516d6.236.2024.09.11.05.29.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Sep 2024 05:29:56 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uVKStR93; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1soMJh-0000CU-4e; Wed, 11 Sep 2024 08:19:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1soMIv-0005Vu-EB for qemu-devel@nongnu.org; Wed, 11 Sep 2024 08:18:37 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1soMIt-0007d7-GF for qemu-devel@nongnu.org; Wed, 11 Sep 2024 08:18:37 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-42cb6f3a5bcso1235465e9.2 for ; Wed, 11 Sep 2024 05:18:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1726057112; x=1726661912; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IjC/62EZVazJYeQw2M6RGzr8NQkf0Ibb5BD/Lj2iJ4w=; b=uVKStR93J3SDrbuKqgz2blhMQwrfsJt/xWFhc/B+OF5yDejnB95fIMGyB6eVnj+2VF A/F/NUdaVdl/UItsD/m3piZe2Yl+wEzOBCdzz9eeO4LjkrS9kkbMpcSLa2eJStXsKr5R WSY0YsQpKcjwrTebNvoLRSKLocLpy2318RpbH4DVrcgD+K6U22AuS8IF82I8LxQplvIJ GMyEI/uVql4VGYrma5tODEWrtWpajd/7hp8nPejFPFEIRe6ZKnUgPmVoQHxz7qQeK+jc /AYmvBSVN29KziBSfnOjpvbVUbRy/iEwgKXtOmV1gjQUEwVkcbKqM7JEGNL+rBCMBESt Dv3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726057112; x=1726661912; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IjC/62EZVazJYeQw2M6RGzr8NQkf0Ibb5BD/Lj2iJ4w=; b=Jsw/ErfM9Cv3Obj1YhGjpT2bkm8xp493A+Xc7S9Z2uat99CmYQtMUqWhE43SdPcsd5 2G3LiWo1cBpBEYF/mtFtIIDcENh2SCP/BPq2FyfemeAeaBR8TtzFAfQnzYzW1d3q15Ra VhL85xeNcz0jA+GNIozc8WuzUTyk75ffvLB1G8NkyMGzqpFJpGQOuMPPxyDKBkdcEOks UGK8E9Fss1/ZyZEC9sQbqukkq6mXvag0sEuSIqqi9rwonQvgiSyjyX/dWHN1K2dQrsSv NogVy2WDc17ZAkGDPvVnd8SHMrqmEGIeePit4TGQ7WAfWmMEwhfpga9EeYLu5GAa+uNX 3LbA== X-Gm-Message-State: AOJu0YzhOhietz3cFJo5NApU/iB8cTBFN5f5Dt1N9Zq0cEVocDyd2l3C ryCyGwmDyvrmo2xiSxN0r0/+y3EC09T+y/88bIJK2c+phbW1YenLz7osSiUTWvpKoxvNBBeobA7 S X-Received: by 2002:a5d:4387:0:b0:374:c160:269e with SMTP id ffacd0b85a97d-378922a6d58mr12019583f8f.22.1726057112444; Wed, 11 Sep 2024 05:18:32 -0700 (PDT) Received: from m1x-phil.lan ([176.187.196.107]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37895649733sm11448859f8f.8.2024.09.11.05.18.31 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 11 Sep 2024 05:18:32 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Mark Cave-Ayland , Alistair Francis , Octavian Purdila , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 34/56] fifo8: add skip parameter to fifo8_peekpop_bufptr() Date: Wed, 11 Sep 2024 14:13:59 +0200 Message-ID: <20240911121422.52585-35-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240911121422.52585-1-philmd@linaro.org> References: <20240911121422.52585-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=philmd@linaro.org; helo=mail-wm1-x334.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Mark Cave-Ayland The skip parameter specifies the number of bytes to be skipped from the current FIFO head before the peek or pop operation. Signed-off-by: Mark Cave-Ayland Reviewed-by: Alistair Francis Reviewed-by: Octavian Purdila Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Message-ID: <20240828122258.928947-4-mark.cave-ayland@ilande.co.uk> Signed-off-by: Philippe Mathieu-Daudé --- util/fifo8.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/util/fifo8.c b/util/fifo8.c index 5faa814a6e..62d6430b05 100644 --- a/util/fifo8.c +++ b/util/fifo8.c @@ -72,18 +72,20 @@ uint8_t fifo8_pop(Fifo8 *fifo) } static const uint8_t *fifo8_peekpop_bufptr(Fifo8 *fifo, uint32_t max, - uint32_t *numptr, bool do_pop) + uint32_t skip, uint32_t *numptr, + bool do_pop) { uint8_t *ret; uint32_t num, head; assert(max > 0 && max <= fifo->num); - head = fifo->head; + assert(skip <= fifo->num); + head = (fifo->head + skip) % fifo->capacity; num = MIN(fifo->capacity - head, max); ret = &fifo->data[head]; if (do_pop) { - fifo->head += num; + fifo->head = head + num; fifo->head %= fifo->capacity; fifo->num -= num; } @@ -95,12 +97,12 @@ static const uint8_t *fifo8_peekpop_bufptr(Fifo8 *fifo, uint32_t max, const uint8_t *fifo8_peek_bufptr(Fifo8 *fifo, uint32_t max, uint32_t *numptr) { - return fifo8_peekpop_bufptr(fifo, max, numptr, false); + return fifo8_peekpop_bufptr(fifo, max, 0, numptr, false); } const uint8_t *fifo8_pop_bufptr(Fifo8 *fifo, uint32_t max, uint32_t *numptr) { - return fifo8_peekpop_bufptr(fifo, max, numptr, true); + return fifo8_peekpop_bufptr(fifo, max, 0, numptr, true); } uint32_t fifo8_pop_buf(Fifo8 *fifo, uint8_t *dest, uint32_t destlen)