@@ -251,59 +251,6 @@ static inline int __coverity_check_and_return__(int condition) {
251251/* Pointers range from NULL to POINTER_MAX */
252252#define POINTER_MAX ((void*) UINTPTR_MAX)
253253
254- #define _DEFINE_TRIVIAL_REF_FUNC (type , name , scope ) \
255- scope type *name##_ref(type *p) { \
256- if (!p) \
257- return NULL; \
258- \
259- /* For type check. */ \
260- unsigned * q = & p -> n_ref ; \
261- assert (* q > 0 ); \
262- assert_se (* q < UINT_MAX ); \
263- \
264- (* q )++ ; \
265- return p ; \
266- }
267-
268- #define _DEFINE_TRIVIAL_UNREF_FUNC (type , name , free_func , scope ) \
269- scope type *name##_unref(type *p) { \
270- if (!p) \
271- return NULL; \
272- \
273- assert(p->n_ref > 0); \
274- p->n_ref--; \
275- if (p->n_ref > 0) \
276- return NULL; \
277- \
278- return free_func(p); \
279- }
280-
281- #define DEFINE_TRIVIAL_REF_FUNC (type , name ) \
282- _DEFINE_TRIVIAL_REF_FUNC(type, name,)
283- #define DEFINE_PRIVATE_TRIVIAL_REF_FUNC (type , name ) \
284- _DEFINE_TRIVIAL_REF_FUNC(type, name, static)
285- #define DEFINE_PUBLIC_TRIVIAL_REF_FUNC (type , name ) \
286- _DEFINE_TRIVIAL_REF_FUNC(type, name, _public_)
287-
288- #define DEFINE_TRIVIAL_UNREF_FUNC (type , name , free_func ) \
289- _DEFINE_TRIVIAL_UNREF_FUNC(type, name, free_func,)
290- #define DEFINE_PRIVATE_TRIVIAL_UNREF_FUNC (type , name , free_func ) \
291- _DEFINE_TRIVIAL_UNREF_FUNC(type, name, free_func, static)
292- #define DEFINE_PUBLIC_TRIVIAL_UNREF_FUNC (type , name , free_func ) \
293- _DEFINE_TRIVIAL_UNREF_FUNC(type, name, free_func, _public_)
294-
295- #define DEFINE_TRIVIAL_REF_UNREF_FUNC (type , name , free_func ) \
296- DEFINE_TRIVIAL_REF_FUNC(type, name); \
297- DEFINE_TRIVIAL_UNREF_FUNC(type, name, free_func);
298-
299- #define DEFINE_PRIVATE_TRIVIAL_REF_UNREF_FUNC (type , name , free_func ) \
300- DEFINE_PRIVATE_TRIVIAL_REF_FUNC(type, name); \
301- DEFINE_PRIVATE_TRIVIAL_UNREF_FUNC(type, name, free_func);
302-
303- #define DEFINE_PUBLIC_TRIVIAL_REF_UNREF_FUNC (type , name , free_func ) \
304- DEFINE_PUBLIC_TRIVIAL_REF_FUNC(type, name); \
305- DEFINE_PUBLIC_TRIVIAL_UNREF_FUNC(type, name, free_func);
306-
307254/* A macro to force copying of a variable from memory. This is useful whenever we want to read something from
308255 * memory and want to make sure the compiler won't optimize away the destination variable for us. It's not
309256 * supposed to be a full CPU memory barrier, i.e. CPU is still allowed to reorder the reads, but it is not
0 commit comments