Mercurial > sdl-ios-xcode
comparison include/SDL_atomic.h @ 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 |
---|---|
50 * using SDL's mutex fuctions. | 50 * using SDL's mutex fuctions. |
51 */ | 51 */ |
52 | 52 |
53 /* Function prototypes */ | 53 /* Function prototypes */ |
54 | 54 |
55 /* 8 bit atomic operations */ | |
56 | |
57 extern DECLSPEC Uint8 SDLCALL SDL_AtomicExchange8(volatile Uint8 * ptr, Uint8 value); | |
58 extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCompareThenSet8(volatile Uint8 * ptr, | |
59 Uint8 oldvalue, Uint8 newvalue); | |
60 extern DECLSPEC SDL_bool SDLCALL SDL_AtomicTestThenSet8(volatile Uint8 * ptr); | |
61 extern DECLSPEC void SDLCALL SDL_AtomicClear8(volatile Uint8 * ptr); | |
62 extern DECLSPEC Uint8 SDLCALL SDL_AtomicFetchThenIncrement8(volatile Uint8 * ptr); | |
63 extern DECLSPEC Uint8 SDLCALL SDL_AtomicFetchThenDecrement8(volatile Uint8 * ptr); | |
64 extern DECLSPEC Uint8 SDLCALL SDL_AtomicFetchThenAdd8(volatile Uint8 * ptr, Uint8 value); | |
65 extern DECLSPEC Uint8 SDLCALL SDL_AtomicFetchThenSubtract8(volatile Uint8 * ptr, Uint8 value); | |
66 extern DECLSPEC Uint8 SDLCALL SDL_AtomicIncrementThenFetch8(volatile Uint8 * ptr); | |
67 extern DECLSPEC Uint8 SDLCALL SDL_AtomicDecrementThenFetch8(volatile Uint8 * ptr); | |
68 extern DECLSPEC Uint8 SDLCALL SDL_AtomicAddThenFetch8(volatile Uint8 * ptr, Uint8 value); | |
69 extern DECLSPEC Uint8 SDLCALL SDL_AtomicSubtractThenFetch8(volatile Uint8 * ptr, Uint8 value); | |
70 | |
71 /* 16 bit atomic operations */ | |
72 | |
73 extern DECLSPEC Uint16 SDLCALL SDL_AtomicExchange16(volatile Uint16 * ptr, Uint16 value); | |
74 extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCompareThenSet16(volatile Uint16 * ptr, | |
75 Uint16 oldvalue, Uint16 newvalue); | |
76 extern DECLSPEC SDL_bool SDLCALL SDL_AtomicTestThenSet16(volatile Uint16 * ptr); | |
77 extern DECLSPEC void SDLCALL SDL_AtomicClear16(volatile Uint16 * ptr); | |
78 extern DECLSPEC Uint16 SDLCALL SDL_AtomicFetchThenIncrement16(volatile Uint16 * ptr); | |
79 extern DECLSPEC Uint16 SDLCALL SDL_AtomicFetchThenDecrement16(volatile Uint16 * ptr); | |
80 extern DECLSPEC Uint16 SDLCALL SDL_AtomicFetchThenAdd16(volatile Uint16 * ptr, Uint16 value); | |
81 extern DECLSPEC Uint16 SDLCALL SDL_AtomicFetchThenSubtract16(volatile Uint16 * ptr, Uint16 value); | |
82 extern DECLSPEC Uint16 SDLCALL SDL_AtomicIncrementThenFetch16(volatile Uint16 * ptr); | |
83 extern DECLSPEC Uint16 SDLCALL SDL_AtomicDecrementThenFetch16(volatile Uint16 * ptr); | |
84 extern DECLSPEC Uint16 SDLCALL SDL_AtomicAddThenFetch16(volatile Uint16 * ptr, Uint16 value); | |
85 extern DECLSPEC Uint16 SDLCALL SDL_AtomicSubtractThenFetch16(volatile Uint16 * ptr, Uint16 value); | |
86 | |
87 /* 32 bit atomic operations */ | 55 /* 32 bit atomic operations */ |
88 | 56 |
89 /** | 57 /** |
90 * \fn int SDL_AtomicExchange32(volatile Uint32 * ptr, Uint32 value) | 58 * \fn int SDL_AtomicExchange32(volatile Uint32 * ptr, Uint32 value) |
91 * | 59 * |
99 * The current value stored at *ptr is returned and it is replaced | 67 * The current value stored at *ptr is returned and it is replaced |
100 * with value. This function can be used to implement SDL_TestThenSet. | 68 * with value. This function can be used to implement SDL_TestThenSet. |
101 * | 69 * |
102 */ | 70 */ |
103 extern DECLSPEC Uint32 SDLCALL SDL_AtomicExchange32(volatile Uint32 * ptr, Uint32 value); | 71 extern DECLSPEC Uint32 SDLCALL SDL_AtomicExchange32(volatile Uint32 * ptr, Uint32 value); |
72 | |
104 /** | 73 /** |
105 * \fn int SDL_AtomicCompareThenSet32(volatile Uint32 * ptr, Uint32 oldvalue, Uint32 newvalue) | 74 * \fn int SDL_AtomicCompareThenSet32(volatile Uint32 * ptr, Uint32 oldvalue, Uint32 newvalue) |
106 * | 75 * |
107 * \brief If *ptr == oldvalue then replace the contents of *ptr by new value. | 76 * \brief If *ptr == oldvalue then replace the contents of *ptr by new value. |
108 * | 77 * |
125 * | 94 * |
126 * \param ptr points to the value to be tested and set. | 95 * \param ptr points to the value to be tested and set. |
127 * | 96 * |
128 */ | 97 */ |
129 extern DECLSPEC SDL_bool SDLCALL SDL_AtomicTestThenSet32(volatile Uint32 * ptr); | 98 extern DECLSPEC SDL_bool SDLCALL SDL_AtomicTestThenSet32(volatile Uint32 * ptr); |
99 | |
130 /** | 100 /** |
131 * \fn void SDL_AtomicClear32(volatile Uint32 * ptr); | 101 * \fn void SDL_AtomicClear32(volatile Uint32 * ptr); |
132 * | 102 * |
133 * \brief set the value pointed to by ptr to be zero. | 103 * \brief set the value pointed to by ptr to be zero. |
134 * | 104 * |
135 * \param ptr address of the value to be set to zero | 105 * \param ptr address of the value to be set to zero |
136 * | 106 * |
137 */ | 107 */ |
138 extern DECLSPEC void SDLCALL SDL_AtomicClear32(volatile Uint32 * ptr); | 108 extern DECLSPEC void SDLCALL SDL_AtomicClear32(volatile Uint32 * ptr); |
109 | |
139 /** | 110 /** |
140 * \fn Uint32 SDL_AtomicFetchThenIncrement32(volatile Uint32 * ptr); | 111 * \fn Uint32 SDL_AtomicFetchThenIncrement32(volatile Uint32 * ptr); |
141 * | 112 * |
142 * \brief fetch the current value of *ptr and then increment that | 113 * \brief fetch the current value of *ptr and then increment that |
143 * value in place. | 114 * value in place. |
146 * | 117 * |
147 * \param ptr address of the value to fetch and increment | 118 * \param ptr address of the value to fetch and increment |
148 * | 119 * |
149 */ | 120 */ |
150 extern DECLSPEC Uint32 SDLCALL SDL_AtomicFetchThenIncrement32(volatile Uint32 * ptr); | 121 extern DECLSPEC Uint32 SDLCALL SDL_AtomicFetchThenIncrement32(volatile Uint32 * ptr); |
122 | |
151 /** | 123 /** |
152 * \fn Uint32 SDL_AtomicFetchThenDecrement32(volatile Uint32 * ptr); | 124 * \fn Uint32 SDL_AtomicFetchThenDecrement32(volatile Uint32 * ptr); |
153 * | 125 * |
154 * \brief fetch *ptr and then decrement the value in place. | 126 * \brief fetch *ptr and then decrement the value in place. |
155 * | 127 * |
157 * | 129 * |
158 * \param ptr address of the value to fetch and drement | 130 * \param ptr address of the value to fetch and drement |
159 * | 131 * |
160 */ | 132 */ |
161 extern DECLSPEC Uint32 SDLCALL SDL_AtomicFetchThenDecrement32(volatile Uint32 * ptr); | 133 extern DECLSPEC Uint32 SDLCALL SDL_AtomicFetchThenDecrement32(volatile Uint32 * ptr); |
134 | |
162 /** | 135 /** |
163 * \fn Uint32 SDL_AtomicFetchThenAdd32(volatile Uint32 * ptr, Uint32 value); | 136 * \fn Uint32 SDL_AtomicFetchThenAdd32(volatile Uint32 * ptr, Uint32 value); |
164 * | 137 * |
165 * \brief fetch the current value at ptr and then add value to *ptr. | 138 * \brief fetch the current value at ptr and then add value to *ptr. |
166 * | 139 * |
169 * \param ptr the address of data we are changing. | 142 * \param ptr the address of data we are changing. |
170 * \param value the value to add to *ptr. | 143 * \param value the value to add to *ptr. |
171 * | 144 * |
172 */ | 145 */ |
173 extern DECLSPEC Uint32 SDLCALL SDL_AtomicFetchThenAdd32(volatile Uint32 * ptr, Uint32 value); | 146 extern DECLSPEC Uint32 SDLCALL SDL_AtomicFetchThenAdd32(volatile Uint32 * ptr, Uint32 value); |
147 | |
174 /** | 148 /** |
175 * \fn Uint32 SDL_AtomicFetchThenSubtract32(volatile Uint32 * ptr, Uint32 value); | 149 * \fn Uint32 SDL_AtomicFetchThenSubtract32(volatile Uint32 * ptr, Uint32 value); |
176 * | 150 * |
177 * \brief Fetch *ptr and then subtract value from it. | 151 * \brief Fetch *ptr and then subtract value from it. |
178 * | 152 * |
181 * \param ptr the address of the data being changed. | 155 * \param ptr the address of the data being changed. |
182 * \param value the value to subtract from *ptr. | 156 * \param value the value to subtract from *ptr. |
183 * | 157 * |
184 */ | 158 */ |
185 extern DECLSPEC Uint32 SDLCALL SDL_AtomicFetchThenSubtract32(volatile Uint32 * ptr, Uint32 value); | 159 extern DECLSPEC Uint32 SDLCALL SDL_AtomicFetchThenSubtract32(volatile Uint32 * ptr, Uint32 value); |
160 | |
186 /** | 161 /** |
187 * \fn Uint32 SDL_AtomicIncrementThenFetch32(volatile Uint32 * ptr); | 162 * \fn Uint32 SDL_AtomicIncrementThenFetch32(volatile Uint32 * ptr); |
188 * | 163 * |
189 * \brief Add one to the data pointed to by ptr and return that value. | 164 * \brief Add one to the data pointed to by ptr and return that value. |
190 * | 165 * |
192 * | 167 * |
193 * \param ptr address of the data to increment. | 168 * \param ptr address of the data to increment. |
194 * | 169 * |
195 */ | 170 */ |
196 extern DECLSPEC Uint32 SDLCALL SDL_AtomicIncrementThenFetch32(volatile Uint32 * ptr); | 171 extern DECLSPEC Uint32 SDLCALL SDL_AtomicIncrementThenFetch32(volatile Uint32 * ptr); |
172 | |
197 /** | 173 /** |
198 * \fn Uint32 SDL_AtomicDecrementThenFetch32(volatile Uint32 * ptr); | 174 * \fn Uint32 SDL_AtomicDecrementThenFetch32(volatile Uint32 * ptr); |
199 * | 175 * |
200 * \brief Subtract one from data pointed to by ptr and return the new value. | 176 * \brief Subtract one from data pointed to by ptr and return the new value. |
201 * | 177 * |
203 * | 179 * |
204 * \param ptr The address of the data to decrement. | 180 * \param ptr The address of the data to decrement. |
205 * | 181 * |
206 */ | 182 */ |
207 extern DECLSPEC Uint32 SDLCALL SDL_AtomicDecrementThenFetch32(volatile Uint32 * ptr); | 183 extern DECLSPEC Uint32 SDLCALL SDL_AtomicDecrementThenFetch32(volatile Uint32 * ptr); |
184 | |
208 /** | 185 /** |
209 * \fn Uint32 SDL_AtomicAddThenFetch32(volatile Uint32 * ptr, Uint32 value); | 186 * \fn Uint32 SDL_AtomicAddThenFetch32(volatile Uint32 * ptr, Uint32 value); |
210 * | 187 * |
211 * \brief Add value to the data pointed to by ptr and return result. | 188 * \brief Add value to the data pointed to by ptr and return result. |
212 * | 189 * |
215 * \param ptr The address of the data to be modified. | 192 * \param ptr The address of the data to be modified. |
216 * \param value The value to be added. | 193 * \param value The value to be added. |
217 * | 194 * |
218 */ | 195 */ |
219 extern DECLSPEC Uint32 SDLCALL SDL_AtomicAddThenFetch32(volatile Uint32 * ptr, Uint32 value); | 196 extern DECLSPEC Uint32 SDLCALL SDL_AtomicAddThenFetch32(volatile Uint32 * ptr, Uint32 value); |
197 | |
220 /** | 198 /** |
221 * \fn Uint32 SDL_AtomicSubtractThenFetch32(volatile Uint32 * ptr, Uint32 value); | 199 * \fn Uint32 SDL_AtomicSubtractThenFetch32(volatile Uint32 * ptr, Uint32 value); |
222 * | 200 * |
223 * \brief Subtract value from the data pointed to by ptr and return the result. | 201 * \brief Subtract value from the data pointed to by ptr and return the result. |
224 * | 202 * |