diff --git a/meson.build b/meson.build index 60c9fc209fe..6118efc6dc1 100644 --- a/meson.build +++ b/meson.build @@ -947,7 +947,7 @@ endif # Check for GCC style builtins foreach b : ['bswap32', 'bswap64', 'clz', 'clzll', 'ctz', 'expect', 'ffs', - 'ffsll', 'popcount', 'popcountll', 'unreachable'] + 'ffsll', 'popcount', 'popcountll', 'unreachable', 'types_compatible_p'] if cc.has_function(b) pre_args += '-DHAVE___BUILTIN_@0@'.format(b.to_upper()) endif diff --git a/src/util/macros.h b/src/util/macros.h index 6856e48cdfc..9b313c172ed 100644 --- a/src/util/macros.h +++ b/src/util/macros.h @@ -57,6 +57,12 @@ # endif #endif +/** + * __builtin_types_compatible_p compat + */ +#if defined(__cplusplus) || !defined(HAVE___BUILTIN_TYPES_COMPATIBLE_P) +# define __builtin_types_compatible_p(type1, type2) (1) +#endif /** * Static (compile-time) assertion. diff --git a/src/util/u_vector.h b/src/util/u_vector.h index 8edd63895a6..dbeda5fe337 100644 --- a/src/util/u_vector.h +++ b/src/util/u_vector.h @@ -84,10 +84,6 @@ u_vector_finish(struct u_vector *queue) free(queue->data); } -#if !defined(__GNUC__) || defined(__cplusplus) -#define __builtin_types_compatible_p(t1, t2) 1 -#endif - #define u_vector_foreach(elem, queue) \ STATIC_ASSERT(__builtin_types_compatible_p(__typeof__(queue), struct u_vector *)); \ for (uint32_t __u_vector_offset = (queue)->tail; \