summaryrefslogtreecommitdiff
path: root/src/glibext
diff options
context:
space:
mode:
Diffstat (limited to 'src/glibext')
-rw-r--r--src/glibext/objhole.h49
1 files changed, 37 insertions, 12 deletions
diff --git a/src/glibext/objhole.h b/src/glibext/objhole.h
index cf9fc28..c256cfb 100644
--- a/src/glibext/objhole.h
+++ b/src/glibext/objhole.h
@@ -25,6 +25,7 @@
#define _GLIBEXT_OBJHOLE_H
+#include <glib.h>
#include <glib-object.h>
@@ -46,17 +47,6 @@
*/
-#define INIT_GOBJECT_EXTRA(obj) \
- do \
- { \
- guint *___space; \
- ___space = (((guint *)&obj->ref_count) + 1); \
- BUILD_BUG_ON((___space + 1) == (guint *)&obj->qdata); \
- *___space = 0; \
- } \
- while (0)
-
-
#define GET_GOBJECT_EXTRA(obj, tp) \
({ \
BUILD_BUG_ON(sizeof(tp) > sizeof(guint)); \
@@ -67,7 +57,6 @@
})
-
/**
* Choix du bit de verrou pour le champ "lock".
*
@@ -90,5 +79,41 @@
#endif
+/* Verrou d'accès pour une encapsulation */
+typedef struct _lockable_obj_extra_t
+{
+ gint lock; /* Gestion d'accès aux fanions */
+
+} lockable_obj_extra_t;
+
+
+#define INIT_GOBJECT_EXTRA_LOCK(xtr) \
+ do \
+ { \
+ lockable_obj_extra_t *__lockable; \
+ __lockable = (lockable_obj_extra_t *)xtr; \
+ __lockable->lock = 0; \
+ } \
+ while (0)
+
+#define LOCK_GOBJECT_EXTRA(xtr) \
+ do \
+ { \
+ lockable_obj_extra_t *__lockable; \
+ __lockable = (lockable_obj_extra_t *)xtr; \
+ g_bit_lock(&__lockable->lock, HOLE_LOCK_BIT); \
+ } \
+ while (0)
+
+#define UNLOCK_GOBJECT_EXTRA(xtr) \
+ do \
+ { \
+ lockable_obj_extra_t *__lockable; \
+ __lockable = (lockable_obj_extra_t *)xtr; \
+ g_bit_unlock(&__lockable->lock, HOLE_LOCK_BIT); \
+ } \
+ while (0)
+
+
#endif /* _GLIBEXT_OBJHOLE_H */