Mercurial > sdl-ios-xcode
annotate src/atomic/linux/SDL_atomic.c @ 3201:c297230efc75
Disabling 64 bit atomics operations until I figure out why they do not link.
author | Bob Pendleton <bob@pendleton.com> |
---|---|
date | Wed, 24 Jun 2009 22:24:23 +0000 |
parents | ef2c029a3a9d |
children | 3aa519a5c676 |
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 #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
|
24 #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
|
25 #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
|
26 |
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 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
|
28 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
|
29 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
30 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
|
31 } |
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
|
32 |
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 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
|
34 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
|
35 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
36 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
|
37 } |
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
|
38 |
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 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
|
40 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
|
41 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
42 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
|
43 } |
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
|
44 |
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 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
|
46 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
|
47 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
48 __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
|
49 } |
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
|
50 |
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 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
|
52 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
|
53 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
54 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
|
55 } |
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
|
56 |
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 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
|
58 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
|
59 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
60 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
|
61 } |
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
|
62 |
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 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
|
64 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
|
65 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
66 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
|
67 } |
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
|
68 |
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 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
|
70 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
|
71 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
72 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
|
73 } |
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
|
74 |
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 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
|
76 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
|
77 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
78 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
|
79 } |
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
|
80 |
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 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
|
82 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
|
83 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
84 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
|
85 } |
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
|
86 |
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 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
|
88 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
|
89 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
90 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
|
91 } |
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
|
92 |
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 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
|
94 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
|
95 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
96 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
|
97 } |
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
|
98 |
3201
c297230efc75
Disabling 64 bit atomics operations until I figure out why they do not link.
Bob Pendleton <bob@pendleton.com>
parents:
3200
diff
changeset
|
99 /* #ifdef SDL_HAS_64BIT_TYPE */ |
c297230efc75
Disabling 64 bit atomics operations until I figure out why they do not link.
Bob Pendleton <bob@pendleton.com>
parents:
3200
diff
changeset
|
100 #if 0 |
3199
3e1bf2b8bd81
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
101 |
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 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
|
103 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
|
104 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
105 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
|
106 } |
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 SDL_bool |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
109 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
|
110 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
111 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
|
112 } |
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 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
|
115 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
|
116 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
117 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
|
118 } |
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 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
|
121 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
|
122 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
123 __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
|
124 } |
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 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
|
127 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
|
128 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
129 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
|
130 } |
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 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
|
133 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
|
134 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
135 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
|
136 } |
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 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
|
139 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
|
140 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
141 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
|
142 } |
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 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
|
145 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
|
146 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
147 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
|
148 } |
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 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
|
151 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
|
152 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
153 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
|
154 } |
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 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
|
157 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
|
158 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
159 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
|
160 } |
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 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
|
163 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
|
164 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
165 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
|
166 } |
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 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
|
169 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
|
170 { |
3200
ef2c029a3a9d
First draft of atomic operations code for GCC and linux.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
171 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
|
172 } |
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 #endif |