From e5c599f8c692e94c96072131b559d8d3b8a6b04b Mon Sep 17 00:00:00 2001 From: pionere Date: Wed, 9 Nov 2022 09:02:23 +0100 Subject: [PATCH] fix SOLARIS_ATOMICS - use 'sizeless' int types (int uses 32-bit even if _LP64 is set) --- src/atomic/SDL_atomic.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/atomic/SDL_atomic.c b/src/atomic/SDL_atomic.c index fa9065bd9..a89134e1a 100644 --- a/src/atomic/SDL_atomic.c +++ b/src/atomic/SDL_atomic.c @@ -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); #elif defined(__MACOSX__) /* this is deprecated in 10.12 sdk; favor gcc atomics. */ return (SDL_bool) OSAtomicCompareAndSwap32Barrier(oldval, newval, &a->value); -#elif defined(__SOLARIS__) && defined(_LP64) - return (SDL_bool) ((int) atomic_cas_64((volatile uint64_t*)&a->value, (uint64_t)oldval, (uint64_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 defined(__SOLARIS__) + return (SDL_bool) ((int) atomic_cas_uint((volatile uint_t*)&a->value, (uint_t)oldval, (uint_t)newval) == oldval); #elif EMULATE_CAS SDL_bool retval = SDL_FALSE; @@ -197,10 +195,8 @@ SDL_AtomicSet(SDL_atomic_t *a, int v) return _SDL_xchg_watcom(&a->value, v); #elif defined(HAVE_GCC_ATOMICS) return __sync_lock_test_and_set(&a->value, v); -#elif defined(__SOLARIS__) && defined(_LP64) - return (int) atomic_swap_64((volatile uint64_t*)&a->value, (uint64_t)v); -#elif defined(__SOLARIS__) && !defined(_LP64) - return (int) atomic_swap_32((volatile uint32_t*)&a->value, (uint32_t)v); +#elif defined(__SOLARIS__) + return (int) atomic_swap_uint((volatile uint_t*)&a->value, v); #else int value; do { @@ -241,13 +237,9 @@ SDL_AtomicAdd(SDL_atomic_t *a, int v) #elif defined(HAVE_GCC_ATOMICS) return __sync_fetch_and_add(&a->value, v); #elif defined(__SOLARIS__) - int pv = a->value; - membar_consumer(); -#if defined(_LP64) - atomic_add_64((volatile uint64_t*)&a->value, v); -#elif !defined(_LP64) - atomic_add_32((volatile uint32_t*)&a->value, v); -#endif + int pv = a->value; + membar_consumer(); + atomic_add_int((volatile uint_t*)&a->value, v); return pv; #else int value;