From 93d70cd3feca4c75a518346e1e20d5df52b53ebf Mon Sep 17 00:00:00 2001 From: Emmanuel Vadot Date: Mon, 25 May 2020 12:42:55 +0000 Subject: [PATCH] linuxkpi: Add __same_type and __must_be_array macros The same_type macro simply wraps around builtin_types_compatible_p which exist for both GCC and CLANG, which returns 1 if both types are the same. The __must_be_array macros returns 1 if the argument is an array. This is needed for DRM v5.3 Sponsored-by: The FreeBSD Foundation Reviewed by: hselasky Differential Revision: https://reviews.freebsd.org/D24953 --- sys/compat/linuxkpi/common/include/linux/compiler.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/compiler.h b/sys/compat/linuxkpi/common/include/linux/compiler.h index b1fa12754f7..1177674aa68 100644 --- a/sys/compat/linuxkpi/common/include/linux/compiler.h +++ b/sys/compat/linuxkpi/common/include/linux/compiler.h @@ -111,4 +111,7 @@ #define _AT(T,X) ((T)(X)) +#define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b)) +#define __must_be_array(a) __same_type(a, &(a)[0]) + #endif /* _LINUX_COMPILER_H_ */