carry out all dtalist pointer accesses atomically, some missing cases

Tue Jan 31 16:45:03 2006  Tim Janik  <timj@imendio.com>

        * glib/gdataset.c: carry out all dtalist pointer accesses atomically,
        some missing cases where pointed out by Sebastian Wilhelmi.
This commit is contained in:
Tim Janik 2006-01-31 15:46:34 +00:00 committed by Tim Janik
parent 7162fbbbfd
commit 20887fa148
5 changed files with 27 additions and 9 deletions

View File

@ -1,3 +1,8 @@
Tue Jan 31 16:45:03 2006 Tim Janik <timj@imendio.com>
* glib/gdataset.c: carry out all dtalist pointer accesses atomically,
some missing cases where pointed out by Sebastian Wilhelmi.
Tue Jan 31 12:33:48 2006 Tim Janik <timj@imendio.com>
* configure.in: generate build/win32/vs8/Makefile, to fix build breakage.

View File

@ -1,3 +1,8 @@
Tue Jan 31 16:45:03 2006 Tim Janik <timj@imendio.com>
* glib/gdataset.c: carry out all dtalist pointer accesses atomically,
some missing cases where pointed out by Sebastian Wilhelmi.
Tue Jan 31 12:33:48 2006 Tim Janik <timj@imendio.com>
* configure.in: generate build/win32/vs8/Makefile, to fix build breakage.

View File

@ -1,3 +1,8 @@
Tue Jan 31 16:45:03 2006 Tim Janik <timj@imendio.com>
* glib/gdataset.c: carry out all dtalist pointer accesses atomically,
some missing cases where pointed out by Sebastian Wilhelmi.
Tue Jan 31 12:33:48 2006 Tim Janik <timj@imendio.com>
* configure.in: generate build/win32/vs8/Makefile, to fix build breakage.

View File

@ -42,14 +42,17 @@
/* --- defines --- */
#define G_QUARK_BLOCK_SIZE (512)
/* datalist pointer modifications have to be done with the g_dataset_global mutex held */
/* datalist pointer accesses vae to be carried out atomically */
#define G_DATALIST_GET_POINTER(datalist) \
((GData*) ((gsize) *(datalist) & ~(gsize) G_DATALIST_FLAGS_MASK))
#define G_DATALIST_SET_POINTER(datalist, pointer) G_STMT_START { \
*(datalist) = (GData*) (G_DATALIST_GET_FLAGS (datalist) | \
(gsize) pointer); \
} G_STMT_END
((GData*) ((gsize) g_atomic_pointer_get ((gpointer*) datalist) & ~(gsize) G_DATALIST_FLAGS_MASK))
#define G_DATALIST_SET_POINTER(datalist, pointer) G_STMT_START { \
gpointer _oldv, _newv; \
do { \
_oldv = g_atomic_pointer_get (datalist); \
_newv = (gpointer) (((gsize) _oldv & G_DATALIST_FLAGS_MASK) | (gsize) pointer); \
} while (!g_atomic_pointer_compare_and_exchange ((void**) datalist, _oldv, _newv)); \
} G_STMT_END
/* --- structures --- */
typedef struct _GDataset GDataset;
@ -501,8 +504,8 @@ void
g_datalist_init (GData **datalist)
{
g_return_if_fail (datalist != NULL);
*datalist = NULL;
g_atomic_pointer_set ((gpointer*) datalist, NULL);
}
/**

View File

@ -36,7 +36,7 @@ G_BEGIN_DECLS
* barriers to take effect without acquiring the global dataset mutex.
*/
#define G_DATALIST_GET_FLAGS(datalist) \
((gsize) g_atomic_pointer_get ((gpointer *)(datalist)) & G_DATALIST_FLAGS_MASK)
((gsize) g_atomic_pointer_get ((gpointer*) datalist) & G_DATALIST_FLAGS_MASK)
G_END_DECLS