[{"id":29409,"web_url":"https://patchwork.libcamera.org/comment/29409/","msgid":"<a2428124-91a0-43da-ad69-adf491e301c2@ideasonboard.com>","date":"2024-05-03T06:54:17","subject":"Re: [PATCH 2/4] libcamera: shared_mem_object: Fix compilation with\n\tuClibc","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/people/86/","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"content":"Hi Laurent,\n\nThank you for the patch\n\nOn 03/05/24 8:22 am, Laurent Pinchart wrote:\n> uClibc doesn't provide a memfd_create() implementation. Fix it by using\n> a direct syscall when the function isn't available.\n>\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Umang Jain <umang.jain@ideasonboard.com>\n> ---\n>   meson.build                         | 4 ++++\n>   src/libcamera/shared_mem_object.cpp | 6 ++++++\n>   2 files changed, 10 insertions(+)\n>\n> diff --git a/meson.build b/meson.build\n> index 740ead1be85f..39e4947f8c97 100644\n> --- a/meson.build\n> +++ b/meson.build\n> @@ -82,6 +82,10 @@ if cc.has_header_symbol('locale.h', 'locale_t', prefix : '#define _GNU_SOURCE')\n>       config_h.set('HAVE_LOCALE_T', 1)\n>   endif\n>   \n> +if cc.has_header_symbol('sys/mman.h', 'memfd_create', prefix : '#define _GNU_SOURCE')\n> +    config_h.set('HAVE_MEMFD_CREATE', 1)\n> +endif\n> +\n>   if cc.has_header_symbol('stdlib.h', 'secure_getenv', prefix : '#define _GNU_SOURCE')\n>       config_h.set('HAVE_SECURE_GETENV', 1)\n>   endif\n> diff --git a/src/libcamera/shared_mem_object.cpp b/src/libcamera/shared_mem_object.cpp\n> index b018fb3bc0a5..e8cb59f7a90f 100644\n> --- a/src/libcamera/shared_mem_object.cpp\n> +++ b/src/libcamera/shared_mem_object.cpp\n> @@ -12,6 +12,8 @@\n>   \n>   #include <stddef.h>\n>   #include <stdint.h>\n> +#include <sys/mman.h>\n> +#include <sys/syscall.h>\n>   #include <sys/types.h>\n>   #include <unistd.h>\n>   \n> @@ -56,7 +58,11 @@ SharedMem::SharedMem() = default;\n>    */\n>   SharedMem::SharedMem(const std::string &name, std::size_t size)\n>   {\n> +#if HAVE_MEMFD_CREATE\n>   \tint fd = memfd_create(name.c_str(), MFD_CLOEXEC);\n> +#else\n> +\tint fd = syscall(SYS_memfd_create, name.c_str(), MFD_CLOEXEC);\n> +#endif\n>   \tif (fd < 0)\n>   \t\treturn;\n>","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 CBF36BDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  3 May 2024 06:54:25 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 05A956340B;\n\tFri,  3 May 2024 08:54:25 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B7DD562C9F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  3 May 2024 08:54:23 +0200 (CEST)","from [192.168.1.105] (unknown [103.251.226.40])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B68452E7;\n\tFri,  3 May 2024 08:53:24 +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=\"hlYJ+prA\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1714719205;\n\tbh=eGdsBG622FAarOJwNhxk4Id4vKdV0wBPk5B7HnNOUVc=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=hlYJ+prAt9s3uqlbQMEA2QZIEVxzGSj8EHp9JOifEuXWm0+tKnOfZPuOxvUXBVAMH\n\t5vqHiXVNZbZMFRYt978fJbXaNmH3nbX23ls48IjLZjQaRGQGrtRVKaJOdexjfRxvGB\n\t/tJB24WGWoj+fHQrlTd+3UgxQ61/FdB8lhdlh6eM=","Message-ID":"<a2428124-91a0-43da-ad69-adf491e301c2@ideasonboard.com>","Date":"Fri, 3 May 2024 12:24:17 +0530","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH 2/4] libcamera: shared_mem_object: Fix compilation with\n\tuClibc","Content-Language":"en-US","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20240503025205.2814-1-laurent.pinchart@ideasonboard.com>\n\t<20240503025205.2814-3-laurent.pinchart@ideasonboard.com>","From":"Umang Jain <umang.jain@ideasonboard.com>","In-Reply-To":"<20240503025205.2814-3-laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","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>"}},{"id":29417,"web_url":"https://patchwork.libcamera.org/comment/29417/","msgid":"<20240503144134.iufpc5bnfgl2cegx@jasper>","date":"2024-05-03T14:41:34","subject":"Re: [PATCH 2/4] libcamera: shared_mem_object: Fix compilation with\n\tuClibc","submitter":{"id":184,"url":"https://patchwork.libcamera.org/api/people/184/","name":"Stefan Klug","email":"stefan.klug@ideasonboard.com"},"content":"Hi Laurent,\n\nthanks for the patch.\n\nOn Fri, May 03, 2024 at 05:52:03AM +0300, Laurent Pinchart wrote:\n> uClibc doesn't provide a memfd_create() implementation. Fix it by using\n\nAhh that answeres my previous question :-)\n\n> a direct syscall when the function isn't available.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Stefan Klug <stefan.klug@ideasonboard.com> \n\nCheers,\nStefan\n\n> ---\n>  meson.build                         | 4 ++++\n>  src/libcamera/shared_mem_object.cpp | 6 ++++++\n>  2 files changed, 10 insertions(+)\n> \n> diff --git a/meson.build b/meson.build\n> index 740ead1be85f..39e4947f8c97 100644\n> --- a/meson.build\n> +++ b/meson.build\n> @@ -82,6 +82,10 @@ if cc.has_header_symbol('locale.h', 'locale_t', prefix : '#define _GNU_SOURCE')\n>      config_h.set('HAVE_LOCALE_T', 1)\n>  endif\n>  \n> +if cc.has_header_symbol('sys/mman.h', 'memfd_create', prefix : '#define _GNU_SOURCE')\n> +    config_h.set('HAVE_MEMFD_CREATE', 1)\n> +endif\n> +\n>  if cc.has_header_symbol('stdlib.h', 'secure_getenv', prefix : '#define _GNU_SOURCE')\n>      config_h.set('HAVE_SECURE_GETENV', 1)\n>  endif\n> diff --git a/src/libcamera/shared_mem_object.cpp b/src/libcamera/shared_mem_object.cpp\n> index b018fb3bc0a5..e8cb59f7a90f 100644\n> --- a/src/libcamera/shared_mem_object.cpp\n> +++ b/src/libcamera/shared_mem_object.cpp\n> @@ -12,6 +12,8 @@\n>  \n>  #include <stddef.h>\n>  #include <stdint.h>\n> +#include <sys/mman.h>\n> +#include <sys/syscall.h>\n>  #include <sys/types.h>\n>  #include <unistd.h>\n>  \n> @@ -56,7 +58,11 @@ SharedMem::SharedMem() = default;\n>   */\n>  SharedMem::SharedMem(const std::string &name, std::size_t size)\n>  {\n> +#if HAVE_MEMFD_CREATE\n>  \tint fd = memfd_create(name.c_str(), MFD_CLOEXEC);\n> +#else\n> +\tint fd = syscall(SYS_memfd_create, name.c_str(), MFD_CLOEXEC);\n> +#endif\n>  \tif (fd < 0)\n>  \t\treturn;\n>  \n> -- \n> Regards,\n> \n> Laurent Pinchart\n>","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 9CCEBBDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  3 May 2024 14:41:40 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9B0C963415;\n\tFri,  3 May 2024 16:41:39 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5B6F061A8A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  3 May 2024 16:41:37 +0200 (CEST)","from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:723:3164:ef7b:46ca])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0004C675;\n\tFri,  3 May 2024 16:40:38 +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=\"GmEKKWH0\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1714747239;\n\tbh=hzMC4jqlKjC0RaGvYfpDBSNUhFJIsEeytSaS5KuE+04=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=GmEKKWH0QG4ZJxlAwhsb+gyXO3pglYyMyXo/JpkPiPuQz1pgFi1QoHpWTnGGclVt7\n\ttXIudUO46gLhwJNQZMBgpHtdHEMr5lqqxMkEwu5mmgdkIHmBj3HaxdwX/MiWu6qofD\n\tXh+2Uzg9c1qP6LEoVBhcyia7LbZcjImtClP6XPRU=","Date":"Fri, 3 May 2024 16:41:34 +0200","From":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH 2/4] libcamera: shared_mem_object: Fix compilation with\n\tuClibc","Message-ID":"<20240503144134.iufpc5bnfgl2cegx@jasper>","References":"<20240503025205.2814-1-laurent.pinchart@ideasonboard.com>\n\t<20240503025205.2814-3-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20240503025205.2814-3-laurent.pinchart@ideasonboard.com>","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>"}}]