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
This commit is contained in:
Emmanuel Vadot 2020-05-25 12:42:55 +00:00
parent 5a90435ccf
commit 93d70cd3fe

View file

@ -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_ */