]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
add types compatible builtin
authorAydın Mercan <aydin@isc.org>
Tue, 3 Feb 2026 07:56:00 +0000 (10:56 +0300)
committerAydın Mercan <aydin@isc.org>
Tue, 14 Jul 2026 13:40:49 +0000 (16:40 +0300)
This builtin function makes macros gain type safety and also the ability
to statically assert the correctness of typedefs that target external
libraries.

lib/isc/include/isc/util.h

index 43026a01ef4e2b09961547fc79f0ac5835574b1d..ddfce87c32489cd5fed2826d8eb55aa8544117dd 100644 (file)
 #define __has_header(x) 0
 #endif
 
+#ifndef __has_builtin
+#define __has_builtin(x) 0
+#endif
+
 /***
  *** General Macros.
  ***/
@@ -303,3 +307,9 @@ mock_assert(const int result, const char *const expression,
                a = b;                    \
                b = __tmp_swap;           \
        }
+
+#if __has_builtin(__builtin_types_compatible_p)
+#define ISC_TYPES_COMPATIBLE(x, y) __builtin_types_compatible_p(x, y)
+#else /* __has_builtin(__builtin_types_compatible_p) */
+#define ISC_TYPES_COMPATIBLE(x, y) 1
+#endif /* __has_builtin(__builtin_types_compatible_p) */