Mercurial > sdl-ios-xcode
comparison test/testatomic.c @ 3237:916f396fe65d
Start of redesign, getting rid of 8 and 16 bit operations in .h and test files.
author | Bob Pendleton <bob@pendleton.com> |
---|---|
date | Tue, 11 Aug 2009 21:27:19 +0000 |
parents | 48a80f2a7ff2 |
children | 72b542f34739 |
comparison
equal
deleted
inserted
replaced
3236:d7497988b677 | 3237:916f396fe65d |
---|---|
21 | 21 |
22 int | 22 int |
23 main(int argc, char **argv) | 23 main(int argc, char **argv) |
24 { | 24 { |
25 | 25 |
26 volatile Uint8 val8 = 0; | |
27 Uint8 ret8 = 0; | |
28 | |
29 volatile Uint16 val16 = 0; | |
30 Uint16 ret16 = 0; | |
31 | |
32 volatile Uint32 val32 = 0; | 26 volatile Uint32 val32 = 0; |
33 Uint32 ret32 = 0; | 27 Uint32 ret32 = 0; |
34 | 28 |
35 volatile Uint64 val64 = 0; | 29 volatile Uint64 val64 = 0; |
36 Uint64 ret64 = 0; | 30 Uint64 ret64 = 0; |
37 | 31 |
38 SDL_bool tfret = SDL_FALSE; | 32 SDL_bool tfret = SDL_FALSE; |
39 | |
40 | |
41 printf("8 bit -----------------------------------------\n\n"); | |
42 | |
43 ret8 = SDL_AtomicExchange8(&val8, 10); | |
44 printf("Exchange8 ret=%d val=%d\n", ret8, val8); | |
45 ret8 = SDL_AtomicExchange8(&val8, 0); | |
46 printf("Exchange8 ret=%d val=%d\n", ret8, val8); | |
47 | |
48 val8 = 10; | |
49 tfret = SDL_AtomicCompareThenSet8(&val8, 10, 20); | |
50 printf("CompareThenSet8 tfret=%s val=%d\n", tf(tfret), val8); | |
51 val8 = 10; | |
52 tfret = SDL_AtomicCompareThenSet8(&val8, 0, 20); | |
53 printf("CompareThenSet8 tfret=%s val=%d\n", tf(tfret), val8); | |
54 | |
55 val8 = 0; | |
56 tfret = SDL_AtomicTestThenSet8(&val8); | |
57 printf("TestThenSet8 tfret=%s val=%d\n", tf(tfret), val8); | |
58 tfret = SDL_AtomicTestThenSet8(&val8); | |
59 printf("TestThenSet8 tfret=%s val=%d\n", tf(tfret), val8); | |
60 | |
61 SDL_AtomicClear8(&val8); | |
62 printf("Clear8 val=%d\n", val8); | |
63 | |
64 ret8 = SDL_AtomicFetchThenIncrement8(&val8); | |
65 printf("FetchThenIncrement8 ret=%d val=%d\n", ret8, val8); | |
66 | |
67 ret8 = SDL_AtomicFetchThenDecrement8(&val8); | |
68 printf("FetchThenDecrement8 ret=%d val=%d\n", ret8, val8); | |
69 | |
70 ret8 = SDL_AtomicFetchThenAdd8(&val8, 10); | |
71 printf("FetchThenAdd8 ret=%d val=%d\n", ret8, val8); | |
72 | |
73 ret8 = SDL_AtomicFetchThenSubtract8(&val8, 10); | |
74 printf("FetchThenSubtract8 ret=%d val=%d\n", ret8, val8); | |
75 | |
76 ret8 = SDL_AtomicIncrementThenFetch8(&val8); | |
77 printf("IncrementThenFetch8 ret=%d val=%d\n", ret8, val8); | |
78 | |
79 ret8 = SDL_AtomicDecrementThenFetch8(&val8); | |
80 printf("DecrementThenFetch8 ret=%d val=%d\n", ret8, val8); | |
81 | |
82 ret8 = SDL_AtomicAddThenFetch8(&val8, 10); | |
83 printf("AddThenFetch8 ret=%d val=%d\n", ret8, val8); | |
84 | |
85 ret8 = SDL_AtomicSubtractThenFetch8(&val8, 10); | |
86 printf("SubtractThenFetch8 ret=%d val=%d\n", ret8, val8); | |
87 | |
88 | |
89 printf("16 bit -----------------------------------------\n\n"); | |
90 | |
91 ret16 = SDL_AtomicExchange16(&val16, 10); | |
92 printf("Exchange16 ret=%d val=%d\n", ret16, val16); | |
93 ret16 = SDL_AtomicExchange16(&val16, 0); | |
94 printf("Exchange16 ret=%d val=%d\n", ret16, val16); | |
95 | |
96 val16 = 10; | |
97 tfret = SDL_AtomicCompareThenSet16(&val16, 10, 20); | |
98 printf("CompareThenSet16 tfret=%s val=%d\n", tf(tfret), val16); | |
99 val16 = 10; | |
100 tfret = SDL_AtomicCompareThenSet16(&val16, 0, 20); | |
101 printf("CompareThenSet16 tfret=%s val=%d\n", tf(tfret), val16); | |
102 | |
103 val16 = 0; | |
104 tfret = SDL_AtomicTestThenSet16(&val16); | |
105 printf("TestThenSet16 tfret=%s val=%d\n", tf(tfret), val16); | |
106 tfret = SDL_AtomicTestThenSet16(&val16); | |
107 printf("TestThenSet16 tfret=%s val=%d\n", tf(tfret), val16); | |
108 | |
109 SDL_AtomicClear16(&val16); | |
110 printf("Clear16 val=%d\n", val16); | |
111 | |
112 ret16 = SDL_AtomicFetchThenIncrement16(&val16); | |
113 printf("FetchThenIncrement16 ret=%d val=%d\n", ret16, val16); | |
114 | |
115 ret16 = SDL_AtomicFetchThenDecrement16(&val16); | |
116 printf("FetchThenDecrement16 ret=%d val=%d\n", ret16, val16); | |
117 | |
118 ret16 = SDL_AtomicFetchThenAdd16(&val16, 10); | |
119 printf("FetchThenAdd16 ret=%d val=%d\n", ret16, val16); | |
120 | |
121 ret16 = SDL_AtomicFetchThenSubtract16(&val16, 10); | |
122 printf("FetchThenSubtract16 ret=%d val=%d\n", ret16, val16); | |
123 | |
124 ret16 = SDL_AtomicIncrementThenFetch16(&val16); | |
125 printf("IncrementThenFetch16 ret=%d val=%d\n", ret16, val16); | |
126 | |
127 ret16 = SDL_AtomicDecrementThenFetch16(&val16); | |
128 printf("DecrementThenFetch16 ret=%d val=%d\n", ret16, val16); | |
129 | |
130 ret16 = SDL_AtomicAddThenFetch16(&val16, 10); | |
131 printf("AddThenFetch16 ret=%d val=%d\n", ret16, val16); | |
132 | |
133 ret16 = SDL_AtomicSubtractThenFetch16(&val16, 10); | |
134 printf("SubtractThenFetch16 ret=%d val=%d\n", ret16, val16); | |
135 | 33 |
136 printf("32 bit -----------------------------------------\n\n"); | 34 printf("32 bit -----------------------------------------\n\n"); |
137 | 35 |
138 ret32 = SDL_AtomicExchange32(&val32, 10); | 36 ret32 = SDL_AtomicExchange32(&val32, 10); |
139 printf("Exchange32 ret=%d val=%d\n", ret32, val32); | 37 printf("Exchange32 ret=%d val=%d\n", ret32, val32); |