Mercurial > sdl-ios-xcode
comparison test/testatomic.c @ 5018:342b158efbbe
Michael gave permission to use his test code
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 18 Jan 2011 10:57:28 -0800 |
parents | 9d6b527e0912 |
children | 470ede30189c |
comparison
equal
deleted
inserted
replaced
5017:a9a3b9852a4a | 5018:342b158efbbe |
---|---|
66 value = SDL_AtomicGet(&v); | 66 value = SDL_AtomicGet(&v); |
67 tfret = (SDL_AtomicCAS(&v, value, 20) == SDL_TRUE); | 67 tfret = (SDL_AtomicCAS(&v, value, 20) == SDL_TRUE); |
68 printf("AtomicCAS() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v)); | 68 printf("AtomicCAS() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v)); |
69 } | 69 } |
70 | 70 |
71 /* Atomic operation test, adapted from code by Michael Davidsaver at: | 71 /**************************************************************************/ |
72 http://bazaar.launchpad.net/~mdavidsaver/epics-base/atomic/revision/12105#src/libCom/test/epicsAtomicTest.c | 72 /* Atomic operation test |
73 */ | 73 * Adapted with permission from code by Michael Davidsaver at: |
74 * http://bazaar.launchpad.net/~mdavidsaver/epics-base/atomic/revision/12105#src/libCom/test/epicsAtomicTest.c | |
75 * Original copyright 2010 Brookhaven Science Associates as operator of Brookhaven National Lab | |
76 * http://www.aps.anl.gov/epics/license/open.php | |
77 */ | |
74 | 78 |
75 /* Tests semantics of atomic operations. Also a stress test | 79 /* Tests semantics of atomic operations. Also a stress test |
76 * to see if they are really atomic. | 80 * to see if they are really atomic. |
77 * | 81 * |
78 * Serveral threads adding to the same variable. | 82 * Serveral threads adding to the same variable. |
222 printf("Atomic %d Non-Atomic %d\n",v,bad); | 226 printf("Atomic %d Non-Atomic %d\n",v,bad); |
223 SDL_assert(v==Expect); | 227 SDL_assert(v==Expect); |
224 SDL_assert(bad!=Expect); | 228 SDL_assert(bad!=Expect); |
225 } | 229 } |
226 | 230 |
231 /* End atomic operation test */ | |
232 /**************************************************************************/ | |
233 | |
227 int | 234 int |
228 main(int argc, char *argv[]) | 235 main(int argc, char *argv[]) |
229 { | 236 { |
230 RunBasicTest(); | 237 RunBasicTest(); |
231 RunEpicTest(); | 238 RunEpicTest(); |