From: Aydın Mercan Date: Thu, 29 May 2025 10:50:25 +0000 (+0000) Subject: add attribute macro for counted_by X-Git-Tag: v9.21.9~20^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=23d70bde6c027a44d5d82a6120f3f8211edc3f52;p=thirdparty%2Fbind9.git add attribute macro for counted_by Using C23 attributes for `counted_by` is broken with clang. `__has_attribute` is used since `__has_c_attribute` only works with C23 attributes, (`gnu::counted_by`/`clang::counted_by`) --- diff --git a/lib/isc/include/isc/attributes.h b/lib/isc/include/isc/attributes.h index eb1bb53e2ed..96d57f9f497 100644 --- a/lib/isc/include/isc/attributes.h +++ b/lib/isc/include/isc/attributes.h @@ -14,12 +14,16 @@ #pragma once /*** - *** Clang Compatibility Macros + *** Attribute Compatibility Macros ***/ -#if !defined(__has_c_attribute) +#ifndef __has_c_attribute #define __has_c_attribute(x) 0 -#endif /* if !defined(__has_c_attribute) */ +#endif /* __has_c_attribute */ + +#ifndef __has_attribute +#define __has_attribute(x) 0 +#endif /* __has_attribute */ #if __has_c_attribute(noreturn) && __STDC_VERSION__ >= 202311L #define ISC_NORETURN [[noreturn]] @@ -102,3 +106,9 @@ #else #define ISC_ATTR_UNUSED __attribute__((__unused__)) #endif + +#if __has_attribute(__counted_by__) +#define ISC_ATTR_COUNTED_BY(x) __attribute__((__counted_by__(x))) +#else +#define ISC_ATTR_COUNTED_BY(x) +#endif