~ubuntu-branches/ubuntu/vivid/glib2.0/vivid-proposed

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>GLib Reference Manual: Atomic Operations</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<link rel="home" href="index.html" title="GLib Reference Manual">
<link rel="up" href="glib-fundamentals.html" title="GLib Fundamentals">
<link rel="prev" href="glib-Miscellaneous-Macros.html" title="Miscellaneous Macros">
<link rel="next" href="glib-core.html" title="GLib Core Application Support">
<meta name="generator" content="GTK-Doc V1.21 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
<td width="100%" align="left" class="shortcuts">
<a href="#" class="shortcut">Top</a><span id="nav_description">  <span class="dim">|</span> 
                  <a href="#glib-Atomic-Operations.description" class="shortcut">Description</a></span>
</td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
<td><a accesskey="u" href="glib-fundamentals.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
<td><a accesskey="p" href="glib-Miscellaneous-Macros.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
<td><a accesskey="n" href="glib-core.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
</tr></table>
<div class="refentry">
<a name="glib-Atomic-Operations"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="glib-Atomic-Operations.top_of_page"></a>Atomic Operations</span></h2>
<p>Atomic Operations — basic atomic integer and pointer operations</p>
</td>
<td class="gallery_image" valign="top" align="right"></td>
</tr></table></div>
<div class="refsect1">
<a name="glib-Atomic-Operations.functions"></a><h2>Functions</h2>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="functions_return">
<col class="functions_name">
</colgroup>
<tbody>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a>
</td>
<td class="function_name">
<a class="link" href="glib-Atomic-Operations.html#g-atomic-int-get" title="g_atomic_int_get ()">g_atomic_int_get</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">void</span>
</td>
<td class="function_name">
<a class="link" href="glib-Atomic-Operations.html#g-atomic-int-set" title="g_atomic_int_set ()">g_atomic_int_set</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">void</span>
</td>
<td class="function_name">
<a class="link" href="glib-Atomic-Operations.html#g-atomic-int-inc" title="g_atomic_int_inc ()">g_atomic_int_inc</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
</td>
<td class="function_name">
<a class="link" href="glib-Atomic-Operations.html#g-atomic-int-dec-and-test" title="g_atomic_int_dec_and_test ()">g_atomic_int_dec_and_test</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
</td>
<td class="function_name">
<a class="link" href="glib-Atomic-Operations.html#g-atomic-int-compare-and-exchange" title="g_atomic_int_compare_and_exchange ()">g_atomic_int_compare_and_exchange</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a>
</td>
<td class="function_name">
<a class="link" href="glib-Atomic-Operations.html#g-atomic-int-add" title="g_atomic_int_add ()">g_atomic_int_add</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="returnvalue">guint</span></a>
</td>
<td class="function_name">
<a class="link" href="glib-Atomic-Operations.html#g-atomic-int-and" title="g_atomic_int_and ()">g_atomic_int_and</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="returnvalue">guint</span></a>
</td>
<td class="function_name">
<a class="link" href="glib-Atomic-Operations.html#g-atomic-int-or" title="g_atomic_int_or ()">g_atomic_int_or</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="returnvalue">guint</span></a>
</td>
<td class="function_name">
<a class="link" href="glib-Atomic-Operations.html#g-atomic-int-xor" title="g_atomic_int_xor ()">g_atomic_int_xor</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a>
</td>
<td class="function_name">
<a class="link" href="glib-Atomic-Operations.html#g-atomic-pointer-get" title="g_atomic_pointer_get ()">g_atomic_pointer_get</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">void</span>
</td>
<td class="function_name">
<a class="link" href="glib-Atomic-Operations.html#g-atomic-pointer-set" title="g_atomic_pointer_set ()">g_atomic_pointer_set</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
</td>
<td class="function_name">
<a class="link" href="glib-Atomic-Operations.html#g-atomic-pointer-compare-and-exchange" title="g_atomic_pointer_compare_and_exchange ()">g_atomic_pointer_compare_and_exchange</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gssize" title="gssize"><span class="returnvalue">gssize</span></a>
</td>
<td class="function_name">
<a class="link" href="glib-Atomic-Operations.html#g-atomic-pointer-add" title="g_atomic_pointer_add ()">g_atomic_pointer_add</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gsize" title="gsize"><span class="returnvalue">gsize</span></a>
</td>
<td class="function_name">
<a class="link" href="glib-Atomic-Operations.html#g-atomic-pointer-and" title="g_atomic_pointer_and ()">g_atomic_pointer_and</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gsize" title="gsize"><span class="returnvalue">gsize</span></a>
</td>
<td class="function_name">
<a class="link" href="glib-Atomic-Operations.html#g-atomic-pointer-or" title="g_atomic_pointer_or ()">g_atomic_pointer_or</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gsize" title="gsize"><span class="returnvalue">gsize</span></a>
</td>
<td class="function_name">
<a class="link" href="glib-Atomic-Operations.html#g-atomic-pointer-xor" title="g_atomic_pointer_xor ()">g_atomic_pointer_xor</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a>
</td>
<td class="function_name">
<a class="link" href="glib-Atomic-Operations.html#g-atomic-int-exchange-and-add" title="g_atomic_int_exchange_and_add ()">g_atomic_int_exchange_and_add</a> <span class="c_punctuation">()</span>
</td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect1">
<a name="glib-Atomic-Operations.other"></a><h2>Types and Values</h2>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="name">
<col class="description">
</colgroup>
<tbody><tr>
<td class="define_keyword">#define</td>
<td class="function_name"><a class="link" href="glib-Atomic-Operations.html#G-ATOMIC-LOCK-FREE:CAPS" title="G_ATOMIC_LOCK_FREE">G_ATOMIC_LOCK_FREE</a></td>
</tr></tbody>
</table></div>
</div>
<div class="refsect1">
<a name="glib-Atomic-Operations.includes"></a><h2>Includes</h2>
<pre class="synopsis">#include &lt;glib.h&gt;
</pre>
</div>
<div class="refsect1">
<a name="glib-Atomic-Operations.description"></a><h2>Description</h2>
<p>The following is a collection of compiler macros to provide atomic
access to integer and pointer-sized values.</p>
<p>The macros that have 'int' in the name will operate on pointers to
<a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> and <a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a>.  The macros with 'pointer' in the name will operate
on pointers to any pointer-sized value, including <a class="link" href="glib-Basic-Types.html#gsize" title="gsize"><span class="type">gsize</span></a>.  There is
no support for 64bit operations on platforms with 32bit pointers
because it is not generally possible to perform these operations
atomically.</p>
<p>The get, set and exchange operations for integers and pointers
nominally operate on <a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> and <a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a>, respectively.  Of the
arithmetic operations, the 'add' operation operates on (and returns)
signed integer values (<a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> and <a class="link" href="glib-Basic-Types.html#gssize" title="gssize"><span class="type">gssize</span></a>) and the 'and', 'or', and
'xor' operations operate on (and return) unsigned integer values
(<a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> and <a class="link" href="glib-Basic-Types.html#gsize" title="gsize"><span class="type">gsize</span></a>).</p>
<p>All of the operations act as a full compiler and (where appropriate)
hardware memory barrier.  Acquire and release or producer and
consumer barrier semantics are not available through this API.</p>
<p>It is very important that all accesses to a particular integer or
pointer be performed using only this API and that different sizes of
operation are not mixed or used on overlapping memory regions.  Never
read or assign directly from or to a value -- always use this API.</p>
<p>For simple reference counting purposes you should use
<a class="link" href="glib-Atomic-Operations.html#g-atomic-int-inc" title="g_atomic_int_inc ()"><code class="function">g_atomic_int_inc()</code></a> and <a class="link" href="glib-Atomic-Operations.html#g-atomic-int-dec-and-test" title="g_atomic_int_dec_and_test ()"><code class="function">g_atomic_int_dec_and_test()</code></a>.  Other uses that
fall outside of simple reference counting patterns are prone to
subtle bugs and occasionally undefined behaviour.  It is also worth
noting that since all of these operations require global
synchronisation of the entire machine, they can be quite slow.  In * the case of performing multiple atomic operations it can often be
faster to simply acquire a mutex lock around the critical area,
perform the operations normally and then release the lock.</p>
</div>
<div class="refsect1">
<a name="glib-Atomic-Operations.functions_details"></a><h2>Functions</h2>
<div class="refsect2">
<a name="g-atomic-int-get"></a><h3>g_atomic_int_get ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a>
g_atomic_int_get (<em class="parameter"><code>const volatile <a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> *atomic</code></em>);</pre>
<p>Gets the current value of <em class="parameter"><code>atomic</code></em>
.</p>
<p>This call acts as a full compiler and hardware
memory barrier (before the get).</p>
<div class="refsect3">
<a name="id-1.3.9.7.2.6"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>atomic</p></td>
<td class="parameter_description"><p>a pointer to a <a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> or <a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a></p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.3.9.7.2.7"></a><h4>Returns</h4>
<p> the value of the integer</p>
<p></p>
</div>
<p class="since">Since 2.4</p>
</div>
<hr>
<div class="refsect2">
<a name="g-atomic-int-set"></a><h3>g_atomic_int_set ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>
g_atomic_int_set (<em class="parameter"><code>volatile <a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> *atomic</code></em>,
                  <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> newval</code></em>);</pre>
