From: Pavel Begunkov <asml.silence@gmail.com>
To: io-uring@vger.kernel.org
Cc: asml.silence@gmail.com, David Wei <dw@davidwei.uk>
Subject: [PATCH liburing 4/5] examples: add extra helpers
Date: Wed, 16 Apr 2025 10:01:16 +0100 [thread overview]
Message-ID: <647b27b73b644e9425f07c79c1c987c7c483c517.1744793980.git.asml.silence@gmail.com> (raw)
In-Reply-To: <cover.1744793980.git.asml.silence@gmail.com>
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
examples/helpers.c | 15 +++++++++++++++
examples/helpers.h | 6 ++++++
2 files changed, 21 insertions(+)
diff --git a/examples/helpers.c b/examples/helpers.c
index 59b31ecb..0c9e0160 100644
--- a/examples/helpers.c
+++ b/examples/helpers.c
@@ -9,6 +9,7 @@
#include <sys/socket.h>
#include <sys/time.h>
#include <unistd.h>
+#include <stdarg.h>
#include "helpers.h"
@@ -70,3 +71,17 @@ void *aligned_alloc(size_t alignment, size_t size)
return ret;
}
+
+void t_error(int status, int errnum, const char *format, ...)
+{
+ va_list args;
+ va_start(args, format);
+
+ vfprintf(stderr, format, args);
+ if (errnum)
+ fprintf(stderr, ": %s", strerror(errnum));
+
+ fprintf(stderr, "\n");
+ va_end(args);
+ exit(status);
+}
diff --git a/examples/helpers.h b/examples/helpers.h
index d73ee4a5..c8bf7332 100644
--- a/examples/helpers.h
+++ b/examples/helpers.h
@@ -2,6 +2,10 @@
#ifndef LIBURING_EX_HELPERS_H
#define LIBURING_EX_HELPERS_H
+#include <stddef.h>
+
+#define T_ALIGN_UP(v, align) (((v) + (align) - 1) & ~((align) - 1))
+
int setup_listening_socket(int port, int ipv6);
/*
@@ -11,4 +15,6 @@ int setup_listening_socket(int port, int ipv6);
*/
void *aligned_alloc(size_t alignment, size_t size);
+void t_error(int status, int errnum, const char *format, ...);
+
#endif
--
2.48.1
next prev parent reply other threads:[~2025-04-16 9:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-16 9:01 [PATCH liburing 0/5] zcrx example and other changes Pavel Begunkov
2025-04-16 9:01 ` [PATCH liburing 1/5] Update io_uring.h for zcrx Pavel Begunkov
2025-04-16 9:01 ` [PATCH liburing 2/5] tests/zcrx: rename a test Pavel Begunkov
2025-04-16 9:01 ` [PATCH liburing 3/5] tests/zcrx: use returned right zcrx id Pavel Begunkov
2025-04-16 9:01 ` Pavel Begunkov [this message]
2025-04-16 9:01 ` [PATCH liburing 5/5] examples: add a zcrx example Pavel Begunkov
2025-04-16 14:48 ` [PATCH liburing 0/5] zcrx example and other changes 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=647b27b73b644e9425f07c79c1c987c7c483c517.1744793980.git.asml.silence@gmail.com \
--to=asml.silence@gmail.com \
--cc=dw@davidwei.uk \
--cc=io-uring@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