Mercurial > sdl-ios-xcode
annotate src/atomic/dummy/SDL_atomic.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 | 48a80f2a7ff2 |
children | 0e000afe3dc0 |
rev | line source |
---|---|
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
1 /* |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
3 Copyright (C) 1997-2009 Sam Lantinga |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
4 |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
7 License as published by the Free Software Foundation; either |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
9 |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
13 Lesser General Public License for more details. |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
14 |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
18 |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
19 Sam Lantinga |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
20 slouken@libsdl.org |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
21 |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
22 Contributed by Bob Pendleton, bob@pendleton.com |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
23 */ |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
24 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
25 #include "SDL_stdinc.h" |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
26 #include "SDL_atomic.h" |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
27 |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
28 #include "SDL_error.h" |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
29 |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
30 /* |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
31 This file provides 32, and 64 bit atomic operations. If the |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
32 operations are provided by the native hardware and operating system |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
33 they are used. If they are not then the operations are emulated |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
34 using the SDL spin lock operations. If spin lock can not be |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
35 implemented then these functions must fail. |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
36 */ |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
37 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
38 /* |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
39 DUMMY VERSION. |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
40 |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
41 This version of the code assumes there is no support for atomic |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
42 operations. Therefore, every function sets the SDL error |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
43 message. Oddly enough, if you only have one thread then this |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
44 version actuallys works. |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
45 */ |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
46 |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
47 /* |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
48 Native spinlock routines. Because this is the dummy implementation |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
49 these will always call SDL_SetError() and do nothing. |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
50 */ |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
51 |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
52 void |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
53 SDL_AtomicLock(SDL_SpinLock *lock) |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
54 { |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
55 SDL_SetError("SDL_atomic.c: is not implemented on this platform"); |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
56 } |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
57 |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
58 void |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
59 SDL_AtomicUnlock(SDL_SpinLock *lock) |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
60 { |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
61 SDL_SetError("SDL_atomic.c: is not implemented on this platform"); |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
62 } |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
63 |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
64 /* |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
65 Note that platform specific versions can be built from this version |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
66 by changing the #undefs to #defines and adding platform specific |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
67 code. |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
68 */ |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
69 |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
70 #undef nativeTestThenSet32 |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
71 #undef nativeClear32 |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
72 #undef nativeFetchThenIncrement32 |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
73 #undef nativeFetchThenDecrement32 |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
74 #undef nativeFetchThenAdd32 |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
75 #undef nativeFetchThenSubtract32 |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
76 #undef nativeIncrementThenFetch32 |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
77 #undef nativeDecrementThenFetch32 |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
78 #undef nativeAddThenFetch32 |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
79 #undef nativeSubtractThenFetch32 |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
80 |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
81 #undef nativeTestThenSet64 |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
82 #undef nativeClear64 |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
83 #undef nativeFetchThenIncrement64 |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
84 #undef nativeFetchThenDecrement64 |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
85 #undef nativeFetchThenAdd64 |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
86 #undef nativeFetchThenSubtract64 |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
87 #undef nativeIncrementThenFetch64 |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
88 #undef nativeDecrementThenFetch64 |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
89 #undef nativeAddThenFetch64 |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
90 #undef nativeSubtractThenFetch64 |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
91 |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
92 /* |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
93 If any of the operations are not provided then we must emulate some |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
94 of them. That means we need a nice implementation of spin locks |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
95 that avoids the "one big lock" problem. We use a vector of spin |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
96 locks and pick which one to use based on the address of the operand |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
97 of the function. |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
98 |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
99 To generate the index of the lock we first shift by 3 bits to get |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
100 rid on the zero bits that result from 32 and 64 bit allignment of |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
101 data. We then mask off all but 5 bits and use those 5 bits as an |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
102 index into the table. |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
103 |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
104 Picking the lock this way insures that accesses to the same data at |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
105 the same time will go to the same lock. OTOH, accesses to different |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
106 data have only a 1/32 chance of hitting the same lock. That should |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
107 pretty much eliminate the chances of several atomic operations on |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
108 different data from waiting on the same "big lock". If it isn't |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
109 then the table of locks can be expanded to a new size so long as |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
110 the new size if a power of two. |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
111 */ |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
112 |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
113 static SDL_SpinLock locks[32] = { |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
114 0, 0, 0, 0, 0, 0, 0, 0, |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
115 0, 0, 0, 0, 0, 0, 0, 0, |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
116 0, 0, 0, 0, 0, 0, 0, 0, |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
117 0, 0, 0, 0, 0, 0, 0, 0, |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
118 }; |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
119 |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
120 static __inline__ void |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
121 privateWaitLock(volatile void *ptr) |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
122 { |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
123 #if SIZEOF_VOIDP == 4 |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
124 Uint32 index = ((((Uint32)ptr) >> 3) & 0x1f); |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
125 #elif SIZEOF_VOIDP == 8 |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
126 Uint64 index = ((((Uint64)ptr) >> 3) & 0x1f); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
127 #endif |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
128 |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
129 SDL_AtomicLock(&locks[index]); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
130 } |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
131 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
132 static __inline__ void |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
133 privateUnlock(volatile void *ptr) |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
134 { |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
135 #if SIZEOF_VOIDP == 4 |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
136 Uint32 index = ((((Uint32)ptr) >> 3) & 0x1f); |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
137 #elif SIZEOF_VOIDP == 8 |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
138 Uint64 index = ((((Uint64)ptr) >> 3) & 0x1f); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
139 #endif |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
140 |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
141 SDL_AtomicUnlock(&locks[index]); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
142 } |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
143 |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
144 /* 32 bit atomic operations */ |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
145 |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
146 SDL_bool |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
147 SDL_AtomicTestThenSet32(volatile Uint32 * ptr) |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
148 { |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
149 #ifdef nativeTestThenSet32 |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
150 #else |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
151 SDL_bool result = SDL_FALSE; |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
152 |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
153 privateWaitLock(ptr); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
154 result = (*ptr == 0); |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
155 if (result) |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
156 { |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
157 *ptr = 1; |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
158 } |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
159 privateUnlock(ptr); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
160 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
161 return result; |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
162 #endif |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
163 } |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
164 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
165 void |
3216
48a80f2a7ff2
volitile... duh, yeah the variable need to be labeled volitile
Bob Pendleton <bob@pendleton.com>
parents:
3212
diff
changeset
|
166 SDL_AtomicClear32(volatile Uint32 * ptr) |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
167 { |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
168 #ifdef nativeClear32 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
169 #else |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
170 privateWaitLock(ptr); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
171 *ptr = 0; |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
172 privateUnlock(ptr); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
173 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
174 return; |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
175 #endif |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
176 } |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
177 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
178 Uint32 |
3216
48a80f2a7ff2
volitile... duh, yeah the variable need to be labeled volitile
Bob Pendleton <bob@pendleton.com>
parents:
3212
diff
changeset
|
179 SDL_AtomicFetchThenIncrement32(volatile Uint32 * ptr) |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
180 { |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
181 #ifdef nativeFetchThenIncrement32 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
182 #else |
3212
759032c318d8
This is a cosmetic fix, I found a stupid typo
Bob Pendleton <bob@pendleton.com>
parents:
3202
diff
changeset
|
183 Uint32 tmp = 0; |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
184 |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
185 privateWaitLock(ptr); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
186 tmp = *ptr; |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
187 (*ptr)+= 1; |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
188 privateUnlock(ptr); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
189 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
190 return tmp; |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
191 #endif |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
192 } |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
193 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
194 Uint32 |
3216
48a80f2a7ff2
volitile... duh, yeah the variable need to be labeled volitile
Bob Pendleton <bob@pendleton.com>
parents:
3212
diff
changeset
|
195 SDL_AtomicFetchThenDecrement32(volatile Uint32 * ptr) |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
196 { |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
197 #ifdef nativeFetchThenDecrement32 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
198 #else |
3212
759032c318d8
This is a cosmetic fix, I found a stupid typo
Bob Pendleton <bob@pendleton.com>
parents:
3202
diff
changeset
|
199 Uint32 tmp = 0; |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
200 |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
201 privateWaitLock(ptr); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
202 tmp = *ptr; |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
203 (*ptr) -= 1; |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
204 privateUnlock(ptr); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
205 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
206 return tmp; |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
207 #endif |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
208 } |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
209 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
210 Uint32 |
3216
48a80f2a7ff2
volitile... duh, yeah the variable need to be labeled volitile
Bob Pendleton <bob@pendleton.com>
parents:
3212
diff
changeset
|
211 SDL_AtomicFetchThenAdd32(volatile Uint32 * ptr, Uint32 value) |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
212 { |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
213 #ifdef nativeFetchThenAdd32 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
214 #else |
3212
759032c318d8
This is a cosmetic fix, I found a stupid typo
Bob Pendleton <bob@pendleton.com>
parents:
3202
diff
changeset
|
215 Uint32 tmp = 0; |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
216 |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
217 privateWaitLock(ptr); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
218 tmp = *ptr; |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
219 (*ptr)+= value; |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
220 privateUnlock(ptr); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
221 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
222 return tmp; |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
223 #endif |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
224 } |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
225 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
226 Uint32 |
3216
48a80f2a7ff2
volitile... duh, yeah the variable need to be labeled volitile
Bob Pendleton <bob@pendleton.com>
parents:
3212
diff
changeset
|
227 SDL_AtomicFetchThenSubtract32(volatile Uint32 * ptr, Uint32 value) |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
228 { |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
229 #ifdef nativeFetchThenSubtract32 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
230 #else |
3212
759032c318d8
This is a cosmetic fix, I found a stupid typo
Bob Pendleton <bob@pendleton.com>
parents:
3202
diff
changeset
|
231 Uint32 tmp = 0; |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
232 |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
233 privateWaitLock(ptr); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
234 tmp = *ptr; |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
235 (*ptr)-= value; |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
236 privateUnlock(ptr); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
237 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
238 return tmp; |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
239 #endif |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
240 } |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
241 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
242 Uint32 |
3216
48a80f2a7ff2
volitile... duh, yeah the variable need to be labeled volitile
Bob Pendleton <bob@pendleton.com>
parents:
3212
diff
changeset
|
243 SDL_AtomicIncrementThenFetch32(volatile Uint32 * ptr) |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
244 { |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
245 #ifdef nativeIncrementThenFetch32 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
246 #else |
3212
759032c318d8
This is a cosmetic fix, I found a stupid typo
Bob Pendleton <bob@pendleton.com>
parents:
3202
diff
changeset
|
247 Uint32 tmp = 0; |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
248 |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
249 privateWaitLock(ptr); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
250 (*ptr)+= 1; |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
251 tmp = *ptr; |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
252 privateUnlock(ptr); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
253 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
254 return tmp; |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
255 #endif |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
256 } |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
257 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
258 Uint32 |
3216
48a80f2a7ff2
volitile... duh, yeah the variable need to be labeled volitile
Bob Pendleton <bob@pendleton.com>
parents:
3212
diff
changeset
|
259 SDL_AtomicDecrementThenFetch32(volatile Uint32 * ptr) |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
260 { |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
261 #ifdef nativeDecrementThenFetch32 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
262 #else |
3212
759032c318d8
This is a cosmetic fix, I found a stupid typo
Bob Pendleton <bob@pendleton.com>
parents:
3202
diff
changeset
|
263 Uint32 tmp = 0; |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
264 |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
265 privateWaitLock(ptr); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
266 (*ptr)-= 1; |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
267 tmp = *ptr; |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
268 privateUnlock(ptr); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
269 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
270 return tmp; |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
271 #endif |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
272 } |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
273 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
274 Uint32 |
3216
48a80f2a7ff2
volitile... duh, yeah the variable need to be labeled volitile
Bob Pendleton <bob@pendleton.com>
parents:
3212
diff
changeset
|
275 SDL_AtomicAddThenFetch32(volatile Uint32 * ptr, Uint32 value) |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
276 { |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
277 #ifdef nativeAddThenFetch32 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
278 #else |
3212
759032c318d8
This is a cosmetic fix, I found a stupid typo
Bob Pendleton <bob@pendleton.com>
parents:
3202
diff
changeset
|
279 Uint32 tmp = 0; |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
280 |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
281 privateWaitLock(ptr); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
282 (*ptr)+= value; |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
283 tmp = *ptr; |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
284 privateUnlock(ptr); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
285 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
286 return tmp; |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
287 #endif |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
288 } |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
289 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
290 Uint32 |
3216
48a80f2a7ff2
volitile... duh, yeah the variable need to be labeled volitile
Bob Pendleton <bob@pendleton.com>
parents:
3212
diff
changeset
|
291 SDL_AtomicSubtractThenFetch32(volatile Uint32 * ptr, Uint32 value) |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
292 { |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
293 #ifdef nativeSubtractThenFetch32 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
294 #else |
3212
759032c318d8
This is a cosmetic fix, I found a stupid typo
Bob Pendleton <bob@pendleton.com>
parents:
3202
diff
changeset
|
295 Uint32 tmp = 0; |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
296 |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
297 privateWaitLock(ptr); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
298 (*ptr)-= value; |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
299 tmp = *ptr; |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
300 privateUnlock(ptr); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
301 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
302 return tmp; |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
303 #endif |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
304 } |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
305 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
306 /* 64 bit atomic operations */ |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
307 #ifdef SDL_HAS_64BIT_TYPE |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
308 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
309 SDL_bool |
3216
48a80f2a7ff2
volitile... duh, yeah the variable need to be labeled volitile
Bob Pendleton <bob@pendleton.com>
parents:
3212
diff
changeset
|
310 SDL_AtomicTestThenSet64(volatile Uint64 * ptr) |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
311 { |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
312 #ifdef nativeTestThenSet64 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
313 #else |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
314 SDL_bool result = SDL_FALSE; |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
315 |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
316 privateWaitLock(ptr); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
317 result = (*ptr == 0); |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
318 if (result) |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
319 { |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
320 *ptr = 1; |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
321 } |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
322 privateUnlock(ptr); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
323 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
324 return result; |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
325 #endif |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
326 } |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
327 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
328 void |
3216
48a80f2a7ff2
volitile... duh, yeah the variable need to be labeled volitile
Bob Pendleton <bob@pendleton.com>
parents:
3212
diff
changeset
|
329 SDL_AtomicClear64(volatile Uint64 * ptr) |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
330 { |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
331 #ifdef nativeClear64 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
332 #else |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
333 privateWaitLock(ptr); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
334 *ptr = 0; |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
335 privateUnlock(ptr); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
336 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
337 return; |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
338 #endif |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
339 } |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
340 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
341 Uint64 |
3216
48a80f2a7ff2
volitile... duh, yeah the variable need to be labeled volitile
Bob Pendleton <bob@pendleton.com>
parents:
3212
diff
changeset
|
342 SDL_AtomicFetchThenIncrement64(volatile Uint64 * ptr) |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
343 { |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
344 #ifdef nativeFetchThenIncrement64 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
345 #else |
3212
759032c318d8
This is a cosmetic fix, I found a stupid typo
Bob Pendleton <bob@pendleton.com>
parents:
3202
diff
changeset
|
346 Uint64 tmp = 0; |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
347 |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
348 privateWaitLock(ptr); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
349 tmp = *ptr; |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
350 (*ptr)+= 1; |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
351 privateUnlock(ptr); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
352 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
353 return tmp; |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
354 #endif |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
355 } |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
356 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
357 Uint64 |
3216
48a80f2a7ff2
volitile... duh, yeah the variable need to be labeled volitile
Bob Pendleton <bob@pendleton.com>
parents:
3212
diff
changeset
|
358 SDL_AtomicFetchThenDecrement64(volatile Uint64 * ptr) |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
359 { |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
360 #ifdef nativeFetchThenDecrement64 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
361 #else |
3212
759032c318d8
This is a cosmetic fix, I found a stupid typo
Bob Pendleton <bob@pendleton.com>
parents:
3202
diff
changeset
|
362 Uint64 tmp = 0; |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
363 |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
364 privateWaitLock(ptr); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
365 tmp = *ptr; |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
366 (*ptr) -= 1; |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
367 privateUnlock(ptr); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
368 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
369 return tmp; |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
370 #endif |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
371 } |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
372 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
373 Uint64 |
3216
48a80f2a7ff2
volitile... duh, yeah the variable need to be labeled volitile
Bob Pendleton <bob@pendleton.com>
parents:
3212
diff
changeset
|
374 SDL_AtomicFetchThenAdd64(volatile Uint64 * ptr, Uint64 value) |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
375 { |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
376 #ifdef nativeFetchThenAdd64 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
377 #else |
3212
759032c318d8
This is a cosmetic fix, I found a stupid typo
Bob Pendleton <bob@pendleton.com>
parents:
3202
diff
changeset
|
378 Uint64 tmp = 0; |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
379 |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
380 privateWaitLock(ptr); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
381 tmp = *ptr; |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
382 (*ptr)+= value; |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
383 privateUnlock(ptr); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
384 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
385 return tmp; |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
386 #endif |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
387 } |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
388 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
389 Uint64 |
3216
48a80f2a7ff2
volitile... duh, yeah the variable need to be labeled volitile
Bob Pendleton <bob@pendleton.com>
parents:
3212
diff
changeset
|
390 SDL_AtomicFetchThenSubtract64(volatile Uint64 * ptr, Uint64 value) |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
391 { |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
392 #ifdef nativeFetchThenSubtract64 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
393 #else |
3212
759032c318d8
This is a cosmetic fix, I found a stupid typo
Bob Pendleton <bob@pendleton.com>
parents:
3202
diff
changeset
|
394 Uint64 tmp = 0; |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
395 |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
396 privateWaitLock(ptr); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
397 tmp = *ptr; |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
398 (*ptr)-= value; |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
399 privateUnlock(ptr); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
400 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
401 return tmp; |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
402 #endif |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
403 } |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
404 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
405 Uint64 |
3216
48a80f2a7ff2
volitile... duh, yeah the variable need to be labeled volitile
Bob Pendleton <bob@pendleton.com>
parents:
3212
diff
changeset
|
406 SDL_AtomicIncrementThenFetch64(volatile Uint64 * ptr) |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
407 { |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
408 #ifdef nativeIncrementThenFetch64 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
409 #else |
3212
759032c318d8
This is a cosmetic fix, I found a stupid typo
Bob Pendleton <bob@pendleton.com>
parents:
3202
diff
changeset
|
410 Uint64 tmp = 0; |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
411 |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
412 privateWaitLock(ptr); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
413 (*ptr)+= 1; |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
414 tmp = *ptr; |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
415 privateUnlock(ptr); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
416 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
417 return tmp; |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
418 #endif |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
419 } |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
420 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
421 Uint64 |
3216
48a80f2a7ff2
volitile... duh, yeah the variable need to be labeled volitile
Bob Pendleton <bob@pendleton.com>
parents:
3212
diff
changeset
|
422 SDL_AtomicDecrementThenFetch64(volatile Uint64 * ptr) |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
423 { |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
424 #ifdef nativeDecrementThenFetch64 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
425 #else |
3212
759032c318d8
This is a cosmetic fix, I found a stupid typo
Bob Pendleton <bob@pendleton.com>
parents:
3202
diff
changeset
|
426 Uint64 tmp = 0; |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
427 |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
428 privateWaitLock(ptr); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
429 (*ptr)-= 1; |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
430 tmp = *ptr; |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
431 privateUnlock(ptr); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
432 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
433 return tmp; |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
434 #endif |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
435 } |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
436 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
437 Uint64 |
3216
48a80f2a7ff2
volitile... duh, yeah the variable need to be labeled volitile
Bob Pendleton <bob@pendleton.com>
parents:
3212
diff
changeset
|
438 SDL_AtomicAddThenFetch64(volatile Uint64 * ptr, Uint64 value) |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
439 { |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
440 #ifdef nativeAddThenFetch64 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
441 #else |
3212
759032c318d8
This is a cosmetic fix, I found a stupid typo
Bob Pendleton <bob@pendleton.com>
parents:
3202
diff
changeset
|
442 Uint64 tmp = 0; |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
443 |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
444 privateWaitLock(ptr); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
445 (*ptr)+= value; |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
446 tmp = *ptr; |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
447 privateUnlock(ptr); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
448 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
449 return tmp; |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
450 #endif |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
451 } |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
452 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
453 Uint64 |
3216
48a80f2a7ff2
volitile... duh, yeah the variable need to be labeled volitile
Bob Pendleton <bob@pendleton.com>
parents:
3212
diff
changeset
|
454 SDL_AtomicSubtractThenFetch64(volatile Uint64 * ptr, Uint64 value) |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
455 { |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
456 #ifdef nativeSubtractThenFetch64 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
457 #else |
3212
759032c318d8
This is a cosmetic fix, I found a stupid typo
Bob Pendleton <bob@pendleton.com>
parents:
3202
diff
changeset
|
458 Uint64 tmp = 0; |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
459 |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
460 privateWaitLock(ptr); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
461 (*ptr)-= value; |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
462 tmp = *ptr; |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
463 privateUnlock(ptr); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
464 |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
465 return tmp; |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
466 #endif |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
467 } |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
468 #endif |
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
469 |