From patchwork Wed Sep 11 12:14:04 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: 827435 Delivered-To: patch@linaro.org Received: by 2002:adf:ab1c:0:b0:367:895a:4699 with SMTP id q28csp768909wrc; Wed, 11 Sep 2024 05:32:19 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXBxsLCwpHVh7ELtYDaFA4jPNvE4FLEarizEfPb1i+jMKHu3qVW33mmkAgW+TFzDJp0gu1/Iw==@linaro.org X-Google-Smtp-Source: AGHT+IGk857mf8YidetnUZSlrZ2f7o8PMua7gLuTunODp9rryJNJ1EqMk+UI08naiFgjI881RTJr X-Received: by 2002:a67:f350:0:b0:497:6ae3:e541 with SMTP id ada2fe7eead31-49c15a13972mr3817073137.14.1726057939455; Wed, 11 Sep 2024 05:32:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1726057924; cv=none; d=google.com; s=arc-20240605; b=Jllk4o0w/NdGlA7xPixxUCrwSPIXMrtDo9c66v8uAFTfsEBBoFcwr3rYfqy6yRRX+3 Msm7qcsYk+zsVt4s4pfSuLIAFNmV5sqR+Ar01c8Jqc8fFS0Uk6EYdbsd2DxlxyTbYTwK QpgYcVldB5x6QMb+pkFSdbZTJ4T7dJj1AxJ4taj5NMR7Fx0oeHAWfYjQM/mADyCyqsvf gbKv8U/Wt2FYwFs0sPh9JGJZOur88zbxOBH0IJ81P4n9e/tnbrYqmFhRpJJNdluNKFe6 PiiDurUEB09ED1CK309J3VuZKkxIY5KivF2uVDT53Xr19ClSaPlOhKMbHQsPywbenPIH fxoQ== 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=rvh1RZxcP1nInMdaaa2bCvNT6U7BxgYnTGGeSM1aBGg=; fh=/9cz0zv9u/ptCvwYMcD3chx+MwYwmNFWtCWoZlabT74=; b=il/gPxWaXWjI+HwFktte5/qjPLhLF/49MsU7Or8DzVtF22v94mmlxSRcp6fNFmD616 XTLTBxGsXm1ffwhpXHKHC6m4Oy7Y7TfxPFW6O4k++18+AhgYnYnSH2OalFJLxGDRq3Uk dPhlnNIwlcYXbY17SKY3IJeyEbgd8wIM1mOnjOAdNGLf0gSpjXAGSzkiHVioUOydFUOZ b7jYvZQlfstPK47UHDqDEoVM//pf062skyR4kewjiZpxrH1XK9XadaIQIQNf9WRRgnZC 8Pi/1VR/4oi9ICKKyexrchkn7mS0l5JoedPimvdGu3StR/2LkhuydwcrwDoz+5okTfOT TbVA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WNPodAmI; 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 ada2fe7eead31-49c16dd3c39si982189137.516.2024.09.11.05.32.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Sep 2024 05:32:04 -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=WNPodAmI; 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 1soMJr-00026P-Ir; Wed, 11 Sep 2024 08:19:35 -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 1soMJc-0008Sp-Pv for qemu-devel@nongnu.org; Wed, 11 Sep 2024 08:19:22 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1soMJN-0007fP-E2 for qemu-devel@nongnu.org; Wed, 11 Sep 2024 08:19:12 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-42cc43454d5so14071795e9.3 for ; Wed, 11 Sep 2024 05:19:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1726057142; x=1726661942; 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=rvh1RZxcP1nInMdaaa2bCvNT6U7BxgYnTGGeSM1aBGg=; b=WNPodAmIQ5yvfz/ps6N0wgaBW7mCRlsrHsZZCrFqVjSZYmBr3W1KHA6/BUSvSrpWkV d2n5lq1i/ReqRiTrUUNiVotW1jdPoU7NrNacslX+wTWLaEoUuHPKzBPqFvEVZiNQRYuY R05Z1M4c2roiHgwxnc64dlrrP9gxfcIuN+jPIyok5ezoibWX8fZMAv39llIkskDWH+WD QKL19pT3/X/kIUuo2tv9f0StxnbCMyIH5ezg/f5+VGgV7NXJ+deacO6qpjXaXAq/VgKR bPEAxb+UqImrgQdfTL6YLzXEMlf4heiU2Ii+R8Us9HJPFUAi2K74j8SwGin9fmjlE2lO SkEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726057142; x=1726661942; 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=rvh1RZxcP1nInMdaaa2bCvNT6U7BxgYnTGGeSM1aBGg=; b=Nnaczw8r1/IF0eXVuXgA4ypQmqbbrQsAHZe2mxK6bTnccjBCk0GDov+JVzTtd5s4uC gOGD4I/gO5ateAskEAGoFnWCrNwaoypTncxj533ZI6sIdU0XZqsjGAATfFP3DzpRjvrn JxfDOAGOJOIMbSLXa5zSFTFDr4bQBJoaQ89zhe1mmPXeIHkyGvQfdaOk/B8XGvYPC5EY Pazz++w64SyQwCrZ9WB8ZPlqX3urGNfvJ1SeRYV/tDkzuaBA2GAVPZs7VT09WBYEpZ3z OKO6sgf5wL2T62PvEwZYxnkPR9mqvqz30idomjzalEijOTmMMjj6TlzjNg69UGrYRct2 RFUg== X-Gm-Message-State: AOJu0YzFjvc+W5DUNN21R1BIURs893hLhu2pvmAJfUP74m+fEtzKn1EZ NibpioUjf7qLy9KOFTnkKrzZcbdk7vLyNjJzRvN3ohLvJUFlr703tBQUhH6MPLTzoeNChu4cORF H X-Received: by 2002:a7b:c4d6:0:b0:42c:ad30:678 with SMTP id 5b1f17b1804b1-42cae76d028mr98544355e9.28.1726057141747; Wed, 11 Sep 2024 05:19:01 -0700 (PDT) Received: from m1x-phil.lan ([176.187.196.107]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42caeb45c81sm142098365e9.28.2024.09.11.05.19.00 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 11 Sep 2024 05:19:01 -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 39/56] fifo8: introduce fifo8_peek() function Date: Wed, 11 Sep 2024 14:14:04 +0200 Message-ID: <20240911121422.52585-40-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::32c; envelope-from=philmd@linaro.org; helo=mail-wm1-x32c.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 This allows uses to peek the byte at the current head of the FIFO. 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-9-mark.cave-ayland@ilande.co.uk> Signed-off-by: Philippe Mathieu-Daudé --- include/qemu/fifo8.h | 11 +++++++++++ util/fifo8.c | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/include/qemu/fifo8.h b/include/qemu/fifo8.h index d09984b146..4f768d4ee3 100644 --- a/include/qemu/fifo8.h +++ b/include/qemu/fifo8.h @@ -62,6 +62,17 @@ void fifo8_push_all(Fifo8 *fifo, const uint8_t *data, uint32_t num); */ uint8_t fifo8_pop(Fifo8 *fifo); +/** + * fifo8_peek: + * @fifo: fifo to peek from + * + * Peek the data byte at the current head of the FIFO. Clients are responsible + * for checking for emptyness using fifo8_is_empty(). + * + * Returns: The peeked data byte. + */ +uint8_t fifo8_peek(Fifo8 *fifo); + /** * fifo8_pop_buf: * @fifo: FIFO to pop from diff --git a/util/fifo8.c b/util/fifo8.c index a8f5cea158..a26da66ad2 100644 --- a/util/fifo8.c +++ b/util/fifo8.c @@ -71,6 +71,12 @@ uint8_t fifo8_pop(Fifo8 *fifo) return ret; } +uint8_t fifo8_peek(Fifo8 *fifo) +{ + assert(fifo->num > 0); + return fifo->data[fifo->head]; +} + static const uint8_t *fifo8_peekpop_bufptr(Fifo8 *fifo, uint32_t max, uint32_t skip, uint32_t *numptr, bool do_pop)