src/atomic/SDL_atomic.c
changeset 10946 623e8891e091
parent 10879 773cbb61ad27
child 10947 56a0a429d309
equal deleted inserted replaced
10945:1300a3135d61 10946:623e8891e091
   209 }
   209 }
   210 
   210 
   211 int
   211 int
   212 SDL_AtomicGet(SDL_atomic_t *a)
   212 SDL_AtomicGet(SDL_atomic_t *a)
   213 {
   213 {
       
   214 #ifdef HAVE_GCC_ATOMICS
       
   215     return __atomic_load_n(&a->value, __ATOMIC_SEQ_CST);
       
   216 #else
   214     int value;
   217     int value;
   215     do {
   218     do {
   216         value = a->value;
   219         value = a->value;
   217     } while (!SDL_AtomicCAS(a, value, value));
   220     } while (!SDL_AtomicCAS(a, value, value));
   218     return value;
   221     return value;
       
   222 #endif
   219 }
   223 }
   220 
   224 
   221 void *
   225 void *
   222 SDL_AtomicGetPtr(void **a)
   226 SDL_AtomicGetPtr(void **a)
   223 {
   227 {
       
   228 #ifdef HAVE_GCC_ATOMICS
       
   229     return __atomic_load_n(a, __ATOMIC_SEQ_CST);
       
   230 #else
   224     void *value;
   231     void *value;
   225     do {
   232     do {
   226         value = *a;
   233         value = *a;
   227     } while (!SDL_AtomicCASPtr(a, value, value));
   234     } while (!SDL_AtomicCASPtr(a, value, value));
   228     return value;
   235     return value;
       
   236 #endif
   229 }
   237 }
   230 
   238 
   231 void
   239 void
   232 SDL_MemoryBarrierReleaseFunction(void)
   240 SDL_MemoryBarrierReleaseFunction(void)
   233 {
   241 {