<p>Sets the value of <em class="parameter"><code>atomic</code></em>
 to <em class="parameter"><code>newval</code></em>
.</p>
<p>This call acts as a full compiler and hardware
memory barrier (after the set).</p>
<div class="refsect3">
<a name="id-1.3.9.7.3.6"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>atomic</p></td>
<td class="parameter_description"><p>a pointer to a <a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> or <a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a></p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>newval</p></td>
<td class="parameter_description"><p>a new value to store</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<p class="since">Since 2.4</p>
</div>
<hr>
<div class="refsect2">
<a name="g-atomic-int-inc"></a><h3>g_atomic_int_inc ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>
g_atomic_int_inc (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> *atomic</code></em>);</pre>
<p>Increments the value of <em class="parameter"><code>atomic</code></em>
 by 1.</p>
<p>Think of this operation as an atomic version of <code class="literal">{ *atomic += 1; }</code>.</p>
<p>This call acts as a full compiler and hardware memory barrier.</p>
<div class="refsect3">
<a name="id-1.3.9.7.4.7"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>atomic</p></td>
<td class="parameter_description"><p>a pointer to a <a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> or <a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a></p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<p class="since">Since 2.4</p>
</div>
<hr>
<div class="refsect2">
<a name="g-atomic-int-dec-and-test"></a><h3>g_atomic_int_dec_and_test ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
g_atomic_int_dec_and_test (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> *atomic</code></em>);</pre>
<p>Decrements the value of <em class="parameter"><code>atomic</code></em>
 by 1.</p>
