From patchwork Tue Oct 7 18:17:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 24570 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 7A265C3261 for ; Tue, 7 Oct 2025 18:18:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7A0376B60F; Tue, 7 Oct 2025 20:17:59 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="YkAgKg7r"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 623D76B5F3 for ; Tue, 7 Oct 2025 20:17:54 +0200 (CEST) Received: from [192.168.1.102] (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C0BFD669; Tue, 7 Oct 2025 20:16:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1759860979; bh=TtWVFnMFJ/ExZHiAIMDGhM/eIx0kluRm82fE3S71cS0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=YkAgKg7r7zk7vvaqTITRTTSwmo0Ee5dZxtRrIIz1VPWojQw50GUTVV+gLOfOvePs0 LeGC/KL1+JTI23BEsNLpekAt7Lj5ytrfx3LpKqG7+vcwIhpYK6W/3W34avn2eWC3MM LY6RTPWgyl8fBtH+tfwTagH+Vrb6NnuI1gWG0U88= From: Jacopo Mondi Date: Tue, 07 Oct 2025 20:17:43 +0200 Subject: [PATCH v5 1/5] include: linux: Add stddef.h MIME-Version: 1.0 Message-Id: <20251007-v4l2-params-v5-1-8db451a81398@ideasonboard.com> References: <20251007-v4l2-params-v5-0-8db451a81398@ideasonboard.com> In-Reply-To: <20251007-v4l2-params-v5-0-8db451a81398@ideasonboard.com> To: libcamera-devel@lists.libcamera.org Cc: Jacopo Mondi X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3568; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=TtWVFnMFJ/ExZHiAIMDGhM/eIx0kluRm82fE3S71cS0=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBo5VlPmrmUhHxZPIGRGpCHD0pdOc4c5CvRgwAzC Bp7sSeRWXGJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaOVZTwAKCRByNAaPFqFW POrFEACDeqZz9XIw98Yw+CvFLPLnyNUvxoz7xUqCx8FkKXoPB+eHnvPwJwbxXGkbDzag4g0euEQ yq3k2Ef5IKIizT0MBSrt3PF9vvJHrZjONBBHUJOwZHMHMUQu43hEagl0sZ8F3pHXjBgDPYQ5Amh /dW5d7/BWOkPIknZ7O3z91CmIArs19zoJRjxXT3sRnUoLIShrAE0L+RPlJ0CEAKy/mjjaREwFdx 0c1Ece17uaEr+5mF/Dj1O66EB07Mo70T9SQMTwVATtbxDCxxqa3FNyneMe5KGQQI/RYwvqIC6So MmQiCEcemibhcePGDjQVw5wT1BZAjqzCGjF039a9b41j85jCBUKuvb+WQmYJmHnTKLVz8s5nkb/ IAjenYtDDegzoRIMopFCQYUqdouBbHLBPqKswoFZQzQ33h+8WBE/GamOSZsqWs+I4ziedwX9XNg qvxShgRMM74Rc2DMnndesDAuT3bPO6qSD50wRtI7Y/AKhMBbHstPL9daWKG9RnZAnDsqg5rEnSp dmBPMHKe1cXc+vFC0Q/9vuPTno9Aj8JlTMBlH5UPrvxCzYqP261yi/bFnc3iWLqi0TtuqAZ1Rjx PHGEAiBlcWV7lB8B4E+dTDtsA2u2P2+ICM5Pql+M1T4HYE9YKJEBOZ2dCZrBxhliBfJUR35s5Vh SD8RSV5EUxf5CkA== 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.17 at revision 3407caa69a06 ("uapi: stddef.h: Introduce __kernel_nonstring") 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 --- include/linux/stddef.h | 75 ++++++++++++++++++++++++++++++++++++++++++ utils/update-kernel-headers.sh | 1 + 2 files changed, 76 insertions(+) diff --git a/include/linux/stddef.h b/include/linux/stddef.h new file mode 100644 index 0000000000000000000000000000000000000000..e1fcfcf3b33261939797d79f4e29a28fa1da6e10 --- /dev/null +++ b/include/linux/stddef.h @@ -0,0 +1,75 @@ +/* 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 9a64dfb5698c67945ab4eee085360c1728589401..666624f9972ea61067e5b5695237ab7a17c61664 100755 --- a/utils/update-kernel-headers.sh +++ b/utils/update-kernel-headers.sh @@ -52,6 +52,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