Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 264686
Collapse All | Expand All

(-)glib-2.18.4-orig/glib/gatomic.c (-52 / +52 lines)
Lines 36-42 Link Here
36
/* Adapted from CVS version 1.10 of glibc's sysdeps/i386/i486/bits/atomic.h 
36
/* Adapted from CVS version 1.10 of glibc's sysdeps/i386/i486/bits/atomic.h 
37
 */
37
 */
38
gint
38
gint
39
g_atomic_int_exchange_and_add (volatile gint *atomic, 
39
g_atomic_int_exchange_and_add (volatile gint G_GNUC_MAY_ALIAS *atomic, 
40
			       gint           val)
40
			       gint           val)
41
{
41
{
42
  gint result;
42
  gint result;
Lines 48-54 Link Here
48
}
48
}
49
 
49
 
50
void
50
void
51
g_atomic_int_add (volatile gint *atomic, 
51
g_atomic_int_add (volatile gint G_GNUC_MAY_ALIAS *atomic, 
52
		  gint           val)
52
		  gint           val)
53
{
53
{
54
  __asm__ __volatile__ ("lock; addl %1,%0"
54
  __asm__ __volatile__ ("lock; addl %1,%0"
Lines 57-63 Link Here
57
}
57
}
58
58
59
gboolean
59
gboolean
60
g_atomic_int_compare_and_exchange (volatile gint *atomic, 
60
g_atomic_int_compare_and_exchange (volatile gint G_GNUC_MAY_ALIAS *atomic, 
61
				   gint           oldval, 
61
				   gint           oldval, 
62
				   gint           newval)
62
				   gint           newval)
63
{
63
{
Lines 75-81 Link Here
75
 * arguments and calling the former function */
75
 * arguments and calling the former function */
76
76
77
gboolean
77
gboolean
78
g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic, 
78
g_atomic_pointer_compare_and_exchange (volatile gpointer G_GNUC_MAY_ALIAS *atomic, 
79
				       gpointer           oldval, 
79
				       gpointer           oldval, 
80
				       gpointer           newval)
80
				       gpointer           newval)
81
{
81
{
Lines 103-109 Link Here
103
103
104
#  if GLIB_SIZEOF_VOID_P == 4 /* 32-bit system */
104
#  if GLIB_SIZEOF_VOID_P == 4 /* 32-bit system */
105
gboolean
105
gboolean
106
g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic, 
106
g_atomic_pointer_compare_and_exchange (volatile gpointer G_GNUC_MAY_ALIAS *atomic, 
107
				       gpointer           oldval, 
107
				       gpointer           oldval, 
108
				       gpointer           newval)
108
				       gpointer           newval)
109
{
109
{
Lines 116-122 Link Here
116
}
116
}
117
#  elif GLIB_SIZEOF_VOID_P == 8 /* 64-bit system */
117
#  elif GLIB_SIZEOF_VOID_P == 8 /* 64-bit system */
118
gboolean
118
gboolean
119
g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic, 
119
g_atomic_pointer_compare_and_exchange (volatile gpointer G_GNUC_MAY_ALIAS *atomic, 
120
				       gpointer           oldval, 
120
				       gpointer           oldval, 
121
				       gpointer           newval)
121
				       gpointer           newval)
122
{
122
{
Lines 162-168 Link Here
162
  })
162
  })
163
#  if GLIB_SIZEOF_VOID_P == 4 /* 32-bit system */
163
#  if GLIB_SIZEOF_VOID_P == 4 /* 32-bit system */
164
gboolean
164
gboolean
165
g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic, 
165
g_atomic_pointer_compare_and_exchange (volatile gpointer G_GNUC_MAY_ALIAS *atomic, 
166
				       gpointer           oldval, 
166
				       gpointer           oldval, 
167
				       gpointer           newval)
167
				       gpointer           newval)
168
{
168
{
Lines 188-194 Link Here
188
}
188
}
189
#  elif GLIB_SIZEOF_VOID_P == 8 /* 64-bit system */
189
#  elif GLIB_SIZEOF_VOID_P == 8 /* 64-bit system */
190
gboolean
190
gboolean
191
g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic, 
191
g_atomic_pointer_compare_and_exchange (volatile gpointer G_GNUC_MAY_ALIAS *atomic, 
192
				       gpointer           oldval, 
192
				       gpointer           oldval, 
193
				       gpointer           newval)
193
				       gpointer           newval)
