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=soufQIX6TYMmC/348jS3xW4pvirGNiNwAJl7GhmX8LY=; 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=VwPXuDtp0zGuGgujQQNYxkzW6Z55i4yLmNobzT1hpwnIJLeU99Vm+JJOzmXBV6clL gTDlykdvM0dahSdZol+9NMFLK4oznNOEk/YKWyBJ46v0xJQJM5y7785YYqajOPquIu FMX+WNod3MSJGwfTtZeLaqtWmN74vo+zpOKUdkUSjik5K8VyI3QbOJf2SU72N/2caE 30Oj9MV13eECqJVATyXnk1K0fDnvesHFP4b3rhJQugVqAPLyxTvgzPBMmxfZ6PSBZG SP/79UhSKkcDYJwC+WSJIKVVD/VRg0HgPV+VSkAJ8FALlVyffQGQKMJ2W3V/JwBN60 A3T73aUQZqA8w== Received: from server-vie001.gnuweeb.org (unknown [192.168.57.1]) by server-vie001.gnuweeb.org (Postfix) with ESMTPSA id 6D31D2109A3B; 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 3/3] examples: Add `memfd_create()` helper Date: Tue, 15 Jul 2025 12:06:29 +0700 Message-Id: <20250715050629.1513826-4-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: Add `memfd_create()` helper to handle missing defintion on an environment where `CONFIG_HAVE_MEMFD_CREATE` is not defined. Co-authored-by: Ammar Faizi Signed-off-by: Ammar Faizi Signed-off-by: Alviro Iskandar Setiawan --- examples/helpers.c | 8 ++++++++ examples/helpers.h | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/examples/helpers.c b/examples/helpers.c index 483ddee..8c112f1 100644 --- a/examples/helpers.c +++ b/examples/helpers.c @@ -13,6 +13,14 @@ #include "helpers.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 + int setup_listening_socket(int port, int ipv6) { struct sockaddr_in srv_addr = { }; diff --git a/examples/helpers.h b/examples/helpers.h index 44543e1..0b6f15f 100644 --- a/examples/helpers.h +++ b/examples/helpers.h @@ -17,4 +17,9 @@ void *t_aligned_alloc(size_t alignment, size_t size); void t_error(int status, int errnum, const char *format, ...); +#ifndef CONFIG_HAVE_MEMFD_CREATE +#include +#endif +int memfd_create(const char *name, unsigned int flags); + #endif -- Alviro Iskandar Setiawan