diff options
author | Matthias Clasen <matthiasc@src.gnome.org> | 2009-02-17 16:14:39 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2009-02-17 16:14:39 +0000 |
commit | c8e37b63e74fafdc1f299ec139677ad0e37676c3 (patch) | |
tree | db040d7bc96a54a76f1693a3f63997ea113b3b64 | |
parent | 3277f24dfc4c36c3130a44d94e66b7ad8f9fa920 (diff) |
Fix strict aliasing warnings and viiolations to make GLib and
GLib users buildable with gcc 4.4. Patch by Jakub Jelinek.
* glib/gatomic.[hc]: Add G_GNUC_MAY_ALIAS to pointer arguments,
fix macro versions to only operate on objects of the same size.
* glib/gdataset.c:
* glib/gthread.[hc]:
* glib/gdatasetprivate.h: Remove unnecessary casts in
g_atomic_pointer_get calls.
svn path=/trunk/; revision=7875
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | glib/gatomic.c | 122 | ||||
-rw-r--r-- | glib/gatomic.h | 33 | ||||
-rw-r--r-- | glib/gdataset.c | 4 | ||||
-rw-r--r-- | glib/gdatasetprivate.h | 2 | ||||
-rw-r--r-- | glib/gthread.c | 8 | ||||
-rw-r--r-- | glib/gthread.h | 4 | ||||
-rw-r--r-- | gobject/ChangeLog | 5 | ||||
-rw-r--r-- | gobject/gobject.c | 8 |
9 files changed, 115 insertions, 84 deletions
@@ -1,3 +1,16 @@ +2009-02-17 Matthias Clasen <mclasen@redhat.com> + + Fix strict aliasing warnings and viiolations to make GLib and + GLib users buildable with gcc 4.4. Patch by Jakub Jelinek. + + * glib/gatomic.[hc]: Add G_GNUC_MAY_ALIAS to pointer arguments, + fix macro versions to only operate on objects of the same size. + + * glib/gdataset.c: + * glib/gthread.[hc]: + * glib/gdatasetprivate.h: Remove unnecessary casts in + g_atomic_pointer_get calls. + 2009-02-16 Matthias Clasen <mclasen@redhat.com> * configure.in: Bump version diff --git a/glib/gatomic.c b/glib/gatomic.c index 3182fd7c7..baa73e7ac 100644 --- a/glib/gatomic.c +++ b/glib/gatomic.c @@ -36,7 +36,7 @@ /* Adapted from CVS version 1.10 of glibc's sysdeps/i386/i486/bits/atomic.h */ gint -g_atomic_int_exchange_and_add (volatile gint *atomic, +g_atomic_int_exchange_and_add (volatile gint G_GNUC_MAY_ALIAS *atomic, gint val) { gint result; @@ -48,7 +48,7 @@ g_atomic_int_exchange_and_add (volatile gint *atomic, } void -g_atomic_int_add (volatile gint *atomic, +g_atomic_int_add (volatile gint G_GNUC_MAY_ALIAS *atomic, gint val) { __asm__ __volatile__ ("lock; addl %1,%0" @@ -57,7 +57,7 @@ g_atomic_int_add (volatile gint *atomic, } gboolean -g_atomic_int_compare_and_exchange (volatile gint *atomic, +g_atomic_int_compare_and_exchange (volatile gint G_GNUC_MAY_ALIAS *atomic, gint oldval, gint newval) { @@ -75,7 +75,7 @@ g_atomic_int_compare_and_exchange (volatile gint *atomic, * arguments and calling the former function */ gboolean -g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic, +g_atomic_pointer_compare_and_exchange (volatile gpointer G_GNUC_MAY_ALIAS *atomic, gpointer oldval, gpointer newval) { @@ -103,7 +103,7 @@ g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic, # if GLIB_SIZEOF_VOID_P == 4 /* 32-bit system */ gboolean -g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic, +g_atomic_pointer_compare_and_exchange (volatile gpointer G_GNUC_MAY_ALIAS *atomic, gpointer oldval, gpointer newval) { @@ -116,7 +116,7 @@ g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic, } # elif GLIB_SIZEOF_VOID_P == 8 /* 64-bit system */ gboolean -g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic, +g_atomic_pointer_compare_and_exchange (volatile gpointer G_GNUC_MAY_ALIAS *atomic, gpointer oldval, gpointer newval) { @@ -162,7 +162,7 @@ g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic, }) # if GLIB_SIZEOF_VOID_P == 4 /* 32-bit system */ gboolean -g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic, +g_atomic_pointer_compare_and_exchange (volatile gpointer G_GNUC_MAY_ALIAS *atomic, gpointer oldval, gpointer newval) { @@ -188,7 +188,7 @@ g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic, } # elif GLIB_SIZEOF_VOID_P == 8 /* 64-bit system */ gboolean -g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic, +g_atomic_pointer_compare_and_exchange (volatile gpointer G_GNUC_MAY_ALIAS *atomic, gpointer oldval, gpointer newval) { @@ -220,7 +220,7 @@ g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic, /* Adapted from CVS version 1.9 of glibc's sysdeps/x86_64/bits/atomic.h */ gint -g_atomic_int_exchange_and_add (volatile gint *atomic, +g_atomic_int_exchange_and_add (volatile gint G_GNUC_MAY_ALIAS *atomic, gint val) { gint result; @@ -232,7 +232,7 @@ g_atomic_int_exchange_and_add (volatile gint *atomic, } void -g_atomic_int_add (volatile gint *atomic, +g_atomic_int_add (volatile gint G_GNUC_MAY_ALIAS *atomic, gint val) { __asm__ __volatile__ ("lock; addl %1,%0" @@ -241,7 +241,7 @@ g_atomic_int_add (volatile gint *atomic, } gboolean -g_atomic_int_compare_and_exchange (volatile gint *atomic, +g_atomic_int_compare_and_exchange (volatile gint G_GNUC_MAY_ALIAS *atomic, gint oldval, gint newval) { @@ -255,7 +255,7 @@ g_atomic_int_compare_and_exchange (volatile gint *atomic, } gboolean -g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic, +g_atomic_pointer_compare_and_exchange (volatile gpointer G_GNUC_MAY_ALIAS *atomic, gpointer oldval, gpointer newval) { @@ -277,7 +277,7 @@ g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic, /* Non-optimizing compile bails on the following two asm statements * for reasons unknown to the author */ gint -g_atomic_int_exchange_and_add (volatile gint *atomic, +g_atomic_int_exchange_and_add (volatile gint G_GNUC_MAY_ALIAS *atomic, gint val) { gint result, temp; @@ -303,7 +303,7 @@ g_atomic_int_exchange_and_add (volatile gint *atomic, /* The same as above, to save a function call repeated here */ void -g_atomic_int_add (volatile gint *atomic, +g_atomic_int_add (volatile gint G_GNUC_MAY_ALIAS *atomic, gint val) { gint result, temp; @@ -327,7 +327,7 @@ g_atomic_int_add (volatile gint *atomic, } # else /* !__OPTIMIZE__ */ gint -g_atomic_int_exchange_and_add (volatile gint *atomic, +g_atomic_int_exchange_and_add (volatile gint G_GNUC_MAY_ALIAS *atomic, gint val) { gint result; @@ -339,7 +339,7 @@ g_atomic_int_exchange_and_add (volatile gint *atomic, } void -g_atomic_int_add (volatile gint *atomic, +g_atomic_int_add (volatile gint G_GNUC_MAY_ALIAS *atomic, gint val) { gint result; @@ -351,7 +351,7 @@ g_atomic_int_add (volatile gint *atomic, # if GLIB_SIZEOF_VOID_P == 4 /* 32-bit system */ gboolean -g_atomic_int_compare_and_exchange (volatile gint *atomic, +g_atomic_int_compare_and_exchange (volatile gint G_GNUC_MAY_ALIAS *atomic, gint oldval, gint newval) { @@ -383,7 +383,7 @@ g_atomic_int_compare_and_exchange (volatile gint *atomic, } gboolean -g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic, +g_atomic_pointer_compare_and_exchange (volatile gpointer G_GNUC_MAY_ALIAS *atomic, gpointer oldval, gpointer newval) { @@ -415,7 +415,7 @@ g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic, } # elif GLIB_SIZEOF_VOID_P == 8 /* 64-bit system */ gboolean -g_atomic_int_compare_and_exchange (volatile gint *atomic, +g_atomic_int_compare_and_exchange (volatile gint G_GNUC_MAY_ALIAS *atomic, gint oldval, gint newval) { @@ -449,7 +449,7 @@ g_atomic_int_compare_and_exchange (volatile gint *atomic, } gboolean -g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic, +g_atomic_pointer_compare_and_exchange (volatile gpointer G_GNUC_MAY_ALIAS *atomic, gpointer oldval, gpointer newval) { @@ -489,21 +489,21 @@ g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic, /* Adapted from CVS version 1.8 of glibc's sysdeps/ia64/bits/atomic.h */ gint -g_atomic_int_exchange_and_add (volatile gint *atomic, +g_atomic_int_exchange_and_add (volatile gint G_GNUC_MAY_ALIAS *atomic, gint val) { return __sync_fetch_and_add (atomic, val); } void -g_atomic_int_add (volatile gint *atomic, +g_atomic_int_add (volatile gint G_GNUC_MAY_ALIAS *atomic, gint val) { __sync_fetch_and_add (atomic, val); } gboolean -g_atomic_int_compare_and_exchange (volatile gint *atomic, +g_atomic_int_compare_and_exchange (volatile gint G_GNUC_MAY_ALIAS *atomic, gint oldval, gint newval) { @@ -511,7 +511,7 @@ g_atomic_int_compare_and_exchange (volatile gint *atomic, } gboolean -g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic, +g_atomic_pointer_compare_and_exchange (volatile gpointer G_GNUC_MAY_ALIAS *atomic, gpointer oldval, gpointer newval) { @@ -534,7 +534,7 @@ g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic, # if GLIB_SIZEOF_VOID_P == 4 /* 32-bit system */ gboolean -g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic, +g_atomic_pointer_compare_and_exchange (volatile gpointer G_GNUC_MAY_ALIAS *atomic, gpointer oldval, gpointer newval) { @@ -546,7 +546,7 @@ g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic, } # elif GLIB_SIZEOF_VOID_P == 8 /* 64-bit system */ gboolean -g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic, +g_atomic_pointer_compare_and_exchange (volatile gpointer G_GNUC_MAY_ALIAS *atomic, gpointer oldval, gpointer newval) { @@ -590,7 +590,7 @@ static void atomic_spin_unlock (void) } gint -g_atomic_int_exchange_and_add (volatile gint *atomic, +g_atomic_int_exchange_and_add (volatile gint G_GNUC_MAY_ALIAS *atomic, gint val) { gint result; @@ -604,7 +604,7 @@ g_atomic_int_exchange_and_add (volatile gint *atomic, } void -g_atomic_int_add (volatile gint *atomic, +g_atomic_int_add (volatile gint G_GNUC_MAY_ALIAS *atomic, gint val) { atomic_spin_lock(); @@ -613,7 +613,7 @@ g_atomic_int_add (volatile gint *atomic, } gboolean -g_atomic_int_compare_and_exchange (volatile gint *atomic, +g_atomic_int_compare_and_exchange (volatile gint G_GNUC_MAY_ALIAS *atomic, gint oldval, gint newval) { @@ -633,7 +633,7 @@ g_atomic_int_compare_and_exchange (volatile gint *atomic, } gboolean -g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic, +g_atomic_pointer_compare_and_exchange (volatile gpointer G_GNUC_MAY_ALIAS *atomic, gpointer oldval, gpointer newval) { @@ -700,19 +700,19 @@ g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic, #define CRIS_ATOMIC_BREAKS_CACHELINE(atomic) \ (((gulong)(atomic) & (CRIS_CACHELINE_SIZE - 1)) > (CRIS_CACHELINE_SIZE - sizeof (atomic))) -gint __g_atomic_int_exchange_and_add (volatile gint *atomic, +gint __g_atomic_int_exchange_and_add (volatile gint G_GNUC_MAY_ALIAS *atomic, gint val); -void __g_atomic_int_add (volatile gint *atomic, +void __g_atomic_int_add (volatile gint G_GNUC_MAY_ALIAS *atomic, gint val); -gboolean __g_atomic_int_compare_and_exchange (volatile gint *atomic, +gboolean __g_atomic_int_compare_and_exchange (volatile gint G_GNUC_MAY_ALIAS *atomic, gint oldval, gint newval); -gboolean __g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic, +gboolean __g_atomic_pointer_compare_and_exchange (volatile gpointer G_GNUC_MAY_ALIAS *atomic, gpointer oldval, gpointer newval); gboolean -g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic, +g_atomic_pointer_compare_and_exchange (volatile gpointer G_GNUC_MAY_ALIAS *atomic, gpointer oldval, gpointer newval) { @@ -723,7 +723,7 @@ g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic, } gboolean -g_atomic_int_compare_and_exchange (volatile gint *atomic, +g_atomic_int_compare_and_exchange (volatile gint G_GNUC_MAY_ALIAS *atomic, gint oldval, gint newval) { @@ -734,7 +734,7 @@ g_atomic_int_compare_and_exchange (volatile gint *atomic, } gint -g_atomic_int_exchange_and_add (volatile gint *atomic, +g_atomic_int_exchange_and_add (volatile gint G_GNUC_MAY_ALIAS *atomic, gint val) { gint result; @@ -750,7 +750,7 @@ g_atomic_int_exchange_and_add (volatile gint *atomic, } void -g_atomic_int_add (volatile gint *atomic, +g_atomic_int_add (volatile gint G_GNUC_MAY_ALIAS *atomic, gint val) { gint result; @@ -797,21 +797,21 @@ g_atomic_int_add (volatile gint *atomic, # endif gint32 -g_atomic_int_exchange_and_add (volatile gint32 *atomic, +g_atomic_int_exchange_and_add (volatile gint32 G_GNUC_MAY_ALIAS *atomic, gint32 val) { return InterlockedExchangeAdd (atomic, val); } void -g_atomic_int_add (volatile gint32 *atomic, +g_atomic_int_add (volatile gint32 G_GNUC_MAY_ALIAS *atomic, gint32 val) { InterlockedExchangeAdd (atomic, val); } gboolean -g_atomic_int_compare_and_exchange (volatile gint32 *atomic, +g_atomic_int_compare_and_exchange (volatile gint32 G_GNUC_MAY_ALIAS *atomic, gint32 oldval, gint32 newval) { @@ -827,7 +827,7 @@ g_atomic_int_compare_and_exchange (volatile gint32 *atomic, } gboolean -g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic, +g_atomic_pointer_compare_and_exchange (volatile gpointer G_GNUC_MAY_ALIAS *atomic, gpointer oldval, gpointer newval) { @@ -848,7 +848,7 @@ g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic, static GMutex *g_atomic_mutex; gint -g_atomic_int_exchange_and_add (volatile gint *atomic, +g_atomic_int_exchange_and_add (volatile gint G_GNUC_MAY_ALIAS *atomic, gint val) { gint result; @@ -863,7 +863,7 @@ g_atomic_int_exchange_and_add (volatile gint *atomic, void -g_atomic_int_add (volatile gint *atomic, +g_atomic_int_add (volatile gint G_GNUC_MAY_ALIAS *atomic, gint val) { g_mutex_lock (g_atomic_mutex); @@ -872,7 +872,7 @@ g_atomic_int_add (volatile gint *atomic, } gboolean -g_atomic_int_compare_and_exchange (volatile gint *atomic, +g_atomic_int_compare_and_exchange (volatile gint G_GNUC_MAY_ALIAS *atomic, gint oldval, gint newval) { @@ -892,7 +892,7 @@ g_atomic_int_compare_and_exchange (volatile gint *atomic, } gboolean -g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic, +g_atomic_pointer_compare_and_exchange (volatile gpointer G_GNUC_MAY_ALIAS *atomic, gpointer oldval, gpointer newval) { @@ -913,7 +913,7 @@ g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic, #ifdef G_ATOMIC_OP_MEMORY_BARRIER_NEEDED gint -g_atomic_int_get (volatile gint *atomic) +(g_atomic_int_get) (volatile gint G_GNUC_MAY_ALIAS *atomic) { gint result; @@ -925,7 +925,7 @@ g_atomic_int_get (volatile gint *atomic) } void -g_atomic_int_set (volatile gint *atomic, +(g_atomic_int_set) (volatile gint G_GNUC_MAY_ALIAS *atomic, gint newval) { g_mutex_lock (g_atomic_mutex); @@ -934,7 +934,7 @@ g_atomic_int_set (volatile gint *atomic, } gpointer -g_atomic_pointer_get (volatile gpointer *atomic) +(g_atomic_pointer_get) (volatile gpointer G_GNUC_MAY_ALIAS *atomic) { gpointer result; @@ -946,7 +946,7 @@ g_atomic_pointer_get (volatile gpointer *atomic) } void -g_atomic_pointer_set (volatile gpointer *atomic, +(g_atomic_pointer_set) (volatile gpointer G_GNUC_MAY_ALIAS *atomic, gpointer newval) { g_mutex_lock (g_atomic_mutex); @@ -956,14 +956,14 @@ g_atomic_pointer_set (volatile gpointer *atomic, #endif /* G_ATOMIC_OP_MEMORY_BARRIER_NEEDED */ #elif defined (G_ATOMIC_OP_MEMORY_BARRIER_NEEDED) gint -g_atomic_int_get (volatile gint *atomic) +(g_atomic_int_get) (volatile gint G_GNUC_MAY_ALIAS *atomic) { G_ATOMIC_MEMORY_BARRIER; return *atomic; } void -g_atomic_int_set (volatile gint *atomic, +(g_atomic_int_set) (volatile gint G_GNUC_MAY_ALIAS *atomic, gint newval) { *atomic = newval; @@ -971,14 +971,14 @@ g_atomic_int_set (volatile gint *atomic, } gpointer -g_atomic_pointer_get (volatile gpointer *atomic) +(g_atomic_pointer_get) (volatile gpointer G_GNUC_MAY_ALIAS *atomic) { G_ATOMIC_MEMORY_BARRIER; return *atomic; } void -g_atomic_pointer_set (volatile gpointer *atomic, +(g_atomic_pointer_set) (volatile gpointer G_GNUC_MAY_ALIAS *atomic, gpointer newval) { *atomic = newval; @@ -988,7 +988,7 @@ g_atomic_pointer_set (volatile gpointer *atomic, #ifdef ATOMIC_INT_CMP_XCHG gboolean -g_atomic_int_compare_and_exchange (volatile gint *atomic, +g_atomic_int_compare_and_exchange (volatile gint G_GNUC_MAY_ALIAS *atomic, gint oldval, gint newval) { @@ -996,7 +996,7 @@ g_atomic_int_compare_and_exchange (volatile gint *atomic, } gint -g_atomic_int_exchange_and_add (volatile gint *atomic, +g_atomic_int_exchange_and_add (volatile gint G_GNUC_MAY_ALIAS *atomic, gint val) { gint result; @@ -1008,7 +1008,7 @@ g_atomic_int_exchange_and_add (volatile gint *atomic, } void -g_atomic_int_add (volatile gint *atomic, +g_atomic_int_add (volatile gint G_GNUC_MAY_ALIAS *atomic, gint val) { gint result; @@ -1028,26 +1028,26 @@ _g_atomic_thread_init (void) #ifndef G_ATOMIC_OP_MEMORY_BARRIER_NEEDED gint -(g_atomic_int_get) (volatile gint *atomic) +(g_atomic_int_get) (volatile gint G_GNUC_MAY_ALIAS *atomic) { return g_atomic_int_get (atomic); } void -(g_atomic_int_set) (volatile gint *atomic, +(g_atomic_int_set) (volatile gint G_GNUC_MAY_ALIAS *atomic, gint newval) { g_atomic_int_set (atomic, newval); } gpointer -(g_atomic_pointer_get) (volatile gpointer *atomic) +(g_atomic_pointer_get) (volatile gpointer G_GNUC_MAY_ALIAS *atomic) { return g_atomic_pointer_get (atomic); } void -(g_atomic_pointer_set) (volatile gpointer *atomic, +(g_atomic_pointer_set) (volatile gpointer G_GNUC_MAY_ALIAS *atomic, gpointer newval) { g_atomic_pointer_set (atomic, newval); diff --git a/glib/gatomic.h b/glib/gatomic.h index 232247bf4..7d9c318cc 100644 --- a/glib/gatomic.h +++ b/glib/gatomic.h @@ -38,29 +38,42 @@ G_BEGIN_DECLS -gint g_atomic_int_exchange_and_add (volatile gint *atomic, +gint g_atomic_int_exchange_and_add (volatile gint G_GNUC_MAY_ALIAS *atomic, gint val); -void g_atomic_int_add (volatile gint *atomic, +void g_atomic_int_add (volatile gint G_GNUC_MAY_ALIAS *atomic, gint val); -gboolean g_atomic_int_compare_and_exchange (volatile gint *atomic, +gboolean g_atomic_int_compare_and_exchange (volatile gint G_GNUC_MAY_ALIAS *atomic, gint oldval, gint newval); -gboolean g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic, +gboolean g_atomic_pointer_compare_and_exchange (volatile gpointer G_GNUC_MAY_ALIAS *atomic, gpointer oldval, gpointer newval); -gint g_atomic_int_get (volatile gint *atomic); -void g_atomic_int_set (volatile gint *atomic, +gint g_atomic_int_get (volatile gint G_GNUC_MAY_ALIAS *atomic); +void g_atomic_int_set (volatile gint G_GNUC_MAY_ALIAS *atomic, gint newval); -gpointer g_atomic_pointer_get (volatile gpointer *atomic); -void g_atomic_pointer_set (volatile gpointer *atomic, +gpointer g_atomic_pointer_get (volatile gpointer G_GNUC_MAY_ALIAS *atomic); +void g_atomic_pointer_set (volatile gpointer G_GNUC_MAY_ALIAS *atomic, gpointer newval); #ifndef G_ATOMIC_OP_MEMORY_BARRIER_NEEDED -# define g_atomic_int_get(atomic) (*(atomic)) +# define g_atomic_int_get(atomic) ((gint)*(atomic)) # define g_atomic_int_set(atomic, newval) ((void) (*(atomic) = (newval))) -# define g_atomic_pointer_get(atomic) (*(atomic)) +# define g_atomic_pointer_get(atomic) ((gpointer)*(atomic)) # define g_atomic_pointer_set(atomic, newval) ((void) (*(atomic) = (newval))) +#else +# define g_atomic_int_get(atomic) \ + ((void) sizeof (gchar [sizeof (*(atomic)) == sizeof (gint) ? 1 : -1]), \ + (g_atomic_int_get) ((volatile gint G_GNUC_MAY_ALIAS *) (void *) (atomic))) +# define g_atomic_int_set(atomic, newval) \ + ((void) sizeof (gchar [sizeof (*(atomic)) == sizeof (gint) ? 1 : -1]), \ + (g_atomic_int_set) ((volatile gint G_GNUC_MAY_ALIAS *) (void *) (atomic), (newval))) +# define g_atomic_pointer_get(atomic) \ + ((void) sizeof (gchar [sizeof (*(atomic)) == sizeof (gpointer) ? 1 : -1]), \ + (g_atomic_pointer_get) ((volatile gpointer G_GNUC_MAY_ALIAS *) (void *) (atomic))) +# define g_atomic_pointer_set(atomic, newval) \ + ((void) sizeof (gchar [sizeof (*(atomic)) == sizeof (gpointer) ? 1 : -1]), \ + (g_atomic_pointer_set) ((volatile gpointer G_GNUC_MAY_ALIAS *) (void *) (atomic), (newval))) #endif /* G_ATOMIC_OP_MEMORY_BARRIER_NEEDED */ #define g_atomic_int_inc(atomic) (g_atomic_int_add ((atomic), 1)) diff --git a/glib/gdataset.c b/glib/gdataset.c index fe6e4edbf..bf5eafe32 100644 --- a/glib/gdataset.c +++ b/glib/gdataset.c @@ -44,7 +44,7 @@ /* datalist pointer accesses have to be carried out atomically */ #define G_DATALIST_GET_POINTER(datalist) \ - ((GData*) ((gsize) g_atomic_pointer_get ((gpointer*) datalist) & ~(gsize) G_DATALIST_FLAGS_MASK)) + ((GData*) ((gsize) g_atomic_pointer_get (datalist) & ~(gsize) G_DATALIST_FLAGS_MASK)) #define G_DATALIST_SET_POINTER(datalist, pointer) G_STMT_START { \ gpointer _oldv, _newv; \ @@ -505,7 +505,7 @@ g_datalist_init (GData **datalist) { g_return_if_fail (datalist != NULL); - g_atomic_pointer_set ((gpointer*) datalist, NULL); + g_atomic_pointer_set (datalist, NULL); } /** diff --git a/glib/gdatasetprivate.h b/glib/gdatasetprivate.h index 1ebbd1385..fdbb87ab4 100644 --- a/glib/gdatasetprivate.h +++ b/glib/gdatasetprivate.h @@ -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 (datalist) & G_DATALIST_FLAGS_MASK) G_END_DECLS diff --git a/glib/gthread.c b/glib/gthread.c index bb3adcf2d..78c7ae59e 100644 --- a/glib/gthread.c +++ b/glib/gthread.c @@ -204,7 +204,7 @@ g_once_init_enter_impl (volatile gsize *value_location) { gboolean need_init = FALSE; g_mutex_lock (g_once_mutex); - if (g_atomic_pointer_get ((void**) value_location) == NULL) + if (g_atomic_pointer_get (value_location) == NULL) { if (!g_slist_find (g_once_init_list, (void*) value_location)) { @@ -224,11 +224,11 @@ void g_once_init_leave (volatile gsize *value_location, gsize initialization_value) { - g_return_if_fail (g_atomic_pointer_get ((void**) value_location) == NULL); + g_return_if_fail (g_atomic_pointer_get (value_location) == NULL); g_return_if_fail (initialization_value != 0); g_return_if_fail (g_once_init_list != NULL); - g_atomic_pointer_set ((void**) value_location, (void*) initialization_value); + g_atomic_pointer_set (value_location, (void*) initialization_value); g_mutex_lock (g_once_mutex); g_once_init_list = g_slist_remove (g_once_init_list, (void*) value_location); g_cond_broadcast (g_once_cond); @@ -256,7 +256,7 @@ g_static_mutex_get_mutex_impl (GMutex** mutex) g_mutex_lock (g_once_mutex); if (!(*mutex)) - g_atomic_pointer_set ((void**) mutex, g_mutex_new()); + g_atomic_pointer_set (mutex, g_mutex_new()); g_mutex_unlock (g_once_mutex); diff --git a/glib/gthread.h b/glib/gthread.h index 8b8f7cdd1..019d0dbf1 100644 --- a/glib/gthread.h +++ b/glib/gthread.h @@ -150,7 +150,7 @@ gboolean g_thread_get_initialized (void); GMutex* g_static_mutex_get_mutex_impl (GMutex **mutex); #define g_static_mutex_get_mutex_impl_shortcut(mutex) \ - (g_atomic_pointer_get ((gpointer*)(void*)mutex) ? *(mutex) : \ + (g_atomic_pointer_get (mutex) ? *(mutex) : \ g_static_mutex_get_mutex_impl (mutex)) /* shorthands for conditional and unconditional function calls */ @@ -341,7 +341,7 @@ void g_once_init_leave (volatile gsize *value_location, G_INLINE_FUNC gboolean g_once_init_enter (volatile gsize *value_location) { - if G_LIKELY (g_atomic_pointer_get ((void*volatile*) value_location) != NULL) + if G_LIKELY ((gpointer) g_atomic_pointer_get (value_location) != NULL) return FALSE; else return g_once_init_enter_impl (value_location); diff --git a/gobject/ChangeLog b/gobject/ChangeLog index 4084b5f5d..4054096a3 100644 --- a/gobject/ChangeLog +++ b/gobject/ChangeLog @@ -1,3 +1,8 @@ +2009-02-17 Matthias Clasen <mclasen@redhat.com> + + * gobject.c: Remove (now) unnecessary cases from g_atomic_int_get + calls. + 2009-02-16 Matthias Clasen <mclasen@redhat.com> * === Released 2.19.7 === diff --git a/gobject/gobject.c b/gobject/gobject.c index d40d2ffb6..10a272321 100644 --- a/gobject/gobject.c +++ b/gobject/gobject.c @@ -807,7 +807,7 @@ g_object_freeze_notify (GObject *object) { g_return_if_fail (G_IS_OBJECT (object)); - if (g_atomic_int_get ((int *)&object->ref_count) == 0) + if (g_atomic_int_get (&object->ref_count) == 0) return; g_object_ref (object); @@ -830,7 +830,7 @@ g_object_notify (GObject *object, g_return_if_fail (G_IS_OBJECT (object)); g_return_if_fail (property_name != NULL); - if (g_atomic_int_get ((int *)&object->ref_count) == 0) + if (g_atomic_int_get (&object->ref_count) == 0) return; g_object_ref (object); @@ -875,7 +875,7 @@ g_object_thaw_notify (GObject *object) GObjectNotifyQueue *nqueue; g_return_if_fail (G_IS_OBJECT (object)); - if (g_atomic_int_get ((int *)&object->ref_count) == 0) + if (g_atomic_int_get (&object->ref_count) == 0) return; g_object_ref (object); @@ -2377,7 +2377,7 @@ g_object_unref (gpointer _object) /* here we want to atomically do: if (ref_count>1) { ref_count--; return; } */ retry_atomic_decrement1: - old_ref = g_atomic_int_get ((int *)&object->ref_count); + old_ref = g_atomic_int_get (&object->ref_count); if (old_ref > 1) { if (!g_atomic_int_compare_and_exchange ((int *)&object->ref_count, old_ref, old_ref - 1)) |