fix SOLARIS_ATOMICS

- use 'sizeless' int types (int uses 32-bit even if _LP64 is set)
main
pionere 2022-11-09 09:02:23 +01:00 committed by Ryan C. Gordon
parent b095df7f5c
commit e5c599f8c6
1 changed files with 7 additions and 15 deletions

View File

@ -136,10 +136,8 @@ SDL_AtomicCAS(SDL_atomic_t *a, int oldval, int newval)
return (SDL_bool) __sync_bool_compare_and_swap(&a->value, oldval, newval); return (SDL_bool) __sync_bool_compare_and_swap(&a->value, oldval, newval);
#elif defined(__MACOSX__) /* this is deprecated in 10.12 sdk; favor gcc atomics. */ #elif defined(__MACOSX__) /* this is deprecated in 10.12 sdk; favor gcc atomics. */
return (SDL_bool) OSAtomicCompareAndSwap32Barrier(oldval, newval, &a->value); return (SDL_bool) OSAtomicCompareAndSwap32Barrier(oldval, newval, &a->value);
#elif defined(__SOLARIS__) && defined(_LP64) #elif defined(__SOLARIS__)
return (SDL_bool) ((int) atomic_cas_64((volatile uint64_t*)&a->value, (uint64_t)oldval, (uint64_t)newval) == oldval); return (SDL_bool) ((int) atomic_cas_uint((volatile uint_t*)&a->value, (uint_t)oldval, (uint_t)newval) == oldval);
#elif defined(__SOLARIS__) && !defined(_LP64)
return (SDL_bool) ((int) atomic_cas_32((volatile uint32_t*)&a->value, (uint32_t)oldval, (uint32_t)newval) == oldval);
#elif EMULATE_CAS #elif EMULATE_CAS
SDL_bool retval = SDL_FALSE; SDL_bool retval = SDL_FALSE;
@ -197,10 +195,8 @@ SDL_AtomicSet(SDL_atomic_t *a, int v)
return _SDL_xchg_watcom(&a->value, v); return _SDL_xchg_watcom(&a->value, v);
#elif defined(HAVE_GCC_ATOMICS) #elif defined(HAVE_GCC_ATOMICS)
return __sync_lock_test_and_set(&a->value, v); return __sync_lock_test_and_set(&a->value, v);
#elif defined(__SOLARIS__) && defined(_LP64) #elif defined(__SOLARIS__)
return (int) atomic_swap_64((volatile uint64_t*)&a->value, (uint64_t)v); return (int) atomic_swap_uint((volatile uint_t*)&a->value, v);
#elif defined(__SOLARIS__) && !defined(_LP64)
return (int) atomic_swap_32((volatile uint32_t*)&a->value, (uint32_t)v);
#else #else
int value; int value;
do { do {
@ -243,11 +239,7 @@ SDL_AtomicAdd(SDL_atomic_t *a, int v)
#elif defined(__SOLARIS__) #elif defined(__SOLARIS__)
int pv = a->value; int pv = a->value;
membar_consumer(); membar_consumer();
#if defined(_LP64) atomic_add_int((volatile uint_t*)&a->value, v);
atomic_add_64((volatile uint64_t*)&a->value, v);
#elif !defined(_LP64)
atomic_add_32((volatile uint32_t*)&a->value, v);
#endif
return pv; return pv;
#else #else
int value; int value;