{"id":20731,"url":"https://patchwork.libcamera.org/api/patches/20731/?format=json","web_url":"https://patchwork.libcamera.org/patch/20731/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20240731135936.2105-3-laurent.pinchart@ideasonboard.com>","date":"2024-07-31T13:59:34","name":"[v2,2/4] libcamera: base: memfd: Handle uClibc compatibility with function wrapper","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"44f459e7f24bf6e27059e89fbd2edd4bf10657e0","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/20731/mbox/","series":[{"id":4470,"url":"https://patchwork.libcamera.org/api/series/4470/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4470","date":"2024-07-31T13:59:32","name":"libcamera: Address soft ISP file seal TODO item","version":2,"mbox":"https://patchwork.libcamera.org/series/4470/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/20731/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/20731/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id D8F1CBDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 31 Jul 2024 14:00:04 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9236C63377;\n\tWed, 31 Jul 2024 16:00:03 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B587763373\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 31 Jul 2024 16:00:00 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id BE1FDF85\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 31 Jul 2024 15:59:12 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"u5gvqy8x\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1722434353;\n\tbh=77zpJSFoPZJqYJyQ1SYf77gaxo8dLAeY+OC+qai2asY=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=u5gvqy8x/hQ+CYPw+JMV3Xqb18+xCSvc8kD1ZnWlkLd3mELNfU8l9oVK0er0Aonho\n\tPD1y/agMgs9+gz5nIeLF1U1AEisM1MZrvZyWTnD+TpWQlXH8so19PpBI48gMLi7nGK\n\tGe/6aeVLf7/Lj0Sph/Fx28ze6MTOhJ4gjhJtjbH8=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Subject":"[PATCH v2 2/4] libcamera: base: memfd: Handle uClibc compatibility\n\twith function wrapper","Date":"Wed, 31 Jul 2024 16:59:34 +0300","Message-ID":"<20240731135936.2105-3-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.44.2","In-Reply-To":"<20240731135936.2105-1-laurent.pinchart@ideasonboard.com>","References":"<20240731135936.2105-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"uClibc doesn't provide memfd_create(), which led libcamera to open-code\nthe call using syscall(). Sprinkling the code with #ifdef's isn't the\nmost readable option, so improve it by providing a local implementation\nof memfd_create(), and call the function unconditionally from\nMemFd::create(). This makes the main code path more readable.\n\nSuggested-by: Nicolas Dufresne <nicolas@ndufresne.ca>\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/base/memfd.cpp | 17 ++++++++++++-----\n 1 file changed, 12 insertions(+), 5 deletions(-)","diff":"diff --git a/src/libcamera/base/memfd.cpp b/src/libcamera/base/memfd.cpp\nindex 72474307af09..d95adb91615c 100644\n--- a/src/libcamera/base/memfd.cpp\n+++ b/src/libcamera/base/memfd.cpp\n@@ -20,15 +20,26 @@\n  * \\brief Anonymous file creation\n  */\n \n-/* uClibc doesn't provide the file sealing API. */\n #ifndef __DOXYGEN__\n+namespace {\n+\n+/* uClibc doesn't provide the file sealing API. */\n #if not HAVE_FILE_SEALS\n #define F_ADD_SEALS\t\t1033\n #define F_SEAL_SHRINK\t\t0x0002\n #define F_SEAL_GROW\t\t0x0004\n #endif\n+\n+#ifndef HAVE_MEMFD_CREATE\n+int memfd_create(const char *name, unsigned int flags)\n+{\n+\treturn syscall(SYS_memfd_create, name, flags);\n+}\n #endif\n \n+} /* namespace */\n+#endif /* __DOXYGEN__ */\n+\n namespace libcamera {\n \n LOG_DECLARE_CATEGORY(File)\n@@ -72,11 +83,7 @@ LOG_DECLARE_CATEGORY(File)\n  */\n UniqueFD MemFd::create(const char *name, std::size_t size, Seals seals)\n {\n-#if HAVE_MEMFD_CREATE\n \tint ret = memfd_create(name, MFD_ALLOW_SEALING | MFD_CLOEXEC);\n-#else\n-\tint ret = syscall(SYS_memfd_create, name, MFD_ALLOW_SEALING | MFD_CLOEXEC);\n-#endif\n \tif (ret < 0) {\n \t\tret = errno;\n \t\tLOG(File, Error)\n","prefixes":["v2","2/4"]}