Mercurial > sdl-ios-xcode
comparison test/testatomic.c @ 3261:72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
The linux code appears to be complete and *should* be the base of all Unix and GCC based versions. The macosx and win32 versions
are currently just copies of the dummy code. I will begin working on the windows version as soon as this check in is done. I
need someone to work on the Mac OS X version.
I'm afraid that this check in will break QNX (Sorry!)
author | Bob Pendleton <bob@pendleton.com> |
---|---|
date | Thu, 17 Sep 2009 20:35:12 +0000 |
parents | 916f396fe65d |
children | 975fd903466b |
comparison
equal
deleted
inserted
replaced
3260:85bf3f297b5c | 3261:72b542f34739 |
---|---|
27 Uint32 ret32 = 0; | 27 Uint32 ret32 = 0; |
28 | 28 |
29 volatile Uint64 val64 = 0; | 29 volatile Uint64 val64 = 0; |
30 Uint64 ret64 = 0; | 30 Uint64 ret64 = 0; |
31 | 31 |
32 SDL_SpinLock lock = 0; | |
33 | |
32 SDL_bool tfret = SDL_FALSE; | 34 SDL_bool tfret = SDL_FALSE; |
33 | 35 |
34 printf("32 bit -----------------------------------------\n\n"); | 36 printf("\nspin lock---------------------------------------\n\n"); |
35 | 37 |
36 ret32 = SDL_AtomicExchange32(&val32, 10); | 38 SDL_AtomicLock(&lock); |
37 printf("Exchange32 ret=%d val=%d\n", ret32, val32); | 39 printf("AtomicLock lock=%d\n", lock); |
38 ret32 = SDL_AtomicExchange32(&val32, 0); | 40 SDL_AtomicUnlock(&lock); |
39 printf("Exchange32 ret=%d val=%d\n", ret32, val32); | 41 printf("AtomicUnlock lock=%d\n", lock); |
40 | 42 |
41 val32 = 10; | 43 printf("\n32 bit -----------------------------------------\n\n"); |
42 tfret = SDL_AtomicCompareThenSet32(&val32, 10, 20); | |
43 printf("CompareThenSet32 tfret=%s val=%d\n", tf(tfret), val32); | |
44 val32 = 10; | |
45 tfret = SDL_AtomicCompareThenSet32(&val32, 0, 20); | |
46 printf("CompareThenSet32 tfret=%s val=%d\n", tf(tfret), val32); | |
47 | 44 |
48 val32 = 0; | 45 val32 = 0; |
49 tfret = SDL_AtomicTestThenSet32(&val32); | 46 tfret = SDL_AtomicTestThenSet32(&val32); |
50 printf("TestThenSet32 tfret=%s val=%d\n", tf(tfret), val32); | 47 printf("TestThenSet32 tfret=%s val=%d\n", tf(tfret), val32); |
51 tfret = SDL_AtomicTestThenSet32(&val32); | 48 tfret = SDL_AtomicTestThenSet32(&val32); |
77 | 74 |
78 ret32 = SDL_AtomicSubtractThenFetch32(&val32, 10); | 75 ret32 = SDL_AtomicSubtractThenFetch32(&val32, 10); |
79 printf("SubtractThenFetch32 ret=%d val=%d\n", ret32, val32); | 76 printf("SubtractThenFetch32 ret=%d val=%d\n", ret32, val32); |
80 | 77 |
81 #ifdef SDL_HAS_64BIT_TYPE | 78 #ifdef SDL_HAS_64BIT_TYPE |
82 printf("64 bit -----------------------------------------\n\n"); | 79 printf("\n64 bit -----------------------------------------\n\n"); |
83 | |
84 ret64 = SDL_AtomicExchange64(&val64, 10); | |
85 printf("Exchange64 ret=%lld val=%lld\n", ret64, val64); | |
86 ret64 = SDL_AtomicExchange64(&val64, 0); | |
87 printf("Exchange64 ret=%lld val=%lld\n", ret64, val64); | |
88 | |
89 val64 = 10; | |
90 tfret = SDL_AtomicCompareThenSet64(&val64, 10, 20); | |
91 printf("CompareThenSet64 tfret=%s val=%lld\n", tf(tfret), val64); | |
92 val64 = 10; | |
93 tfret = SDL_AtomicCompareThenSet64(&val64, 0, 20); | |
94 printf("CompareThenSet64 tfret=%s val=%lld\n", tf(tfret), val64); | |
95 | 80 |
96 val64 = 0; | 81 val64 = 0; |
97 tfret = SDL_AtomicTestThenSet64(&val64); | 82 tfret = SDL_AtomicTestThenSet64(&val64); |
98 printf("TestThenSet64 tfret=%s val=%lld\n", tf(tfret), val64); | 83 printf("TestThenSet64 tfret=%s val=%lld\n", tf(tfret), val64); |
99 tfret = SDL_AtomicTestThenSet64(&val64); | 84 tfret = SDL_AtomicTestThenSet64(&val64); |