<p>Think of this operation as an atomic version of
<code class="literal">{ *atomic -= 1; return (*atomic == 0); }</code>.</p>
<p>This call acts as a full compiler and hardware memory barrier.</p>
<div class="refsect3">
<a name="id-1.3.9.7.5.7"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>atomic</p></td>
<td class="parameter_description"><p>a pointer to a <a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> or <a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a></p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.3.9.7.5.8"></a><h4>Returns</h4>
<p> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the resultant value is zero</p>
<p></p>
</div>
<p class="since">Since 2.4</p>
</div>
<hr>
<div class="refsect2">
<a name="g-atomic-int-compare-and-exchange"></a><h3>g_atomic_int_compare_and_exchange ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
g_atomic_int_compare_and_exchange (<em class="parameter"><code>volatile <a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> *atomic</code></em>,
                                   <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> oldval</code></em>,
                                   <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> newval</code></em>);</pre>
<p>Compares <em class="parameter"><code>atomic</code></em>
 to <em class="parameter"><code>oldval</code></em>
 and, if equal, sets it to <em class="parameter"><code>newval</code></em>
.
If <em class="parameter"><code>atomic</code></em>
 was not equal to <em class="parameter"><code>oldval</code></em>
 then no change occurs.</p>
<p>This compare and exchange is done atomically.</p>
<p>Think of this operation as an atomic version of
<code class="literal">{ if (*atomic == oldval) { *atomic = newval; return TRUE; } else return FALSE; }</code>.</p>
<p>This call acts as a full compiler and hardware memory barrier.</p>
<div class="refsect3">
<a name="id-1.3.9.7.6.8"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>atomic</p></td>
<td class="parameter_description"><p>a pointer to a <a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> or <a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a></p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>oldval</p></td>
<td class="parameter_description"><p>the value to compare with</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>newval</p></td>
<td class="parameter_description"><p>the value to conditionally replace with</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.3.9.7.6.9"></a><h4>Returns</h4>
<p> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the exchange took place</p>
<p></p>
</div>
<p class="since">Since 2.4</p>
</div>
<hr>
<div class="refsect2">
<a name="g-atomic-int-add"></a><h3>g_atomic_int_add ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a>
g_atomic_int_add (<em class="parameter"><code>volatile <a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> *atomic</code></em>,
                  <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> val</code></em>);</pre>
