This repository has been archived by the owner on Feb 11, 2021. It is now read-only.
/
testatomic.c
64 lines (53 loc) · 2.43 KB
1
2
3
#include "SDL.h"
int
4
main(int argc, char **argv)
5
{
6
7
/* int rv = 10; */
/* volatile int atomic; */
8
9
10
11
12
13
/* SDL_atomic_int_set(&atomic, 10); */
/* if (SDL_atomic_int_get(&atomic) != 10) */
/* printf("Error: "); */
/* printf("SDL_atomic_int_set(atomic, 10): atomic-> %d\n", */
/* SDL_atomic_int_get(&atomic)); */
14
15
16
17
18
19
/* SDL_atomic_int_add(&atomic, 10); */
/* if (SDL_atomic_int_get(&atomic) != 20) */
/* printf("Error: "); */
/* printf("SDL_atomic_int_add(atomic, 10): atomic-> %d\n", */
/* SDL_atomic_int_get(&atomic)); */
20
21
22
23
24
25
/* rv = SDL_atomic_int_cmp_xchg(&atomic, 20, 30); */
/* if (rv != SDL_TRUE || SDL_atomic_int_get(&atomic) != 30) */
/* printf("Error: "); */
/* printf("SDL_atomic_int_cmp_xchg(atomic, 20, 30): rv-> %d, atomic-> %d\n", */
/* rv, SDL_atomic_int_get(&atomic)); */
26
27
28
29
30
31
/* rv = SDL_atomic_int_cmp_xchg(&atomic, 20, 30); */
/* if (rv != SDL_FALSE || SDL_atomic_int_get(&atomic) != 30) */
/* printf("Error: "); */
/* printf("SDL_atomic_int_cmp_xchg(atomic, 20, 40): rv-> %d, atomic-> %d\n", */
/* rv, SDL_atomic_int_get(&atomic)); */
32
33
34
35
36
37
/* rv = SDL_atomic_int_xchg_add(&atomic, 10); */
/* if (rv != 30 || SDL_atomic_int_get(&atomic) != 40) */
/* printf("Error: "); */
/* printf("SDL_atomic_int_xchg_add(atomic, 10): rv-> %d, atomic-> %d\n", */
/* rv, SDL_atomic_int_get(&atomic)); */
38
39
40
41
42
43
/* SDL_atomic_int_inc(&atomic); */
/* if (SDL_atomic_int_get(&atomic) != 41) */
/* printf("Error: "); */
/* printf("SDL_atomic_int_inc(atomic): atomic-> %d\n", */
/* SDL_atomic_int_get(&atomic)); */
44
45
46
47
48
49
/* rv = SDL_atomic_int_dec_test(&atomic); */
/* if (rv != SDL_FALSE || SDL_atomic_int_get(&atomic) != 40) */
/* printf("Error: "); */
/* printf("SDL_atomic_int_dec_test(atomic): rv-> %d, atomic-> %d\n", */
/* rv, SDL_atomic_int_get(&atomic)); */
50
51
52
53
54
55
/* SDL_atomic_int_set(&atomic, 1); */
/* if (SDL_atomic_int_get(&atomic) != 1) */
/* printf("Error: "); */
/* printf("SDL_atomic_int_set(atomic, 1): atomic-> %d\n", */
/* SDL_atomic_int_get(&atomic)); */
56
57
58
59
60
61
/* rv = SDL_atomic_int_dec_test(&atomic); */
/* if (rv != SDL_TRUE || SDL_atomic_int_get(&atomic) != 0) */
/* printf("Error: "); */
/* printf("SDL_atomic_int_dec_test(atomic): rv-> %d, atomic-> %d\n", */
/* rv, SDL_atomic_int_get(&atomic)); */
62
63
return 0;
64
}