author | Philipp Wiesemann <philipp.wiesemann@arcor.de> |
Sat, 27 Jul 2013 14:06:06 +0200 | |
changeset 7532 | 2c54272792e2 |
parent 7191 | 75360622e65f |
child 7828 | 1451063c8ecd |
child 8477 | ad08f0d710f3 |
permissions | -rw-r--r-- |
5003
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 |
/* |
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5328
diff
changeset
|
2 |
Simple DirectMedia Layer |
6885 | 3 |
Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org> |
5003
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
|
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5328
diff
changeset
|
5 |
This software is provided 'as-is', without any express or implied |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5328
diff
changeset
|
6 |
warranty. In no event will the authors be held liable for any damages |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5328
diff
changeset
|
7 |
arising from the use of this software. |
5003
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 |
|
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5328
diff
changeset
|
9 |
Permission is granted to anyone to use this software for any purpose, |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5328
diff
changeset
|
10 |
including commercial applications, and to alter it and redistribute it |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5328
diff
changeset
|
11 |
freely, subject to the following restrictions: |
5003
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 |
|
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5328
diff
changeset
|
13 |
1. The origin of this software must not be misrepresented; you must not |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5328
diff
changeset
|
14 |
claim that you wrote the original software. If you use this software |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5328
diff
changeset
|
15 |
in a product, an acknowledgment in the product documentation would be |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5328
diff
changeset
|
16 |
appreciated but is not required. |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5328
diff
changeset
|
17 |
2. Altered source versions must be plainly marked as such, and must not be |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5328
diff
changeset
|
18 |
misrepresented as being the original software. |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5328
diff
changeset
|
19 |
3. This notice may not be removed or altered from any source distribution. |
5003
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 |
*/ |
6217
6952b11b7f46
Make sure that we use consistent configuration options on platforms like Windows so that command line builds and IDE builds have ABI compatibility.
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
21 |
#include "SDL_config.h" |
5003
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 |
|
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 |
#include "SDL_atomic.h" |
5225
5d01d426f2ea
It's now possible to disable the fast atomic operations, at a huge performance penalty.
Sam Lantinga <slouken@libsdl.org>
parents:
5097
diff
changeset
|
24 |
#include "SDL_mutex.h" |
5003
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 |
#include "SDL_timer.h" |
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 |
|
5073 | 27 |
/* Don't do the check for Visual Studio 2005, it's safe here */ |
5091
2164a79b5ca9
Only include windows.h on Windows. :)
Sam Lantinga <slouken@libsdl.org>
parents:
5090
diff
changeset
|
28 |
#ifdef __WIN32__ |
5090
327f181542f1
Include windows.h in a single point in the source, so we can be consistent about the definition of UNICODE and have core utility functions for Windows that all modules can share.
Sam Lantinga <slouken@libsdl.org>
parents:
5086
diff
changeset
|
29 |
#include "../core/windows/SDL_windows.h" |
5091
2164a79b5ca9
Only include windows.h on Windows. :)
Sam Lantinga <slouken@libsdl.org>
parents:
5090
diff
changeset
|
30 |
#endif |
5003
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 |
|
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 |
/* This function is where all the magic happens... */ |
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
33 |
SDL_bool |
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 |
SDL_AtomicTryLock(SDL_SpinLock *lock) |
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 |
{ |
5225
5d01d426f2ea
It's now possible to disable the fast atomic operations, at a huge performance penalty.
Sam Lantinga <slouken@libsdl.org>
parents:
5097
diff
changeset
|
36 |
#if SDL_ATOMIC_DISABLED |
5d01d426f2ea
It's now possible to disable the fast atomic operations, at a huge performance penalty.
Sam Lantinga <slouken@libsdl.org>
parents:
5097
diff
changeset
|
37 |
/* Terrible terrible damage */ |
5d01d426f2ea
It's now possible to disable the fast atomic operations, at a huge performance penalty.
Sam Lantinga <slouken@libsdl.org>
parents:
5097
diff
changeset
|
38 |
static SDL_mutex *_spinlock_mutex; |
5d01d426f2ea
It's now possible to disable the fast atomic operations, at a huge performance penalty.
Sam Lantinga <slouken@libsdl.org>
parents:
5097
diff
changeset
|
39 |
|
5d01d426f2ea
It's now possible to disable the fast atomic operations, at a huge performance penalty.
Sam Lantinga <slouken@libsdl.org>
parents:
5097
diff
changeset
|
40 |
if (!_spinlock_mutex) { |
5d01d426f2ea
It's now possible to disable the fast atomic operations, at a huge performance penalty.
Sam Lantinga <slouken@libsdl.org>
parents:
5097
diff
changeset
|
41 |
/* Race condition on first lock... */ |
5d01d426f2ea
It's now possible to disable the fast atomic operations, at a huge performance penalty.
Sam Lantinga <slouken@libsdl.org>
parents:
5097
diff
changeset
|
42 |
_spinlock_mutex = SDL_CreateMutex(); |
5d01d426f2ea
It's now possible to disable the fast atomic operations, at a huge performance penalty.
Sam Lantinga <slouken@libsdl.org>
parents:
5097
diff
changeset
|
43 |
} |
6977
b73d51026c68
Changed the name of SDL_mutexP() SDL_mutexV()
Sam Lantinga <slouken@libsdl.org>
parents:
6885
diff
changeset
|
44 |
SDL_LockMutex(_spinlock_mutex); |
5225
5d01d426f2ea
It's now possible to disable the fast atomic operations, at a huge performance penalty.
Sam Lantinga <slouken@libsdl.org>
parents:
5097
diff
changeset
|
45 |
if (*lock == 0) { |
5d01d426f2ea
It's now possible to disable the fast atomic operations, at a huge performance penalty.
Sam Lantinga <slouken@libsdl.org>
parents:
5097
diff
changeset
|
46 |
*lock = 1; |
6977
b73d51026c68
Changed the name of SDL_mutexP() SDL_mutexV()
Sam Lantinga <slouken@libsdl.org>
parents:
6885
diff
changeset
|
47 |
SDL_UnlockMutex(_spinlock_mutex); |
5225
5d01d426f2ea
It's now possible to disable the fast atomic operations, at a huge performance penalty.
Sam Lantinga <slouken@libsdl.org>
parents:
5097
diff
changeset
|
48 |
return SDL_TRUE; |
5d01d426f2ea
It's now possible to disable the fast atomic operations, at a huge performance penalty.
Sam Lantinga <slouken@libsdl.org>
parents:
5097
diff
changeset
|
49 |
} else { |
6977
b73d51026c68
Changed the name of SDL_mutexP() SDL_mutexV()
Sam Lantinga <slouken@libsdl.org>
parents:
6885
diff
changeset
|
50 |
SDL_UnlockMutex(_spinlock_mutex); |
5225
5d01d426f2ea
It's now possible to disable the fast atomic operations, at a huge performance penalty.
Sam Lantinga <slouken@libsdl.org>
parents:
5097
diff
changeset
|
51 |
return SDL_FALSE; |
5d01d426f2ea
It's now possible to disable the fast atomic operations, at a huge performance penalty.
Sam Lantinga <slouken@libsdl.org>
parents:
5097
diff
changeset
|
52 |
} |
5d01d426f2ea
It's now possible to disable the fast atomic operations, at a huge performance penalty.
Sam Lantinga <slouken@libsdl.org>
parents:
5097
diff
changeset
|
53 |
|
5d01d426f2ea
It's now possible to disable the fast atomic operations, at a huge performance penalty.
Sam Lantinga <slouken@libsdl.org>
parents:
5097
diff
changeset
|
54 |
#elif defined(_MSC_VER) |
5015
1bf9e38431ec
Use compiler intrinsics on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
5004
diff
changeset
|
55 |
SDL_COMPILE_TIME_ASSERT(locksize, sizeof(*lock) == sizeof(long)); |
5090
327f181542f1
Include windows.h in a single point in the source, so we can be consistent about the definition of UNICODE and have core utility functions for Windows that all modules can share.
Sam Lantinga <slouken@libsdl.org>
parents:
5086
diff
changeset
|
56 |
return (InterlockedExchange((long*)lock, 1) == 0); |
5003
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 |
|
5095
dceec93471e7
Improvements based on feedback from Anthony Williams
Sam Lantinga <slouken@libsdl.org>
parents:
5091
diff
changeset
|
58 |
#elif HAVE_GCC_ATOMICS || HAVE_GCC_SYNC_LOCK_TEST_AND_SET |
5004
0c72ae7b7cb2
Added native atomic operations for Windows, Mac OS X, and gcc compiler intrinsics.
Sam Lantinga <slouken@libsdl.org>
parents:
5003
diff
changeset
|
59 |
return (__sync_lock_test_and_set(lock, 1) == 0); |
0c72ae7b7cb2
Added native atomic operations for Windows, Mac OS X, and gcc compiler intrinsics.
Sam Lantinga <slouken@libsdl.org>
parents:
5003
diff
changeset
|
60 |
|
5328
f34a5f9ce9f6
Fixed bug 1122 (spinlock fails to compile with -march=armv4t)
Sam Lantinga <slouken@libsdl.org>
parents:
5289
diff
changeset
|
61 |
#elif defined(__GNUC__) && defined(__arm__) && \ |
f34a5f9ce9f6
Fixed bug 1122 (spinlock fails to compile with -march=armv4t)
Sam Lantinga <slouken@libsdl.org>
parents:
5289
diff
changeset
|
62 |
(defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__) || \ |
5999
0e3fd8178e1d
Check for __ARM_ARCH_5TEJ__ in spinlock atomics.
Ryan C. Gordon <icculus@icculus.org>
parents:
5998
diff
changeset
|
63 |
defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5TE__) || \ |
0e3fd8178e1d
Check for __ARM_ARCH_5TEJ__ in spinlock atomics.
Ryan C. Gordon <icculus@icculus.org>
parents:
5998
diff
changeset
|
64 |
defined(__ARM_ARCH_5TEJ__)) |
5003
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
65 |
int result; |
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
66 |
__asm__ __volatile__ ( |
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
67 |
"swp %0, %1, [%2]\n" |
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
68 |
: "=&r,&r" (result) : "r,0" (1), "r,r" (lock) : "memory"); |
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
69 |
return (result == 0); |
5004
0c72ae7b7cb2
Added native atomic operations for Windows, Mac OS X, and gcc compiler intrinsics.
Sam Lantinga <slouken@libsdl.org>
parents:
5003
diff
changeset
|
70 |
|
5097
b938ad843e52
More fixes for compilation on Visual Studio
Sam Lantinga <slouken@libsdl.org>
parents:
5095
diff
changeset
|
71 |
#elif defined(__GNUC__) && defined(__arm__) |
5003
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
72 |
int result; |
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
73 |
__asm__ __volatile__ ( |
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
74 |
"ldrex %0, [%2]\nteq %0, #0\nstrexeq %0, %1, [%2]" |
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
75 |
: "=&r" (result) : "r" (1), "r" (lock) : "cc", "memory"); |
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
76 |
return (result == 0); |
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
77 |
|
5957
9a2b091abb2c
Implemented x86 and x86-64 spinlock inline asm.
Ryan C. Gordon <icculus@icculus.org>
parents:
5956
diff
changeset
|
78 |
#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) |
7191
75360622e65f
File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents:
6977
diff
changeset
|
79 |
int result; |
75360622e65f
File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents:
6977
diff
changeset
|
80 |
__asm__ __volatile__( |
5957
9a2b091abb2c
Implemented x86 and x86-64 spinlock inline asm.
Ryan C. Gordon <icculus@icculus.org>
parents:
5956
diff
changeset
|
81 |
"lock ; xchgl %0, (%1)\n" |
9a2b091abb2c
Implemented x86 and x86-64 spinlock inline asm.
Ryan C. Gordon <icculus@icculus.org>
parents:
5956
diff
changeset
|
82 |
: "=r" (result) : "r" (lock), "0" (1) : "cc", "memory"); |
7191
75360622e65f
File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents:
6977
diff
changeset
|
83 |
return (result == 0); |
5957
9a2b091abb2c
Implemented x86 and x86-64 spinlock inline asm.
Ryan C. Gordon <icculus@icculus.org>
parents:
5956
diff
changeset
|
84 |
|
5998
e9b9ef14aef4
Let iOS use OSAtomicCompareAndSwap32Barrier() if nothing else is available.
Ryan C. Gordon <icculus@icculus.org>
parents:
5957
diff
changeset
|
85 |
#elif defined(__MACOSX__) || defined(__IPHONEOS__) |
5957
9a2b091abb2c
Implemented x86 and x86-64 spinlock inline asm.
Ryan C. Gordon <icculus@icculus.org>
parents:
5956
diff
changeset
|
86 |
/* Maybe used for PowerPC, but the Intel asm or gcc atomics are favored. */ |
9a2b091abb2c
Implemented x86 and x86-64 spinlock inline asm.
Ryan C. Gordon <icculus@icculus.org>
parents:
5956
diff
changeset
|
87 |
return OSAtomicCompareAndSwap32Barrier(0, 1, lock); |
9a2b091abb2c
Implemented x86 and x86-64 spinlock inline asm.
Ryan C. Gordon <icculus@icculus.org>
parents:
5956
diff
changeset
|
88 |
|
5557
c1ed57cbfd66
Implemented pthread spinlocks.
Nathan Heisey <nathanheisey@gmail.com>
parents:
5535
diff
changeset
|
89 |
#elif HAVE_PTHREAD_SPINLOCK |
c1ed57cbfd66
Implemented pthread spinlocks.
Nathan Heisey <nathanheisey@gmail.com>
parents:
5535
diff
changeset
|
90 |
/* pthread instructions */ |
c1ed57cbfd66
Implemented pthread spinlocks.
Nathan Heisey <nathanheisey@gmail.com>
parents:
5535
diff
changeset
|
91 |
return (pthread_spin_trylock(lock) == 0); |
5957
9a2b091abb2c
Implemented x86 and x86-64 spinlock inline asm.
Ryan C. Gordon <icculus@icculus.org>
parents:
5956
diff
changeset
|
92 |
|
9a2b091abb2c
Implemented x86 and x86-64 spinlock inline asm.
Ryan C. Gordon <icculus@icculus.org>
parents:
5956
diff
changeset
|
93 |
#else |
5956
c7aebf1841ca
Use an actual #error instead of a bogus symbol if there's no spinlock support.
Ryan C. Gordon <icculus@icculus.org>
parents:
5557
diff
changeset
|
94 |
#error Please implement for your platform. |
c7aebf1841ca
Use an actual #error instead of a bogus symbol if there's no spinlock support.
Ryan C. Gordon <icculus@icculus.org>
parents:
5557
diff
changeset
|
95 |
return SDL_FALSE; |
5003
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
96 |
#endif |
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
97 |
} |
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 |
|
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
99 |
void |
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
100 |
SDL_AtomicLock(SDL_SpinLock *lock) |
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
101 |
{ |
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
102 |
/* FIXME: Should we have an eventual timeout? */ |
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
103 |
while (!SDL_AtomicTryLock(lock)) { |
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
104 |
SDL_Delay(0); |
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
105 |
} |
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
106 |
} |
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
107 |
|
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
108 |
void |
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
109 |
SDL_AtomicUnlock(SDL_SpinLock *lock) |
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
110 |
{ |
5095
dceec93471e7
Improvements based on feedback from Anthony Williams
Sam Lantinga <slouken@libsdl.org>
parents:
5091
diff
changeset
|
111 |
#if defined(_MSC_VER) |
dceec93471e7
Improvements based on feedback from Anthony Williams
Sam Lantinga <slouken@libsdl.org>
parents:
5091
diff
changeset
|
112 |
_ReadWriteBarrier(); |
5003
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
113 |
*lock = 0; |
5095
dceec93471e7
Improvements based on feedback from Anthony Williams
Sam Lantinga <slouken@libsdl.org>
parents:
5091
diff
changeset
|
114 |
|
dceec93471e7
Improvements based on feedback from Anthony Williams
Sam Lantinga <slouken@libsdl.org>
parents:
5091
diff
changeset
|
115 |
#elif HAVE_GCC_ATOMICS || HAVE_GCC_SYNC_LOCK_TEST_AND_SET |
dceec93471e7
Improvements based on feedback from Anthony Williams
Sam Lantinga <slouken@libsdl.org>
parents:
5091
diff
changeset
|
116 |
__sync_lock_release(lock); |
7191
75360622e65f
File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents:
6977
diff
changeset
|
117 |
|
5557
c1ed57cbfd66
Implemented pthread spinlocks.
Nathan Heisey <nathanheisey@gmail.com>
parents:
5535
diff
changeset
|
118 |
#elif HAVE_PTHREAD_SPINLOCK |
c1ed57cbfd66
Implemented pthread spinlocks.
Nathan Heisey <nathanheisey@gmail.com>
parents:
5535
diff
changeset
|
119 |
pthread_spin_unlock(lock); |
7191
75360622e65f
File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents:
6977
diff
changeset
|
120 |
|
5095
dceec93471e7
Improvements based on feedback from Anthony Williams
Sam Lantinga <slouken@libsdl.org>
parents:
5091
diff
changeset
|
121 |
#else |
dceec93471e7
Improvements based on feedback from Anthony Williams
Sam Lantinga <slouken@libsdl.org>
parents:
5091
diff
changeset
|
122 |
*lock = 0; |
dceec93471e7
Improvements based on feedback from Anthony Williams
Sam Lantinga <slouken@libsdl.org>
parents:
5091
diff
changeset
|
123 |
#endif |
5003
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
124 |
} |
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
125 |
|
3a95a2b93eb3
Updated the atomic API for better use cases
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
126 |
/* vi: set ts=4 sw=4 expandtab: */ |