ISC_INSIST(_refs > 0); \
} while (0)
-#define ISC_REFCOUNT_TRACE_DECL(name) \
- name##_t *name##__ref(name##_t *ptr, const char *func, \
- const char *file, unsigned int line); \
- void name##__unref(name##_t *ptr, const char *func, const char *file, \
- unsigned int line); \
- void name##__attach(name##_t *ptr, name##_t **ptrp, const char *func, \
- const char *file, unsigned int line); \
- void name##__detach(name##_t **ptrp, const char *func, \
- const char *file, unsigned int line)
-
-#define ISC_REFCOUNT_TRACE_IMPL(name, destroy) \
- name##_t *name##__ref(name##_t *ptr, const char *func, \
- const char *file, unsigned int line) { \
+#define ISC__REFCOUNT_TRACE_DECL(name, stat) \
+ stat name##_t *name##__ref(name##_t *ptr, const char *func, \
+ const char *file, unsigned int line); \
+ stat void name##__unref(name##_t *ptr, const char *func, \
+ const char *file, unsigned int line); \
+ stat void name##__attach(name##_t *ptr, name##_t **ptrp, \
+ const char *func, const char *file, \
+ unsigned int line); \
+ stat name##__detach(name##_t **ptrp, const char *func, \
+ const char *file, unsigned int line)
+
+#define ISC_REFCOUNT_BLANK
+#define ISC_REFCOUNT_TRACE_DECL(name) \
+ ISC__REFCOUNT_TRACE_DECL(name, ISC_REFCOUNT_BLANK)
+#define ISC_REFCOUNT_STATIC_TRACE_DECL(name) \
+ ISC__REFCOUNT_TRACE_DECL(name, static inline)
+
+#define ISC__REFCOUNT_TRACE_IMPL(name, destroy, stat) \
+ stat name##_t *name##__ref(name##_t *ptr, const char *func, \
+ const char *file, unsigned int line) { \
REQUIRE(ptr != NULL); \
uint_fast32_t refs = \
isc_refcount_increment(&ptr->references) + 1; \
return (ptr); \
} \
\
- void name##__unref(name##_t *ptr, const char *func, const char *file, \
- unsigned int line) { \
+ stat void name##__unref(name##_t *ptr, const char *func, \
+ const char *file, unsigned int line) { \
REQUIRE(ptr != NULL); \
uint_fast32_t refs = \
isc_refcount_decrement(&ptr->references) - 1; \
"%s:%s:%s:%u:t%u:%p->references = %" PRIuFAST32 "\n", \
__func__, func, file, line, isc_tid(), ptr, refs); \
} \
- void name##__attach(name##_t *ptr, name##_t **ptrp, const char *func, \
- const char *file, unsigned int line) { \
+ stat void name##__attach(name##_t *ptr, name##_t **ptrp, \
+ const char *func, const char *file, \
+ unsigned int line) { \
REQUIRE(ptrp != NULL && *ptrp == NULL); \
uint_fast32_t refs = \
isc_refcount_increment(&ptr->references) + 1; \
*ptrp = ptr; \
} \
\
- void name##__detach(name##_t **ptrp, const char *func, \
- const char *file, unsigned int line) { \
+ stat void name##__detach(name##_t **ptrp, const char *func, \
+ const char *file, unsigned int line) { \
REQUIRE(ptrp != NULL && *ptrp != NULL); \
name##_t *ptr = *ptrp; \
*ptrp = NULL; \
__func__, func, file, line, isc_tid(), ptr, refs); \
}
-#define ISC_REFCOUNT_DECL(name) \
- name##_t *name##_ref(name##_t *ptr); \
- void name##_unref(name##_t *ptr); \
- void name##_attach(name##_t *ptr, name##_t **ptrp); \
- void name##_detach(name##_t **ptrp)
+#define ISC_REFCOUNT_TRACE_IMPL(name, destroy) \
+ ISC__REFCOUNT_TRACE_DECL(name, destroy, ISC_REFCOUNT_BLANK)
+#define ISC_REFCOUNT_STATIC_TRACE_IMPL(name, destroy) \
+ ISC__REFCOUNT_TRACE_DECL(name, destroy, static inline)
-#define ISC_REFCOUNT_IMPL(name, destroy) \
- name##_t *name##_ref(name##_t *ptr) { \
+#define ISC__REFCOUNT_DECL(name, stat) \
+ stat name##_t *name##_ref(name##_t *ptr) __attribute__((unused)); \
+ stat void name##_unref(name##_t *ptr) __attribute__((unused)); \
+ stat void name##_attach(name##_t *ptr, name##_t **ptrp) \
+ __attribute__((unused)); \
+ stat void name##_detach(name##_t **ptrp) __attribute__((unused))
+
+#define ISC_REFCOUNT_DECL(name) ISC__REFCOUNT_DECL(name, ISC_REFCOUNT_BLANK)
+#define ISC_REFCOUNT_STATIC_DECL(name) ISC__REFCOUNT_DECL(name, static inline)
+
+#define ISC__REFCOUNT_IMPL(name, destroy, stat) \
+ stat name##_t *name##_ref(name##_t *ptr) { \
REQUIRE(ptr != NULL); \
isc_refcount_increment(&ptr->references); \
return (ptr); \
} \
\
- void name##_unref(name##_t *ptr) { \
+ stat void name##_unref(name##_t *ptr) { \
REQUIRE(ptr != NULL); \
if (isc_refcount_decrement(&ptr->references) == 1) { \
isc_refcount_destroy(&ptr->references); \
destroy(ptr); \
} \
} \
- void name##_attach(name##_t *ptr, name##_t **ptrp) { \
+ stat void name##_attach(name##_t *ptr, name##_t **ptrp) { \
REQUIRE(ptrp != NULL && *ptrp == NULL); \
name##_ref(ptr); \
*ptrp = ptr; \
} \
\
- void name##_detach(name##_t **ptrp) { \
+ stat void name##_detach(name##_t **ptrp) { \
REQUIRE(ptrp != NULL && *ptrp != NULL); \
name##_t *ptr = *ptrp; \
*ptrp = NULL; \
name##_unref(ptr); \
}
+#define ISC_REFCOUNT_IMPL(name, destroy) \
+ ISC__REFCOUNT_IMPL(name, destroy, ISC_REFCOUNT_BLANK)
+#define ISC_REFCOUNT_STATIC_IMPL(name, destroy) \
+ ISC__REFCOUNT_IMPL(name, destroy, static inline)
+
ISC_LANG_ENDDECLS