1 #ifndef EL__MAIN_OBJECT_H
2 #define EL__MAIN_OBJECT_H
4 #include "util/lists.h"
17 #define OBJECT_HEAD(type) \
22 OBJECT_HEAD(struct object
*);
26 #include "util/error.h"
28 #define object_lock_debug(obj, info) \
29 DBG("object %s[%p] lock %s to %d", (obj)->object.name, obj, \
30 info, (obj)->object.refcount)
32 #define object_lock_debug(obj, info) \
33 DBG("object %p lock %s to %d", obj, info, (obj)->object.refcount)
34 #endif /* CONFIG_DEBUG */
36 #define object_lock_debug(obj, info)
37 #endif /* DEBUG_REFCOUNT */
40 #include "util/error.h"
41 #define object_sanity_check(obj) \
44 assertm((obj)->object.refcount >= 0, \
45 "Object %s[%p] refcount underflow.", \
46 (obj)->object.name, obj); \
47 if_assert_failed (obj)->object.refcount = 0; \
50 #define object_set_name(obj, objname) \
51 do { (obj)->object.name = (objname); } while (0)
52 #define INIT_OBJECT(name) { 0, name }
54 #define object_sanity_check(obj)
55 #define object_set_name(obj, name)
56 #define INIT_OBJECT(name) { 0 }
57 #endif /* CONFIG_DEBUG */
59 #define get_object_refcount(obj) ((obj)->object.refcount)
60 #define is_object_used(obj) (!!(obj)->object.refcount)
62 #define object_lock(obj) \
64 object_sanity_check(obj); \
65 (obj)->object.refcount++; \
66 object_lock_debug(obj, "incremented"); \
69 #define object_unlock(obj) \
71 (obj)->object.refcount--; \
72 object_lock_debug(obj, "decremented"); \
73 object_sanity_check(obj); \
76 /* Please keep this one. It serves for debugging. --Zas */
77 #define object_nolock(obj, name) \
79 object_set_name(obj, name); \
80 object_sanity_check(obj); \
81 object_lock_debug(obj, "initialized"); \