From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server-vie001.gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,URIBL_ZEN_BLOCKED_OPENDNS autolearn=ham autolearn_force=no version=3.4.6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1752555996; bh=M4kWDyZCqYHuWnsGkdgcYbAx+5ci5psYJKq6L5JYEH4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding:Message-ID:Date:From: Reply-To:Subject:To:Cc:In-Reply-To:References:Resent-Date: Resent-From:Resent-To:Resent-Cc:User-Agent:Content-Type: Content-Transfer-Encoding; b=ZIhi5pfTkYwr5WPSGDV9MMUub7QPY1/ty6c+SJ4fEBsuTolic3DQDJtHu/6tDyqAz ZO9t9zKb/rRZSEgcWRpRz5EnIUfmmTTKTzJ08+mSH1Uu89VWWTABo4uO7H1ohY8A40 snyeEVIwYif6vmzE+HRZqKyhbCYuTDpGfWG0BA8Be9xNRvHMepLWXJ1zkBk2hlVqhq MpnChGp/M7Y+gy7b24leJHbwTEL9JFfQBgLy7++5RkaXHiKPi8X8zeb3IK+TnONvtc f/JvPd/NW2b0ZSr2MnusmRoBQx+T4pUwnZNX/6E58SOLkkLQWT+tFdPIxXq1S7QjCw X+KoBKI3GNOHg== Received: from server-vie001.gnuweeb.org (unknown [192.168.57.1]) by server-vie001.gnuweeb.org (Postfix) with ESMTPSA id 526C52109A3A; Tue, 15 Jul 2025 05:06:36 +0000 (UTC) From: Alviro Iskandar Setiawan To: Jens Axboe Cc: Alviro Iskandar Setiawan , Linux Kernel Mailing List , io-uring Mailing List , GNU/Weeb Mailing List , Ammar Faizi 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 Message-Id: <20250715050629.1513826-3-alviro.iskandar@gnuweeb.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250715050629.1513826-1-alviro.iskandar@gnuweeb.org> References: <20250715050629.1513826-1-alviro.iskandar@gnuweeb.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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 Signed-off-by: Ammar Faizi Signed-off-by: Alviro Iskandar Setiawan --- 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 +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 +#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 -#include - -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