[{"id":36172,"web_url":"https://patchwork.libcamera.org/comment/36172/","msgid":"<20251008081405.GE16422@pendragon.ideasonboard.com>","date":"2025-10-08T08:14:05","subject":"Re: [PATCH v5 1/5] include: linux: Add stddef.h","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nThank you for the patch.\n\nOn Tue, Oct 07, 2025 at 08:17:43PM +0200, Jacopo Mondi wrote:\n> Import stddef.h from the Linux kernel sources v6.17 at revision\n> 3407caa69a06 (\"uapi: stddef.h: Introduce __kernel_nonstring\")\n> \n> The stddef.h header is imported to provide the __counted_by() symbol\n> which is not available in the header version shipped with, in example,\n> Debian 12.  __counted_by() will be used by the v4l2-isp.h header which\n> will be imported next.\n\nI'm happy this worked, it should be easier to maintain.\n\n> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>\n\n> ---\n>  include/linux/stddef.h         | 75 ++++++++++++++++++++++++++++++++++++++++++\n>  utils/update-kernel-headers.sh |  1 +\n>  2 files changed, 76 insertions(+)\n> \n> diff --git a/include/linux/stddef.h b/include/linux/stddef.h\n> new file mode 100644\n> index 0000000000000000000000000000000000000000..e1fcfcf3b33261939797d79f4e29a28fa1da6e10\n> --- /dev/null\n> +++ b/include/linux/stddef.h\n> @@ -0,0 +1,75 @@\n> +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */\n> +#ifndef _LINUX_STDDEF_H\n> +#define _LINUX_STDDEF_H\n> +\n> +\n> +\n> +#ifndef __always_inline\n> +#define __always_inline __inline__\n> +#endif\n> +\n> +/* Not all C++ standards support type declarations inside an anonymous union */\n> +#ifndef __cplusplus\n> +#define __struct_group_tag(TAG)\t\tTAG\n> +#else\n> +#define __struct_group_tag(TAG)\n> +#endif\n> +\n> +/**\n> + * __struct_group() - Create a mirrored named and anonyomous struct\n> + *\n> + * @TAG: The tag name for the named sub-struct (usually empty)\n> + * @NAME: The identifier name of the mirrored sub-struct\n> + * @ATTRS: Any struct attributes (usually empty)\n> + * @MEMBERS: The member declarations for the mirrored structs\n> + *\n> + * Used to create an anonymous union of two structs with identical layout\n> + * and size: one anonymous and one named. The former's members can be used\n> + * normally without sub-struct naming, and the latter can be used to\n> + * reason about the start, end, and size of the group of struct members.\n> + * The named struct can also be explicitly tagged for layer reuse (C only),\n> + * as well as both having struct attributes appended.\n> + */\n> +#define __struct_group(TAG, NAME, ATTRS, MEMBERS...) \\\n> +\tunion { \\\n> +\t\tstruct { MEMBERS } ATTRS; \\\n> +\t\tstruct __struct_group_tag(TAG) { MEMBERS } ATTRS NAME; \\\n> +\t} ATTRS\n> +\n> +#ifdef __cplusplus\n> +/* sizeof(struct{}) is 1 in C++, not 0, can't use C version of the macro. */\n> +#define __DECLARE_FLEX_ARRAY(T, member)\t\\\n> +\tT member[0]\n> +#else\n> +/**\n> + * __DECLARE_FLEX_ARRAY() - Declare a flexible array usable in a union\n> + *\n> + * @TYPE: The type of each flexible array element\n> + * @NAME: The name of the flexible array member\n> + *\n> + * In order to have a flexible array member in a union or alone in a\n> + * struct, it needs to be wrapped in an anonymous struct with at least 1\n> + * named member, but that member can be empty.\n> + */\n> +#define __DECLARE_FLEX_ARRAY(TYPE, NAME)\t\\\n> +\tstruct { \\\n> +\t\tstruct { } __empty_ ## NAME; \\\n> +\t\tTYPE NAME[]; \\\n> +\t}\n> +#endif\n> +\n> +#ifndef __counted_by\n> +#define __counted_by(m)\n> +#endif\n> +\n> +#ifndef __counted_by_le\n> +#define __counted_by_le(m)\n> +#endif\n> +\n> +#ifndef __counted_by_be\n> +#define __counted_by_be(m)\n> +#endif\n> +\n> +#define __kernel_nonstring\n> +\n> +#endif /* _LINUX_STDDEF_H */\n> diff --git a/utils/update-kernel-headers.sh b/utils/update-kernel-headers.sh\n> index 9a64dfb5698c67945ab4eee085360c1728589401..666624f9972ea61067e5b5695237ab7a17c61664 100755\n> --- a/utils/update-kernel-headers.sh\n> +++ b/utils/update-kernel-headers.sh\n> @@ -52,6 +52,7 @@ headers=\"\n>  \tlinux/media-bus-format.h\n>  \tlinux/media.h\n>  \tlinux/rkisp1-config.h\n> +\tlinux/stddef.h\n>  \tlinux/udmabuf.h\n>  \tlinux/v4l2-common.h\n>  \tlinux/v4l2-controls.h","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 93D13BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  8 Oct 2025 08:14:16 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 864676B5F3;\n\tWed,  8 Oct 2025 10:14:15 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B135A6B5A2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  8 Oct 2025 10:14:12 +0200 (CEST)","from pendragon.ideasonboard.com (82-203-166-19.bb.dnainternet.fi\n\t[82.203.166.19])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 3FEBC191B; \n\tWed,  8 Oct 2025 10:12:38 +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=\"VwSsSQiI\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1759911158;\n\tbh=ML0nQfM+pGH+thQDljUxqiEQaZwiqGmrAumIXajqUwM=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=VwSsSQiIMbYPcuwWc/G9qIvX1u7R0L6flKtlSA1QxmOHwugOCziuG5d68GpOA/yt+\n\tD9ciqNOw+gHIWjyt+ayUNY7htLYr5i1ha8/0YMiu3/fF0oxg1gBVgawSX5Wqt/6ylQ\n\tX+OKLwCPy1GUobcyoUCpEJ6LkBM6p56bMwNTVRoQ=","Date":"Wed, 8 Oct 2025 11:14:05 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v5 1/5] include: linux: Add stddef.h","Message-ID":"<20251008081405.GE16422@pendragon.ideasonboard.com>","References":"<20251007-v4l2-params-v5-0-8db451a81398@ideasonboard.com>\n\t<20251007-v4l2-params-v5-1-8db451a81398@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20251007-v4l2-params-v5-1-8db451a81398@ideasonboard.com>","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>"}},{"id":36177,"web_url":"https://patchwork.libcamera.org/comment/36177/","msgid":"<175991845936.2893472.14914077095946084904@ping.linuxembedded.co.uk>","date":"2025-10-08T10:14:19","subject":"Re: [PATCH v5 1/5] include: linux: Add stddef.h","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Jacopo Mondi (2025-10-07 19:17:43)\n> Import stddef.h from the Linux kernel sources v6.17 at revision\n> 3407caa69a06 (\"uapi: stddef.h: Introduce __kernel_nonstring\")\n> \n> The stddef.h header is imported to provide the __counted_by() symbol\n> which is not available in the header version shipped with, in example,\n> Debian 12.  __counted_by() will be used by the v4l2-isp.h header which\n> will be imported next.\n> \n> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n\nNot reviewing kernel code:\n\nAcked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> ---\n>  include/linux/stddef.h         | 75 ++++++++++++++++++++++++++++++++++++++++++\n>  utils/update-kernel-headers.sh |  1 +\n>  2 files changed, 76 insertions(+)\n> \n> diff --git a/include/linux/stddef.h b/include/linux/stddef.h\n> new file mode 100644\n> index 0000000000000000000000000000000000000000..e1fcfcf3b33261939797d79f4e29a28fa1da6e10\n> --- /dev/null\n> +++ b/include/linux/stddef.h\n> @@ -0,0 +1,75 @@\n> +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */\n> +#ifndef _LINUX_STDDEF_H\n> +#define _LINUX_STDDEF_H\n> +\n> +\n> +\n> +#ifndef __always_inline\n> +#define __always_inline __inline__\n> +#endif\n> +\n> +/* Not all C++ standards support type declarations inside an anonymous union */\n> +#ifndef __cplusplus\n> +#define __struct_group_tag(TAG)                TAG\n> +#else\n> +#define __struct_group_tag(TAG)\n> +#endif\n> +\n> +/**\n> + * __struct_group() - Create a mirrored named and anonyomous struct\n> + *\n> + * @TAG: The tag name for the named sub-struct (usually empty)\n> + * @NAME: The identifier name of the mirrored sub-struct\n> + * @ATTRS: Any struct attributes (usually empty)\n> + * @MEMBERS: The member declarations for the mirrored structs\n> + *\n> + * Used to create an anonymous union of two structs with identical layout\n> + * and size: one anonymous and one named. The former's members can be used\n> + * normally without sub-struct naming, and the latter can be used to\n> + * reason about the start, end, and size of the group of struct members.\n> + * The named struct can also be explicitly tagged for layer reuse (C only),\n> + * as well as both having struct attributes appended.\n> + */\n> +#define __struct_group(TAG, NAME, ATTRS, MEMBERS...) \\\n> +       union { \\\n> +               struct { MEMBERS } ATTRS; \\\n> +               struct __struct_group_tag(TAG) { MEMBERS } ATTRS NAME; \\\n> +       } ATTRS\n> +\n> +#ifdef __cplusplus\n> +/* sizeof(struct{}) is 1 in C++, not 0, can't use C version of the macro. */\n> +#define __DECLARE_FLEX_ARRAY(T, member)        \\\n> +       T member[0]\n> +#else\n> +/**\n> + * __DECLARE_FLEX_ARRAY() - Declare a flexible array usable in a union\n> + *\n> + * @TYPE: The type of each flexible array element\n> + * @NAME: The name of the flexible array member\n> + *\n> + * In order to have a flexible array member in a union or alone in a\n> + * struct, it needs to be wrapped in an anonymous struct with at least 1\n> + * named member, but that member can be empty.\n> + */\n> +#define __DECLARE_FLEX_ARRAY(TYPE, NAME)       \\\n> +       struct { \\\n> +               struct { } __empty_ ## NAME; \\\n> +               TYPE NAME[]; \\\n> +       }\n> +#endif\n> +\n> +#ifndef __counted_by\n> +#define __counted_by(m)\n> +#endif\n> +\n> +#ifndef __counted_by_le\n> +#define __counted_by_le(m)\n> +#endif\n> +\n> +#ifndef __counted_by_be\n> +#define __counted_by_be(m)\n> +#endif\n> +\n> +#define __kernel_nonstring\n> +\n> +#endif /* _LINUX_STDDEF_H */\n> diff --git a/utils/update-kernel-headers.sh b/utils/update-kernel-headers.sh\n> index 9a64dfb5698c67945ab4eee085360c1728589401..666624f9972ea61067e5b5695237ab7a17c61664 100755\n> --- a/utils/update-kernel-headers.sh\n> +++ b/utils/update-kernel-headers.sh\n> @@ -52,6 +52,7 @@ headers=\"\n>         linux/media-bus-format.h\n>         linux/media.h\n>         linux/rkisp1-config.h\n> +       linux/stddef.h\n>         linux/udmabuf.h\n>         linux/v4l2-common.h\n>         linux/v4l2-controls.h\n> \n> -- \n> 2.51.0\n>","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 49A92BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  8 Oct 2025 10:14:24 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E58D06B5F8;\n\tWed,  8 Oct 2025 12:14:23 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4133C6B5AA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  8 Oct 2025 12:14:22 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 4DBE8EFE;\n\tWed,  8 Oct 2025 12:12: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=\"EmyLhMSz\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1759918368;\n\tbh=7Mhph8uOu7ZXMZ5nkY/nr5y6DCqIJp63T/XdTE+0TIQ=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=EmyLhMSzgLxohvqJ/apGk555LP4aQgB9+ROM3nARSiYlDM8gcUoxJG2EYOe0TbwOp\n\toFnZ1CUaeEEZTBJ5Qanyfvw0oH0UX+HH+fXaPAUvGT/l0YaZzWMa1mZrh8zi2aQW1O\n\tZHmibgfs5g+bjeeWlL8hVpnvtmOfBDTNXfj7vhKM=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20251007-v4l2-params-v5-1-8db451a81398@ideasonboard.com>","References":"<20251007-v4l2-params-v5-0-8db451a81398@ideasonboard.com>\n\t<20251007-v4l2-params-v5-1-8db451a81398@ideasonboard.com>","Subject":"Re: [PATCH v5 1/5] include: linux: Add stddef.h","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Wed, 08 Oct 2025 11:14:19 +0100","Message-ID":"<175991845936.2893472.14914077095946084904@ping.linuxembedded.co.uk>","User-Agent":"alot/0.9.1","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>"}}]