{"id":20696,"url":"https://patchwork.libcamera.org/api/1.1/patches/20696/?format=json","web_url":"https://patchwork.libcamera.org/patch/20696/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20240721213111.24638-1-laurent.pinchart@ideasonboard.com>","date":"2024-07-21T21:31:11","name":"v4l2: v4l2_compat: Fix ioctl() prototype with musl C library","commit_ref":"83b3141178282b11665c4485a33b9bc3e61d7c18","pull_url":null,"state":"accepted","archived":false,"hash":"2612772530112a101730db215d44d27483c4a1da","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/20696/mbox/","series":[{"id":4456,"url":"https://patchwork.libcamera.org/api/1.1/series/4456/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4456","date":"2024-07-21T21:31:11","name":"v4l2: v4l2_compat: Fix ioctl() prototype with musl C library","version":1,"mbox":"https://patchwork.libcamera.org/series/4456/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/20696/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/20696/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 994A2BDB1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 21 Jul 2024 21:31:32 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 628B26336F;\n\tSun, 21 Jul 2024 23:31:31 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 77F916336B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 21 Jul 2024 23:31:29 +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 4E650B3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 21 Jul 2024 23:30:48 +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=\"vNRZHw/z\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1721597448;\n\tbh=9JNQehAUn7ZMiGBJ4vaHqaQfO8q5lkqsWrJVWNmE/qc=;\n\th=From:To:Subject:Date:From;\n\tb=vNRZHw/zrX2/XfCHg3VMYccv/SteGb45EtWbzryHuo3RKaF1JcXaI67BCxUk0tbF2\n\tQC7oXXdpnJ9H3jaWv2j+UDc/I0VLJfmQctu9pQ/aJF2cZkzAcIqkrX12jM0rT9GTlr\n\tweF/5gr844E3Jsd+0FEqwywVT+0lE7B03ONLT21o=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Subject":"[PATCH] v4l2: v4l2_compat: Fix ioctl() prototype with musl C library","Date":"Mon, 22 Jul 2024 00:31:11 +0300","Message-ID":"<20240721213111.24638-1-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.44.2","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":"The musl C library, as well as the POSIX standard, define the ioctl()\nfunction's request argument as an int. glibc and uclibc, on the other\nhand, define it as an unsigned long.\n\nThis difference between the function prototype and the implementation in\nthe V4L2 adaptation layer causes a compilation error with musl. Fix it\nby detecting the function prototype and declaring the libcamera ioctl()\nhandler accordingly.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n meson.build              | 9 +++++++++\n src/v4l2/v4l2_compat.cpp | 4 ++++\n 2 files changed, 13 insertions(+)\n\n\nbase-commit: 4661a7eedf81f00212956f0d396196b3eb4a417b","diff":"diff --git a/meson.build b/meson.build\nindex 2acd8c3e8cfe..ccd766a1e98c 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -90,6 +90,15 @@ if cc.has_header_symbol('sys/mman.h', 'memfd_create', prefix : '#define _GNU_SOU\n     config_h.set('HAVE_MEMFD_CREATE', 1)\n endif\n \n+ioctl_posix_test = '''\n+#include <sys/ioctl.h>\n+int ioctl (int, int, ...);\n+'''\n+\n+if cc.compiles(ioctl_posix_test)\n+    config_h.set('HAVE_POSIX_IOCTL', 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\ndiff --git a/src/v4l2/v4l2_compat.cpp b/src/v4l2/v4l2_compat.cpp\nindex 66468bf38d5b..6c9dca7201a3 100644\n--- a/src/v4l2/v4l2_compat.cpp\n+++ b/src/v4l2/v4l2_compat.cpp\n@@ -154,7 +154,11 @@ LIBCAMERA_PUBLIC int munmap(void *addr, size_t length)\n \treturn V4L2CompatManager::instance()->munmap(addr, length);\n }\n \n+#if HAVE_POSIX_IOCTL\n+LIBCAMERA_PUBLIC int ioctl(int fd, int request, ...)\n+#else\n LIBCAMERA_PUBLIC int ioctl(int fd, unsigned long request, ...)\n+#endif\n {\n \tvoid *arg;\n \textract_va_arg(void *, arg, request);\n","prefixes":[]}