From: Mark Andrews Date: Wed, 27 Apr 2022 20:56:56 +0000 (+1000) Subject: Define local instances of FALLTHROUGH and UNREACHABLE X-Git-Tag: v9.19.1~31^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6d68a22954e6101f817dfbe9bc17d2e2a7782744;p=thirdparty%2Fbind9.git Define local instances of FALLTHROUGH and UNREACHABLE FALLTHOUGH is a copy of how it is defined in UNREACHABLE follows the model used in MacOS /usr/include/c++/v1/cstdlib to determine if __builtin_ureachable is available --- diff --git a/contrib/dlz/modules/include/dlz_minimal.h b/contrib/dlz/modules/include/dlz_minimal.h index 24ef250059f..4f77dbba45f 100644 --- a/contrib/dlz/modules/include/dlz_minimal.h +++ b/contrib/dlz/modules/include/dlz_minimal.h @@ -27,6 +27,7 @@ #include #include +#include #include #include @@ -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;