Mercurial > sdl-ios-xcode
annotate src/atomic/linux/SDL_atomic.c @ 3200:ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
author | Bob Pendleton <bob@pendleton.com> |
---|---|
date | Wed, 24 Jun 2009 20:20:57 +0000 |
parents | 3e1bf2b8bd81 |
children | c297230efc75 |
rev | line source |
---|---|
3199
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
1 /* |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
3 Copyright (C) 1997-2009 Sam Lantinga |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
4 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
9 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
13 Lesser General Public License for more details. |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
14 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
18 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
19 Sam Lantinga |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
20 slouken@libsdl.org |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
21 */ |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
22 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
23 #ifdef SDL_ATOMIC_LINUX |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
24 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
25 #include "SDL.h" |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
26 #include "SDL_config.h" |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
27 #include "SDL_atomic.h" |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
28 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
29 Uint32 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
30 SDL_AtomicExchange32(Uint32 * ptr, Uint32 value) |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
31 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
32 return __sync_lock_test_and_set(ptr, value); |
3199
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
33 } |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
34 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
35 SDL_bool |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
36 SDL_AtomicCompareThenSet32(Uint32 * ptr, Uint32 oldvalue, Uint32 newvalue) |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
37 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
38 return (SDL_bool)__sync_bool_compare_and_swap(ptr, oldvalue, newvalue); |
3199
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
39 } |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
40 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
41 SDL_bool |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
42 SDL_AtomicTestThenSet32(Uint32 * ptr) |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
43 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
44 return (SDL_bool)(0 == __sync_lock_test_and_set(ptr, 1)); |
3199
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
45 } |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
46 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
47 void |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
48 SDL_AtomicClear32(Uint32 * ptr) |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
49 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
50 __sync_lock_release(ptr); |
3199
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
51 } |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
52 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
53 Uint32 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
54 SDL_AtomicFetchThenIncrement32(Uint32 * ptr) |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
55 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
56 return __sync_fetch_and_add(ptr, 1); |
3199
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
57 } |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
58 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
59 Uint32 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
60 SDL_AtomicFetchThenDecrement32(Uint32 * ptr) |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
61 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
62 return __sync_fetch_and_sub(ptr, 1); |
3199
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
63 } |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
64 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
65 Uint32 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
66 SDL_AtomicFetchThenAdd32(Uint32 * ptr, Uint32 value) |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
67 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
68 return __sync_fetch_and_add(ptr, value); |
3199
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
69 } |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
70 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
71 Uint32 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
72 SDL_AtomicFetchThenSubtract32(Uint32 * ptr, Uint32 value) |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
73 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
74 return __sync_fetch_and_sub(ptr, value); |
3199
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
75 } |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
76 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
77 Uint32 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
78 SDL_AtomicIncrementThenFetch32(Uint32 * ptr) |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
79 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
80 return __sync_add_and_fetch(ptr, 1); |
3199
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
81 } |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
82 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
83 Uint32 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
84 SDL_AtomicDecrementThenFetch32(Uint32 * ptr) |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
85 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
86 return __sync_sub_and_fetch(ptr, 1); |
3199
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
87 } |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
88 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
89 Uint32 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
90 SDL_AtomicAddThenFetch32(Uint32 * ptr, Uint32 value) |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
91 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
92 return __sync_add_and_fetch(ptr, value); |
3199
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
93 } |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
94 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
95 Uint32 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
96 SDL_AtomicSubtractThenFetch32(Uint32 * ptr, Uint32 value) |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
97 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
98 return __sync_sub_and_fetch(ptr, value); |
3199
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
99 } |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
100 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
101 #ifdef SDL_HAS_64BIT_TYPE |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
102 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
103 Uint64 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
104 SDL_AtomicExchange64(Uint64 * ptr, Uint64 value) |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
105 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
106 return __sync_lock_test_and_set(ptr, value); |
3199
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
107 } |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
108 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
109 SDL_bool |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
110 SDL_AtomicCompareThenSet64(Uint64 * ptr, Uint64 oldvalue, Uint64 newvalue) |
3199
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
111 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
112 return (SDL_bool)__sync_bool_compare_and_swap(ptr, oldvalue, newvalue); |
3199
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
113 } |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
114 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
115 SDL_bool |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
116 SDL_AtomicTestThenSet64(Uint64 * ptr) |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
117 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
118 return (SDL_bool)(0 == __sync_lock_test_and_set(ptr, 1)); |
3199
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
119 } |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
120 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
121 void |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
122 SDL_AtomicClear64(Uint64 * ptr) |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
123 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
124 __sync_lock_release(ptr); |
3199
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
125 } |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
126 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
127 Uint64 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
128 SDL_AtomicFetchThenIncrement64(Uint64 * ptr) |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
129 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
130 return __sync_fetch_and_add(ptr, 1); |
3199
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
131 } |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
132 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
133 Uint64 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
134 SDL_AtomicFetchThenDecrement64(Uint64 * ptr) |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
135 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
136 return __sync_fetch_and_sub(ptr, 1); |
3199
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
137 } |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
138 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
139 Uint64 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
140 SDL_AtomicFetchThenAdd64(Uint64 * ptr, Uint64 value) |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
141 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
142 return __sync_fetch_and_add(ptr, value); |
3199
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
143 } |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
144 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
145 Uint64 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
146 SDL_AtomicFetchThenSubtract64(Uint64 * ptr, Uint64 value) |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
147 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
148 return __sync_fetch_and_sub(ptr, value); |
3199
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
149 } |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
150 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
151 Uint64 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
152 SDL_AtomicIncrementThenFetch64(Uint64 * ptr) |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
153 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
154 return __sync_add_and_fetch(ptr, 1); |
3199
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
155 } |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
156 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
157 Uint64 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
158 SDL_AtomicDecrementThenFetch64(Uint64 * ptr) |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
159 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
160 return __sync_sub_and_fetch(ptr, 1); |
3199
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
161 } |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
162 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
163 Uint64 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
164 SDL_AtomicAddThenFetch64(Uint64 * ptr, Uint64 value) |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
165 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
166 return __sync_add_and_fetch(ptr, value); |
3199
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
167 } |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
168 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
169 Uint64 |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
170 SDL_AtomicSubtractThenFetch64(Uint64 * ptr, Uint64 value) |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
171 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
172 return __sync_sub_and_fetch(ptr, value); |
3199
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
173 } |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
174 #endif |
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
175 #endif |