glib r7875 - in trunk: . glib gobject



Author: matthiasc
Date: Tue Feb 17 16:14:39 2009
New Revision: 7875
URL: http://svn.gnome.org/viewvc/glib?rev=7875&view=rev

Log:
        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.



Modified:
   trunk/ChangeLog
   trunk/glib/gatomic.c
   trunk/glib/gatomic.h
   trunk/glib/gdataset.c
   trunk/glib/gdatasetprivate.h
   trunk/glib/gthread.c
   trunk/glib/gthread.h
   trunk/gobject/ChangeLog
   trunk/gobject/gobject.c

Modified: trunk/glib/gatomic.c
==============================================================================
--- trunk/glib/gatomic.c	(original)
+++ trunk/glib/gatomic.c	Tue Feb 17 16:14:39 2009
@@ -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 @@
 }
  
 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 @@
 }
 
 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 @@
  * 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 @@
 
 #  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 @@
 }
 #  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 @@
   })
 #  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 @@
 }
 #  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 @@
 /* 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 @@
 }
  
 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 @@
 }
 
 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 @@
 }
 
 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 @@
 /* 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 @@
  
 /* 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 @@
 }
 #   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 @@
 }
  
 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 @@
 
 #   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 @@
 }
 
 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 @@
 }
 #   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 @@
 }
 
 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 @@
 /* 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 @@
 }
 
 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 @@
 
 #  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 @@
 }
 #  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 @@
 }
 
 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 @@
 }
 
 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 @@
 }
 
 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 @@
 }
 
 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 @@
 #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 @@
 }
 
 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 @@
 }
 
 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 @@
 }
 
 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 @@
 # 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 @@
 }
 
 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 @@
 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 @@
 
 
 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 @@
 }
 
 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 @@
 }
 
 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 @@
 
 #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 @@
 }
 
 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 @@
 }
 
 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 @@
 }
 
 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 @@
 #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 @@
 }
 
 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 @@
 
 #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 @@
 }
 
 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 @@
 }
  
 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 @@
 
 #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);

Modified: trunk/glib/gatomic.h
==============================================================================
--- trunk/glib/gatomic.h	(original)
+++ trunk/glib/gatomic.h	Tue Feb 17 16:14:39 2009
@@ -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))

Modified: trunk/glib/gdataset.c
==============================================================================
--- trunk/glib/gdataset.c	(original)
+++ trunk/glib/gdataset.c	Tue Feb 17 16:14:39 2009
@@ -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_return_if_fail (datalist != NULL);
 
-  g_atomic_pointer_set ((gpointer*) datalist, NULL);
+  g_atomic_pointer_set (datalist, NULL);
 }
 
 /**

Modified: trunk/glib/gdatasetprivate.h
==============================================================================
--- trunk/glib/gdatasetprivate.h	(original)
+++ trunk/glib/gdatasetprivate.h	Tue Feb 17 16:14:39 2009
@@ -36,7 +36,7 @@
  * 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

Modified: trunk/glib/gthread.c
==============================================================================
--- trunk/glib/gthread.c	(original)
+++ trunk/glib/gthread.c	Tue Feb 17 16:14:39 2009
@@ -204,7 +204,7 @@
 {
   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 @@
 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_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);
 

Modified: trunk/glib/gthread.h
==============================================================================
--- trunk/glib/gthread.h	(original)
+++ trunk/glib/gthread.h	Tue Feb 17 16:14:39 2009
@@ -150,7 +150,7 @@
 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 @@
 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);

Modified: trunk/gobject/gobject.c
==============================================================================
--- trunk/gobject/gobject.c	(original)
+++ trunk/gobject/gobject.c	Tue Feb 17 16:14:39 2009
@@ -807,7 +807,7 @@
 {
   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_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 @@
   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 @@
 
   /* 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))



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]