From patchwork Mon Dec 15 15:11:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 25561 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 20778C3257 for ; Mon, 15 Dec 2025 15:11:44 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0B510619EB; Mon, 15 Dec 2025 16:11:42 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="MOtdKtdE"; 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 0308E615B2 for ; Mon, 15 Dec 2025 16:11:39 +0100 (CET) Received: from [192.168.0.172] (mob-5-90-49-39.net.vodafone.it [5.90.49.39]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id CDAD4C6F; Mon, 15 Dec 2025 16:11:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1765811493; bh=m3or9HIkWJobjJdq2zdmxOw+i/OpN5p1+9z80dhX+DQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=MOtdKtdEzudioupXC7JQBFJEenCXuHP3Hy5dETRvPnTR11IfvWtPhRme1GwaVLUl5 pG9u7g08+0GMiOKUut/EsIgTB4Gu9q+WdPC/oNgQzBTJbwikJTcvufnW1Wkl2UWnHq gW0rb9PYZXwzM8Nzy/QhTFPYF/p3ZkOFBGa1Rx1Q= From: Jacopo Mondi Date: Mon, 15 Dec 2025 16:11:21 +0100 Subject: [PATCH v7 1/5] include: linux: Add stddef.h MIME-Version: 1.0 Message-Id: <20251215-v4l2-params-v7-1-be2b8c75ad09@ideasonboard.com> References: <20251215-v4l2-params-v7-0-be2b8c75ad09@ideasonboard.com> In-Reply-To: <20251215-v4l2-params-v7-0-be2b8c75ad09@ideasonboard.com> To: libcamera-devel@lists.libcamera.org Cc: Jacopo Mondi , Laurent Pinchart , Kieran Bingham X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3730; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=m3or9HIkWJobjJdq2zdmxOw+i/OpN5p1+9z80dhX+DQ=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBpQCUn3Q0CxREFQNxWByabrrQYoeCGyd+aVbOi6 GT9lTKWCkCJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaUAlJwAKCRByNAaPFqFW PPrFD/9PKqBmvoS7WHM1VCGptbuMl2EZ7y+SELaLufpp5+/WgcXDLEw5nwu8+9sxltC9/dM5b1E rx5JZX903YJMIvJsKqv/S1K5kTAvBAO24Wg0Di3PHL9ebQGBhKp9HFO+xbDBpbWlY5xxU9iVLlV tsgkGwIEPeMgpKez3euxAnl3xMAYiY2jrSByNv5D3LM2xGXQyJznK3803Y+iXoFZ/yI+XmivwRI Vsz7ZO3k3B1DRXxle3IDrCaHlS8uLm6ZCHJmsXLfA9q2lMA2ffTjnSAVtXrQcDof2L9xRYZJVbN /jktImcM20Wnmrbky79gVt8VcKrSR+EHLpy0FY96Jcyez+t1xzAPWV+5Yfm5mzeoOlHhqk8SVHs RHDqw5jL48OyI6sncKSFYGIGVJZuuPk5SxbJJ/Xa50RgJU9q5tpXDzuQMWIVAmsrHevwNjnQZhp uSDRzRzvcyN55ZJ25sYU9t5M5WA8A8cjeKvNvAydZzE5+TdmYlbQVjIJ4RVNfmeo66wYDTh8+Zm ZvzSTPZEwE6mRNbP5nb1wDqkx09IZFT1TLzYHMPd6/XSniv0XaBPmMzGwIJ7le6djHZf60BzVco smBpDtiHPas27V0QlHzkeRbVKIifiHCz//n0gaLXK1fwI/V5i3mJUp85WG3Yy4gv9E8QP3KQYSS 17HldJ/MyUl9ryg== X-Developer-Key: i=jacopo.mondi@ideasonboard.com; a=openpgp; fpr=72392EDC88144A65C701EA9BA5826A2587AD026B 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" Import stddef.h from the Linux kernel sources v6.19-rc1 at revision c2a756891bb4 ("uapi: wrap compiler_types.h in an ifdef instead of the implicit strip") The stddef.h header is imported to provide the __counted_by() symbol which is not available in the header version shipped with, in example, Debian 12. __counted_by() will be used by the v4l2-isp.h header which will be imported next. Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart Acked-by: Kieran Bingham --- include/linux/stddef.h | 74 ++++++++++++++++++++++++++++++++++++++++++ utils/update-kernel-headers.sh | 1 + 2 files changed, 75 insertions(+) diff --git a/include/linux/stddef.h b/include/linux/stddef.h new file mode 100644 index 0000000000000000000000000000000000000000..48ee4438e0ef053680c64af21553e8180ce5fdee --- /dev/null +++ b/include/linux/stddef.h @@ -0,0 +1,74 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _LINUX_STDDEF_H +#define _LINUX_STDDEF_H + + +#ifndef __always_inline +#define __always_inline __inline__ +#endif + +/* Not all C++ standards support type declarations inside an anonymous union */ +#ifndef __cplusplus +#define __struct_group_tag(TAG) TAG +#else +#define __struct_group_tag(TAG) +#endif + +/** + * __struct_group() - Create a mirrored named and anonyomous struct + * + * @TAG: The tag name for the named sub-struct (usually empty) + * @NAME: The identifier name of the mirrored sub-struct + * @ATTRS: Any struct attributes (usually empty) + * @MEMBERS: The member declarations for the mirrored structs + * + * Used to create an anonymous union of two structs with identical layout + * and size: one anonymous and one named. The former's members can be used + * normally without sub-struct naming, and the latter can be used to + * reason about the start, end, and size of the group of struct members. + * The named struct can also be explicitly tagged for layer reuse (C only), + * as well as both having struct attributes appended. + */ +#define __struct_group(TAG, NAME, ATTRS, MEMBERS...) \ + union { \ + struct { MEMBERS } ATTRS; \ + struct __struct_group_tag(TAG) { MEMBERS } ATTRS NAME; \ + } ATTRS + +#ifdef __cplusplus +/* sizeof(struct{}) is 1 in C++, not 0, can't use C version of the macro. */ +#define __DECLARE_FLEX_ARRAY(T, member) \ + T member[0] +#else +/** + * __DECLARE_FLEX_ARRAY() - Declare a flexible array usable in a union + * + * @TYPE: The type of each flexible array element + * @NAME: The name of the flexible array member + * + * In order to have a flexible array member in a union or alone in a + * struct, it needs to be wrapped in an anonymous struct with at least 1 + * named member, but that member can be empty. + */ +#define __DECLARE_FLEX_ARRAY(TYPE, NAME) \ + struct { \ + struct { } __empty_ ## NAME; \ + TYPE NAME[]; \ + } +#endif + +#ifndef __counted_by +#define __counted_by(m) +#endif + +#ifndef __counted_by_le +#define __counted_by_le(m) +#endif + +#ifndef __counted_by_be +#define __counted_by_be(m) +#endif + +#define __kernel_nonstring + +#endif /* _LINUX_STDDEF_H */ diff --git a/utils/update-kernel-headers.sh b/utils/update-kernel-headers.sh index f298a2aeaea7063a655554178f4086ca8ae658ac..3d402de24b207b3b7b181f8b7335965a2f74cff4 100755 --- a/utils/update-kernel-headers.sh +++ b/utils/update-kernel-headers.sh @@ -53,6 +53,7 @@ headers=" linux/media-bus-format.h linux/media.h linux/rkisp1-config.h + linux/stddef.h linux/udmabuf.h linux/v4l2-common.h linux/v4l2-controls.h