]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
add attribute macro for counted_by
authorAydın Mercan <aydin@isc.org>
Thu, 29 May 2025 10:50:25 +0000 (10:50 +0000)
committerAydın Mercan <aydin@isc.org>
Fri, 30 May 2025 08:04:49 +0000 (08:04 +0000)
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`)

lib/isc/include/isc/attributes.h

index eb1bb53e2ede4de75e57b87e0052dc4801a65714..96d57f9f4971f69d5fcc522ce2a4f84dc802e43c 100644 (file)
 #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]]
 #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