annotate src/atomic/win32/SDL_atomic.c @ 3308:0e000afe3dc0

fixed a spelling error in the documentation.
author Bob Pendleton <bob@pendleton.com>
date Fri, 25 Sep 2009 19:26:21 +0000
parents a8ec88ff18c7
children 3889325ca987
rev   line source
3199
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
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: 3212
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: 3212
diff changeset
3 Copyright (C) 1997-2009 Sam Lantinga
3199
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
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: 3212
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: 3212
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: 3212
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: 3212
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
3199
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
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: 3212
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: 3212
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: 3212
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: 3212
diff changeset
13 Lesser General Public License for more details.
3199
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
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: 3212
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: 3212
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: 3212
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
3199
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
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: 3212
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: 3212
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: 3212
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: 3212
diff changeset
22 Contributed by Bob Pendleton, bob@pendleton.com
3199
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
23 */
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
24
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: 3199
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: 3199
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: 3199
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: 3212
diff changeset
28 #include "SDL_error.h"
3306
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
29 #include "Windows.h"
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: 3212
diff changeset
30
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: 3199
diff changeset
31 /*
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: 3212
diff changeset
32 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: 3199
diff changeset
33 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: 3199
diff changeset
34 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: 3212
diff changeset
35 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: 3212
diff changeset
36 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: 3199
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: 3199
diff changeset
38
3aa519a5c676 I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents: 3199
diff changeset
39 /*
3306
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
40 WIN32 VERSION.
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: 3212
diff changeset
41
3306
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
42 This makes use of native Windows atomic operations.
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: 3212
diff changeset
43 */
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: 3199
diff changeset
44
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: 3212
diff changeset
45 /*
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: 3212
diff changeset
46 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: 3212
diff changeset
47 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: 3212
diff changeset
48 */
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: 3212
diff changeset
49
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: 3212
diff changeset
50 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: 3212
diff changeset
51 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: 3212
diff changeset
52 {
3306
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
53 long volatile * l = (long volatile *)lock;
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
54 Uint32 old = 0;
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
55 Uint32 new = 1;
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
56
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
57 old = InterlockedExchange(l, new);
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
58 while(1 == old)
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
59 {
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
60 old = InterlockedExchange(l, new);
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
61 }
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: 3212
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: 3199
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: 3212
diff changeset
64 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: 3212
diff changeset
65 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: 3212
diff changeset
66 {
3306
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
67 long volatile * l = (long volatile *)lock;
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
68 Uint32 new = 0;
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
69
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
70 InterlockedExchange(l, new);
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: 3212
diff changeset
71 }
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: 3199
diff changeset
72
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: 3212
diff changeset
73 /*
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: 3212
diff changeset
74 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: 3212
diff changeset
75 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: 3212
diff changeset
76 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: 3212
diff changeset
77 */
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: 3212
diff changeset
78
3306
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
79 #define nativeTestThenSet32
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
80 #define nativeClear32
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
81 #define nativeFetchThenIncrement32
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
82 #define nativeFetchThenDecrement32
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
83 #define nativeFetchThenAdd32
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
84 #define nativeFetchThenSubtract32
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
85 #define nativeIncrementThenFetch32
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
86 #define nativeDecrementThenFetch32
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
87 #define nativeAddThenFetch32
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
88 #define 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: 3199
diff changeset
89
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: 3212
diff changeset
90 #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: 3212
diff changeset
91 #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: 3212
diff changeset
92 #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: 3212
diff changeset
93 #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: 3212
diff changeset
94 #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: 3212
diff changeset
95 #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: 3212
diff changeset
96 #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: 3212
diff changeset
97 #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: 3212
diff changeset
98 #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: 3212
diff changeset
99 #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: 3212
diff changeset
100
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: 3212
diff changeset
101 /*
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: 3212
diff changeset
102 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: 3212
diff changeset
103 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: 3212
diff changeset
104 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: 3212
diff changeset
105 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: 3212
diff changeset
106 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: 3212
diff changeset
107
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: 3212
diff changeset
108 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: 3212
diff changeset
109 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: 3212
diff changeset
110 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: 3212
diff changeset
111 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: 3199
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: 3212
diff changeset
113 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: 3212
diff changeset
114 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: 3212
diff changeset
115 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: 3212
diff changeset
116 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: 3212
diff changeset
117 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: 3212
diff changeset
118 then the table of locks can be expanded to a new size so long as
3308
0e000afe3dc0 fixed a spelling error in the documentation.
Bob Pendleton <bob@pendleton.com>
parents: 3306
diff changeset
119 the new size is a power of two.
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: 3212
diff changeset
120 */
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: 3199
diff changeset
121
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: 3212
diff changeset
122 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: 3212
diff changeset
123 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: 3212
diff changeset
124 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: 3212
diff changeset
125 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: 3212
diff changeset
126 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: 3212
diff changeset
127 };
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: 3212
diff changeset
128
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: 3212
diff changeset
129 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: 3212
diff changeset
130 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: 3212
diff changeset
131 {
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: 3212
diff changeset
132 #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: 3212
diff changeset
133 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: 3212
diff changeset
134 #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: 3212
diff changeset
135 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: 3199
diff changeset
136 #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: 3199
diff changeset
137
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: 3212
diff changeset
138 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: 3199
diff changeset
139 }
3aa519a5c676 I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents: 3199
diff changeset
140
3aa519a5c676 I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents: 3199
diff changeset
141 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: 3212
diff changeset
142 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: 3199
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: 3212
diff changeset
144 #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: 3212
diff changeset
145 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: 3212
diff changeset
146 #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: 3212
diff changeset
147 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: 3199
diff changeset
148 #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: 3199
diff changeset
149
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: 3212
diff changeset
150 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: 3199
diff changeset
151 }
3aa519a5c676 I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents: 3199
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: 3212
diff changeset
153 /* 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: 3212
diff changeset
154
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: 3199
diff changeset
155 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: 3212
diff changeset
156 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: 3199
diff changeset
157 {
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: 3212
diff changeset
158 #ifdef nativeTestThenSet32
3306
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
159 long volatile * p = (long volatile *)ptr;
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
160 Uint32 new = 1;
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
161
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
162 return 0 == InterlockedExchange(p, new);
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: 3199
diff changeset
163 #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: 3199
diff changeset
164 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: 3199
diff changeset
165
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: 3212
diff changeset
166 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: 3199
diff changeset
167 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: 3199
diff changeset
168 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: 3199
diff changeset
169 {
3aa519a5c676 I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents: 3199
diff changeset
170 *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: 3199
diff changeset
171 }
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: 3212
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: 3199
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: 3199
diff changeset
174 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: 3199
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: 3199
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: 3199
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: 3199
diff changeset
178 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: 3212
diff changeset
179 SDL_AtomicClear32(volatile Uint32 * ptr)
3199
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
180 {
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: 3199
diff changeset
181 #ifdef nativeClear32
3306
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
182 long volatile * p = (long volatile *)ptr;
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
183 Uint32 new = 0;
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
184
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
185 InterlockedExchange(p, new);
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: 3199
diff changeset
186 #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: 3212
diff changeset
187 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: 3199
diff changeset
188 *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: 3212
diff changeset
189 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: 3199
diff changeset
190
3aa519a5c676 I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents: 3199
diff changeset
191 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: 3199
diff changeset
192 #endif
3199
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
193 }
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
194
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
195 Uint32
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: 3212
diff changeset
196 SDL_AtomicFetchThenIncrement32(volatile Uint32 * ptr)
3199
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
197 {
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: 3199
diff changeset
198 #ifdef nativeFetchThenIncrement32
3306
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
199 long volatile * p = (long volatile *)ptr;
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
200
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
201 return InterlockedExchangeAdd(p, 1);
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: 3199
diff changeset
202 #else
3212
759032c318d8 This is a cosmetic fix, I found a stupid typo
Bob Pendleton <bob@pendleton.com>
parents: 3202
diff changeset
203 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: 3199
diff changeset
204
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: 3212
diff changeset
205 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: 3199
diff changeset
206 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: 3199
diff changeset
207 (*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: 3212
diff changeset
208 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: 3199
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: 3199
diff changeset
210 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: 3199
diff changeset
211 #endif
3199
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
212 }
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
213
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
214 Uint32
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: 3212
diff changeset
215 SDL_AtomicFetchThenDecrement32(volatile Uint32 * ptr)
3199
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
216 {
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: 3199
diff changeset
217 #ifdef nativeFetchThenDecrement32
3306
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
218 long volatile * p = (long volatile *)ptr;
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
219
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
220 return InterlockedExchangeAdd(p, -1);
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: 3199
diff changeset
221 #else
3212
759032c318d8 This is a cosmetic fix, I found a stupid typo
Bob Pendleton <bob@pendleton.com>
parents: 3202
diff changeset
222 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: 3199
diff changeset
223
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: 3212
diff changeset
224 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: 3199
diff changeset
225 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: 3199
diff changeset
226 (*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: 3212
diff changeset
227 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: 3199
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: 3199
diff changeset
229 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: 3199
diff changeset
230 #endif
3199
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
231 }
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
232
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
233 Uint32
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: 3212
diff changeset
234 SDL_AtomicFetchThenAdd32(volatile Uint32 * ptr, Uint32 value)
3199
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
235 {
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: 3199
diff changeset
236 #ifdef nativeFetchThenAdd32
3306
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
237 long volatile * p = (long volatile *)ptr;
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
238
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
239 return InterlockedExchangeAdd(p, 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: 3199
diff changeset
240 #else
3212
759032c318d8 This is a cosmetic fix, I found a stupid typo
Bob Pendleton <bob@pendleton.com>
parents: 3202
diff changeset
241 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: 3199
diff changeset
242
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: 3212
diff changeset
243 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: 3199
diff changeset
244 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: 3199
diff changeset
245 (*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: 3212
diff changeset
246 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: 3199
diff changeset
247
3aa519a5c676 I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents: 3199
diff changeset
248 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: 3199
diff changeset
249 #endif
3199
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
250 }
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
251
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
252 Uint32
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: 3212
diff changeset
253 SDL_AtomicFetchThenSubtract32(volatile Uint32 * ptr, Uint32 value)
3199
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
254 {
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: 3199
diff changeset
255 #ifdef nativeFetchThenSubtract32
3306
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
256 long volatile * p = (long volatile *)ptr;
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
257
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
258 return InterlockedExchangeAdd(p, (0 - 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: 3199
diff changeset
259 #else
3212
759032c318d8 This is a cosmetic fix, I found a stupid typo
Bob Pendleton <bob@pendleton.com>
parents: 3202
diff changeset
260 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: 3199
diff changeset
261
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: 3212
diff changeset
262 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: 3199
diff changeset
263 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: 3199
diff changeset
264 (*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: 3212
diff changeset
265 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: 3199
diff changeset
266
3aa519a5c676 I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents: 3199
diff changeset
267 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: 3199
diff changeset
268 #endif
3199
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
269 }
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
270
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
271 Uint32
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: 3212
diff changeset
272 SDL_AtomicIncrementThenFetch32(volatile Uint32 * ptr)
3199
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
273 {
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: 3199
diff changeset
274 #ifdef nativeIncrementThenFetch32
3306
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
275 long volatile * p = (LONG volatile *)ptr;
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
276
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
277 return InterlockedIncrement(p);
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: 3199
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: 3199
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: 3212
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: 3199
diff changeset
282 (*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: 3199
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: 3212
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: 3199
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: 3199
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: 3199
diff changeset
287 #endif
3199
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
288 }
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
289
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
290 Uint32
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: 3212
diff changeset
291 SDL_AtomicDecrementThenFetch32(volatile Uint32 * ptr)
3199
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
292 {
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: 3199
diff changeset
293 #ifdef nativeDecrementThenFetch32
3306
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
294 long volatile * p = (LONG volatile *)ptr;
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
295
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
296 return InterlockedDecrement(p);
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: 3199
diff changeset
297 #else
3212
759032c318d8 This is a cosmetic fix, I found a stupid typo
Bob Pendleton <bob@pendleton.com>
parents: 3202
diff changeset
298 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: 3199
diff changeset
299
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: 3212
diff changeset
300 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: 3199
diff changeset
301 (*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: 3199
diff changeset
302 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: 3212
diff changeset
303 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: 3199
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: 3199
diff changeset
305 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: 3199
diff changeset
306 #endif
3199
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
307 }
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
308
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
309 Uint32
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: 3212
diff changeset
310 SDL_AtomicAddThenFetch32(volatile Uint32 * ptr, Uint32 value)
3199
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
311 {
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: 3199
diff changeset
312 #ifdef nativeAddThenFetch32
3306
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
313 long volatile * p = (long volatile *)ptr;
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
314
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
315 return InterlockedExchangeAdd(p, value) + 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: 3199
diff changeset
316 #else
3212
759032c318d8 This is a cosmetic fix, I found a stupid typo
Bob Pendleton <bob@pendleton.com>
parents: 3202
diff changeset
317 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: 3199
diff changeset
318
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: 3212
diff changeset
319 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: 3199
diff changeset
320 (*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: 3199
diff changeset
321 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: 3212
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: 3199
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: 3199
diff changeset
324 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: 3199
diff changeset
325 #endif
3199
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
326 }
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
327
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
328 Uint32
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: 3212
diff changeset
329 SDL_AtomicSubtractThenFetch32(volatile Uint32 * ptr, Uint32 value)
3199
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
330 {
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: 3199
diff changeset
331 #ifdef nativeSubtractThenFetch32
3306
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
332 long volatile * p = (long volatile *)ptr;
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
333
a8ec88ff18c7 This version actaully should work on Windows.
Bob Pendleton <bob@pendleton.com>
parents: 3261
diff changeset
334 return InterlockedExchangeAdd(p, (0 - value)) - 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: 3199
diff changeset
335 #else
3212
759032c318d8 This is a cosmetic fix, I found a stupid typo
Bob Pendleton <bob@pendleton.com>
parents: 3202
diff changeset
336 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: 3199
diff changeset
337
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: 3212
diff changeset
338 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: 3199
diff changeset
339 (*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: 3199
diff changeset
340 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: 3212
diff changeset
341 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: 3199
diff changeset
342
3aa519a5c676 I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents: 3199
diff changeset
343 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: 3199
diff changeset
344 #endif
3199
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
345 }
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
346
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: 3199
diff changeset
347 /* 64 bit atomic operations */
3199
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
348 #ifdef SDL_HAS_64BIT_TYPE
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
349
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: 3212
diff changeset
350 SDL_bool
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: 3212
diff changeset
351 SDL_AtomicTestThenSet64(volatile Uint64 * ptr)
3199
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
352 {
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: 3212
diff changeset
353 #ifdef nativeTestThenSet64
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: 3199
diff changeset
354 #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: 3199
diff changeset
355 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: 3199
diff changeset
356
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: 3212
diff changeset
357 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: 3199
diff changeset
358 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: 3199
diff changeset
359 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: 3199
diff changeset
360 {
3aa519a5c676 I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents: 3199
diff changeset
361 *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: 3199
diff changeset
362 }
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: 3212
diff changeset
363 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: 3199
diff changeset
364
3aa519a5c676 I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents: 3199
diff changeset
365 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: 3199
diff changeset
366 #endif
3199
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
367 }
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
368
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
369 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: 3212
diff changeset
370 SDL_AtomicClear64(volatile Uint64 * ptr)
3199
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
371 {
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: 3199
diff changeset
372 #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: 3199
diff changeset
373 #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: 3212
diff changeset
374 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: 3199
diff changeset
375 *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: 3212
diff changeset
376 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: 3199
diff changeset
377
3aa519a5c676 I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents: 3199
diff changeset
378 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: 3199
diff changeset
379 #endif
3199
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
380 }
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
381
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
382 Uint64
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: 3212
diff changeset
383 SDL_AtomicFetchThenIncrement64(volatile Uint64 * ptr)
3199
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
384 {
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: 3199
diff changeset
385 #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: 3199
diff changeset
386 #else
3212
759032c318d8 This is a cosmetic fix, I found a stupid typo
Bob Pendleton <bob@pendleton.com>
parents: 3202
diff changeset
387 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: 3199
diff changeset
388
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: 3212
diff changeset
389 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: 3199
diff changeset
390 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: 3199
diff changeset
391 (*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: 3212
diff changeset
392 privateUnlock(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: 3212
diff changeset
393
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: 3212
diff changeset
394 return tmp;
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: 3212
diff changeset
395 #endif
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: 3212
diff changeset
396 }
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: 3212
diff changeset
397
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: 3212
diff changeset
398 Uint64
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: 3212
diff changeset
399 SDL_AtomicFetchThenDecrement64(volatile Uint64 * 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: 3212
diff changeset
400 {
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: 3212
diff changeset
401 #ifdef 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: 3212
diff changeset
402 #else
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: 3212
diff changeset
403 Uint64 tmp = 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: 3212
diff changeset
404
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: 3212
diff changeset
405 privateWaitLock(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: 3212
diff changeset
406 tmp = *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: 3212
diff changeset
407 (*ptr) -= 1;
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: 3212
diff changeset
408 privateUnlock(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: 3212
diff changeset
409
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: 3212
diff changeset
410 return tmp;
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: 3212
diff changeset
411 #endif
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: 3212
diff changeset
412 }
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: 3212
diff changeset
413
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: 3212
diff changeset
414 Uint64
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: 3212
diff changeset
415 SDL_AtomicFetchThenAdd64(volatile Uint64 * ptr, Uint64 value)
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: 3212
diff changeset
416 {
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: 3212
diff changeset
417 #ifdef 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: 3212
diff changeset
418 #else
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: 3212
diff changeset
419 Uint64 tmp = 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: 3212
diff changeset
420
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: 3212
diff changeset
421 privateWaitLock(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: 3212
diff changeset
422 tmp = *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: 3212
diff changeset
423 (*ptr)+= value;
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: 3212
diff changeset
424 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: 3199
diff changeset
425
3aa519a5c676 I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents: 3199
diff changeset
426 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: 3199
diff changeset
427 #endif
3199
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
428 }
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
429
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
430 Uint64
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: 3212
diff changeset
431 SDL_AtomicFetchThenSubtract64(volatile Uint64 * ptr, Uint64 value)
3199
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
432 {
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: 3212
diff changeset
433 #ifdef nativeFetchThenSubtract64
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: 3199
diff changeset
434 #else
3212
759032c318d8 This is a cosmetic fix, I found a stupid typo
Bob Pendleton <bob@pendleton.com>
parents: 3202
diff changeset
435 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: 3199
diff changeset
436
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: 3212
diff changeset
437 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: 3199
diff changeset
438 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: 3212
diff changeset
439 (*ptr)-= value;
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: 3212
diff changeset
440 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: 3199
diff changeset
441
3aa519a5c676 I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents: 3199
diff changeset
442 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: 3199
diff changeset
443 #endif
3199
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
444 }
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
445
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
446 Uint64
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: 3212
diff changeset
447 SDL_AtomicIncrementThenFetch64(volatile Uint64 * ptr)
3199
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
448 {
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: 3212
diff changeset
449 #ifdef nativeIncrementThenFetch64
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: 3199
diff changeset
450 #else
3212
759032c318d8 This is a cosmetic fix, I found a stupid typo
Bob Pendleton <bob@pendleton.com>
parents: 3202
diff changeset
451 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: 3199
diff changeset
452
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: 3212
diff changeset
453 privateWaitLock(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: 3212
diff changeset
454 (*ptr)+= 1;
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: 3199
diff changeset
455 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: 3212
diff changeset
456 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: 3199
diff changeset
457
3aa519a5c676 I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents: 3199
diff changeset
458 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: 3199
diff changeset
459 #endif
3199
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
460 }
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
461
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
462 Uint64
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: 3212
diff changeset
463 SDL_AtomicDecrementThenFetch64(volatile Uint64 * ptr)
3199
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
464 {
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: 3212
diff changeset
465 #ifdef nativeDecrementThenFetch64
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: 3199
diff changeset
466 #else
3212
759032c318d8 This is a cosmetic fix, I found a stupid typo
Bob Pendleton <bob@pendleton.com>
parents: 3202
diff changeset
467 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: 3199
diff changeset
468
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: 3212
diff changeset
469 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: 3199
diff changeset
470 (*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: 3199
diff changeset
471 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: 3212
diff changeset
472 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: 3199
diff changeset
473
3aa519a5c676 I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents: 3199
diff changeset
474 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: 3199
diff changeset
475 #endif
3199
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
476 }
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
477
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
478 Uint64
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: 3212
diff changeset
479 SDL_AtomicAddThenFetch64(volatile Uint64 * ptr, Uint64 value)
3199
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
480 {
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: 3199
diff changeset
481 #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: 3199
diff changeset
482 #else
3212
759032c318d8 This is a cosmetic fix, I found a stupid typo
Bob Pendleton <bob@pendleton.com>
parents: 3202
diff changeset
483 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: 3199
diff changeset
484
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: 3212
diff changeset
485 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: 3199
diff changeset
486 (*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: 3199
diff changeset
487 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: 3212
diff changeset
488 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: 3199
diff changeset
489
3aa519a5c676 I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents: 3199
diff changeset
490 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: 3199
diff changeset
491 #endif
3199
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
492 }
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
493
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
494 Uint64
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: 3212
diff changeset
495 SDL_AtomicSubtractThenFetch64(volatile Uint64 * ptr, Uint64 value)
3199
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
496 {
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: 3199
diff changeset
497 #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: 3199
diff changeset
498 #else
3212
759032c318d8 This is a cosmetic fix, I found a stupid typo
Bob Pendleton <bob@pendleton.com>
parents: 3202
diff changeset
499 Uint64 tmp = 0;
3199
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
500
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: 3212
diff changeset
501 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: 3199
diff changeset
502 (*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: 3199
diff changeset
503 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: 3212
diff changeset
504 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: 3199
diff changeset
505
3aa519a5c676 I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents: 3199
diff changeset
506 return tmp;
3199
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
507 #endif
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: 3199
diff changeset
508 }
3199
3e1bf2b8bd81 This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff changeset
509 #endif
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: 3199
diff changeset
510