util: Promote __builtin_types_compatible_p compat
authorRob Clark <robdclark@chromium.org>
Sat, 5 Dec 2020 19:26:44 +0000 (11:26 -0800)
committerMarge Bot <eric+marge@anholt.net>
Thu, 10 Dec 2020 16:48:36 +0000 (16:48 +0000)
Signed-off-by: Rob Clark <robdclark@chromium.org>
Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7941>

meson.build
src/util/macros.h
src/util/u_vector.h

index 60c9fc2..6118efc 100644 (file)
@@ -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
index 6856e48..9b313c1 100644 (file)
 #  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.
index 8edd638..dbeda5f 100644 (file)
@@ -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;                                \