<p>Atomically adds <em class="parameter"><code>val</code></em>
 to the value of <em class="parameter"><code>atomic</code></em>
.</p>
<p>Think of this operation as an atomic version of
<code class="literal">{ tmp = *atomic; *atomic += val; return tmp; }</code>.</p>
<p>This call acts as a full compiler and hardware memory barrier.</p>
<p>Before version 2.30, this function did not return a value
(but <a class="link" href="glib-Atomic-Operations.html#g-atomic-int-exchange-and-add" title="g_atomic_int_exchange_and_add ()"><code class="function">g_atomic_int_exchange_and_add()</code></a> did, and had the same meaning).</p>
<div class="refsect3">
<a name="id-1.3.9.7.7.8"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>atomic</p></td>
<td class="parameter_description"><p>a pointer to a <a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> or <a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a></p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>val</p></td>
<td class="parameter_description"><p>the value to add</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.3.9.7.7.9"></a><h4>Returns</h4>
<p> the value of <em class="parameter"><code>atomic</code></em>
before the add, signed</p>
<p></p>
</div>
<p class="since">Since 2.4</p>
</div>
<hr>
<div class="refsect2">
<a name="g-atomic-int-and"></a><h3>g_atomic_int_and ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="returnvalue">guint</span></a>
g_atomic_int_and (<em class="parameter"><code>volatile <a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> *atomic</code></em>,
                  <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> val</code></em>);</pre>
<p>Performs an atomic bitwise 'and' of the value of <em class="parameter"><code>atomic</code></em>
 and <em class="parameter"><code>val</code></em>
,
storing the result back in <em class="parameter"><code>atomic</code></em>
.</p>
<p>This call acts as a full compiler and hardware memory barrier.</p>
<p>Think of this operation as an atomic version of
<code class="literal">{ tmp = *atomic; *atomic &amp;= val; return tmp; }</code>.</p>
<div class="refsect3">
<a name="id-1.3.9.7.8.7"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>atomic</p></td>
<td class="parameter_description"><p>a pointer to a <a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> or <a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a></p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>val</p></td>
<td class="parameter_description"><p>the value to 'and'</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.3.9.7.8.8"></a><h4>Returns</h4>
<p> the value of <em class="parameter"><code>atomic</code></em>
before the operation, unsigned</p>
<p></p>
</div>
<p class="since">Since 2.30</p>
</div>
<hr>
<div class="refsect2">
<a name="g-atomic-int-or"></a><h3>g_atomic_int_or ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="returnvalue">guint</span></a>
g_atomic_int_or (<em class="parameter"><code>volatile <a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> *atomic</code></em>,
                 <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> val</code></em>);</pre>
<p>Performs an atomic bitwise 'or' of the value of <em class="parameter"><code>atomic</code></em>
 and <em class="parameter"><code>val</code></em>
,
storing the result back in <em class="parameter"><code>atomic</code></em>
.</p>
<p>Think of this operation as an atomic version of
<code class="literal">{ tmp = *atomic; *atomic |= val; return tmp; }</code>.</p>
<p>This call acts as a full compiler and hardware memory barrier.</p>
<div class="refsect3">
<a name="id-1.3.9.7.9.7"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>atomic</p></td>
<td class="parameter_description"><p>a pointer to a <a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> or <a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a></p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>val</p></td>
<td class="parameter_description"><p>the value to 'or'</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.3.9.7.9.8"></a><h4>Returns</h4>
<p> the value of <em class="parameter"><code>atomic</code></em>
before the operation, unsigned</p>
<p></p>
</div>
<p class="since">Since 2.30</p>
</div>
<hr>
<div class="refsect2">
<a name="g-atomic-int-xor"></a><h3>g_atomic_int_xor ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="returnvalue">guint</span></a>
g_atomic_int_xor (<em class="parameter"><code>volatile <a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> *atomic</code></em>,
                  <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> val</code></em>);</pre>
