author | Sam Lantinga <slouken@libsdl.org> |
Mon, 19 Oct 2009 13:31:58 +0000 | |
changeset 3407 | d3baf5ac4e37 |
parent 3261 | 72b542f34739 |
child 3697 | f7b03b6838cb |
permissions | -rw-r--r-- |
3180
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
1 |
/* |
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
2 |
SDL - Simple DirectMedia Layer |
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
3 |
Copyright (C) 1997-2006 Sam Lantinga |
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
4 |
|
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
5 |
This library is free software; you can redistribute it and/or |
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
6 |
modify it under the terms of the GNU Lesser General Public |
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
7 |
License as published by the Free Software Foundation; either |
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
8 |
version 2.1 of the License, or (at your option) any later version. |
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
9 |
|
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
10 |
This library is distributed in the hope that it will be useful, |
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
13 |
Lesser General Public License for more details. |
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
14 |
|
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
15 |
You should have received a copy of the GNU Lesser General Public |
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
16 |
License along with this library; if not, write to the Free Software |
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
17 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
18 |
|
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
19 |
Sam Lantinga |
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
20 |
slouken@libsdl.org |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3237
diff
changeset
|
21 |
|
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3237
diff
changeset
|
22 |
Contributed by Bob Pendleton, bob@pendleton.com |
3180
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
23 |
*/ |
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
24 |
|
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
25 |
/** |
3407
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
26 |
* \file SDL_atomic.h |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
27 |
* |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
28 |
* Atomic operations. |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
29 |
* |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
30 |
* These operations may, or may not, actually be implemented using |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
31 |
* processor specific atomic operations. When possible they are |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
32 |
* implemented as true processor specific atomic operations. When that |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
33 |
* is not possible the are implemented using locks that *do* use the |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
34 |
* available atomic operations. |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
35 |
* |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
36 |
* At the very minimum spin locks must be implemented. Without spin |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
37 |
* locks it is not possible (AFAICT) to emulate the rest of the atomic |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
38 |
* operations. |
3180
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
39 |
*/ |
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
40 |
|
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
41 |
#ifndef _SDL_atomic_h_ |
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
42 |
#define _SDL_atomic_h_ |
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
43 |
|
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
44 |
#include "SDL_stdinc.h" |
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
45 |
#include "SDL_platform.h" |
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
46 |
|
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
47 |
#include "begin_code.h" |
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
48 |
|
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
49 |
/* Set up for C function definitions, even when using C++ */ |
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
50 |
#ifdef __cplusplus |
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
51 |
/* *INDENT-OFF* */ |
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
52 |
extern "C" { |
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
53 |
/* *INDENT-ON* */ |
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
54 |
#endif |
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
55 |
|
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:
3187
diff
changeset
|
56 |
/* Function prototypes */ |
3180
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
57 |
|
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3237
diff
changeset
|
58 |
/** |
3407
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
59 |
* \name SDL AtomicLock |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
60 |
* |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
61 |
* The spin lock functions and type are required and can not be |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
62 |
* emulated because they are used in the emulation code. |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3237
diff
changeset
|
63 |
*/ |
3407
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
64 |
/*@{*/ |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3237
diff
changeset
|
65 |
|
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3237
diff
changeset
|
66 |
typedef volatile Uint32 SDL_SpinLock; |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3237
diff
changeset
|
67 |
|
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3237
diff
changeset
|
68 |
/** |
3407
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
69 |
* \brief Lock a spin lock by setting it to a none zero value. |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
70 |
* |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
71 |
* \param lock Points to the lock. |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3237
diff
changeset
|
72 |
*/ |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3237
diff
changeset
|
73 |
extern DECLSPEC void SDLCALL SDL_AtomicLock(SDL_SpinLock *lock); |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3237
diff
changeset
|
74 |
|
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3237
diff
changeset
|
75 |
/** |
3407
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
76 |
* \brief Unlock a spin lock by setting it to 0. Always returns immediately |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3237
diff
changeset
|
77 |
* |
3407
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
78 |
* \param lock Points to the lock. |
3261
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3237
diff
changeset
|
79 |
*/ |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3237
diff
changeset
|
80 |
extern DECLSPEC void SDLCALL SDL_AtomicUnlock(SDL_SpinLock *lock); |
72b542f34739
The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops.
Bob Pendleton <bob@pendleton.com>
parents:
3237
diff
changeset
|
81 |
|
3407
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
82 |
/*@}*//*SDL AtomicLock*/ |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
83 |
|
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:
3187
diff
changeset
|
84 |
/** |
3407
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
85 |
* \name 32 bit atomic operations |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
86 |
*/ |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
87 |
/*@{*/ |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
88 |
|
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
89 |
/** |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
90 |
* \brief Check to see if \c *ptr == 0 and set it to 1. |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
91 |
* |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
92 |
* \return SDL_True if the value pointed to by \c ptr was zero and |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
93 |
* SDL_False if it was not zero |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
94 |
* |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
95 |
* \param ptr Points to the value to be tested and set. |
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:
3187
diff
changeset
|
96 |
*/ |
3216
48a80f2a7ff2
volitile... duh, yeah the variable need to be labeled volitile
Bob Pendleton <bob@pendleton.com>
parents:
3202
diff
changeset
|
97 |
extern DECLSPEC SDL_bool SDLCALL SDL_AtomicTestThenSet32(volatile Uint32 * ptr); |
3237
916f396fe65d
Start of redesign, getting rid of 8 and 16 bit operations in .h and test files.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
98 |
|
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:
3187
diff
changeset
|
99 |
/** |
3407
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
100 |
* \brief Set the value pointed to by \c ptr to be zero. |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
101 |
* |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
102 |
* \param ptr Address of the value to be set to zero |
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:
3187
diff
changeset
|
103 |
*/ |
3216
48a80f2a7ff2
volitile... duh, yeah the variable need to be labeled volitile
Bob Pendleton <bob@pendleton.com>
parents:
3202
diff
changeset
|
104 |
extern DECLSPEC void SDLCALL SDL_AtomicClear32(volatile Uint32 * ptr); |
3237
916f396fe65d
Start of redesign, getting rid of 8 and 16 bit operations in .h and test files.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
105 |
|
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:
3187
diff
changeset
|
106 |
/** |
3407
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
107 |
* \brief Fetch the current value of \c *ptr and then increment that |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
108 |
* value in place. |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
109 |
* |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
110 |
* \return The value before it was incremented. |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
111 |
* |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
112 |
* \param ptr Address of the value to fetch and increment |
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:
3187
diff
changeset
|
113 |
*/ |
3216
48a80f2a7ff2
volitile... duh, yeah the variable need to be labeled volitile
Bob Pendleton <bob@pendleton.com>
parents:
3202
diff
changeset
|
114 |
extern DECLSPEC Uint32 SDLCALL SDL_AtomicFetchThenIncrement32(volatile Uint32 * ptr); |
3237
916f396fe65d
Start of redesign, getting rid of 8 and 16 bit operations in .h and test files.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
115 |
|
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:
3187
diff
changeset
|
116 |
/** |
3407
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
117 |
* \brief Fetch \c *ptr and then decrement the value in place. |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
118 |
* |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
119 |
* \return The value before it was decremented. |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
120 |
* |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
121 |
* \param ptr Address of the value to fetch and drement |
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:
3187
diff
changeset
|
122 |
*/ |
3216
48a80f2a7ff2
volitile... duh, yeah the variable need to be labeled volitile
Bob Pendleton <bob@pendleton.com>
parents:
3202
diff
changeset
|
123 |
extern DECLSPEC Uint32 SDLCALL SDL_AtomicFetchThenDecrement32(volatile Uint32 * ptr); |
3237
916f396fe65d
Start of redesign, getting rid of 8 and 16 bit operations in .h and test files.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
124 |
|
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:
3187
diff
changeset
|
125 |
/** |
3407
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
126 |
* \brief Fetch the current value at \c ptr and then add \c value to \c *ptr. |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
127 |
* |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
128 |
* \return \c *ptr before the addition took place. |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
129 |
* |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
130 |
* \param ptr The address of data we are changing. |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
131 |
* \param value The value to add to \c *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:
3187
diff
changeset
|
132 |
*/ |
3216
48a80f2a7ff2
volitile... duh, yeah the variable need to be labeled volitile
Bob Pendleton <bob@pendleton.com>
parents:
3202
diff
changeset
|
133 |
extern DECLSPEC Uint32 SDLCALL SDL_AtomicFetchThenAdd32(volatile Uint32 * ptr, Uint32 value); |
3237
916f396fe65d
Start of redesign, getting rid of 8 and 16 bit operations in .h and test files.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
134 |
|
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:
3187
diff
changeset
|
135 |
/** |
3407
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
136 |
* \brief Fetch \c *ptr and then subtract \c value from it. |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
137 |
* |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
138 |
* \return \c *ptr before the subtraction took place. |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
139 |
* |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
140 |
* \param ptr The address of the data being changed. |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
141 |
* \param value The value to subtract from \c *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:
3187
diff
changeset
|
142 |
*/ |
3216
48a80f2a7ff2
volitile... duh, yeah the variable need to be labeled volitile
Bob Pendleton <bob@pendleton.com>
parents:
3202
diff
changeset
|
143 |
extern DECLSPEC Uint32 SDLCALL SDL_AtomicFetchThenSubtract32(volatile Uint32 * ptr, Uint32 value); |
3237
916f396fe65d
Start of redesign, getting rid of 8 and 16 bit operations in .h and test files.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
144 |
|
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:
3187
diff
changeset
|
145 |
/** |
3407
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
146 |
* \brief Add one to the data pointed to by \c ptr and return that value. |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
147 |
* |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
148 |
* \return The incremented value. |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
149 |
* |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
150 |
* \param ptr The address of the data to increment. |
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:
3187
diff
changeset
|
151 |
*/ |
3216
48a80f2a7ff2
volitile... duh, yeah the variable need to be labeled volitile
Bob Pendleton <bob@pendleton.com>
parents:
3202
diff
changeset
|
152 |
extern DECLSPEC Uint32 SDLCALL SDL_AtomicIncrementThenFetch32(volatile Uint32 * ptr); |
3237
916f396fe65d
Start of redesign, getting rid of 8 and 16 bit operations in .h and test files.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
153 |
|
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:
3187
diff
changeset
|
154 |
/** |
3407
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
155 |
* \brief Subtract one from data pointed to by \c ptr and return the new value. |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
156 |
* |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
157 |
* \return The decremented value. |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
158 |
* |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
159 |
* \param ptr The address of the data to decrement. |
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:
3187
diff
changeset
|
160 |
*/ |
3216
48a80f2a7ff2
volitile... duh, yeah the variable need to be labeled volitile
Bob Pendleton <bob@pendleton.com>
parents:
3202
diff
changeset
|
161 |
extern DECLSPEC Uint32 SDLCALL SDL_AtomicDecrementThenFetch32(volatile Uint32 * ptr); |
3237
916f396fe65d
Start of redesign, getting rid of 8 and 16 bit operations in .h and test files.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
162 |
|
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:
3187
diff
changeset
|
163 |
/** |
3407
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
164 |
* \brief Add \c value to the data pointed to by \c ptr and return result. |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
165 |
* |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
166 |
* \return The sum of \c *ptr and \c value. |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
167 |
* |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
168 |
* \param ptr The address of the data to be modified. |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
169 |
* \param value The value to be added. |
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:
3187
diff
changeset
|
170 |
*/ |
3216
48a80f2a7ff2
volitile... duh, yeah the variable need to be labeled volitile
Bob Pendleton <bob@pendleton.com>
parents:
3202
diff
changeset
|
171 |
extern DECLSPEC Uint32 SDLCALL SDL_AtomicAddThenFetch32(volatile Uint32 * ptr, Uint32 value); |
3237
916f396fe65d
Start of redesign, getting rid of 8 and 16 bit operations in .h and test files.
Bob Pendleton <bob@pendleton.com>
parents:
3216
diff
changeset
|
172 |
|
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:
3187
diff
changeset
|
173 |
/** |
3407
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
174 |
* \brief Subtract \c value from the data pointed to by \c ptr and return the result. |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
175 |
* |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
176 |
* \return The difference between \c *ptr and \c value. |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
177 |
* |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
178 |
* \param ptr The address of the data to be modified. |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
179 |
* \param value The value to be subtracted. |
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:
3187
diff
changeset
|
180 |
*/ |
3216
48a80f2a7ff2
volitile... duh, yeah the variable need to be labeled volitile
Bob Pendleton <bob@pendleton.com>
parents:
3202
diff
changeset
|
181 |
extern DECLSPEC Uint32 SDLCALL SDL_AtomicSubtractThenFetch32(volatile Uint32 * ptr, Uint32 value); |
3180
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
182 |
|
3407
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
183 |
/*@}*//*32 bit atomic operations*/ |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
184 |
|
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
185 |
/** |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
186 |
* \name 64 bit atomic operations |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
187 |
*/ |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
188 |
/*@{*/ |
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:
3187
diff
changeset
|
189 |
#ifdef SDL_HAS_64BIT_TYPE |
3180
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
190 |
|
3216
48a80f2a7ff2
volitile... duh, yeah the variable need to be labeled volitile
Bob Pendleton <bob@pendleton.com>
parents:
3202
diff
changeset
|
191 |
extern DECLSPEC SDL_bool SDLCALL SDL_AtomicTestThenSet64(volatile Uint64 * ptr); |
48a80f2a7ff2
volitile... duh, yeah the variable need to be labeled volitile
Bob Pendleton <bob@pendleton.com>
parents:
3202
diff
changeset
|
192 |
extern DECLSPEC void SDLCALL SDL_AtomicClear64(volatile Uint64 * ptr); |
48a80f2a7ff2
volitile... duh, yeah the variable need to be labeled volitile
Bob Pendleton <bob@pendleton.com>
parents:
3202
diff
changeset
|
193 |
extern DECLSPEC Uint64 SDLCALL SDL_AtomicFetchThenIncrement64(volatile Uint64 * ptr); |
48a80f2a7ff2
volitile... duh, yeah the variable need to be labeled volitile
Bob Pendleton <bob@pendleton.com>
parents:
3202
diff
changeset
|
194 |
extern DECLSPEC Uint64 SDLCALL SDL_AtomicFetchThenDecrement64(volatile Uint64 * ptr); |
48a80f2a7ff2
volitile... duh, yeah the variable need to be labeled volitile
Bob Pendleton <bob@pendleton.com>
parents:
3202
diff
changeset
|
195 |
extern DECLSPEC Uint64 SDLCALL SDL_AtomicFetchThenAdd64(volatile Uint64 * ptr, Uint64 value); |
48a80f2a7ff2
volitile... duh, yeah the variable need to be labeled volitile
Bob Pendleton <bob@pendleton.com>
parents:
3202
diff
changeset
|
196 |
extern DECLSPEC Uint64 SDLCALL SDL_AtomicFetchThenSubtract64(volatile Uint64 * ptr, Uint64 value); |
48a80f2a7ff2
volitile... duh, yeah the variable need to be labeled volitile
Bob Pendleton <bob@pendleton.com>
parents:
3202
diff
changeset
|
197 |
extern DECLSPEC Uint64 SDLCALL SDL_AtomicIncrementThenFetch64(volatile Uint64 * ptr); |
48a80f2a7ff2
volitile... duh, yeah the variable need to be labeled volitile
Bob Pendleton <bob@pendleton.com>
parents:
3202
diff
changeset
|
198 |
extern DECLSPEC Uint64 SDLCALL SDL_AtomicDecrementThenFetch64(volatile Uint64 * ptr); |
48a80f2a7ff2
volitile... duh, yeah the variable need to be labeled volitile
Bob Pendleton <bob@pendleton.com>
parents:
3202
diff
changeset
|
199 |
extern DECLSPEC Uint64 SDLCALL SDL_AtomicAddThenFetch64(volatile Uint64 * ptr, Uint64 value); |
48a80f2a7ff2
volitile... duh, yeah the variable need to be labeled volitile
Bob Pendleton <bob@pendleton.com>
parents:
3202
diff
changeset
|
200 |
extern DECLSPEC Uint64 SDLCALL SDL_AtomicSubtractThenFetch64(volatile Uint64 * ptr, Uint64 value); |
3202
3aa519a5c676
I've made so many changes I don't dare continue until I check the current stuff in.
Bob Pendleton <bob@pendleton.com>
parents:
3199
diff
changeset
|
201 |
#endif /* SDL_HAS_64BIT_TYPE */ |
3180
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
202 |
|
3407
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
203 |
/*@}*//*64 bit atomic operations*/ |
d3baf5ac4e37
Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents:
3261
diff
changeset
|
204 |
|
3180
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
205 |
/* Ends C function definitions when using C++ */ |
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
206 |
#ifdef __cplusplus |
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
207 |
/* *INDENT-OFF* */ |
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
208 |
} |
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
209 |
/* *INDENT-ON* */ |
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
210 |
#endif |
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
211 |
|
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
212 |
#include "close_code.h" |
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
213 |
|
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
214 |
#endif /* _SDL_atomic_h_ */ |
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
215 |
|
77d6336711fc
First commit for SDL atomic operations.
Bob Pendleton <bob@pendleton.com>
parents:
diff
changeset
|
216 |
/* vi: set ts=4 sw=4 expandtab: */ |