2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2007 Starbreeze Studios
5 This software is provided 'as-is', without any express or implied warranty.
6 In no event will the authors be held liable for any damages arising from the use of this software.
7 Permission is granted to anyone to use this software for any purpose,
8 including commercial applications, and to alter it and redistribute it freely,
9 subject to the following restrictions:
11 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
12 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
13 3. This notice may not be removed or altered from any source distribution.
15 Written by: Marten Svanfeldt
22 #include "PlatformDefinitions.h"
27 #define WIN32_LEAN_AND_MEAN
34 ///The btSpinlock is a structure to allow multi-platform synchronization. This allows to port the SPU tasks to other platforms.
38 //typedef volatile LONG SpinVariable;
39 typedef CRITICAL_SECTION SpinVariable
;
41 btSpinlock (SpinVariable
* var
)
48 InitializeCriticalSection(spinVariable
);
53 EnterCriticalSection(spinVariable
);
58 LeaveCriticalSection(spinVariable
);
62 SpinVariable
* spinVariable
;
66 #elif defined (__CELLOS_LV2__)
68 //#include <cell/atomic.h>
69 #include <cell/sync/mutex.h>
71 ///The btSpinlock is a structure to allow multi-platform synchronization. This allows to port the SPU tasks to other platforms.
75 typedef CellSyncMutex SpinVariable
;
77 btSpinlock (SpinVariable
* var
)
85 cellSyncMutexInitialize(spinVariable
);
95 /*while (cellAtomicTestAndDecr32(atomic_buf, (uint64_t)spinVariable) == 0)
99 cellSyncMutexLock((uint64_t)spinVariable
);
106 //cellAtomicIncr32(atomic_buf, (uint64_t)spinVariable);
107 cellSyncMutexUnlock((uint64_t)spinVariable
);
113 SpinVariable
* spinVariable
;
114 ATTRIBUTE_ALIGNED128(uint32_t atomic_buf
[32]);
118 //create a dummy implementation (without any locking) useful for serial processing
122 typedef int SpinVariable
;
124 btSpinlock (SpinVariable
* var
)
141 SpinVariable
* spinVariable
;
148 #endif //BT_SPU_SYNC_H