Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Latest commit

 

History

History
674 lines (631 loc) · 25.1 KB

SDL_atomic.h

File metadata and controls

674 lines (631 loc) · 25.1 KB
 
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
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
/**
* \file SDL_atomic.h
*
* Atomic int and pointer magic
*/
#ifndef _SDL_atomic_h_
#define _SDL_atomic_h_
#include "SDL_stdinc.h"
#include "SDL_platform.h"
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
/* *INDENT-OFF* */
extern "C" {
/* *INDENT-ON* */
#endif
#if defined(__GNUC__) && (defined(i386) || defined(__i386__) || defined(__x86_64__))
static __inline__ void
SDL_atomic_int_add(volatile int* atomic, int value)
{
__asm__ __volatile__("lock;"
"addl %1, %0"
: "=m" (*atomic)
: "ir" (value),
"m" (*atomic));
}
static __inline__ int
SDL_atomic_int_xchg_add(volatile int* atomic, int value)
{
int rv;
__asm__ __volatile__("lock;"
"xaddl %0, %1"
: "=r" (rv),
"=m" (*atomic)
: "0" (value),
"m" (*atomic));
return rv;
}
static __inline__ SDL_bool
SDL_atomic_int_cmp_xchg(volatile int* atomic, int oldvalue, int newvalue)
{
int rv;
__asm__ __volatile__("lock;"
"cmpxchgl %2, %1"
: "=a" (rv),
"=m" (*atomic)
: "r" (newvalue),
"m" (*atomic),
"0" (oldvalue));
Jun 9, 2009
Jun 9, 2009
80
return (SDL_bool)(rv == oldvalue);
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
}
static __inline__ SDL_bool
SDL_atomic_ptr_cmp_xchg(volatile void** atomic, void* oldvalue, void* newvalue)
{
void* rv;
__asm__ __volatile__("lock;"
# if defined(__x86_64__)
"cmpxchgq %q2, %1"
# else
"cmpxchgl %2, %1"
# endif
: "=a" (rv),
"=m" (*atomic)
: "r" (newvalue),
"m" (*atomic),
"0" (oldvalue));
Jun 9, 2009
Jun 9, 2009
98
return (SDL_bool)(rv == oldvalue);
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
}
#elif defined(__GNUC__) && defined(__alpha__)
# define ATOMIC_MEMORY_BARRIER (__asm__ __volatile__ ("mb" : : : "memory"))
# define ATOMIC_INT_CMP_XCHG(atomic,value) \
({ \
int rv,prev; \
__asm__ __volatile__(" mb\n" \
"1: ldl_l %0,%2\n" \
" cmpeq %0,%3,%1\n" \
" beq %1,2f\n" \
" mov %4,%1\n" \
" stl_c %1,%2\n" \
" beq %1,1b\n" \
" mb\n" \
"2:" \
: "=&r" (prev), \
"=&r" (rv) \
: "m" (*(atomic)), \
"Ir" (oldvalue), \
"Ir" (newvalue) \
: "memory"); \
(rv != 0); \
})
# if (SIZEOF_VOIDP == 4)
static __inline__ SDL_bool
SDL_atomic_ptr_cmp_xchg(volatile void** atomic, void* oldvalue, void* newvalue)
{
int rv;
void* prev;
__asm__ __volatile__(" mb\n"
"1: ldl_l %0,%2\n"
" cmpeq %0,%3,%1\n"
" beq $1,2f\n"
" mov %4,%1\n"
" stl_c %1,%2\n"
" beq %1,1b\n"
" mb\n"
"2:"
: "=&r" (prev),
"=&r" (rv)
: "m" (*atomic),
"Ir" (oldvalue),
"Ir" (newvalue)
: "memory");
Jun 9, 2009
Jun 9, 2009
144
return (SDL_bool)(rv != 0);
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
}
# elif (SIZEOF_VOIDP == 8)
static __inline__ SDL_bool
SDL_atomic_ptr_cmp_xchg(volatile void** atomic, void* oldvalue, void* newvalue)
{
int rv;
void* prev;
__asm__ __volatile__(" mb\n"
"1: ldq_l %0,%2\n"
" cmpeq %0,%3,%1\n"
" beq %1,2f\n"
" mov %4,%1\n"
" stq_c %1,%2\n"
" beq %1,1b\n"
" mb\n"
"2:"
: "=&r" (prev),
"=&r" (rv)
: "m" (*atomic),
"Ir" (oldvalue),
"Ir" (newvalue)
: "memory");
Jun 9, 2009
Jun 9, 2009
167
return (SDL_bool)(rv != 0);
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
}
# else
# error "Your system has an unsupported pointer size"
# endif /* SIZEOF_VOIDP */
#elif defined(__GNUC__) && defined(__sparc__)
# define ATOMIC_MEMORY_BARRIER \
(__asm__ __volatile__("membar #LoadLoad | #LoadStore" \
" | #StoreLoad | #StoreStore" : : : "memory"))
# define ATOMIC_INT_CMP_XCHG(atomic,oldvalue,newvalue) \
({ \
int rv; \
__asm__ __volatile__("cas [%4], %2, %0" \
: "=r" (rv), "=m" (*(atomic)) \
: "r" (oldvalue), "m" (*(atomic)), \
"r" (atomic), "0" (newvalue)); \
rv == oldvalue; \
})
# if (SIZEOF_VOIDP == 4)
static __inline__ SDL_bool
SDL_atomic_ptr_cmp_xchg(volatile void** atomic, void* oldvalue, void* newvalue)
{
void* rv;
__asm__ __volatile__("cas [%4], %2, %0"
: "=r" (rv),
"=m" (*atomic)
: "r" (oldvalue),
"m" (*atomic),
"r" (atomic),
"0" (newvalue));
Jun 9, 2009
Jun 9, 2009
198
return (SDL_bool)(rv == oldvalue);
199
200
201
202
203
204
205
206
207
208
209
210
211
212
}
# elif (SIZEOF_VOIDP == 8)
static __inline__ SDL_bool
SDL_atomic_ptr_cmp_xchg(volatile void** atomic, void* oldvalue, void* newvalue)
{
void* rv;
void** a = atomic;
__asm__ __volatile__("casx [%4], %2, %0"
: "=r" (rv),
"=m" (*a)
: "r" (oldvalue),
"m" (*a),
"r" (a),
"0" (newvalue));
Jun 9, 2009
Jun 9, 2009
213
return (SDL_bool)(rv == oldvalue);
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
}
# else
# error "Your system has an unsupported pointer size"
# endif /* SIZEOF_VOIDP */
#elif defined(__GNUC__) && (defined(__POWERPC__) || defined(__powerpc__) || defined(__ppc__) || defined(_M_PPC))
# define ATOMIC_MEMORY_BARRIER \
(__asm__ __volatile__ ("sync" : : : "memory"))
static __inline__ void
SDL_atomic_int_add(volatile int* atomic, int value)
{
int rv,tmp;
__asm__ __volatile__("1: lwarx %0, 0, %3\n"
" add %1, %0, %4\n"
" stwcx. %1, 0, %3\n"
" bne- 1b"
: "=&b" (rv),
"=&r" (tmp),
"=m" (*atomic)
: "b" (atomic),
"r" (value),
"m" (*atomic)
: "cr0",
"memory");
}
static __inline__ int
SDL_atomic_int_xchg_add(volatile int* atomic, int value)
{
int rv,tmp;
__asm__ __volatile__("1: lwarx %0, 0, %3\n"
" add %1, %0, %4\n"
" stwcx. %1, 0, %3\n"
" bne- 1b"
: "=&b" (rv),
"=&r" (tmp),
"=m" (*atomic)
: "b" (atomic),
"r" (value),
"m" (*atomic)
: "cr0",
"memory");
return rv;
}
# if (SIZEOF_VOIDP == 4)
static __inline__ SDL_bool
SDL_atomic_int_cmp_xchg(volatile int* atomic, int oldvalue, int newvalue)
{
int rv;
__asm__ __volatile__(" sync\n"
"1: lwarx %0, 0, %1\n"
" subf. %0, %2, %0\n"
" bne 2f\n"
" stwcx. %3, 0, %1\n"
" bne- 1b\n"
"2: isync"
: "=&r" (rv)
: "b" (atomic),
"r" (oldvalue),
"r"
: "cr0",
"memory");
Jun 9, 2009
Jun 9, 2009
276
return (SDL_bool)(rv == 0);
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
}
static __inline__ SDL_bool
SDL_atomic_ptr_cmp_xchg(volatile void** atomic, void* oldvalue, void* newvalue)
{
void* rv;
__asm__ __volatile__("sync\n"
"1: lwarx %0, 0, %1\n"
" subf. %0, %2, %0\n"
" bne 2f\n"
" stwcx. %3, 0, %1\n"
" bne- 1b\n"
"2: isync"
: "=&r" (rv)
: "b" (atomic),
"r" (oldvalue),
"r" (newvalue)
: "cr0",
"memory");
Jun 9, 2009
Jun 9, 2009
296
return (SDL_bool)(rv == 0);
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
}
# elif (SIZEOF_VOIDP == 8)
static __inline__ SDL_bool
SDL_atomic_int_cmp_xchg(volatile int* atomic, int oldvalue, int newvalue)
{
int rv;
__asm__ __volatile__(" sync\n"
"1: lwarx %0, 0, %1\n"
" extsw %0, %0\n"
" subf. %0, %2, %0\n"
" bne 2f\n"
" stwcx. %3, 0, %1\n"
" bne- 1b\n"
"2: isync"
: "=&r" (rv)
: "b" (atomic),
"r" (oldvalue),
"r"
: "cr0",
"memory");
Jun 9, 2009
Jun 9, 2009
317
return (SDL_bool)(rv == 0);
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
}
static __inline__ SDL_bool
SDL_atomic_ptr_cmp_xchg(volatile void** atomic, void* oldvalue, void* newvalue)
{
void* rv;
__asm__ __volatile__("sync\n"
"1: ldarx %0, 0, %1\n"
" subf. %0, %2, %0\n"
" bne 2f\n"
" stdcx. %3, 0, %1\n"
" bne- 1b\n"
"2: isync"
: "=&r" (rv)
: "b" (atomic),
"r" (oldvalue),
"r" (newvalue)
: "cr0",
"memory");
Jun 9, 2009
Jun 9, 2009
337
return (SDL_bool)(rv == 0);
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
}
# else
# error "Your system has an unsupported pointer size"
# endif /* SIZEOF_VOIDP */
#elif defined(__GNUC__) && (defined(__IA64__) || defined(__ia64__))
# define ATOMIC_MEMORY_BARRIER (__sync_synchronize())
# define SDL_atomic_int_xchg_add(atomic, value) \
(__sync_fetch_and_add((atomic),(value)))
# define SDL_atomic_int_add(atomic, value) \
((void)__sync_fetch_and_add((atomic),(value)))
# define SDL_atomic_int_cmp_xchg(atomic,oldvalue,newvalue) \
(__sync_bool_compare_and_swap((atomic),(oldvalue),(newvalue)))
# define SDL_atomic_ptr_cmp_xchg(atomic,oldvalue,newvalue) \
(__sync_bool_compare_and_swap((long*)(atomic),(long)(oldvalue),(long)(newvalue)))
#elif defined(__GNUC__) && defined(__LINUX__) && (defined(__mips__) || defined(__MIPS__))
static __inline__ int
SDL_atomic_int_xchg_add(volatile int* atomic, int value)
{
int rv,tmp;
__asm__ __volatile__("1: \n"
".set push \n"
".set mips2 \n"
"ll %0,%3 \n"
"addu %1,%4,%0 \n"
"sc %1,%2 \n"
".set pop \n"
"beqz %1,1b \n"
: "=&r" (rv),
"=&r" (tmp),
"=m" (*atomic)
: "m" (*atomic),
"r" (value)
: "memory");
return rv;
}
static __inline__ void
SDL_atomic_int_add(volatile int* atomic, int value)
{
int rv;
__asm__ __volatile__("1: \n"
".set push \n"
".set mips2 \n"
"ll %0,%2 \n"
"addu %0,%3,%0 \n"
"sc %0,%1 \n"
".set pop \n"
"beqz %0,1b \n"
: "=&r" (rv),
"=m" (*atomic)
: "m" (*atomic),
"r" (value)
: "memory");
}
static __inline__ SDL_bool
SDL_atomic_int_cmp_xchg(volatile int* atomic, int oldvalue, int newvalue)
{
int rv;
__asm__ __volatile__(" .set push \n"
" .set noat \n"
" .set mips3 \n"
"1: ll %0, %2 \n"
" bne %0, %z3, 2f \n"
" .set mips0 \n"
" move $1, %z4 \n"
" .set mips3 \n"
" sc $1, %1 \n"
" beqz $1, 1b \n"
" sync \n"
"2: \n"
" .set pop \n"
: "=&r" (rv),
"=R" (*atomic)
: "R" (*atomic),
"Jr" (oldvalue),
"Jr" (newvalue)
: "memory");
return (SDL_bool)rv;
}
static __inline__ SDL_bool
SDL_atomic_ptr_cmp_xchg(volatile void** atomic, void* oldvalue, void* newvalue)
{
int rv;
__asm__ __volatile__(" .set push \n"
" .set noat \n"
" .set mips3 \n"
# if defined(__mips64)
"1: lld %0, %2 \n"
# else
"1: ll %0, %2 \n"
# endif
" bne %0, %z3, 2f \n"
" move $1, %z4 \n"
# if defined(__mips64)
" sc $1, %1 \n"
# else
" scd $1, %1 \n"
# endif
" beqz $1, 1b \n"
" sync \n"
"2: \n"
" .set pop \n"
: "=&r" (rv),
"=R" (*atomic)
: "R" (*atomic),
"Jr" (oldvalue),
"Jr" (newvalue)
: "memory");
return (SDL_bool)rv;
}
#elif defined(__GNUC__) && defined(__m68k__)
static __inline__ int
SDL_atomic_int_xchg_add(volatile int* atomic, int value)
{
int rv = *atomic;
int tmp;
__asm__ __volatile__("1: move%.l %0,%1 \n"
" add%.l %2,%1 \n"
" cas%.l %0,%1,%3 \n"
" jbne 1b \n"
: "=d" (rv),
"=&d" (tmp)
: "d" (value),
"m" (*atomic),
"0" (rv)
: "memory");
Jun 9, 2009
Jun 9, 2009
466
return (SDL_bool)rv;
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
}
static __inline__ void
SDL_atomic_int_add(volatile int* atomic, int value)
{
__asm__ __volatile__("add%.l %0,%1"
:
: "id" (value),
"m" (*atomic)
: "memory");
}
static __inline__ SDL_bool
SDL_atomic_int_cmp_xchg(volatile int* atomic, int oldvalue, int newvalue)
{
char rv;
int readvalue;
__asm__ __volatile__("cas%.l %2,%3,%1\n"
"seq %0"
: "=dm" (rv),
"=m" (*atomic),
"=d" (readvalue)
: "d" (newvalue),
"m" (*atomic),
"2" (oldvalue));
Jun 9, 2009
Jun 9, 2009
492
return (SDL_bool)rv;
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
}
static __inline__ SDL_bool
SDL_atomic_ptr_cmp_xchg(volatile void** atomic, void* oldvalue, void* newvalue)
{
char rv;
int readvalue;
__asm__ __volatile__("cas%.l %2,%3,%1\n"
"seq %0"
: "=dm" (rv),
"=m" (*atomic),
"=d" (readvalue)
: "d" (newvalue),
"m" (*atomic),
"2" (oldvalue));
Jun 9, 2009
Jun 9, 2009
508
return (SDL_bool)rv;
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
}
#elif defined(__GNUC__) && defined(__s390__)
# define ATOMIC_INT_CMP_XCHG(atomic,oldvalue,newvalue) \
({ \
int rv = oldvalue; \
__asm__ __volatile__("cs %0, %2, %1" \
: "+d" (rv), \
"=Q" (*(atomic)) \
: "d" (newvalue), \
"m" (*(atomic)) \
: "cc"); \
rv == oldvalue; \
})
# if (SIZEOF_VOIDP == 4)
static __inline__ SDL_bool
SDL_atomic_ptr_cmp_xchg(volatile void** atomic, void* oldvalue, void* newvalue)
{
void* rv = oldvalue;
__asm__ __volatile__("cs %0, %2, %1"
: "+d" (rv),
"=Q" (*atomic)
: "d" (newvalue),
"m" (*atomic)
: "cc");
Jun 9, 2009
Jun 9, 2009
533
return (SDL_bool)(rv == oldvalue);
534
535
536
537
538
539
540
541
542
543
544
545
546
}
# elif (SIZEOF_VOIDP == 8)
static __inline__ SDL_bool
SDL_atomic_ptr_cmp_xchg(volatile void** atomic, void* oldvalue, void* newvalue)
{
void* rv = oldvalue;
void** a = atomic;
__asm__ __volatile__("csg %0, %2, %1"
: "+d" (rv),
"=Q" (*a)
: "d" ((long)(newvalue)),
"m" (*a)
: "cc");
Jun 9, 2009
Jun 9, 2009
547
return (SDL_bool)(rv == oldvalue);
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
}
# else
# error "Your system has an unsupported pointer size"
# endif /* SIZEOF_VOIDP */
#elif defined(__WIN32__)
# include <windows.h>
static __inline__ int
SDL_atomic_int_xchg_add(volatile int* atomic, int value)
{
return InterlockedExchangeAdd(atomic, value);
}
static __inline__ void
SDL_atomic_int_add(volatile int* atomic, int value)
{
InterlockedExchangeAdd(atomic, value);
}
# if (WINVER > 0X0400)
static __inline__ SDL_bool
SDL_atmoic_int_cmp_xchg(volatile int* atomic, int oldvalue, int newvalue)
{
Jun 9, 2009
Jun 9, 2009
570
571
572
return (SDL_bool)(InterlockedCompareExchangePointer((PVOID*)atomic,
(PVOID)newvalue,
(PVOID)oldvalue) == oldvalue);
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
}
static __inline__ SDL_bool
SDL_atomic_ptr_cmp_xchg(volatile void** atomic, void* oldvalue, void* newvalue)
{
return (InterlockedCompareExchangePointer(atomic, newvalue, oldvalue) == oldvalue);
}
# else /* WINVER <= 0x0400 */
# if (SIZEOF_VOIDP != 4)
# error "InterlockedCompareExchangePointer needed"
# endif
static __inline__ SDL_bool
SDL_atomic_int_cmp_xchg(volatile int* atomic, int oldvalue, int newvalue)
{
return (InterlockedCompareExchange(atomic, newvalue, oldvalue) == oldvalue);
}
static __inline__ SDL_bool
SDL_atomic_ptr_cmp_xchg(volatile void** atomic, void* oldvalue, void* newvalue)
{
return (InterlockedCompareExchange(atomic, newvalue, oldvalue) == oldvalue);
}
# endif
#else /* when all else fails */
# define SDL_ATOMIC_OPS_NOT_SUPPORTED
# warning "Atomic Ops for this platform not supported!"
static __inline__ int
SDL_atomic_int_xchg_add(volatile int* atomic, int value)
{
int rv = *atomic;
*(atomic) += value;
return rv;
}
static __inline__ SDL_bool
SDL_atomic_int_cmp_xchg(volatile int* atomic, int oldvalue, int newvalue)
{
return (*atomic == oldvalue) ?
((*atomic = newvalue), SDL_TRUE) : SDL_FALSE;
}
static __inline__ void
SDL_atomic_int_add(volatile int* atomic, int value)
{
*atomic += value;
}
#endif /* arch & platforms */
#ifdef ATOMIC_INT_CMP_XCHG
static __inline__ SDL_bool
SDL_atomic_int_cmp_xchg(volatile int* atomic, int oldvalue, int newvalue)
{
Jun 9, 2009
Jun 9, 2009
627
return (SDL_bool)ATOMIC_INT_CMP_XCHG(atomic,oldvalue,newvalue);
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
}
static __inline__ int
SDL_atomic_int_xchg_add(volatile int* atomic, int value)
{
int rv;
do
rv = *atomic;
while(!ATOMIC_INT_CMP_XCHG(atomic,rv,rv+value));
return rv;
}
static __inline__ void
SDL_atomic_int_add(volatile int* atomic, int value)
{
int rv;
do
rv = *atomic;
while(!ATOMIC_INT_CMP_XCHG(atomic,rv,rv+value));
}
#endif /* ATOMIC_CMP_XCHG */
#ifdef ATOMIC_MEMORY_BARRIER
# define SDL_atomic_int_get(atomic) \
(ATOMIC_MEMORY_BARRIER,*(atomic))
# define SDL_atomic_int_set(atomic,value) \
(*(atomic)=value,ATOMIC_MEMORY_BARRIER)
#else
# define SDL_atomic_int_get(atomic) (*(atomic))
# define SDL_atomic_int_set(atomic, newvalue) ((void)(*(atomic) = (newvalue)))
#endif /* MEMORY_BARRIER_NEEDED */
#define SDL_atomic_int_inc(atomic) (SDL_atomic_int_add((atomic),1))
#define SDL_atomic_int_dec_test(atomic) (SDL_atomic_int_xchg_add((atomic),-1) == 1)
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
/* *INDENT-OFF* */
}
/* *INDENT-ON* */
#endif
#include "close_code.h"
#endif /* _SDL_atomic_h_ */
/* vi: set ts=4 sw=4 expandtab: */