]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Define local instances of FALLTHROUGH and UNREACHABLE
authorMark Andrews <marka@isc.org>
Wed, 27 Apr 2022 20:56:56 +0000 (06:56 +1000)
committerMark Andrews <marka@isc.org>
Fri, 29 Apr 2022 00:12:46 +0000 (10:12 +1000)
FALLTHOUGH is a copy of how it is defined in <isc/util.h>

UNREACHABLE follows the model used in MacOS /usr/include/c++/v1/cstdlib
to determine if __builtin_ureachable is available

contrib/dlz/modules/include/dlz_minimal.h

index 24ef250059ff7e77976d579211ac8f5d3807f338..4f77dbba45ff6d010cef076654509d436da4aafc 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <inttypes.h>
 #include <stdbool.h>
+#include <stdlib.h>
 
 #include <arpa/inet.h>
 #include <net/if.h>
@@ -85,6 +86,24 @@ typedef uint32_t     dns_ttl_t;
                var = _u.v;            \
        } while (0)
 
+#if !defined(__has_attribute)
+#define __has_attribute(x) 0
+#endif /* if !defined(__has_attribute) */
+
+#if __GNUC__ >= 7 || __has_attribute(fallthrough)
+#define FALLTHROUGH __attribute__((fallthrough))
+#else
+/* clang-format off */
+#define FALLTHROUGH do {} while (0) /* FALLTHROUGH */
+/* clang-format on */
+#endif
+
+#ifdef __GNUC__
+#define UNREACHABLE() __builtin_unreachable()
+#else
+#define UNREACHABLE() abort()
+#endif
+
 /* opaque structures */
 typedef void *dns_sdlzlookup_t;
 typedef void *dns_sdlzallnodes_t;