194
{
194
{
Lines 220-226 Link Here
220
/* Adapted from CVS version 1.9 of glibc's sysdeps/x86_64/bits/atomic.h 
220
/* Adapted from CVS version 1.9 of glibc's sysdeps/x86_64/bits/atomic.h 
221
 */
221
 */
222
gint
222
gint
223
g_atomic_int_exchange_and_add (volatile gint *atomic,
223
g_atomic_int_exchange_and_add (volatile gint G_GNUC_MAY_ALIAS *atomic,
224
			       gint           val)
224
			       gint           val)
225
{
225
{
226
  gint result;
226
  gint result;
Lines 232-238 Link Here
232
}
232
}
233
 
233
 
234
void
234
void
235
g_atomic_int_add (volatile gint *atomic, 
235
g_atomic_int_add (volatile gint G_GNUC_MAY_ALIAS *atomic, 
236
		  gint           val)
236
		  gint           val)
237
{
237
{
238
  __asm__ __volatile__ ("lock; addl %1,%0"
238
  __asm__ __volatile__ ("lock; addl %1,%0"
Lines 241-247 Link Here
241
}
241
}
242
242
243
gboolean
243
gboolean
244
g_atomic_int_compare_and_exchange (volatile gint *atomic, 
244
g_atomic_int_compare_and_exchange (volatile gint G_GNUC_MAY_ALIAS *atomic, 
245
				   gint           oldval, 
245
				   gint           oldval, 
246
				   gint           newval)
246
				   gint           newval)
247
{
247
{
Lines 255-261 Link Here
255
}
255
}
256
256
257
gboolean
257
gboolean
258
g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic, 
258
g_atomic_pointer_compare_and_exchange (volatile gpointer G_GNUC_MAY_ALIAS *atomic, 
259
				       gpointer           oldval, 
259
				       gpointer           oldval, 
260
				       gpointer           newval)
260
				       gpointer           newval)
261
{
261
{
Lines 277-283 Link Here
277
/* Non-optimizing compile bails on the following two asm statements
277
/* Non-optimizing compile bails on the following two asm statements
278
 * for reasons unknown to the author */
278
 * for reasons unknown to the author */
279
gint
279
gint
280
g_atomic_int_exchange_and_add (volatile gint *atomic, 
280
g_atomic_int_exchange_and_add (volatile gint G_GNUC_MAY_ALIAS *atomic, 
281
			       gint           val)
281
			       gint           val)
282
{
282
{
283
  gint result, temp;
283
  gint result, temp;
Lines 303-309 Link Here
303
 
303
 
304
/* The same as above, to save a function call repeated here */
304
/* The same as above, to save a function call repeated here */
305
void
305
void
306
g_atomic_int_add (volatile gint *atomic, 
306
g_atomic_int_add (volatile gint G_GNUC_MAY_ALIAS *atomic, 
307
		  gint           val)
307
		  gint           val)
308
{
308
{
309
  gint result, temp;  
309
  gint result, temp;  
Lines 327-333 Link Here
327
}
327
}
328
#   else /* !__OPTIMIZE__ */
328
#   else /* !__OPTIMIZE__ */
329
gint
329
gint
330
g_atomic_int_exchange_and_add (volatile gint *atomic, 
330
g_atomic_int_exchange_and_add (volatile gint G_GNUC_MAY_ALIAS *atomic, 
331
			       gint           val)
331
			       gint           val)
332
{
332
{
333
  gint result;
333
  gint result;
Lines 339-345 Link Here
339
}
339
}
340
 
340
 
341
void
341
void
342
g_atomic_int_add (volatile gint *atomic,
342
g_atomic_int_add (volatile gint G_GNUC_MAY_ALIAS *atomic,
343
		  gint           val)
343
		  gint           val)
344
{
344
{
345
  gint result;
345
  gint result;
Lines 351-357 Link Here
351
351
352
#   if GLIB_SIZEOF_VOID_P == 4 /* 32-bit system */
352
#   if GLIB_SIZEOF_VOID_P == 4 /* 32-bit system */
353
gboolean
353
gboolean
354
g_atomic_int_compare_and_exchange (volatile gint *atomic, 
354
g_atomic_int_compare_and_exchange (volatile gint G_GNUC_MAY_ALIAS *atomic, 
355
				   gint           oldval, 
355
				   gint           oldval, 
356
				   gint           newval)
356
				   gint           newval)
357
{
357
{
Lines 383-389 Link Here
383
}
383
}
384
384
385
gboolean
385
gboolean
386
g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic, 
386
g_atomic_pointer_compare_and_exchange (volatile gpointer G_GNUC_MAY_ALIAS *atomic, 
387
				       gpointer           oldval, 
387
				       gpointer           oldval, 
388
				       gpointer           newval)
388
				       gpointer           newval)
389
{
389
{
Lines 415-421 Link Here
415
}
415
}
416
#   elif GLIB_SIZEOF_VOID_P == 8 /* 64-bit system */
416
#   elif GLIB_SIZEOF_VOID_P == 8 /* 64-bit system */
417
gboolean
417
gboolean
418
g_atomic_int_compare_and_exchange (volatile gint *atomic,
418
g_atomic_int_compare_and_exchange (volatile gint G_GNUC_MAY_ALIAS *atomic,
419
				   gint           oldval, 
419
				   gint           oldval, 
420
				   gint           newval)
420
				   gint           newval)
421
{
421
{
Lines 449-455 Link Here
449
}
449
}
450
450
451
gboolean
451
gboolean
452
g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic, 
452
g_atomic_pointer_compare_and_exchange (volatile gpointer G_GNUC_MAY_ALIAS *atomic, 
453
				       gpointer           oldval, 
453
				       gpointer           oldval, 
454
				       gpointer           newval)
454
				       gpointer           newval)
455
{
455
{
Lines 489-495 Link Here
489
/* Adapted from CVS version 1.8 of glibc's sysdeps/ia64/bits/atomic.h
489
/* Adapted from CVS version 1.8 of glibc's sysdeps/ia64/bits/atomic.h
490
 */
490
 */
491
gint
491
gint
492
g_atomic_int_exchange_and_add (volatile gint *atomic,
492
g_atomic_int_exchange_and_add (volatile gint G_GNUC_MAY_ALIAS *atomic,
493
			       gint           val)
493
			       gint           val)
494
{
494
{
495
  return __sync_fetch_and_add (atomic, val);
495
  return __sync_fetch_and_add (atomic, val);
Lines 503-509 Link Here
503
}
503
}
504
504
505
gboolean
505
gboolean
506
g_atomic_int_compare_and_exchange (volatile gint *atomic,
506
g_atomic_int_compare_and_exchange (volatile gint G_GNUC_MAY_ALIAS *atomic,
507
				   gint           oldval, 
507
				   gint           oldval, 
508
				   gint           newval)
508
				   gint           newval)
509
{
509
{
Lines 511-517 Link Here
511
}
511
}
512
512
513
gboolean
513
gboolean
514
g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic,
514
g_atomic_pointer_compare_and_exchange (volatile gpointer G_GNUC_MAY_ALIAS *atomic,
515
				       gpointer           oldval, 
515
				       gpointer           oldval, 
516
				       gpointer           newval)
516
				       gpointer           newval)
517
{
517
{
Lines 534-540 Link Here
534
534
535
#  if GLIB_SIZEOF_VOID_P == 4 /* 32-bit system */
535
#  if GLIB_SIZEOF_VOID_P == 4 /* 32-bit system */
536
gboolean
536
gboolean
537
g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic,
537
g_atomic_pointer_compare_and_exchange (volatile gpointer G_GNUC_MAY_ALIAS *atomic,
538
				       gpointer           oldval,
538
				       gpointer           oldval,
539
				       gpointer           newval)
539
				       gpointer           newval)
540
{
540
{
Lines 546-552 Link Here
546
}
546
}
547
#  elif GLIB_SIZEOF_VOID_P == 8 /* 64-bit system */
547
#  elif GLIB_SIZEOF_VOID_P == 8 /* 64-bit system */
548
gboolean
548
gboolean
549
g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic,
549
g_atomic_pointer_compare_and_exchange (volatile gpointer G_GNUC_MAY_ALIAS *atomic,
550
				       gpointer           oldval,
550
				       gpointer           oldval,
551
				       gpointer           newval)
551
				       gpointer           newval)
552
{
552
{
Lines 590-596 Link Here
590
}
590
}
591
591
592
gint
592
gint
593
g_atomic_int_exchange_and_add (volatile gint *atomic, 
593
g_atomic_int_exchange_and_add (volatile gint G_GNUC_MAY_ALIAS *atomic, 
594
			       gint           val)
594
			       gint           val)
595
{
595
{
596
  gint result;
596
  gint result;
Lines 604-610 Link Here
604
}
604
}
605
605
606
void
606
void
607
g_atomic_int_add (volatile gint *atomic,
607
g_atomic_int_add (volatile gint G_GNUC_MAY_ALIAS *atomic,
608
		  gint           val)
608
		  gint           val)
609
{
609
{
610
  atomic_spin_lock();
610
  atomic_spin_lock();
Lines 613-619 Link Here
613
}
613
}
614
614
615
gboolean
615
gboolean
616
g_atomic_int_compare_and_exchange (volatile gint *atomic, 
616
g_atomic_int_compare_and_exchange (volatile gint G_GNUC_MAY_ALIAS *atomic, 
617
				   gint           oldval, 
617
				   gint           oldval, 
618
				   gint           newval)
618
				   gint           newval)
619
{
619
{
Lines 633-639 Link Here
633
}
633
}
634
634
635
gboolean
635
gboolean
636
g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic, 
636
g_atomic_pointer_compare_and_exchange (volatile gpointer G_GNUC_MAY_ALIAS *atomic, 
637
				       gpointer           oldval, 
637
				       gpointer           oldval, 
638
				       gpointer           newval)
638
				       gpointer           newval)
639
{
639
{
Lines 675-695 Link Here
675
# endif
675
# endif
676
676
677
gint32
677
gint32
678
g_atomic_int_exchange_and_add (volatile gint32 *atomic,
678
g_atomic_int_exchange_and_add (volatile gint32 G_GNUC_MAY_ALIAS *atomic,
679
			       gint32           val)
679
			       gint32           val)
680
{
680
{
681
  return InterlockedExchangeAdd (atomic, val);
681
  return InterlockedExchangeAdd (atomic, val);
682
}
682
}
683
683
684
void     
684
void     
685
g_atomic_int_add (volatile gint32 *atomic, 
685
g_atomic_int_add (volatile gint32 G_GNUC_MAY_ALIAS *atomic, 
686
		  gint32           val)
686
		  gint32           val)
687
{
687
{
688
  InterlockedExchangeAdd (atomic, val);
688
  InterlockedExchangeAdd (atomic, val);
689
}
689
}
690
690
691
gboolean 
691
gboolean 
692
g_atomic_int_compare_and_exchange (volatile gint32 *atomic,
692
g_atomic_int_compare_and_exchange (volatile gint32 G_GNUC_MAY_ALIAS *atomic,
693
				   gint32           oldval,
693
				   gint32           oldval,
694
				   gint32           newval)
694
				   gint32           newval)
695
{
695
{
Lines 705-711 Link Here
705
}
705
}
706
706
707
gboolean 
707
gboolean 
708
g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic,
708
g_atomic_pointer_compare_and_exchange (volatile gpointer G_GNUC_MAY_ALIAS *atomic,
709
				       gpointer           oldval,
709
				       gpointer           oldval,
710
				       gpointer           newval)
710
				       gpointer           newval)
711
{
711
{
Lines 726-732 Link Here
726
static GMutex *g_atomic_mutex; 
726
static GMutex *g_atomic_mutex; 
727
727
728
gint
728
gint
729
g_atomic_int_exchange_and_add (volatile gint *atomic, 
729
g_atomic_int_exchange_and_add (volatile gint G_GNUC_MAY_ALIAS *atomic, 
730
			       gint           val)
730
			       gint           val)
731
{
731
{
732
  gint result;
732
  gint result;
Lines 741-747 Link Here
741
741
742
742
743
void
743
void
744
g_atomic_int_add (volatile gint *atomic,
744
g_atomic_int_add (volatile gint G_GNUC_MAY_ALIAS *atomic,
745
		  gint           val)
745
		  gint           val)
746
{
746
{
747
  g_mutex_lock (g_atomic_mutex);
747
  g_mutex_lock (g_atomic_mutex);
Lines 750-756 Link Here
750
}
750
}
751
751
752
gboolean
752
gboolean
753
g_atomic_int_compare_and_exchange (volatile gint *atomic, 
753
g_atomic_int_compare_and_exchange (volatile gint G_GNUC_MAY_ALIAS *atomic, 
754
				   gint           oldval, 
754
				   gint           oldval, 
755
				   gint           newval)
755
				   gint           newval)
756
{
756
{
Lines 770-776 Link Here
770
}
770
}
771
771
772
gboolean
772
gboolean
773
g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic, 
773
g_atomic_pointer_compare_and_exchange (volatile gpointer G_GNUC_MAY_ALIAS *atomic, 
774
				       gpointer           oldval, 
774
				       gpointer           oldval, 
775
				       gpointer           newval)
775
				       gpointer           newval)
776
{
776
{
Lines 791-797 Link Here
791
791
792
#ifdef G_ATOMIC_OP_MEMORY_BARRIER_NEEDED
792
#ifdef G_ATOMIC_OP_MEMORY_BARRIER_NEEDED
793
gint
793
gint
794
g_atomic_int_get (volatile gint *atomic)
794
g_atomic_int_get (volatile gint G_GNUC_MAY_ALIAS *atomic)
795
{
795
{
796
  gint result;
796
  gint result;
797
797
Lines 803-809 Link Here
803
}
803
}
804
804
805
void
805
void
806
g_atomic_int_set (volatile gint *atomic,
806
g_atomic_int_set (volatile gint G_GNUC_MAY_ALIAS *atomic,
807
                  gint           newval)
807
                  gint           newval)
808
{
808
{
809
  g_mutex_lock (g_atomic_mutex);
809
  g_mutex_lock (g_atomic_mutex);
Lines 812-818 Link Here
812
}
812
}
813
813
814
gpointer
814
gpointer
815
g_atomic_pointer_get (volatile gpointer *atomic)
815
g_atomic_pointer_get (volatile gpointer G_GNUC_MAY_ALIAS *atomic)
816
{
816
{
817
  gpointer result;
817
  gpointer result;
818
818
Lines 824-830 Link Here
824
}
824
}
825
825
826
void
826
void
827
g_atomic_pointer_set (volatile gpointer *atomic,
827
g_atomic_pointer_set (volatile gpointer G_GNUC_MAY_ALIAS *atomic,
828
                      gpointer           newval)
828
                      gpointer           newval)
829
{
829
{
830
  g_mutex_lock (g_atomic_mutex);
830
  g_mutex_lock (g_atomic_mutex);
Lines 834-847 Link Here
834
#endif /* G_ATOMIC_OP_MEMORY_BARRIER_NEEDED */   
834
#endif /* G_ATOMIC_OP_MEMORY_BARRIER_NEEDED */   
835
#elif defined (G_ATOMIC_OP_MEMORY_BARRIER_NEEDED)
835
#elif defined (G_ATOMIC_OP_MEMORY_BARRIER_NEEDED)
836
gint
836
gint
837
g_atomic_int_get (volatile gint *atomic)
837
g_atomic_int_get (volatile gint G_GNUC_MAY_ALIAS *atomic)
838
{
838
{
839
  G_ATOMIC_MEMORY_BARRIER;
839
  G_ATOMIC_MEMORY_BARRIER;
840
  return *atomic;
840
  return *atomic;
841
}
841
}
842
842
843
void
843
void
844
g_atomic_int_set (volatile gint *atomic,
844
g_atomic_int_set (volatile gint G_GNUC_MAY_ALIAS *atomic,
845
                  gint           newval)
845
                  gint           newval)
846
{
846
{
847
  *atomic = newval;
847
  *atomic = newval;
Lines 849-862 Link Here
849
}
849
}
850
850
851
gpointer
851
gpointer
852
g_atomic_pointer_get (volatile gpointer *atomic)
852
g_atomic_pointer_get (volatile gpointer G_GNUC_MAY_ALIAS *atomic)
853
{
853
{
854
  G_ATOMIC_MEMORY_BARRIER;
854
  G_ATOMIC_MEMORY_BARRIER;
855
  return *atomic;
855
  return *atomic;
856
}   
856
}   
857
857
858
void
858
void
859
g_atomic_pointer_set (volatile gpointer *atomic,
859
g_atomic_pointer_set (volatile gpointer G_GNUC_MAY_ALIAS *atomic,
860
                      gpointer           newval)
860
                      gpointer           newval)
861
{
861
{
862
  *atomic = newval;
862
  *atomic = newval;
Lines 866-872 Link Here
866
866
867
#ifdef ATOMIC_INT_CMP_XCHG
867
#ifdef ATOMIC_INT_CMP_XCHG
868
gboolean
868
gboolean
869
g_atomic_int_compare_and_exchange (volatile gint *atomic,
869
g_atomic_int_compare_and_exchange (volatile gint G_GNUC_MAY_ALIAS *atomic,
870
				   gint           oldval,
870
				   gint           oldval,
871
				   gint           newval)
871
				   gint           newval)
872
{
872
{
Lines 874-880 Link Here
874
}
874
}
875
875
876
gint
876
gint
877
g_atomic_int_exchange_and_add (volatile gint *atomic,
877
g_atomic_int_exchange_and_add (volatile gint G_GNUC_MAY_ALIAS *atomic,
878
			       gint           val)
878
			       gint           val)
879
{
879
{
880
  gint result;
880
  gint result;
Lines 886-892 Link Here
886
}
886
}
887
 
887
 
888
void
888
void
889
g_atomic_int_add (volatile gint *atomic,
889
g_atomic_int_add (volatile gint G_GNUC_MAY_ALIAS *atomic,
890
		  gint           val)
890
		  gint           val)
891
{
891
{
892
  gint result;
892
  gint result;
Lines 906-931 Link Here
906
906
907
#ifndef G_ATOMIC_OP_MEMORY_BARRIER_NEEDED
907
#ifndef G_ATOMIC_OP_MEMORY_BARRIER_NEEDED
908
gint
908
gint
909
(g_atomic_int_get) (volatile gint *atomic)
909
(g_atomic_int_get) (volatile gint G_GNUC_MAY_ALIAS *atomic)
910
{
910
{
911
  return g_atomic_int_get (atomic);
911
  return g_atomic_int_get (atomic);
912
}
912
}
913
913
914
void
914
void
915
(g_atomic_int_set) (volatile gint *atomic,
915
(g_atomic_int_set) (volatile gint G_GNUC_MAY_ALIAS *atomic,
916
		    gint           newval)
916
		    gint           newval)
917
{
917
{
918
  g_atomic_int_set (atomic, newval);
918
  g_atomic_int_set (atomic, newval);
919
}
919
}
920
920
921
gpointer
921
gpointer
922
(g_atomic_pointer_get) (volatile gpointer *atomic)
922
(g_atomic_pointer_get) (volatile gpointer G_GNUC_MAY_ALIAS *atomic)
923
{
923
{
924
  return g_atomic_pointer_get (atomic);
924
  return g_atomic_pointer_get (atomic);
925
}
925
}
926
926
927
void
927
void
928
(g_atomic_pointer_set) (volatile gpointer *atomic,
928
(g_atomic_pointer_set) (volatile gpointer G_GNUC_MAY_ALIAS *atomic,
929
			gpointer           newval)
929
			gpointer           newval)
930
{
930
{
931
  g_atomic_pointer_set (atomic, newval);
931
  g_atomic_pointer_set (atomic, newval);
(-)glib-2.18.4-orig/glib/gatomic.h (-10 / +23 lines)
Lines 38-66 Link Here
38
38
39
G_BEGIN_DECLS
39
G_BEGIN_DECLS
40
40
41
gint     g_atomic_int_exchange_and_add         (volatile gint	  *atomic,
41
gint     g_atomic_int_exchange_and_add         (volatile gint G_GNUC_MAY_ALIAS *atomic,
42
						gint      	   val);
42
						gint      	   val);
43
void     g_atomic_int_add                      (volatile gint	  *atomic,
43
void     g_atomic_int_add                      (volatile gint G_GNUC_MAY_ALIAS *atomic,
44
						gint      	   val);
44
						gint      	   val);
45
gboolean g_atomic_int_compare_and_exchange     (volatile gint	  *atomic,
45
gboolean g_atomic_int_compare_and_exchange     (volatile gint G_GNUC_MAY_ALIAS *atomic,
46
						gint      	   oldval,
46
						gint      	   oldval,
47
						gint      	   newval);
47
						gint      	   newval);
48
gboolean g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic, 
48
gboolean g_atomic_pointer_compare_and_exchange (volatile gpointer G_GNUC_MAY_ALIAS *atomic, 
49
						gpointer  	   oldval, 
49
						gpointer  	   oldval, 
50
						gpointer  	   newval);
50
						gpointer  	   newval);
51
51
52
gint     g_atomic_int_get                      (volatile gint  	  *atomic);
52
gint     g_atomic_int_get                      (volatile gint G_GNUC_MAY_ALIAS *atomic);
53
void     g_atomic_int_set                      (volatile gint  	  *atomic,
53
void     g_atomic_int_set                      (volatile gint G_GNUC_MAY_ALIAS *atomic,
54
						gint               newval);
54
						gint               newval);
55
gpointer g_atomic_pointer_get                  (volatile gpointer *atomic);
55
gpointer g_atomic_pointer_get                  (volatile gpointer G_GNUC_MAY_ALIAS *atomic);
56
void     g_atomic_pointer_set                  (volatile gpointer *atomic,
56
void     g_atomic_pointer_set                  (volatile gpointer G_GNUC_MAY_ALIAS *atomic,
57
						gpointer           newval);
57
						gpointer           newval);
58
58
59
#ifndef G_ATOMIC_OP_MEMORY_BARRIER_NEEDED
59
#ifndef G_ATOMIC_OP_MEMORY_BARRIER_NEEDED
60
# define g_atomic_int_get(atomic) 		(*(atomic))
60
# define g_atomic_int_get(atomic) 		((gint)*(atomic))
61
# define g_atomic_int_set(atomic, newval) 	((void) (*(atomic) = (newval)))
61
# define g_atomic_int_set(atomic, newval) 	((void) (*(atomic) = (newval)))
62
# define g_atomic_pointer_get(atomic) 		(*(atomic))
62
# define g_atomic_pointer_get(atomic) 		((gpointer)*(atomic))
63
# define g_atomic_pointer_set(atomic, newval)	((void) (*(atomic) = (newval)))
63
# define g_atomic_pointer_set(atomic, newval)	((void) (*(atomic) = (newval)))
64
#else
65
# define g_atomic_int_get(atomic) \
66
 ((void) sizeof (gchar [sizeof (*(atomic)) == sizeof (gint) ? 1 : -1]), \
67
  (g_atomic_int_get) ((volatile gint G_GNUC_MAY_ALIAS *) (void *) (atomic)))
68
# define g_atomic_int_set(atomic, newval) \
69
 ((void) sizeof (gchar [sizeof (*(atomic)) == sizeof (gint) ? 1 : -1]), \
70
  (g_atomic_int_set) ((volatile gint G_GNUC_MAY_ALIAS *) (void *) (atomic), (newval)))
71
# define g_atomic_pointer_get(atomic) \
72
 ((void) sizeof (gchar [sizeof (*(atomic)) == sizeof (gpointer) ? 1 : -1]), \
73
  (g_atomic_pointer_get) ((volatile gpointer G_GNUC_MAY_ALIAS *) (void *) (atomic)))
74
# define g_atomic_pointer_set(atomic, newval) \
75
 ((void) sizeof (gchar [sizeof (*(atomic)) == sizeof (gpointer) ? 1 : -1]), \
76
  (g_atomic_pointer_set) ((volatile gpointer G_GNUC_MAY_ALIAS *) (void *) (atomic), (newval)))
64
#endif /* G_ATOMIC_OP_MEMORY_BARRIER_NEEDED */
77
#endif /* G_ATOMIC_OP_MEMORY_BARRIER_NEEDED */
65
78
66
#define g_atomic_int_inc(atomic) (g_atomic_int_add ((atomic), 1))
79
#define g_atomic_int_inc(atomic) (g_atomic_int_add ((atomic), 1))
(-)glib-2.18.4-orig/glib/gdataset.c (-2 / +2 lines)
Lines 44-50 Link Here
44
44
45
/* datalist pointer accesses have to be carried out atomically */
45
/* datalist pointer accesses have to be carried out atomically */
46
#define G_DATALIST_GET_POINTER(datalist)						\
46
#define G_DATALIST_GET_POINTER(datalist)						\
47
  ((GData*) ((gsize) g_atomic_pointer_get ((gpointer*) datalist) & ~(gsize) G_DATALIST_FLAGS_MASK))
47
  ((GData*) ((gsize) g_atomic_pointer_get (datalist) & ~(gsize) G_DATALIST_FLAGS_MASK))
48
48
49
#define G_DATALIST_SET_POINTER(datalist, pointer)       G_STMT_START {                  \
49
#define G_DATALIST_SET_POINTER(datalist, pointer)       G_STMT_START {                  \
50
  gpointer _oldv, _newv;                                                                \
50
  gpointer _oldv, _newv;                                                                \
Lines 505-511 Link Here
505
{
505
{
506
  g_return_if_fail (datalist != NULL);
506
  g_return_if_fail (datalist != NULL);
507
507
508
  g_atomic_pointer_set ((gpointer*) datalist, NULL);
508
  g_atomic_pointer_set (datalist, NULL);
509
}
509
}
510
510
511
/**
511
/**
(-)glib-2.18.4-orig/glib/gdatasetprivate.h (-1 / +1 lines)
Lines 36-42 Link Here
36
 * barriers to take effect without acquiring the global dataset mutex.
36
 * barriers to take effect without acquiring the global dataset mutex.
37
 */
37
 */
38
#define G_DATALIST_GET_FLAGS(datalist)				\
38
#define G_DATALIST_GET_FLAGS(datalist)				\
39
  ((gsize) g_atomic_pointer_get ((gpointer*) datalist) & G_DATALIST_FLAGS_MASK)
39
  ((gsize) g_atomic_pointer_get (datalist) & G_DATALIST_FLAGS_MASK)
40
40
41
41
42
G_END_DECLS
42
G_END_DECLS
(-)glib-2.18.4-orig/glib/gthread.c (-4 / +4 lines)
Lines 204-210 Link Here
204
{
204
{
205
  gboolean need_init = FALSE;
205
  gboolean need_init = FALSE;
206
  g_mutex_lock (g_once_mutex);
206
  g_mutex_lock (g_once_mutex);
207
  if (g_atomic_pointer_get ((void**) value_location) == NULL)
207
  if (g_atomic_pointer_get (value_location) == NULL)
208
    {
208
    {
209
      if (!g_slist_find (g_once_init_list, (void*) value_location))
209
      if (!g_slist_find (g_once_init_list, (void*) value_location))
210
        {
210
        {
Lines 224-234 Link Here
224
g_once_init_leave (volatile gsize *value_location,
224
g_once_init_leave (volatile gsize *value_location,
225
                   gsize           initialization_value)
225
                   gsize           initialization_value)
226
{
226
{
227
  g_return_if_fail (g_atomic_pointer_get ((void**) value_location) == NULL);
227
  g_return_if_fail (g_atomic_pointer_get (value_location) == NULL);
228
  g_return_if_fail (initialization_value != 0);
228
  g_return_if_fail (initialization_value != 0);
229
  g_return_if_fail (g_once_init_list != NULL);
229
  g_return_if_fail (g_once_init_list != NULL);
230
230
231
  g_atomic_pointer_set ((void**) value_location, (void*) initialization_value);
231
  g_atomic_pointer_set (value_location, (void*) initialization_value);
232
  g_mutex_lock (g_once_mutex);
232
  g_mutex_lock (g_once_mutex);
233
  g_once_init_list = g_slist_remove (g_once_init_list, (void*) value_location);
233
  g_once_init_list = g_slist_remove (g_once_init_list, (void*) value_location);
234
  g_cond_broadcast (g_once_cond);
234
  g_cond_broadcast (g_once_cond);
Lines 256-262 Link Here
256
  g_mutex_lock (g_once_mutex);
256
  g_mutex_lock (g_once_mutex);
257
257
258
  if (!(*mutex))
258
  if (!(*mutex))
259
    g_atomic_pointer_set ((void**) mutex, g_mutex_new());
259
    g_atomic_pointer_set (mutex, g_mutex_new());
260
260
261
  g_mutex_unlock (g_once_mutex);
261
  g_mutex_unlock (g_once_mutex);
262
262
(-)glib-2.18.4-orig/glib/gthread.h (-2 / +2 lines)
Lines 145-151 Link Here
145
GMutex* g_static_mutex_get_mutex_impl   (GMutex **mutex);
145
GMutex* g_static_mutex_get_mutex_impl   (GMutex **mutex);
146
146
147
#define g_static_mutex_get_mutex_impl_shortcut(mutex) \
147
#define g_static_mutex_get_mutex_impl_shortcut(mutex) \
148
  (g_atomic_pointer_get ((gpointer*)(void*)mutex) ? *(mutex) : \
148
  (g_atomic_pointer_get (mutex) ? *(mutex) : \
149
   g_static_mutex_get_mutex_impl (mutex))
149
   g_static_mutex_get_mutex_impl (mutex))
150
150
151
/* shorthands for conditional and unconditional function calls */
151
/* shorthands for conditional and unconditional function calls */
Lines 336-342 Link Here
336
G_INLINE_FUNC gboolean
336
G_INLINE_FUNC gboolean
337
g_once_init_enter (volatile gsize *value_location)
337
g_once_init_enter (volatile gsize *value_location)
338
{
338
{
339
  if G_LIKELY (g_atomic_pointer_get ((void*volatile*) value_location) != NULL)
339
  if G_LIKELY ((gpointer) g_atomic_pointer_get (value_location) != NULL)
340
    return FALSE;
340
    return FALSE;
341
  else
341
  else
342
    return g_once_init_enter_impl (value_location);
342
    return g_once_init_enter_impl (value_location);

Return to bug 264686