From: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>
To: Jens Axboe <axboe@kernel.dk>
Cc: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
io-uring Mailing List <io-uring@vger.kernel.org>,
GNU/Weeb Mailing List <gwml@vger.gnuweeb.org>,
Ammar Faizi <ammarfaizi2@gnuweeb.org>
Subject: [PATCH liburing 2/3] test: Move `memfd_create()` to helpers.c, make it accessible for all tests
Date: Tue, 15 Jul 2025 12:06:28 +0700 [thread overview]
Message-ID: <20250715050629.1513826-3-alviro.iskandar@gnuweeb.org> (raw)
In-Reply-To: <20250715050629.1513826-1-alviro.iskandar@gnuweeb.org>
Previously, the static definition of `memfd_create()` was limited to
io_uring_register.c. Now, promote it to a shared location accessible
to all test cases, ensuring that future tests using `memfd_create()`
do not trigger build failures on Android targets where the syscall
is undefined in the standard headers. It improves portability and
prevents regressions across test builds.
Co-authored-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Signed-off-by: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>
---
test/helpers.c | 8 ++++++++
test/helpers.h | 5 +++++
test/io_uring_register.c | 11 -----------
3 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/test/helpers.c b/test/helpers.c
index 0589548..f1d4477 100644
--- a/test/helpers.c
+++ b/test/helpers.c
@@ -18,6 +18,14 @@
#include "helpers.h"
#include "liburing.h"
+#ifndef CONFIG_HAVE_MEMFD_CREATE
+#include <sys/syscall.h>
+int memfd_create(const char *name, unsigned int flags)
+{
+ return (int)syscall(SYS_memfd_create, name, flags);
+}
+#endif
+
/*
* Helper for allocating memory in tests.
*/
diff --git a/test/helpers.h b/test/helpers.h
index 3f0c11a..8ab0920 100644
--- a/test/helpers.h
+++ b/test/helpers.h
@@ -122,6 +122,11 @@ unsigned long long mtime_since_now(struct timeval *tv);
unsigned long long utime_since(const struct timeval *s, const struct timeval *e);
unsigned long long utime_since_now(struct timeval *tv);
+#ifndef CONFIG_HAVE_MEMFD_CREATE
+#include <linux/memfd.h>
+#endif
+int memfd_create(const char *name, unsigned int flags);
+
#ifdef __cplusplus
}
#endif
diff --git a/test/io_uring_register.c b/test/io_uring_register.c
index f08f0ca..c36c4d8 100644
--- a/test/io_uring_register.c
+++ b/test/io_uring_register.c
@@ -32,17 +32,6 @@ static int pagesize;
static rlim_t mlock_limit;
static int devnull;
-#if !defined(CONFIG_HAVE_MEMFD_CREATE)
-#include <sys/syscall.h>
-#include <linux/memfd.h>
-
-static int memfd_create(const char *name, unsigned int flags)
-{
- return (int)syscall(SYS_memfd_create, name, flags);
-}
-#endif
-
-
static int expect_fail(int fd, unsigned int opcode, void *arg,
unsigned int nr_args, int error, int error2)
{
--
Alviro Iskandar Setiawan
next prev parent reply other threads:[~2025-07-15 5:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-15 5:06 [PATCH liburing 0/3] Bring back `CONFIG_HAVE_MEMFD_CREATE` to fix Android build error Alviro Iskandar Setiawan
2025-07-15 5:06 ` [PATCH liburing 1/3] Revert "test/io_uring_register: kill old memfd test" Alviro Iskandar Setiawan
2025-07-15 14:10 ` Jens Axboe
2025-07-16 0:03 ` Alviro Iskandar Setiawan
2025-07-15 5:06 ` Alviro Iskandar Setiawan [this message]
2025-07-15 5:06 ` [PATCH liburing 3/3] examples: Add `memfd_create()` helper Alviro Iskandar Setiawan
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=20250715050629.1513826-3-alviro.iskandar@gnuweeb.org \
--to=alviro.iskandar@gnuweeb.org \
--cc=ammarfaizi2@gnuweeb.org \
--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