[PATCH v3 1/9] uapi: import VDUSE and VFIO header from v7.3-rc5 kernel

Maxime Coquelin maxime.coquelin at redhat.com
Tue Sep 29 13:41:04 CEST 2026



On 9/29/26 12:53 PM, Eugenio Pérez wrote:
> This header will be used by the Vhost library.
> 
> Including also uapi/linux/stddef.h, which defines __counted_by if the
> compiler does not support it.
> 
> Signed-off-by: Eugenio Pérez <eperezma at redhat.com>
> ---
>   kernel/linux/uapi/linux/stddef.h |  85 +++++++++++++++++++++++
>   kernel/linux/uapi/linux/vduse.h  | 115 +++++++++++++++++++++++++++++--
>   kernel/linux/uapi/linux/vfio.h   |  91 +++++++++++++++++++++++-
>   kernel/linux/uapi/version        |   2 +-
>   4 files changed, 284 insertions(+), 9 deletions(-)
>   create mode 100644 kernel/linux/uapi/linux/stddef.h
> 
> diff --git a/kernel/linux/uapi/linux/stddef.h b/kernel/linux/uapi/linux/stddef.h
> new file mode 100644
> index 000000000000..3d238e09c8f8
> --- /dev/null
> +++ b/kernel/linux/uapi/linux/stddef.h
> @@ -0,0 +1,85 @@
> +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
> +#ifndef _LINUX_STDDEF_H
> +#define _LINUX_STDDEF_H
> +
> +#ifdef __KERNEL__
> +#include <linux/compiler_types.h>
> +#endif
> +
> +#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
> +
> +#ifndef __counted_by_ptr
> +#define __counted_by_ptr(m)
> +#endif
> +
> +#ifdef __KERNEL__
> +#define __kernel_nonstring	__nonstring
> +#else
> +#define __kernel_nonstring
> +#endif
> +
> +#endif /* _LINUX_STDDEF_H */
Not give my R-by right now as this is imported from a release candidate, 
but it looks good to me.

Thanks,
Maxime



More information about the dev mailing list