annotate src/atomic/qnx/SDL_atomic.c @ 3249:2befcf0c5ce0

Fix build on native 64-bit architecture
author Sam Lantinga <slouken@libsdl.org>
date Sat, 05 Sep 2009 14:22:12 +0000
parents 26ce0b98f2fb
children 70bfe3337f8a
rev   line source
3217
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
1 /*
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
3 Copyright (C) 1997-2009 Sam Lantinga
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
4
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
6 modify it under the terms of the GNU Lesser General Public
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
9
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
13 Lesser General Public License for more details.
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
14
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
15 You should have received a copy of the GNU Lesser General Public
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
16 License along with this library; if not, write to the Free Software
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
18
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
19 Sam Lantinga
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
20 slouken@libsdl.org
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
21 */
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
22
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
23 #include "SDL_stdinc.h"
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
24 #include "SDL_atomic.h"
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
25
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
26 #include <atomic.h>
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
27
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
28 /*
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
29 This file provides 8, 16, 32, and 64 bit atomic operations. If the
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
30 operations are provided by the native hardware and operating system
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
31 they are used. If they are not then the operations are emulated
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
32 using the SDL mutex operations.
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
33 */
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
34
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
35 /*
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
36 First, detect whether the operations are supported and create
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
37 #defines that indicate that they do exist. The goal is to have all
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
38 the system dependent code in the top part of the file so that the
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
39 bottom can be use unchanged across all platforms.
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
40
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
41 Second, #define all the operations in each size class that are
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
42 supported. Doing this allows supported operations to be used along
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
43 side of emulated operations.
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
44 */
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
45
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
46 /*
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
47 Emmulated version.
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
48
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
49 Assume there is no support for atomic operations. All such
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
50 operations are implemented using SDL mutex operations.
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
51 */
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
52
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
53 #ifdef EMULATED_ATOMIC_OPERATIONS
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
54 #undef EMULATED_ATOMIC_OPERATIONS
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
55 #endif
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
56
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
57 #ifdef EMULATED_ATOMIC_OPERATIONS
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
58 #define HAVE_ALL_8_BIT_OPS
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
59
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
60 #define nativeExchange8(ptr, value) ()
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
61 #define nativeCompareThenSet8(ptr, oldvalue, newvalue) ()
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
62 #define nativeTestThenSet8(ptr) ()
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
63 #define nativeClear8(ptr) ()
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
64 #define nativeFetchThenIncrement8(ptr) ()
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
65 #define nativeFetchThenDecrement8(ptr) ()
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
66 #define nativeFetchThenAdd8(ptr, value) ()
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
67 #define nativeFetchThenSubtract8(ptr, value) ()
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
68 #define nativeIncrementThenFetch8(ptr) ()
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
69 #define nativeDecrementThenFetch8(ptr) ()
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
70 #define nativeAddThenFetch8(ptr, value) ()
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
71 #define nativeSubtractThenFetch8(ptr, value) ()
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
72 #endif
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
73
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
74 #ifdef EMULATED_ATOMIC_OPERATIONS
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
75 #define HAVE_ALL_16_BIT_OPS
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
76
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
77 #define nativeExchange16(ptr, value) ()
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
78 #define nativeCompareThenSet16(ptr, oldvalue, newvalue) ()
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
79 #define nativeTestThenSet16(ptr) ()
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
80 #define nativeClear16(ptr) ()
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
81 #define nativeFetchThenIncrement16(ptr) ()
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
82 #define nativeFetchThenDecrement16(ptr) ()
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
83 #define nativeFetchThenAdd16(ptr, value) ()
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
84 #define nativeFetchThenSubtract16(ptr, value) ()
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
85 #define nativeIncrementThenFetch16(ptr) ()
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
86 #define nativeDecrementThenFetch16(ptr) ()
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
87 #define nativeAddThenFetch16(ptr, value) ()
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
88 #define nativeSubtractThenFetch16(ptr, value) ()
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
89 #endif
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
90
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
91 #ifdef EMULATED_ATOMIC_OPERATIONS
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
92 #define HAVE_ALL_64_BIT_OPS
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
93
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
94 #define nativeExchange64(ptr, value) ()
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
95 #define nativeCompareThenSet64(ptr, oldvalue, newvalue) ()
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
96 #define nativeTestThenSet64(ptr) ()
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
97 #define nativeClear64(ptr) ()
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
98 #define nativeFetchThenIncrement64(ptr) ()
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
99 #define nativeFetchThenDecrement64(ptr) ()
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
100 #define nativeFetchThenAdd64(ptr, value) ()
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
101 #define nativeFetchThenSubtract64(ptr, value) ()
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
102 #define nativeIncrementThenFetch64(ptr) ()
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
103 #define nativeDecrementThenFetch64(ptr) ()
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
104 #define nativeAddThenFetch64(ptr, value) ()
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
105 #define nativeSubtractThenFetch64(ptr, value) ()
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
106 #endif
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
107
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
108 /*
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
109 If any of the operations are not provided then we must emulate some of
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
110 them.
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
111 */
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
112
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
113 #if !defined(HAVE_ALL_8_BIT_OPS) || !defined(HAVE_ALL_16_BIT_OPS) || !defined(HAVE_ALL_64_BIT_OPS)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
114
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
115 #include "SDL_mutex.h"
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
116 #include "SDL_error.h"
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
117
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
118 static SDL_mutex * lock = NULL;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
119
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
120 static __inline__ void
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
121 privateWaitLock()
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
122 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
123 if(NULL == lock)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
124 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
125 lock = SDL_CreateMutex();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
126 if (NULL == lock)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
127 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
128 SDL_SetError("SDL_atomic.c: can't create a mutex");
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
129 return;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
130 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
131 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
132
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
133 if (-1 == SDL_LockMutex(lock))
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
134 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
135 SDL_SetError("SDL_atomic.c: can't lock mutex");
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
136 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
137 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
138
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
139 static __inline__ void
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
140 privateUnlock()
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
141 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
142 if (-1 == SDL_UnlockMutex(lock))
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
143 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
144 SDL_SetError("SDL_atomic.c: can't unlock mutex");
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
145 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
146 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
147
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
148 #endif
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
149
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
150 /* 8 bit atomic operations */
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
151
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
152 Uint8
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
153 SDL_AtomicExchange8(volatile Uint8 * ptr, Uint8 value)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
154 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
155 #ifdef nativeExchange8
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
156 return nativeExchange8(ptr, value);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
157 #else
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
158 Uint8 tmp = 0;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
159
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
160 privateWaitLock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
161 tmp = *ptr;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
162 *ptr = value;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
163 privateUnlock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
164
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
165 return tmp;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
166 #endif
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
167 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
168
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
169 SDL_bool
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
170 SDL_AtomicCompareThenSet8(volatile Uint8 * ptr, Uint8 oldvalue, Uint8 newvalue)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
171 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
172 #ifdef nativeCompareThenSet8
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
173 return (SDL_bool)nativeCompareThenSet8(ptr, oldvalue, newvalue);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
174 #else
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
175 SDL_bool result = SDL_FALSE;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
176
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
177 privateWaitLock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
178 result = (*ptr == oldvalue);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
179 if (result)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
180 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
181 *ptr = newvalue;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
182 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
183 privateUnlock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
184
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
185 return result;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
186 #endif
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
187 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
188
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
189 SDL_bool
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
190 SDL_AtomicTestThenSet8(volatile Uint8 * ptr)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
191 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
192 #ifdef nativeTestThenSet8
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
193 return (SDL_bool)nativeTestThenSet8(ptr);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
194 #else
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
195 SDL_bool result = SDL_FALSE;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
196
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
197 privateWaitLock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
198 result = (*ptr == 0);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
199 if (result)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
200 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
201 *ptr = 1;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
202 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
203 privateUnlock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
204
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
205 return result;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
206 #endif
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
207 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
208
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
209 void
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
210 SDL_AtomicClear8(volatile Uint8 * ptr)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
211 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
212 #ifdef nativeClear8
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
213 nativeClear8(ptr);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
214 #else
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
215 privateWaitLock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
216 *ptr = 0;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
217 privateUnlock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
218
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
219 return;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
220 #endif
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
221 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
222
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
223 Uint8
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
224 SDL_AtomicFetchThenIncrement8(volatile Uint8 * ptr)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
225 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
226 #ifdef nativeFetchThenIncrement8
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
227 return nativeFetchThenIncrement8(ptr);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
228 #else
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
229 Uint8 tmp = 0;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
230
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
231 privateWaitLock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
232 tmp = *ptr;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
233 (*ptr)+= 1;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
234 privateUnlock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
235
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
236 return tmp;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
237 #endif
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
238 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
239
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
240 Uint8
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
241 SDL_AtomicFetchThenDecrement8(volatile Uint8 * ptr)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
242 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
243 #ifdef nativeFetchThenDecrement8
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
244 return nativeFetchThenDecrement8(ptr);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
245 #else
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
246 Uint8 tmp = 0;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
247
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
248 privateWaitLock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
249 tmp = *ptr;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
250 (*ptr) -= 1;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
251 privateUnlock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
252
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
253 return tmp;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
254 #endif
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
255 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
256
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
257 Uint8
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
258 SDL_AtomicFetchThenAdd8(volatile Uint8 * ptr, Uint8 value)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
259 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
260 #ifdef nativeFetchThenAdd8
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
261 return nativeFetchThenAdd8(ptr, value);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
262 #else
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
263 Uint8 tmp = 0;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
264
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
265 privateWaitLock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
266 tmp = *ptr;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
267 (*ptr)+= value;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
268 privateUnlock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
269
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
270 return tmp;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
271 #endif
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
272 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
273
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
274 Uint8
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
275 SDL_AtomicFetchThenSubtract8(volatile Uint8 * ptr, Uint8 value)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
276 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
277 #ifdef nativeFetchThenSubtract8
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
278 return nativeFetchThenSubtract8(ptr, value);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
279 #else
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
280 Uint8 tmp = 0;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
281
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
282 privateWaitLock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
283 tmp = *ptr;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
284 (*ptr)-= value;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
285 privateUnlock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
286
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
287 return tmp;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
288 #endif
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
289 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
290
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
291 Uint8
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
292 SDL_AtomicIncrementThenFetch8(volatile Uint8 * ptr)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
293 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
294 #ifdef nativeIncrementThenFetch8
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
295 return nativeIncrementThenFetch8(ptr);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
296 #else
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
297 Uint8 tmp = 0;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
298
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
299 privateWaitLock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
300 (*ptr)+= 1;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
301 tmp = *ptr;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
302 privateUnlock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
303
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
304 return tmp;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
305 #endif
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
306 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
307
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
308 Uint8
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
309 SDL_AtomicDecrementThenFetch8(volatile Uint8 * ptr)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
310 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
311 #ifdef nativeDecrementThenFetch8
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
312 return nativeDecrementThenFetch8(ptr);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
313 #else
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
314 Uint8 tmp = 0;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
315
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
316 privateWaitLock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
317 (*ptr)-= 1;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
318 tmp = *ptr;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
319 privateUnlock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
320
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
321 return tmp;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
322 #endif
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
323 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
324
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
325 Uint8
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
326 SDL_AtomicAddThenFetch8(volatile Uint8 * ptr, Uint8 value)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
327 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
328 #ifdef nativeAddThenFetch8
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
329 return nativeAddThenFetch8(ptr, value);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
330 #else
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
331 Uint8 tmp = 0;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
332
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
333 privateWaitLock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
334 (*ptr)+= value;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
335 tmp = *ptr;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
336 privateUnlock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
337
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
338 return tmp;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
339 #endif
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
340 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
341
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
342 Uint8
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
343 SDL_AtomicSubtractThenFetch8(volatile Uint8 * ptr, Uint8 value)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
344 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
345 #ifdef nativeSubtractThenFetch8
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
346 return nativeSubtractThenFetch8(ptr, value);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
347 #else
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
348 Uint8 tmp = 0;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
349
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
350 privateWaitLock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
351 (*ptr)-= value;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
352 tmp = *ptr;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
353 privateUnlock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
354
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
355 return tmp;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
356 #endif
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
357 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
358
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
359 /* 16 bit atomic operations */
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
360
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
361 Uint16
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
362 SDL_AtomicExchange16(volatile Uint16 * ptr, Uint16 value)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
363 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
364 #ifdef nativeExchange16
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
365 return nativeExchange16(ptr, value);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
366 #else
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
367 Uint16 tmp = 0;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
368
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
369 privateWaitLock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
370 tmp = *ptr;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
371 *ptr = value;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
372 privateUnlock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
373
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
374 return tmp;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
375 #endif
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
376 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
377
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
378 SDL_bool
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
379 SDL_AtomicCompareThenSet16(volatile Uint16 * ptr, Uint16 oldvalue, Uint16 newvalue)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
380 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
381 #ifdef nativeCompareThenSet16
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
382 return (SDL_bool)nativeCompareThenSet16(ptr, oldvalue, newvalue);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
383 #else
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
384 SDL_bool result = SDL_FALSE;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
385
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
386 privateWaitLock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
387 result = (*ptr == oldvalue);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
388 if (result)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
389 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
390 *ptr = newvalue;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
391 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
392 privateUnlock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
393
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
394 return result;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
395 #endif
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
396 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
397
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
398 SDL_bool
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
399 SDL_AtomicTestThenSet16(volatile Uint16 * ptr)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
400 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
401 #ifdef nativeTestThenSet16
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
402 return (SDL_bool)nativeTestThenSet16(ptr);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
403 #else
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
404 SDL_bool result = SDL_FALSE;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
405
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
406 privateWaitLock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
407 result = (*ptr == 0);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
408 if (result)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
409 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
410 *ptr = 1;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
411 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
412 privateUnlock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
413
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
414 return result;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
415 #endif
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
416 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
417
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
418 void
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
419 SDL_AtomicClear16(volatile Uint16 * ptr)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
420 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
421 #ifdef nativeClear16
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
422 nativeClear16(ptr);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
423 #else
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
424 privateWaitLock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
425 *ptr = 0;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
426 privateUnlock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
427
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
428 return;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
429 #endif
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
430 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
431
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
432 Uint16
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
433 SDL_AtomicFetchThenIncrement16(volatile Uint16 * ptr)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
434 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
435 #ifdef nativeFetchThenIncrement16
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
436 return nativeFetchThenIncrement16(ptr);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
437 #else
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
438 Uint16 tmp = 0;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
439
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
440 privateWaitLock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
441 tmp = *ptr;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
442 (*ptr)+= 1;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
443 privateUnlock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
444
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
445 return tmp;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
446 #endif
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
447 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
448
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
449 Uint16
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
450 SDL_AtomicFetchThenDecrement16(volatile Uint16 * ptr)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
451 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
452 #ifdef nativeFetchThenDecrement16
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
453 return nativeFetchThenDecrement16(ptr);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
454 #else
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
455 Uint16 tmp = 0;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
456
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
457 privateWaitLock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
458 tmp = *ptr;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
459 (*ptr) -= 1;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
460 privateUnlock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
461
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
462 return tmp;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
463 #endif
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
464 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
465
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
466 Uint16
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
467 SDL_AtomicFetchThenAdd16(volatile Uint16 * ptr, Uint16 value)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
468 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
469 #ifdef nativeFetchThenAdd16
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
470 return nativeFetchThenAdd16(ptr, value);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
471 #else
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
472 Uint16 tmp = 0;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
473
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
474 privateWaitLock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
475 tmp = *ptr;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
476 (*ptr)+= value;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
477 privateUnlock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
478
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
479 return tmp;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
480 #endif
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
481 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
482
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
483 Uint16
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
484 SDL_AtomicFetchThenSubtract16(volatile Uint16 * ptr, Uint16 value)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
485 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
486 #ifdef nativeFetchThenSubtract16
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
487 return nativeFetchThenSubtract16(ptr, value);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
488 #else
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
489 Uint16 tmp = 0;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
490
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
491 privateWaitLock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
492 tmp = *ptr;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
493 (*ptr)-= value;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
494 privateUnlock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
495
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
496 return tmp;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
497 #endif
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
498 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
499
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
500 Uint16
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
501 SDL_AtomicIncrementThenFetch16(volatile Uint16 * ptr)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
502 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
503 #ifdef nativeIncrementThenFetch16
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
504 return nativeIncrementThenFetch16(ptr);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
505 #else
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
506 Uint16 tmp = 0;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
507
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
508 privateWaitLock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
509 (*ptr)+= 1;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
510 tmp = *ptr;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
511 privateUnlock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
512
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
513 return tmp;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
514 #endif
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
515 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
516
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
517 Uint16
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
518 SDL_AtomicDecrementThenFetch16(volatile Uint16 * ptr)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
519 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
520 #ifdef nativeDecrementThenFetch16
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
521 return nativeDecrementThenFetch16(ptr);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
522 #else
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
523 Uint16 tmp = 0;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
524
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
525 privateWaitLock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
526 (*ptr)-= 1;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
527 tmp = *ptr;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
528 privateUnlock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
529
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
530 return tmp;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
531 #endif
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
532 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
533
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
534 Uint16
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
535 SDL_AtomicAddThenFetch16(volatile Uint16 * ptr, Uint16 value)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
536 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
537 #ifdef nativeAddThenFetch16
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
538 return nativeAddThenFetch16(ptr, value);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
539 #else
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
540 Uint16 tmp = 0;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
541
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
542 privateWaitLock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
543 (*ptr)+= value;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
544 tmp = *ptr;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
545 privateUnlock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
546
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
547 return tmp;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
548 #endif
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
549 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
550
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
551 Uint16
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
552 SDL_AtomicSubtractThenFetch16(volatile Uint16 * ptr, Uint16 value)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
553 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
554 #ifdef nativeSubtractThenFetch16
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
555 return nativeSubtractThenFetch16(ptr, value);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
556 #else
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
557 Uint16 tmp = 0;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
558
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
559 privateWaitLock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
560 (*ptr)-= value;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
561 tmp = *ptr;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
562 privateUnlock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
563
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
564 return tmp;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
565 #endif
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
566 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
567
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
568 /* 64 bit atomic operations */
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
569 #ifdef SDL_HAS_64BIT_TYPE
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
570
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
571 Uint64
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
572 SDL_AtomicExchange64(volatile Uint64 * ptr, Uint64 value)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
573 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
574 #ifdef nativeExchange64
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
575 return nativeExchange64(ptr, value);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
576 #else
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
577 Uint64 tmp = 0;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
578
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
579 privateWaitLock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
580 tmp = *ptr;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
581 *ptr = value;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
582 privateUnlock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
583
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
584 return tmp;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
585 #endif
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
586 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
587
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
588 SDL_bool
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
589 SDL_AtomicCompareThenSet64(volatile Uint64 * ptr, Uint64 oldvalue, Uint64 newvalue)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
590 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
591 #ifdef nativeCompareThenSet64
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
592 return (SDL_bool)nativeCompareThenSet64(ptr, oldvalue, newvalue);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
593 #else
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
594 SDL_bool result = SDL_FALSE;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
595
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
596 privateWaitLock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
597 result = (*ptr == oldvalue);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
598 if (result)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
599 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
600 *ptr = newvalue;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
601 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
602 privateUnlock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
603
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
604 return result;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
605 #endif
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
606 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
607
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
608 SDL_bool
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
609 SDL_AtomicTestThenSet64(volatile Uint64 * ptr)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
610 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
611 #ifdef nativeTestThenSet64
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
612 return (SDL_bool)nativeTestThenSet64(ptr);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
613 #else
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
614 SDL_bool result = SDL_FALSE;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
615
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
616 privateWaitLock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
617 result = (*ptr == 0);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
618 if (result)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
619 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
620 *ptr = 1;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
621 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
622 privateUnlock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
623
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
624 return result;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
625 #endif
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
626 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
627
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
628 void
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
629 SDL_AtomicClear64(volatile Uint64 * ptr)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
630 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
631 #ifdef nativeClear64
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
632 nativeClear64(ptr);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
633 #else
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
634 privateWaitLock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
635 *ptr = 0;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
636 privateUnlock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
637
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
638 return;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
639 #endif
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
640 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
641
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
642 Uint64
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
643 SDL_AtomicFetchThenIncrement64(volatile Uint64 * ptr)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
644 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
645 #ifdef nativeFetchThenIncrement64
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
646 return nativeFetchThenIncrement64(ptr);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
647 #else
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
648 Uint64 tmp = 0;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
649
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
650 privateWaitLock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
651 tmp = *ptr;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
652 (*ptr)+= 1;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
653 privateUnlock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
654
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
655 return tmp;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
656 #endif
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
657 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
658
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
659 Uint64
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
660 SDL_AtomicFetchThenDecrement64(volatile Uint64 * ptr)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
661 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
662 #ifdef nativeFetchThenDecrement64
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
663 return nativeFetchThenDecrement64(ptr);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
664 #else
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
665 Uint64 tmp = 0;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
666
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
667 privateWaitLock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
668 tmp = *ptr;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
669 (*ptr) -= 1;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
670 privateUnlock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
671
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
672 return tmp;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
673 #endif
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
674 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
675
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
676 Uint64
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
677 SDL_AtomicFetchThenAdd64(volatile Uint64 * ptr, Uint64 value)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
678 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
679 #ifdef nativeFetchThenAdd64
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
680 return nativeFetchThenAdd64(ptr, value);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
681 #else
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
682 Uint64 tmp = 0;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
683
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
684 privateWaitLock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
685 tmp = *ptr;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
686 (*ptr)+= value;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
687 privateUnlock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
688
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
689 return tmp;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
690 #endif
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
691 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
692
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
693 Uint64
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
694 SDL_AtomicFetchThenSubtract64(volatile Uint64 * ptr, Uint64 value)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
695 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
696 #ifdef nativeFetchThenSubtract64
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
697 return nativeFetchThenSubtract64(ptr, value);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
698 #else
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
699 Uint64 tmp = 0;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
700
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
701 privateWaitLock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
702 tmp = *ptr;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
703 (*ptr)-= value;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
704 privateUnlock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
705
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
706 return tmp;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
707 #endif
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
708 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
709
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
710 Uint64
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
711 SDL_AtomicIncrementThenFetch64(volatile Uint64 * ptr)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
712 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
713 #ifdef nativeIncrementThenFetch64
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
714 return nativeIncrementThenFetch64(ptr);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
715 #else
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
716 Uint64 tmp = 0;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
717
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
718 privateWaitLock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
719 (*ptr)+= 1;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
720 tmp = *ptr;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
721 privateUnlock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
722
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
723 return tmp;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
724 #endif
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
725 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
726
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
727 Uint64
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
728 SDL_AtomicDecrementThenFetch64(volatile Uint64 * ptr)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
729 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
730 #ifdef nativeDecrementThenFetch64
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
731 return nativeDecrementThenFetch64(ptr);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
732 #else
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
733 Uint64 tmp = 0;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
734
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
735 privateWaitLock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
736 (*ptr)-= 1;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
737 tmp = *ptr;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
738 privateUnlock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
739
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
740 return tmp;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
741 #endif
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
742 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
743
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
744 Uint64
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
745 SDL_AtomicAddThenFetch64(volatile Uint64 * ptr, Uint64 value)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
746 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
747 #ifdef nativeAddThenFetch64
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
748 return nativeAddThenFetch64(ptr, value);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
749 #else
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
750 Uint64 tmp = 0;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
751
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
752 privateWaitLock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
753 (*ptr)+= value;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
754 tmp = *ptr;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
755 privateUnlock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
756
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
757 return tmp;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
758 #endif
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
759 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
760
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
761 Uint64
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
762 SDL_AtomicSubtractThenFetch64(volatile Uint64 * ptr, Uint64 value)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
763 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
764 #ifdef nativeSubtractThenFetch64
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
765 return nativeSubtractThenFetch64(ptr, value);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
766 #else
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
767 Uint64 tmp = 0;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
768
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
769 privateWaitLock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
770 (*ptr)-= value;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
771 tmp = *ptr;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
772 privateUnlock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
773
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
774 return tmp;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
775 #endif
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
776 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
777 #endif
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
778
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
779 /* QNX native 32 bit atomic operations */
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
780
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
781 Uint32
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
782 SDL_AtomicExchange32(volatile Uint32 * ptr, Uint32 value)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
783 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
784 Uint32 tmp = 0;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
785
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
786 privateWaitLock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
787 tmp = *ptr;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
788 *ptr = value;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
789 privateUnlock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
790
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
791 return tmp;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
792 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
793
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
794 SDL_bool
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
795 SDL_AtomicCompareThenSet32(volatile Uint32 * ptr, Uint32 oldvalue, Uint32 newvalue)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
796 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
797 SDL_bool result = SDL_FALSE;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
798
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
799 privateWaitLock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
800 result = (*ptr == oldvalue);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
801 if (result)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
802 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
803 *ptr = newvalue;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
804 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
805 privateUnlock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
806
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
807 return result;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
808 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
809
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
810 SDL_bool
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
811 SDL_AtomicTestThenSet32(volatile Uint32 * ptr)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
812 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
813 SDL_bool result = SDL_FALSE;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
814
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
815 privateWaitLock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
816 result = (*ptr == 0);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
817 if (result)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
818 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
819 *ptr = 1;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
820 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
821 privateUnlock();
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
822
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
823 return result;
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
824 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
825
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
826 void
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
827 SDL_AtomicClear32(volatile Uint32 * ptr)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
828 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
829 atomic_clr(ptr, 0xFFFFFFFF);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
830 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
831
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
832 Uint32
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
833 SDL_AtomicFetchThenIncrement32(volatile Uint32 * ptr)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
834 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
835 return atomic_add_value(ptr, 0x00000001);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
836 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
837
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
838 Uint32
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
839 SDL_AtomicFetchThenDecrement32(volatile Uint32 * ptr)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
840 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
841 return atomic_sub_value(ptr, 0x00000001);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
842 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
843
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
844 Uint32
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
845 SDL_AtomicFetchThenAdd32(volatile Uint32 * ptr, Uint32 value)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
846 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
847 return atomic_add_value(ptr, value);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
848 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
849
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
850 Uint32
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
851 SDL_AtomicFetchThenSubtract32(volatile Uint32 * ptr, Uint32 value)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
852 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
853 return atomic_sub_value(ptr, value);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
854 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
855
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
856 Uint32
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
857 SDL_AtomicIncrementThenFetch32(volatile Uint32 * ptr)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
858 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
859 atomic_add(ptr, 0x00000001);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
860 return atomic_add_value(ptr, 0x00000000);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
861 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
862
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
863 Uint32
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
864 SDL_AtomicDecrementThenFetch32(volatile Uint32 * ptr)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
865 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
866 atomic_sub(ptr, 0x00000001);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
867 return atomic_sub_value(ptr, 0x00000000);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
868 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
869
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
870 Uint32
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
871 SDL_AtomicAddThenFetch32(volatile Uint32 * ptr, Uint32 value)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
872 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
873 atomic_add(ptr, value);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
874 return atomic_add_value(ptr, 0x00000000);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
875 }
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
876
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
877 Uint32
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
878 SDL_AtomicSubtractThenFetch32(volatile Uint32 * ptr, Uint32 value)
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
879 {
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
880 atomic_sub(ptr, value);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
881 return atomic_sub_value(ptr, 0x00000000);
26ce0b98f2fb Support for native and emulated atomic operations has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
882 }