Fix atomic support for PS2

This commit is contained in:
Francisco Javier Trujillo Mata 2022-06-06 00:00:45 +02:00 committed by Sam Lantinga
parent 161a316dfa
commit 273d9e4640
1 changed files with 16 additions and 0 deletions

View File

@ -40,6 +40,10 @@
#include <xmmintrin.h> #include <xmmintrin.h>
#endif #endif
#if defined(PS2)
#include <kernel.h>
#endif
#if defined(__WATCOMC__) && defined(__386__) #if defined(__WATCOMC__) && defined(__386__)
SDL_COMPILE_TIME_ASSERT(locksize, 4==sizeof(SDL_SpinLock)); SDL_COMPILE_TIME_ASSERT(locksize, 4==sizeof(SDL_SpinLock));
extern __inline int _SDL_xchg_watcom(volatile int *a, int v); extern __inline int _SDL_xchg_watcom(volatile int *a, int v);
@ -131,7 +135,19 @@ SDL_AtomicTryLock(SDL_SpinLock *lock)
#elif defined(__SOLARIS__) && !defined(_LP64) #elif defined(__SOLARIS__) && !defined(_LP64)
/* Used for Solaris with non-gcc compilers. */ /* Used for Solaris with non-gcc compilers. */
return (SDL_bool) ((int) atomic_cas_32((volatile uint32_t*)lock, 0, 1) == 0); return (SDL_bool) ((int) atomic_cas_32((volatile uint32_t*)lock, 0, 1) == 0);
#elif defined(PS2)
uint32_t oldintr;
SDL_bool res = SDL_FALSE;
// disable interuption
oldintr = DIntr();
if (*lock == 0) {
*lock = 1;
res = SDL_TRUE;
}
// enable interuption
if(oldintr) { EIntr(); }
return res;
#else #else
#error Please implement for your platform. #error Please implement for your platform.
return SDL_FALSE; return SDL_FALSE;