From patchwork Mon Nov 16 00:50:43 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 28912 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 C2E80C3304 for ; Mon, 16 Nov 2026 00:50:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 690B16A833; Mon, 16 Nov 2026 01:50:52 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="JBuDs31f"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A84086A836 for ; Mon, 16 Nov 2026 01:50:47 +0100 (CET) Received: from killaraus.ideasonboard.com (81-175-209-152.bb.dnainternet.fi [81.175.209.152]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 135DD4BB; Mon, 16 Nov 2026 01:48:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1794790101; bh=Pp/MizQ2YcFEHM4MIYFlJU2KGx1uW45fF0UON4TXKLo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JBuDs31f0gL/Mi8lz8taCKBVQRIEXGrjS6HxMwXCjesjh+pEFbZBBLx9eItozu8Cp O/AqYbMCFZHjMU6Bn2k1EcTuDmqVgsrhpxhxwTg5q3sAEXwV8GG+gfNaqB27c9MNoA 4Ww4PJmTJBiADUDxS/Rbp1VAcvysEv/9W/Dr9Gt4= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Cc: Paul Elder , Prasanth R Subject: [PATCH v3 2/2] v4l2: v4l2_compat: Compile compat layer core with native time_t Date: Mon, 16 Nov 2026 02:50:43 +0200 Message-ID: <20261116005043.1651041-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261116005043.1651041-1-laurent.pinchart@ideasonboard.com> References: <20261116005043.1651041-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" On 32-bit systems, the whole libcamera V4L2 compatibility layer is compiled with 32-bit time_t as a consequence of disabling transparent large file support that in turn requires undefining _TIME_BITS. The compatibility layer ends up using the 32-bit time_t layout of V4L2 ioctl structures. This breaks applications compiled with 64-bit time_t support. Fixing this for all use cases requires translating between structures that use 32-bit and 64-bit time_t. A simpler partial solution is however possible for the most common cases. Transparent large file support and time_t impact different parts of the V4L2 compatibility layer. The former is only needed in the entry points, handled in v4l2_compat.cpp, while the latter only impacts the V4L2 ioctl handlers in v4l2_camera_proxy.cpp. We can compile the entry points with transparent large file support disabled (and therefore with 32-bit time_t), and the rest of the compatibility later with the system defaults. Applications using the same time_t size as the system default will work correctly. Two cases will still be unsupported: - Applications using 64-bit time_t on a 32-bit time_t system - Applications using 32-bit time_t on a 64-bit time_t system The former should be very rare, as systems are transitioning to 64-bit time_t. The latter is likely less rare, but is still not a very common use case. Implement the simpler fix for the time being. If hybrid time_t use cases need to be supported, translation between ioctl structures will be implemented. Closes: https://gitlab.freedesktop.org/camera/libcamera/-/issues/290 Signed-off-by: Laurent Pinchart --- src/v4l2/meson.build | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/v4l2/meson.build b/src/v4l2/meson.build index 2c0404147183..8674040f121f 100644 --- a/src/v4l2/meson.build +++ b/src/v4l2/meson.build @@ -10,10 +10,13 @@ v4l2_compat_sources = files([ 'v4l2_camera.cpp', 'v4l2_camera_file.cpp', 'v4l2_camera_proxy.cpp', - 'v4l2_compat.cpp', 'v4l2_compat_manager.cpp', ]) +v4l2_compat_cpp_sources = files([ + 'v4l2_compat.cpp', +]) + v4l2_compat_cpp_args = [ # Meson enables large file support unconditionally, which redirect file # operations to 64-bit versions. This results in some symbols being @@ -27,9 +30,16 @@ v4l2_compat_cpp_args = [ '-fvisibility=hidden', ] + +v4l2_compat_core = static_library('v4l2-compat-core', + v4l2_compat_sources, + install : false, + dependencies : [libcamera_private, libdl]) + v4l2_compat = shared_library('v4l2-compat', - v4l2_compat_sources, + v4l2_compat_cpp_sources, name_prefix : '', + link_with : v4l2_compat_core, install : true, install_dir : libcamera_libexecdir, dependencies : [libcamera_private, libdl],