<p>Performs an atomic bitwise 'xor' of the value of <em class="parameter"><code>atomic</code></em>
 and <em class="parameter"><code>val</code></em>
,
storing the result back in <em class="parameter"><code>atomic</code></em>
.</p>
<p>Think of this operation as an atomic version of
<code class="literal">{ tmp = *atomic; *atomic ^= val; return tmp; }</code>.</p>
<p>This call acts as a full compiler and hardware memory barrier.</p>
<div class="refsect3">
<a name="id-1.3.9.7.10.7"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>atomic</p></td>
<td class="parameter_description"><p>a pointer to a <a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> or <a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a></p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>val</p></td>
<td class="parameter_description"><p>the value to 'xor'</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.3.9.7.10.8"></a><h4>Returns</h4>
<p> the value of <em class="parameter"><code>atomic</code></em>
before the operation, unsigned</p>
<p></p>
</div>
<p class="since">Since 2.30</p>
</div>
<hr>
<div class="refsect2">
<a name="g-atomic-pointer-get"></a><h3>g_atomic_pointer_get ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a>
g_atomic_pointer_get (<em class="parameter"><code>const volatile <span class="type">void</span> *atomic</code></em>);</pre>
<p>Gets the current value of <em class="parameter"><code>atomic</code></em>
.</p>
<p>This call acts as a full compiler and hardware
memory barrier (before the get).</p>
<div class="refsect3">
<a name="id-1.3.9.7.11.6"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>atomic</p></td>
<td class="parameter_description"><p>a pointer to a <span class="type">gpointer-sized</span> value</p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.3.9.7.11.7"></a><h4>Returns</h4>
<p> the value of the pointer</p>
<p></p>
</div>
<p class="since">Since 2.4</p>
</div>
<hr>
<div class="refsect2">
<a name="g-atomic-pointer-set"></a><h3>g_atomic_pointer_set ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>
g_atomic_pointer_set (<em class="parameter"><code>volatile <span class="type">void</span> *atomic</code></em>,
                      <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> newval</code></em>);</pre>
<p>Sets the value of <em class="parameter"><code>atomic</code></em>
 to <em class="parameter"><code>newval</code></em>
.</p>
<p>This call acts as a full compiler and hardware
memory barrier (after the set).</p>
<div class="refsect3">
<a name="id-1.3.9.7.12.6"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>atomic</p></td>
<td class="parameter_description"><p>a pointer to a <span class="type">gpointer-sized</span> value</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>newval</p></td>
<td class="parameter_description"><p>a new value to store</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<p class="since">Since 2.4</p>
</div>
<hr>
<div class="refsect2">
<a name="g-atomic-pointer-compare-and-exchange"></a><h3>g_atomic_pointer_compare_and_exchange ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
g_atomic_pointer_compare_and_exchange (<em class="parameter"><code>volatile <span class="type">void</span> *atomic</code></em>,
                                       <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> oldval</code></em>,
                                       <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> newval</code></em>);</pre>
<p>Compares <em class="parameter"><code>atomic</code></em>
 to <em class="parameter"><code>oldval</code></em>
 and, if equal, sets it to <em class="parameter"><code>newval</code></em>
.
If <em class="parameter"><code>atomic</code></em>
 was not equal to <em class="parameter"><code>oldval</code></em>
 then no change occurs.</p>
