public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ammar Faizi <ammarfaizi2@gnuweeb.org>
To: Jens Axboe <axboe@kernel.dk>
Cc: Ammar Faizi <ammarfaizi2@gnuweeb.org>,
	Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>,
	GNU/Weeb Mailing List <gwml@vger.gnuweeb.org>,
	Pavel Begunkov <asml.silence@gmail.com>,
	io-uring Mailing List <io-uring@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [PATCH liburing v1 2/2] man/io_uring_for_each_cqe: Explicitly tell it's a macro and add an example
Date: Fri,  9 Jun 2023 08:54:03 +0700	[thread overview]
Message-ID: <20230609015403.3523811-3-ammarfaizi2@gnuweeb.org> (raw)
In-Reply-To: <20230609015403.3523811-1-ammarfaizi2@gnuweeb.org>

Let the reader directly know that it's not a function, but a macro.
Also, give a simple example of its usage.

Co-authored-by: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>
Signed-off-by: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>
Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
---
 man/io_uring_for_each_cqe.3 | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/man/io_uring_for_each_cqe.3 b/man/io_uring_for_each_cqe.3
index 8445fd605d0b02a6..78d8f6fc168d12e3 100644
--- a/man/io_uring_for_each_cqe.3
+++ b/man/io_uring_for_each_cqe.3
@@ -17,7 +17,7 @@ io_uring_for_each_cqe \- iterate pending completion events
 .PP
 The
 .BR io_uring_for_each_cqe (3)
-helper iterates completion events belonging to the
+is a macro helper that iterates completion events belonging to the
 .I ring
 using
 .I head
@@ -35,6 +35,24 @@ calling
 .BR io_uring_cqe_seen (3)
 for each of them.
 
+.SH EXAMPLE
+.EX
+void handle_cqes(struct io_uring *ring)
+{
+	struct io_uring_cqe *cqe;
+	unsigned head;
+	unsigned i = 0;
+
+	io_uring_for_each_cqe(ring, head, cqe) {
+		/* handle completion */
+		printf("cqe: %d\\n", cqe->res);
+		i++;
+	}
+
+	io_uring_cq_advance(ring, i);
+}
+.EE
+
 .SH RETURN VALUE
 None
 .SH SEE ALSO
-- 
Ammar Faizi


  parent reply	other threads:[~2023-06-09  1:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-09  1:54 [PATCH liburing v1 0/2] Fixes for io_uring_for_each_cqe Ammar Faizi
2023-06-09  1:54 ` [PATCH liburing v1 1/2] man/io_uring_for_each_cqe: Fix return value, title, and typo Ammar Faizi
2023-06-09  1:54 ` Ammar Faizi [this message]
2023-06-09  3:02 ` [PATCH liburing v1 0/2] Fixes for io_uring_for_each_cqe Jens Axboe
2023-06-09  3:02 ` Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230609015403.3523811-3-ammarfaizi2@gnuweeb.org \
    --to=ammarfaizi2@gnuweeb.org \
    --cc=alviro.iskandar@gnuweeb.org \
    --cc=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=gwml@vger.gnuweeb.org \
    --cc=io-uring@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox