From patchwork Sun Jul 21 21:31:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 20696 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 994A2BDB1C for ; Sun, 21 Jul 2024 21:31:32 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 628B26336F; Sun, 21 Jul 2024 23:31:31 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="vNRZHw/z"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 77F916336B for ; Sun, 21 Jul 2024 23:31:29 +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 4E650B3 for ; Sun, 21 Jul 2024 23:30:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1721597448; bh=9JNQehAUn7ZMiGBJ4vaHqaQfO8q5lkqsWrJVWNmE/qc=; h=From:To:Subject:Date:From; b=vNRZHw/zrX2/XfCHg3VMYccv/SteGb45EtWbzryHuo3RKaF1JcXaI67BCxUk0tbF2 QC7oXXdpnJ9H3jaWv2j+UDc/I0VLJfmQctu9pQ/aJF2cZkzAcIqkrX12jM0rT9GTlr weF/5gr844E3Jsd+0FEqwywVT+0lE7B03ONLT21o= From: Laurent Pinchart 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 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" The musl C library, as well as the POSIX standard, define the ioctl() function's request argument as an int. glibc and uclibc, on the other hand, define it as an unsigned long. This difference between the function prototype and the implementation in the V4L2 adaptation layer causes a compilation error with musl. Fix it by detecting the function prototype and declaring the libcamera ioctl() handler accordingly. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Paul Elder --- meson.build | 9 +++++++++ src/v4l2/v4l2_compat.cpp | 4 ++++ 2 files changed, 13 insertions(+) base-commit: 4661a7eedf81f00212956f0d396196b3eb4a417b diff --git a/meson.build b/meson.build index 2acd8c3e8cfe..ccd766a1e98c 100644 --- a/meson.build +++ b/meson.build @@ -90,6 +90,15 @@ if cc.has_header_symbol('sys/mman.h', 'memfd_create', prefix : '#define _GNU_SOU config_h.set('HAVE_MEMFD_CREATE', 1) endif +ioctl_posix_test = ''' +#include +int ioctl (int, int, ...); +''' + +if cc.compiles(ioctl_posix_test) + config_h.set('HAVE_POSIX_IOCTL', 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/v4l2/v4l2_compat.cpp b/src/v4l2/v4l2_compat.cpp index 66468bf38d5b..6c9dca7201a3 100644 --- a/src/v4l2/v4l2_compat.cpp +++ b/src/v4l2/v4l2_compat.cpp @@ -154,7 +154,11 @@ LIBCAMERA_PUBLIC int munmap(void *addr, size_t length) return V4L2CompatManager::instance()->munmap(addr, length); } +#if HAVE_POSIX_IOCTL +LIBCAMERA_PUBLIC int ioctl(int fd, int request, ...) +#else LIBCAMERA_PUBLIC int ioctl(int fd, unsigned long request, ...) +#endif { void *arg; extract_va_arg(void *, arg, request);