<p>This compare and exchange is done atomically.</p>
<p>Think of this operation as an atomic version of
<code class="literal">{ if (*atomic == oldval) { *atomic = newval; return TRUE; } else return FALSE; }</code>.</p>
<p>This call acts as a full compiler and hardware memory barrier.</p>
<div class="refsect3">
<a name="id-1.3.9.7.13.8"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>atomic</p></td>
<td class="parameter_description"><p>a pointer to a <span class="type">gpointer-sized</span> value</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>oldval</p></td>
<td class="parameter_description"><p>the value to compare with</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>newval</p></td>
<td class="parameter_description"><p>the value to conditionally replace with</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.3.9.7.13.9"></a><h4>Returns</h4>
<p> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the exchange took place</p>
<p></p>
</div>
<p class="since">Since 2.4</p>
</div>
<hr>
<div class="refsect2">
<a name="g-atomic-pointer-add"></a><h3>g_atomic_pointer_add ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gssize" title="gssize"><span class="returnvalue">gssize</span></a>
g_atomic_pointer_add (<em class="parameter"><code>volatile <span class="type">void</span> *atomic</code></em>,
                      <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gssize" title="gssize"><span class="type">gssize</span></a> val</code></em>);</pre>
<p>Atomically adds <em class="parameter"><code>val</code></em>
 to the value of <em class="parameter"><code>atomic</code></em>
.</p>
<p>Think of this operation as an atomic version of
<code class="literal">{ tmp = *atomic; *atomic += val; return tmp; }</code>.</p>
<p>This call acts as a full compiler and hardware memory barrier.</p>
<div class="refsect3">
<a name="id-1.3.9.7.14.7"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>atomic</p></td>
<td class="parameter_description"><p>a pointer to a <span class="type">gpointer-sized</span> value</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>val</p></td>
<td class="parameter_description"><p>the value to add</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.3.9.7.14.8"></a><h4>Returns</h4>
<p> the value of <em class="parameter"><code>atomic</code></em>
before the add, signed</p>
<p></p>
</div>
<p class="since">Since 2.30</p>
</div>
<hr>
<div class="refsect2">
<a name="g-atomic-pointer-and"></a><h3>g_atomic_pointer_and ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gsize" title="gsize"><span class="returnvalue">gsize</span></a>
g_atomic_pointer_and (<em class="parameter"><code>volatile <span class="type">void</span> *atomic</code></em>,
                      <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gsize" title="gsize"><span class="type">gsize</span></a> val</code></em>);</pre>
<p>Performs an atomic bitwise 'and' of the value of <em class="parameter"><code>atomic</code></em>
 and <em class="parameter"><code>val</code></em>
,
storing the result back in <em class="parameter"><code>atomic</code></em>
.</p>
<p>Think of this operation as an atomic version of
<code class="literal">{ tmp = *atomic; *atomic &amp;= val; return tmp; }</code>.</p>
<p>This call acts as a full compiler and hardware memory barrier.</p>
<div class="refsect3">
<a name="id-1.3.9.7.15.7"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>atomic</p></td>
<td class="parameter_description"><p>a pointer to a <span class="type">gpointer-sized</span> value</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>val</p></td>
<td class="parameter_description"><p>the value to 'and'</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.3.9.7.15.8"></a><h4>Returns</h4>
<p> the value of <em class="parameter"><code>atomic</code></em>
before the operation, unsigned</p>
<p></p>
</div>
<p class="since">Since 2.30</p>
</div>
<hr>
<div class="refsect2">
<a name="g-atomic-pointer-or"></a><h3>g_atomic_pointer_or ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gsize" title="gsize"><span class="returnvalue">gsize</span></a>
g_atomic_pointer_or (<em class="parameter"><code>volatile <span class="type">void</span> *atomic</code></em>,
                     <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gsize" title="gsize"><span class="type">gsize</span></a> val</code></em>);</pre>
<p>Performs an atomic bitwise 'or' of the value of <em class="parameter"><code>atomic</code></em>
 and <em class="parameter"><code>val</code></em>
,
storing the result back in <em class="parameter"><code>atomic</code></em>
.</p>
<p>Think of this operation as an atomic version of
<code class="literal">{ tmp = *atomic; *atomic |= val; return tmp; }</code>.</p>
<p>This call acts as a full compiler and hardware memory barrier.</p>
<div class="refsect3">
<a name="id-1.3.9.7.16.7"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>atomic</p></td>
<td class="parameter_description"><p>a pointer to a <span class="type">gpointer-sized</span> value</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>val</p></td>
<td class="parameter_description"><p>the value to 'or'</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.3.9.7.16.8"></a><h4>Returns</h4>
<p> the value of <em class="parameter"><code>atomic</code></em>
before the operation, unsigned</p>
<p></p>
</div>
<p class="since">Since 2.30</p>
</div>
<hr>
<div class="refsect2">
<a name="g-atomic-pointer-xor"></a><h3>g_atomic_pointer_xor ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gsize" title="gsize"><span class="returnvalue">gsize</span></a>
g_atomic_pointer_xor (<em class="parameter"><code>volatile <span class="type">void</span> *atomic</code></em>,
                      <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gsize" title="gsize"><span class="type">gsize</span></a> val</code></em>);</pre>
<p>Performs an atomic bitwise 'xor' of the value of <em class="parameter"><code>atomic</code></em>
 and <em class="parameter"><code>val</code></em>
,
storing the result back in <em class="parameter"><code>atomic</code></em>
.</p>
<p>Think of this operation as an atomic version of
<code class="literal">{ tmp = *atomic; *atomic ^= val; return tmp; }</code>.</p>
<p>This call acts as a full compiler and hardware memory barrier.</p>
<div class="refsect3">
<a name="id-1.3.9.7.17.7"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>atomic</p></td>
<td class="parameter_description"><p>a pointer to a <span class="type">gpointer-sized</span> value</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>val</p></td>
<td class="parameter_description"><p>the value to 'xor'</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.3.9.7.17.8"></a><h4>Returns</h4>
<p> the value of <em class="parameter"><code>atomic</code></em>
before the operation, unsigned</p>
<p></p>
</div>
<p class="since">Since 2.30</p>
</div>
<hr>
<div class="refsect2">
<a name="g-atomic-int-exchange-and-add"></a><h3>g_atomic_int_exchange_and_add ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a>
g_atomic_int_exchange_and_add (<em class="parameter"><code>volatile <a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> *atomic</code></em>,
                               <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> val</code></em>);</pre>
<div class="warning">
<p><code class="literal">g_atomic_int_exchange_and_add</code> has been deprecated since version 2.30 and should not be used in newly-written code.</p>
<p>Use <a class="link" href="glib-Atomic-Operations.html#g-atomic-int-add" title="g_atomic_int_add ()"><code class="function">g_atomic_int_add()</code></a> instead.</p>
</div>
<p>This function existed before <a class="link" href="glib-Atomic-Operations.html#g-atomic-int-add" title="g_atomic_int_add ()"><code class="function">g_atomic_int_add()</code></a> returned the prior
value of the integer (which it now does).  It is retained only for
compatibility reasons.  Don't use this function in new code.</p>
<div class="refsect3">
<a name="id-1.3.9.7.18.7"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>atomic</p></td>
<td class="parameter_description"><p>a pointer to a <a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a></p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>val</p></td>
<td class="parameter_description"><p>the value to add</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.3.9.7.18.8"></a><h4>Returns</h4>
<p> the value of <em class="parameter"><code>atomic</code></em>
before the add, signed</p>
<p></p>
</div>
<p class="since">Since 2.4</p>
</div>
</div>
<div class="refsect1">
<a name="glib-Atomic-Operations.other_details"></a><h2>Types and Values</h2>
<div class="refsect2">
<a name="G-ATOMIC-LOCK-FREE:CAPS"></a><h3>G_ATOMIC_LOCK_FREE</h3>
<pre class="programlisting">#define G_ATOMIC_LOCK_FREE
</pre>
<p>This macro is defined if the atomic operations of GLib are
implemented using real hardware atomic operations.  This means that
the GLib atomic API can be used between processes and safely mixed
with other (hardware) atomic APIs.</p>
<p>If this macro is not defined, the atomic operations may be
emulated using a mutex.  In that case, the GLib atomic operations are
only atomic relative to themselves and within a single process.</p>
</div>
</div>
<div class="refsect1">
<a name="glib-Atomic-Operations.see-also"></a><h2>See Also</h2>
<p><a class="link" href="glib-Threads.html#GMutex" title="union GMutex"><span class="type">GMutex</span></a></p>
</div>
</div>
<div class="footer">
<hr>
          Generated by GTK-Doc V1.21</div>
</body>
</html>