From patchwork Fri May 3 02:52:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 19993 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id DB4D5C3220 for ; Fri, 3 May 2024 02:52:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7173F6341C; Fri, 3 May 2024 04:52:17 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="H5807v0A"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3B1796340B for ; Fri, 3 May 2024 04:52:15 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3D57D3A3 for ; Fri, 3 May 2024 04:51:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1714704677; bh=xfifvORN7LQ04rfpaGWFaVpc6JGUaYkYuRtvNU/+Vp8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=H5807v0AFHLN2JYifCwvXCaPymIYYQljQs1FsvjuHWyyOG40iKd7Wa0yGQBY+HMwT moP/No6+LR98qfjfL8flNFkrTcUzS38qKAmJZIdY1VhPhGyvkaiblmMQeaWFBfDRwn EHbnfSSKriaOyFKD+60A+PO+tC0j0Nz+TuE/arEk= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH 2/4] libcamera: shared_mem_object: Fix compilation with uClibc Date: Fri, 3 May 2024 05:52:03 +0300 Message-ID: <20240503025205.2814-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240503025205.2814-1-laurent.pinchart@ideasonboard.com> References: <20240503025205.2814-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" uClibc doesn't provide a memfd_create() implementation. Fix it by using a direct syscall when the function isn't available. Signed-off-by: Laurent Pinchart Reviewed-by: Umang Jain Reviewed-by: Stefan Klug --- meson.build | 4 ++++ src/libcamera/shared_mem_object.cpp | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/meson.build b/meson.build index 740ead1be85f..39e4947f8c97 100644 --- a/meson.build +++ b/meson.build @@ -82,6 +82,10 @@ if cc.has_header_symbol('locale.h', 'locale_t', prefix : '#define _GNU_SOURCE') config_h.set('HAVE_LOCALE_T', 1) endif +if cc.has_header_symbol('sys/mman.h', 'memfd_create', prefix : '#define _GNU_SOURCE') + config_h.set('HAVE_MEMFD_CREATE', 1) +endif + if cc.has_header_symbol('stdlib.h', 'secure_getenv', prefix : '#define _GNU_SOURCE') config_h.set('HAVE_SECURE_GETENV', 1) endif diff --git a/src/libcamera/shared_mem_object.cpp b/src/libcamera/shared_mem_object.cpp index b018fb3bc0a5..e8cb59f7a90f 100644 --- a/src/libcamera/shared_mem_object.cpp +++ b/src/libcamera/shared_mem_object.cpp @@ -12,6 +12,8 @@ #include #include +#include +#include #include #include @@ -56,7 +58,11 @@ SharedMem::SharedMem() = default; */ SharedMem::SharedMem(const std::string &name, std::size_t size) { +#if HAVE_MEMFD_CREATE int fd = memfd_create(name.c_str(), MFD_CLOEXEC); +#else + int fd = syscall(SYS_memfd_create, name.c_str(), MFD_CLOEXEC); +#endif if (fd < 0) return;