This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
authorBob Pendleton <bob@pendleton.com>
Wed, 24 Jun 2009 20:04:08 +0000
changeset 31993e1bf2b8bd81
parent 3198 fefe74ca604d
child 3200 ef2c029a3a9d
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
It also update configure.in to compile the linux version of the library. The three versions are all dummies
implementations that do nothing. They are being checked in as place holders. Mostly, I just wanted to get
place holders and the configure.in checked in.
configure.in
include/SDL_atomic.h
src/atomic/linux/SDL_atomic.c
src/atomic/macosx/SDL_atomic.c
src/atomic/win32/SDL_atomic.c
test/testatomic.c
     1.1 --- a/configure.in	Wed Jun 17 04:26:19 2009 +0000
     1.2 +++ b/configure.in	Wed Jun 24 20:04:08 2009 +0000
     1.3 @@ -217,6 +217,12 @@
     1.4  
     1.5  dnl Enable/disable various subsystems of the SDL library
     1.6  
     1.7 +AC_ARG_ENABLE(atomic,
     1.8 +AC_HELP_STRING([--enable-atomic], [Enable the atomic operations subsystem [[default=yes]]]),
     1.9 +              , enable_atomic=yes)
    1.10 +if test x$enable_atomic != xyes; then
    1.11 +    AC_DEFINE(SDL_ATOMIC_DISABLED)
    1.12 +fi
    1.13  AC_ARG_ENABLE(audio,
    1.14  AC_HELP_STRING([--enable-audio], [Enable the audio subsystem [[default=yes]]]),
    1.15                , enable_audio=yes)
    1.16 @@ -2433,6 +2439,16 @@
    1.17              ;;
    1.18            esac
    1.19          fi
    1.20 +        # Set up files for the atomic operations library
    1.21 +        if test x$enable_atomic = xyes; then
    1.22 +          case $ARCH in
    1.23 +            linux)
    1.24 +                AC_DEFINE(SDL_ATOMIC_LINUX)
    1.25 +                SOURCES="$SOURCES $srcdir/src/atomic/linux/*.c"
    1.26 +                have_atomic=yes
    1.27 +            ;;
    1.28 +          esac
    1.29 +        fi
    1.30          # Set up files for the joystick library
    1.31          if test x$enable_joystick = xyes; then
    1.32            case $ARCH in
     2.1 --- a/include/SDL_atomic.h	Wed Jun 17 04:26:19 2009 +0000
     2.2 +++ b/include/SDL_atomic.h	Wed Jun 24 20:04:08 2009 +0000
     2.3 @@ -23,7 +23,7 @@
     2.4  /**
     2.5   * \file SDL_atomic.h
     2.6   *
     2.7 - * Atomic int and pointer magic
     2.8 + * Atomic operations.
     2.9   */
    2.10  
    2.11  #ifndef _SDL_atomic_h_
    2.12 @@ -42,628 +42,232 @@
    2.13  /* *INDENT-ON* */
    2.14  #endif
    2.15  
    2.16 -/* indent is really bad at handling assembly */
    2.17  /* *INDENT-OFF* */
    2.18 +/**
    2.19 + * \def SDL_AtomicBusyWait32 (ptr)
    2.20 + *
    2.21 + * \brief Implements a simple busy wait for use with
    2.22 + * SDL_AtomicTestThenSet and SDL_AtomicClear.
    2.23 + *
    2.24 + * Note: This can be an infinite loop.
    2.25 + *
    2.26 + */
    2.27 +#define SDL_AtomicBusyWait32(ptr)		\
    2.28 +   {						\
    2.29 +   while (!SDL_AtomicTestThenSet32(ptr)		\
    2.30 +      {						\
    2.31 +      };					\
    2.32 +   };
    2.33  
    2.34 -#if defined(__GNUC__) && (defined(i386) || defined(__i386__)  || defined(__x86_64__))
    2.35 -static __inline__ void
    2.36 -SDL_atomic_int_add(volatile int* atomic, int value)
    2.37 -{
    2.38 -  __asm__ __volatile__("lock;"
    2.39 -                       "addl %1, %0"
    2.40 -                       : "=m" (*atomic)
    2.41 -                       : "ir" (value),
    2.42 -                         "m" (*atomic));
    2.43 -}
    2.44 +/**
    2.45 + * \def SDL_AtomicWait32(ptr)
    2.46 + *
    2.47 + * \brief A safer way to wait for a test-then-set lock to be cleared.
    2.48 + *
    2.49 + * This assumes that the SDL_Sleep(0) call acts as a thread_yeild
    2.50 + * operation. 
    2.51 + *
    2.52 + */
    2.53 +#define SDL_AtomicWait32(ptr)			\
    2.54 +   {						\
    2.55 +   while (!SDL_AtomicTestThenSet32(ptr)		\
    2.56 +      {						\
    2.57 +	 SDL_Sleep(0);				\
    2.58 +      };                                        \
    2.59 +   };
    2.60  
    2.61 -static __inline__ int
    2.62 -SDL_atomic_int_xchg_add(volatile int* atomic, int value)
    2.63 -{                                              
    2.64 -  int rv;                                    
    2.65 -  __asm__ __volatile__("lock;"               
    2.66 -                       "xaddl %0, %1"        
    2.67 -                       : "=r" (rv),          
    2.68 -                         "=m" (*atomic)    
    2.69 -                       : "0" (value),        
    2.70 -                         "m" (*atomic));   
    2.71 -  return rv;                                        
    2.72 -}
    2.73 +/**
    2.74 + * \def SDL_AtomicBusyWait64(ptr)
    2.75 + *
    2.76 + * \brief 64 bit version of busy wait
    2.77 + *
    2.78 + * \sa SDL_AtomicBusyWait32
    2.79 + */
    2.80 +#define SDL_AtomicBusyWait64(ptr)		\
    2.81 +   {						\
    2.82 +   while (!SDL_AtomicTestThenSet64(ptr)		\
    2.83 +      {						\
    2.84 +      };					\
    2.85 +   };
    2.86  
    2.87 -static __inline__ SDL_bool
    2.88 -SDL_atomic_int_cmp_xchg(volatile int* atomic, int oldvalue, int newvalue)
    2.89 -{
    2.90 -  int rv;                                                      
    2.91 -  __asm__ __volatile__("lock;"                               
    2.92 -                       "cmpxchgl %2, %1"                     
    2.93 -                       : "=a" (rv),                          
    2.94 -                         "=m" (*atomic)             
    2.95 -                       : "r" (newvalue),                     
    2.96 -                         "m" (*atomic),                    
    2.97 -                         "0" (oldvalue));
    2.98 -  return (SDL_bool)(rv == oldvalue);                                          
    2.99 -}
   2.100 -
   2.101 -static __inline__ SDL_bool
   2.102 -SDL_atomic_ptr_cmp_xchg(volatile void** atomic, void* oldvalue, void* newvalue)
   2.103 -{
   2.104 -  void* rv;
   2.105 -  __asm__ __volatile__("lock;"
   2.106 -# if defined(__x86_64__)                       
   2.107 -                       "cmpxchgq %q2, %1"
   2.108 -# else
   2.109 -                       "cmpxchgl %2, %1"
   2.110 -# endif                       
   2.111 -                       : "=a" (rv),
   2.112 -                         "=m" (*atomic)
   2.113 -                       : "r" (newvalue),
   2.114 -                         "m" (*atomic),
   2.115 -                         "0" (oldvalue));
   2.116 -  return (SDL_bool)(rv == oldvalue);
   2.117 -}
   2.118 -#elif defined(__GNUC__) && defined(__alpha__)
   2.119 -# define ATOMIC_MEMORY_BARRIER (__asm__ __volatile__ ("mb" : : : "memory"))
   2.120 -# define ATOMIC_INT_CMP_XCHG(atomic,value)              \
   2.121 -  ({                                                    \
   2.122 -    int rv,prev;                                        \
   2.123 -    __asm__ __volatile__("   mb\n"                      \
   2.124 -                         "1: ldl_l   %0,%2\n"           \
   2.125 -                         "   cmpeq   %0,%3,%1\n"        \
   2.126 -                         "   beq     %1,2f\n"           \
   2.127 -                         "   mov     %4,%1\n"           \
   2.128 -                         "   stl_c   %1,%2\n"           \
   2.129 -                         "   beq     %1,1b\n"           \
   2.130 -                         "   mb\n"                      \
   2.131 -                         "2:"                           \
   2.132 -                         : "=&r" (prev),                \
   2.133 -                           "=&r" (rv)                   \
   2.134 -                         : "m" (*(atomic)),             \
   2.135 -                           "Ir" (oldvalue),             \
   2.136 -                           "Ir" (newvalue)              \
   2.137 -                         : "memory");                   \
   2.138 -    (rv != 0);                                          \
   2.139 -  })
   2.140 -
   2.141 -# if (SIZEOF_VOIDP == 4)
   2.142 -static __inline__ SDL_bool
   2.143 -SDL_atomic_ptr_cmp_xchg(volatile void** atomic, void* oldvalue, void* newvalue)
   2.144 -{
   2.145 -  int rv;
   2.146 -  void* prev;
   2.147 -  __asm__ __volatile__("   mb\n"
   2.148 -                       "1: ldl_l %0,%2\n"
   2.149 -                       "   cmpeq %0,%3,%1\n"
   2.150 -                       "   beq   $1,2f\n"
   2.151 -                       "   mov   %4,%1\n"
   2.152 -                       "   stl_c %1,%2\n"
   2.153 -                       "   beq   %1,1b\n"
   2.154 -                       "   mb\n"
   2.155 -                       "2:"
   2.156 -                       : "=&r" (prev),
   2.157 -                         "=&r" (rv)
   2.158 -                       : "m" (*atomic),
   2.159 -                         "Ir" (oldvalue),
   2.160 -                         "Ir" (newvalue)
   2.161 -                       : "memory");
   2.162 -  return (SDL_bool)(rv != 0);
   2.163 -}
   2.164 -# elif (SIZEOF_VOIDP == 8)
   2.165 -static __inline__ SDL_bool
   2.166 -SDL_atomic_ptr_cmp_xchg(volatile void** atomic, void* oldvalue, void* newvalue)
   2.167 -{
   2.168 -  int rv;
   2.169 -  void* prev;
   2.170 -  __asm__ __volatile__("   mb\n"
   2.171 -                       "1: ldq_l %0,%2\n"
   2.172 -                       "   cmpeq %0,%3,%1\n"
   2.173 -                       "   beq   %1,2f\n"
   2.174 -                       "   mov   %4,%1\n"
   2.175 -                       "   stq_c %1,%2\n"
   2.176 -                       "   beq   %1,1b\n"
   2.177 -                       "   mb\n"
   2.178 -                       "2:"
   2.179 -                       : "=&r" (prev),
   2.180 -                         "=&r" (rv)
   2.181 -                       : "m" (*atomic),
   2.182 -                         "Ir" (oldvalue),
   2.183 -                         "Ir" (newvalue)
   2.184 -                       : "memory");
   2.185 -  return (SDL_bool)(rv != 0);
   2.186 -}
   2.187 -# else
   2.188 -#  error "Your system has an unsupported pointer size"  
   2.189 -# endif  /* SIZEOF_VOIDP */
   2.190 -#elif defined(__GNUC__) && defined(__sparc__)
   2.191 -# define ATOMIC_MEMORY_BARRIER                                          \
   2.192 -  (__asm__ __volatile__("membar #LoadLoad | #LoadStore"                 \
   2.193 -                        " | #StoreLoad | #StoreStore" : : : "memory"))
   2.194 -# define ATOMIC_INT_CMP_XCHG(atomic,oldvalue,newvalue)                  \
   2.195 -  ({                                                                    \
   2.196 -    int rv;                                                             \
   2.197 -    __asm__ __volatile__("cas [%4], %2, %0"                             \
   2.198 -                         : "=r" (rv), "=m" (*(atomic))                  \
   2.199 -                         : "r" (oldvalue), "m" (*(atomic)),             \
   2.200 -                         "r" (atomic), "0" (newvalue));                 \
   2.201 -    rv == oldvalue;                                                     \
   2.202 -  })
   2.203 -
   2.204 -# if (SIZEOF_VOIDP == 4)
   2.205 -static __inline__ SDL_bool
   2.206 -SDL_atomic_ptr_cmp_xchg(volatile void** atomic, void* oldvalue, void* newvalue)
   2.207 -{
   2.208 -  void* rv;
   2.209 -  __asm__ __volatile__("cas [%4], %2, %0"
   2.210 -                       : "=r" (rv),
   2.211 -                         "=m" (*atomic)
   2.212 -                       : "r" (oldvalue),
   2.213 -                         "m" (*atomic),
   2.214 -                         "r" (atomic),
   2.215 -                         "0" (newvalue));
   2.216 -  return (SDL_bool)(rv == oldvalue);
   2.217 -}
   2.218 -# elif (SIZEOF_VOIDP == 8)
   2.219 -static __inline__ SDL_bool
   2.220 -SDL_atomic_ptr_cmp_xchg(volatile void** atomic, void* oldvalue, void* newvalue)
   2.221 -{
   2.222 -  void* rv;
   2.223 -  void** a = atomic;
   2.224 -  __asm__ __volatile__("casx [%4], %2, %0"
   2.225 -                       : "=r" (rv),
   2.226 -                         "=m" (*a)
   2.227 -                       : "r" (oldvalue),
   2.228 -                         "m" (*a),
   2.229 -                         "r" (a),
   2.230 -                         "0" (newvalue));
   2.231 -  return (SDL_bool)(rv == oldvalue);
   2.232 -}
   2.233 -# else
   2.234 -#  error "Your system has an unsupported pointer size"
   2.235 -# endif /* SIZEOF_VOIDP */
   2.236 -#elif defined(__GNUC__) && (defined(__POWERPC__) || defined(__powerpc__) || defined(__ppc__) || defined(_M_PPC))
   2.237 -# define ATOMIC_MEMORY_BARRIER \
   2.238 -  (__asm__ __volatile__ ("sync" : : : "memory"))
   2.239 -static __inline__ void
   2.240 -SDL_atomic_int_add(volatile int* atomic, int value)
   2.241 -{                                           
   2.242 -  int rv,tmp;                                   
   2.243 -  __asm__ __volatile__("1: lwarx   %0,  0, %3\n" 
   2.244 -                       "   add     %1, %0, %4\n"
   2.245 -                       "   stwcx.  %1,  0, %3\n" 
   2.246 -                       "   bne-    1b"          
   2.247 -                       : "=&b" (rv),            
   2.248 -                         "=&r" (tmp),           
   2.249 -                         "=m" (*atomic)       
   2.250 -                       : "b" (atomic),          
   2.251 -                         "r" (value),           
   2.252 -                         "m" (*atomic)        
   2.253 -                       : "cr0",                 
   2.254 -                         "memory");             
   2.255 -}
   2.256 -
   2.257 -static __inline__ int
   2.258 -SDL_atomic_int_xchg_add(volatile int* atomic, int value)
   2.259 -{                                          
   2.260 -  int rv,tmp;                               
   2.261 -  __asm__ __volatile__("1: lwarx  %0, 0, %3\n"        
   2.262 -                       "   add    %1, %0, %4\n"       
   2.263 -                       "   stwcx. %1, 0, %3\n"        
   2.264 -                       "   bne-   1b"                 
   2.265 -                       : "=&b" (rv),                  
   2.266 -                         "=&r" (tmp),                 
   2.267 -                         "=m" (*atomic)
   2.268 -                       : "b" (atomic),                
   2.269 -                         "r" (value),                 
   2.270 -                         "m" (*atomic)
   2.271 -                       : "cr0",                       
   2.272 -                       "memory");                   
   2.273 -  return rv;                                                 
   2.274 -}
   2.275 -
   2.276 -# if (SIZEOF_VOIDP == 4)
   2.277 -static __inline__ SDL_bool
   2.278 -SDL_atomic_int_cmp_xchg(volatile int* atomic, int oldvalue, int newvalue)
   2.279 -{                                                        
   2.280 -  int rv;                                                 
   2.281 -  __asm__ __volatile__("   sync\n"                         
   2.282 -                       "1: lwarx   %0, 0, %1\n"           
   2.283 -                       "   subf.   %0, %2, %0\n"          
   2.284 -                       "   bne     2f\n"                  
   2.285 -                       "   stwcx.  %3, 0, %1\n"           
   2.286 -                       "   bne-    1b\n"                  
   2.287 -                       "2: isync"                         
   2.288 -                       : "=&r" (rv)                       
   2.289 -                       : "b" (atomic),                    
   2.290 -                         "r" (oldvalue),                  
   2.291 -                         "r"                              
   2.292 -                       : "cr0",                           
   2.293 -                         "memory");                         
   2.294 -  return (SDL_bool)(rv == 0);                                              
   2.295 -}
   2.296 -
   2.297 -static __inline__ SDL_bool
   2.298 -SDL_atomic_ptr_cmp_xchg(volatile void** atomic, void* oldvalue, void* newvalue)
   2.299 -{
   2.300 -  void* rv;
   2.301 -  __asm__ __volatile__("sync\n"
   2.302 -                       "1: lwarx  %0,  0, %1\n"
   2.303 -                       "   subf.  %0, %2, %0\n"
   2.304 -                       "   bne    2f\n"
   2.305 -                       "   stwcx. %3,  0, %1\n"
   2.306 -                       "   bne-   1b\n"
   2.307 -                       "2: isync"
   2.308 -                       : "=&r" (rv)
   2.309 -                       : "b" (atomic),
   2.310 -                         "r" (oldvalue),
   2.311 -                         "r" (newvalue)
   2.312 -                       : "cr0",
   2.313 -                       "memory");
   2.314 -  return (SDL_bool)(rv == 0);
   2.315 -}
   2.316 -# elif (SIZEOF_VOIDP == 8)
   2.317 -static __inline__ SDL_bool
   2.318 -SDL_atomic_int_cmp_xchg(volatile int* atomic, int oldvalue, int newvalue)
   2.319 -{                                                        
   2.320 -  int rv;                                                 
   2.321 -  __asm__ __volatile__("   sync\n"                         
   2.322 -                       "1: lwarx   %0,  0, %1\n"
   2.323 -                       "   extsw   %0, %0\n"
   2.324 -                       "   subf.   %0, %2, %0\n"          
   2.325 -                       "   bne     2f\n"                  
   2.326 -                       "   stwcx.  %3,  0, %1\n"           
   2.327 -                       "   bne-    1b\n"                  
   2.328 -                       "2: isync"                         
   2.329 -                       : "=&r" (rv)                       
   2.330 -                       : "b" (atomic),                    
   2.331 -                         "r" (oldvalue),                  
   2.332 -                         "r"                              
   2.333 -                       : "cr0",                           
   2.334 -                         "memory");                         
   2.335 -  return (SDL_bool)(rv == 0);                                              
   2.336 -}
   2.337 -
   2.338 -static __inline__ SDL_bool
   2.339 -SDL_atomic_ptr_cmp_xchg(volatile void** atomic, void* oldvalue, void* newvalue)
   2.340 -{
   2.341 -  void* rv;
   2.342 -  __asm__ __volatile__("sync\n"
   2.343 -                       "1: ldarx  %0,  0, %1\n"
   2.344 -                       "   subf.  %0, %2, %0\n"
   2.345 -                       "   bne    2f\n"
   2.346 -                       "   stdcx. %3,  0, %1\n"
   2.347 -                       "   bne-   1b\n"
   2.348 -                       "2: isync"
   2.349 -                       : "=&r" (rv)
   2.350 -                       : "b" (atomic),
   2.351 -                         "r" (oldvalue),
   2.352 -                         "r" (newvalue)
   2.353 -                       : "cr0",
   2.354 -                       "memory");
   2.355 -  return (SDL_bool)(rv == 0);
   2.356 -}
   2.357 -# else
   2.358 -#  error "Your system has an unsupported pointer size"
   2.359 -# endif /* SIZEOF_VOIDP */
   2.360 -#elif defined(__GNUC__) && (defined(__IA64__) || defined(__ia64__))
   2.361 -# define ATOMIC_MEMORY_BARRIER (__sync_synchronize())
   2.362 -# define SDL_atomic_int_xchg_add(atomic, value)     \
   2.363 -  (__sync_fetch_and_add((atomic),(value)))
   2.364 -# define SDL_atomic_int_add(atomic, value)                  \
   2.365 -  ((void)__sync_fetch_and_add((atomic),(value)))
   2.366 -# define SDL_atomic_int_cmp_xchg(atomic,oldvalue,newvalue)  \
   2.367 -  (__sync_bool_compare_and_swap((atomic),(oldvalue),(newvalue)))
   2.368 -# define SDL_atomic_ptr_cmp_xchg(atomic,oldvalue,newvalue)              \
   2.369 -  (__sync_bool_compare_and_swap((long*)(atomic),(long)(oldvalue),(long)(newvalue)))
   2.370 -#elif defined(__GNUC__) && defined(__LINUX__) && (defined(__mips__) || defined(__MIPS__))
   2.371 -static __inline__ int
   2.372 -SDL_atomic_int_xchg_add(volatile int* atomic, int value)
   2.373 -{                                            
   2.374 -  int rv,tmp;                                 
   2.375 -  __asm__ __volatile__("1:              \n"                 
   2.376 -                       ".set  push      \n"         
   2.377 -                       ".set  mips2     \n"        
   2.378 -                       "ll    %0,%3     \n"        
   2.379 -                       "addu  %1,%4,%0  \n"     
   2.380 -                       "sc    %1,%2     \n"        
   2.381 -                       ".set  pop       \n"          
   2.382 -                       "beqz  %1,1b     \n"        
   2.383 -                       : "=&r" (rv),          
   2.384 -                         "=&r" (tmp),         
   2.385 -                         "=m" (*atomic)     
   2.386 -                       : "m" (*atomic),     
   2.387 -                         "r" (value)          
   2.388 -                       : "memory");           
   2.389 -  return rv;                                         
   2.390 -}
   2.391 -
   2.392 -static __inline__ void
   2.393 -SDL_atomic_int_add(volatile int* atomic, int value)
   2.394 -{                                           
   2.395 -  int rv;                                    
   2.396 -  __asm__ __volatile__("1:               \n"                
   2.397 -                       ".set  push       \n"        
   2.398 -                       ".set  mips2      \n"       
   2.399 -                       "ll    %0,%2      \n"       
   2.400 -                       "addu  %0,%3,%0   \n"    
   2.401 -                       "sc    %0,%1      \n"       
   2.402 -                       ".set  pop        \n"         
   2.403 -                       "beqz  %0,1b      \n"       
   2.404 -                       : "=&r" (rv),         
   2.405 -                         "=m" (*atomic)    
   2.406 -                       : "m" (*atomic),    
   2.407 -                         "r" (value)         
   2.408 -                       : "memory");          
   2.409 -}
   2.410 -
   2.411 -static __inline__ SDL_bool
   2.412 -SDL_atomic_int_cmp_xchg(volatile int* atomic, int oldvalue, int newvalue)
   2.413 -{
   2.414 -  int rv;
   2.415 -  __asm__ __volatile__("     .set push        \n"
   2.416 -                       "     .set noat        \n"
   2.417 -                       "     .set mips3       \n"
   2.418 -                       "1:   ll   %0, %2      \n"
   2.419 -                       "     bne  %0, %z3, 2f \n"
   2.420 -                       "     .set mips0       \n"
   2.421 -                       "     move $1, %z4     \n"
   2.422 -                       "     .set mips3       \n"
   2.423 -                       "     sc   $1, %1      \n"
   2.424 -                       "     beqz $1, 1b      \n"
   2.425 -                       "     sync             \n"
   2.426 -                       "2:                    \n"
   2.427 -                       "     .set pop         \n"
   2.428 -                       : "=&r" (rv),
   2.429 -                         "=R" (*atomic)
   2.430 -                       : "R" (*atomic),
   2.431 -                         "Jr" (oldvalue),
   2.432 -                         "Jr" (newvalue)
   2.433 -                       : "memory");
   2.434 -  return (SDL_bool)rv;                  
   2.435 -}
   2.436 -
   2.437 -static __inline__ SDL_bool
   2.438 -SDL_atomic_ptr_cmp_xchg(volatile void** atomic, void* oldvalue, void* newvalue)
   2.439 -{                                                     
   2.440 -  int rv;
   2.441 -  __asm__ __volatile__("     .set push        \n"
   2.442 -                       "     .set noat        \n"
   2.443 -                       "     .set mips3       \n"
   2.444 -# if defined(__mips64)
   2.445 -                       "1:   lld  %0, %2      \n"
   2.446 -# else
   2.447 -                       "1:   ll   %0, %2      \n"
   2.448 -# endif                       
   2.449 -                       "     bne  %0, %z3, 2f \n"
   2.450 -                       "     move $1, %z4     \n"
   2.451 -# if defined(__mips64)
   2.452 -                       "     sc   $1, %1      \n"
   2.453 -# else
   2.454 -                       "     scd  $1, %1      \n"
   2.455 -# endif                       
   2.456 -                       "     beqz $1, 1b      \n"
   2.457 -                       "     sync             \n"
   2.458 -                       "2:                    \n"
   2.459 -                       "     .set pop         \n"
   2.460 -                       : "=&r" (rv),
   2.461 -                         "=R" (*atomic)
   2.462 -                       : "R" (*atomic),
   2.463 -                         "Jr" (oldvalue),
   2.464 -                         "Jr" (newvalue)
   2.465 -                       : "memory");
   2.466 -  return (SDL_bool)rv;                                                  
   2.467 -}
   2.468 -#elif defined(__GNUC__) && defined(__m68k__)
   2.469 -static __inline__ int
   2.470 -SDL_atomic_int_xchg_add(volatile int* atomic, int value)
   2.471 -{                                          
   2.472 -  int rv = *atomic;
   2.473 -  int tmp;
   2.474 -  __asm__ __volatile__("1: move%.l %0,%1    \n"
   2.475 -                       "   add%.l  %2,%1    \n"
   2.476 -                       "   cas%.l  %0,%1,%3 \n"
   2.477 -                       "   jbne    1b       \n"
   2.478 -                       : "=d" (rv),
   2.479 -                         "=&d" (tmp)
   2.480 -                       : "d" (value),
   2.481 -                         "m" (*atomic),
   2.482 -                         "0" (rv)
   2.483 -                       : "memory");
   2.484 -  return (SDL_bool)rv;
   2.485 -}
   2.486 -
   2.487 -static __inline__ void
   2.488 -SDL_atomic_int_add(volatile int* atomic, int value)
   2.489 -{                                           
   2.490 -  __asm__ __volatile__("add%.l %0,%1"        
   2.491 -                       :                     
   2.492 -                       : "id" (value),       
   2.493 -                         "m" (*atomic)
   2.494 -                       : "memory");          
   2.495 -}
   2.496 -
   2.497 -static __inline__ SDL_bool
   2.498 -SDL_atomic_int_cmp_xchg(volatile int* atomic, int oldvalue, int newvalue)
   2.499 -{                                           
   2.500 -  char rv;                                   
   2.501 -  int readvalue;                             
   2.502 -  __asm__ __volatile__("cas%.l %2,%3,%1\n"   
   2.503 -                       "seq    %0"           
   2.504 -                       : "=dm" (rv),         
   2.505 -                         "=m" (*atomic),   
   2.506 -                         "=d" (readvalue)    
   2.507 -                       : "d" (newvalue),     
   2.508 -                         "m" (*atomic),    
   2.509 -                         "2" (oldvalue));    
   2.510 -    return (SDL_bool)rv;                                        
   2.511 -}
   2.512 -
   2.513 -static __inline__ SDL_bool
   2.514 -SDL_atomic_ptr_cmp_xchg(volatile void** atomic, void* oldvalue, void* newvalue)
   2.515 -{
   2.516 -  char rv;                                   
   2.517 -  int readvalue;                             
   2.518 -  __asm__ __volatile__("cas%.l %2,%3,%1\n"   
   2.519 -                       "seq    %0"           
   2.520 -                       : "=dm" (rv),         
   2.521 -                         "=m" (*atomic),   
   2.522 -                         "=d" (readvalue)    
   2.523 -                       : "d" (newvalue),     
   2.524 -                         "m" (*atomic),    
   2.525 -                         "2" (oldvalue));    
   2.526 -    return (SDL_bool)rv;                                        
   2.527 -}
   2.528 -#elif defined(__GNUC__) && defined(__s390__)
   2.529 -# define ATOMIC_INT_CMP_XCHG(atomic,oldvalue,newvalue)  \
   2.530 -  ({                                                    \
   2.531 -    int rv = oldvalue;                                  \
   2.532 -    __asm__ __volatile__("cs %0, %2, %1"                \
   2.533 -                         : "+d" (rv),                   \
   2.534 -                           "=Q" (*(atomic))             \
   2.535 -                         : "d" (newvalue),              \
   2.536 -                           "m" (*(atomic))              \
   2.537 -                         : "cc");                       \
   2.538 -    rv == oldvalue;                                     \
   2.539 -  })
   2.540 -# if (SIZEOF_VOIDP == 4)
   2.541 -static __inline__ SDL_bool
   2.542 -SDL_atomic_ptr_cmp_xchg(volatile void** atomic, void* oldvalue, void* newvalue)
   2.543 -{
   2.544 -  void* rv = oldvalue;
   2.545 -  __asm__ __volatile__("cs %0, %2, %1"
   2.546 -                       : "+d" (rv),
   2.547 -                         "=Q" (*atomic)
   2.548 -                       : "d" (newvalue),
   2.549 -                         "m" (*atomic)
   2.550 -                       : "cc");
   2.551 -  return (SDL_bool)(rv == oldvalue);
   2.552 -}
   2.553 -# elif (SIZEOF_VOIDP == 8)
   2.554 -static __inline__ SDL_bool
   2.555 -SDL_atomic_ptr_cmp_xchg(volatile void** atomic, void* oldvalue, void* newvalue)
   2.556 -{
   2.557 -  void* rv = oldvalue;
   2.558 -  void** a = atomic;
   2.559 -  __asm__ __volatile__("csg %0, %2, %1"
   2.560 -                       : "+d" (rv),
   2.561 -                         "=Q" (*a)
   2.562 -                       : "d" ((long)(newvalue)),
   2.563 -                         "m" (*a)
   2.564 -                       : "cc");
   2.565 -  return (SDL_bool)(rv == oldvalue);
   2.566 -}
   2.567 -# else
   2.568 -#  error "Your system has an unsupported pointer size"
   2.569 -# endif /* SIZEOF_VOIDP */
   2.570 -#elif defined(__WIN32__)
   2.571 -# include <windows.h>
   2.572 -static __inline__ int
   2.573 -SDL_atomic_int_xchg_add(volatile int* atomic, int value)
   2.574 -{
   2.575 -  return InterlockedExchangeAdd(atomic, value);
   2.576 -}
   2.577 -
   2.578 -static __inline__ void
   2.579 -SDL_atomic_int_add(volatile int* atomic, int value)
   2.580 -{
   2.581 -  InterlockedExchangeAdd(atomic, value);
   2.582 -}
   2.583 -
   2.584 -# if (WINVER > 0X0400)
   2.585 -static __inline__ SDL_bool
   2.586 -SDL_atmoic_int_cmp_xchg(volatile int* atomic, int oldvalue, int newvalue)
   2.587 -{
   2.588 -   return (SDL_bool)(InterlockedCompareExchangePointer((PVOID*)atomic,
   2.589 -                                                       (PVOID)newvalue,
   2.590 -                                                       (PVOID)oldvalue) == oldvalue);
   2.591 -}
   2.592 -
   2.593 -
   2.594 -static __inline__ SDL_bool
   2.595 -SDL_atomic_ptr_cmp_xchg(volatile void** atomic, void* oldvalue, void* newvalue)
   2.596 -{
   2.597 -  return (InterlockedCompareExchangePointer(atomic, newvalue, oldvalue) == oldvalue);
   2.598 -}
   2.599 -# else /* WINVER <= 0x0400 */
   2.600 -#  if (SIZEOF_VOIDP != 4)
   2.601 -#   error "InterlockedCompareExchangePointer needed"
   2.602 -#  endif
   2.603 -
   2.604 -static __inline__ SDL_bool
   2.605 -SDL_atomic_int_cmp_xchg(volatile int* atomic, int oldvalue, int newvalue)
   2.606 -{
   2.607 -  return (InterlockedCompareExchange(atomic, newvalue, oldvalue) == oldvalue);
   2.608 -}
   2.609 -
   2.610 -static __inline__ SDL_bool
   2.611 -SDL_atomic_ptr_cmp_xchg(volatile void** atomic, void* oldvalue, void* newvalue)
   2.612 -{
   2.613 -  return (InterlockedCompareExchange(atomic, newvalue, oldvalue) == oldvalue);
   2.614 -}
   2.615 -# endif
   2.616 -#else /* when all else fails */
   2.617 -# define SDL_ATOMIC_OPS_NOT_SUPPORTED
   2.618 -# warning "Atomic Ops for this platform not supported!"
   2.619 -static __inline__ int
   2.620 -SDL_atomic_int_xchg_add(volatile int* atomic, int value)
   2.621 -{                                           
   2.622 -  int rv = *atomic;                          
   2.623 -  *(atomic) += value;                        
   2.624 -  return rv;                                        
   2.625 -}
   2.626 -
   2.627 -static __inline__ SDL_bool
   2.628 -SDL_atomic_int_cmp_xchg(volatile int* atomic, int oldvalue, int newvalue)
   2.629 -{
   2.630 -  return (*atomic == oldvalue) ?  
   2.631 -    ((*atomic = newvalue), SDL_TRUE) : SDL_FALSE;
   2.632 -}
   2.633 -
   2.634 -static __inline__ void
   2.635 -SDL_atomic_int_add(volatile int* atomic, int value)
   2.636 -{
   2.637 -  *atomic += value;
   2.638 -}
   2.639 -#endif /* arch & platforms */
   2.640 -  
   2.641 +/**
   2.642 + * \def SDL_AtomicWait64(ptr)
   2.643 + *
   2.644 + * \brief 64 bit version of SDL_AtomicWait32
   2.645 + *
   2.646 + * \sa SDL_AtomicWait32
   2.647 + */
   2.648 +#define SDL_AtomicWait64(ptr)			\
   2.649 +   {						\
   2.650 +   while (!SDL_AtomicTestThenSet64(ptr)		\
   2.651 +      {						\
   2.652 +	 SDL_Sleep(0);				\
   2.653 +      };                                        \
   2.654 +   };
   2.655  /* *INDENT-ON* */
   2.656  
   2.657 -#ifdef ATOMIC_INT_CMP_XCHG
   2.658 -static __inline__ SDL_bool
   2.659 -SDL_atomic_int_cmp_xchg(volatile int *atomic, int oldvalue, int newvalue)
   2.660 -{
   2.661 -    return (SDL_bool) ATOMIC_INT_CMP_XCHG(atomic, oldvalue, newvalue);
   2.662 -}
   2.663 +/* Function prototypes */
   2.664  
   2.665 -static __inline__ int
   2.666 -SDL_atomic_int_xchg_add(volatile int *atomic, int value)
   2.667 -{
   2.668 -    int rv;
   2.669 -    do
   2.670 -        rv = *atomic;
   2.671 -    while (!ATOMIC_INT_CMP_XCHG(atomic, rv, rv + value));
   2.672 -    return rv;
   2.673 -}
   2.674 +/**
   2.675 + * \fn int SDL_AtomicExchange32(Uint32 * ptr, Uint32 value)
   2.676 + *
   2.677 + * \brief Atomically exchange two 32 bit values.
   2.678 + *
   2.679 + * \return the value point to by ptr.
   2.680 + *
   2.681 + * \param ptr points to the value to be fetched from *ptr.  
   2.682 + * \param value is value to be stored at *ptr.
   2.683 + *
   2.684 + * The current value stored at *ptr is returned and it is replaced
   2.685 + * with value. This function can be used to implement SDL_TestThenSet.
   2.686 + *
   2.687 + */
   2.688 +extern DECLSPEC Uint32 SDLCALL SDL_AtomicExchange32(Uint32 * ptr, Uint32 value);
   2.689 +/**
   2.690 + * \fn int SDL_AtomicCompareThenSet32(Uint32 * ptr, Uint32 oldvalue, Uint32 newvalue)
   2.691 + *
   2.692 + * \brief If *ptr == oldvalue then replace the contents of *ptr by new value. 
   2.693 + *
   2.694 + * \return true if the newvalue was stored.
   2.695 + *
   2.696 + * \param *ptr is the value to be compared and replaced.
   2.697 + * \param oldvalue is value to be compared to *ptr.
   2.698 + * \param newvalue is value to be stored at *ptr.
   2.699 + *
   2.700 + */
   2.701 +extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCompareThenSet32(Uint32 * ptr,
   2.702 +                                                            Uint32 oldvalue, Uint32 newvalue);
   2.703 +/**
   2.704 + * \fn  SDL_bool SDL_AtomicTestThenSet32(Uint32 * ptr);
   2.705 + *
   2.706 + * \brief Check to see if *ptr == 0 and set it to non-zero.
   2.707 + *
   2.708 + * \return SDL_True if the value pointed to by ptr was zero and
   2.709 + * SDL_False if it was not zero
   2.710 + *
   2.711 + * \param ptr points to the value to be tested and set.
   2.712 + *
   2.713 + */
   2.714 +extern DECLSPEC SDL_bool SDLCALL SDL_AtomicTestThenSet32(Uint32 * ptr);
   2.715 +/**
   2.716 + * \fn  void SDL_AtomicClear32(Uint32 * ptr);
   2.717 + *
   2.718 + * \brief set the value pointed to by ptr to be zero.
   2.719 + *
   2.720 + * \param ptr address of the value to be set to zero
   2.721 + *
   2.722 + */
   2.723 +extern DECLSPEC void SDLCALL SDL_AtomicClear32(Uint32 * ptr);
   2.724 +/**
   2.725 + * \fn  Uint32 SDL_AtomicFetchThenIncrement32(Uint32 * ptr);
   2.726 + *
   2.727 + * \brief fetch the current value of *ptr and then increment that
   2.728 + * value in place.
   2.729 + *
   2.730 + * \return the value before it was incremented.
   2.731 + *
   2.732 + * \param ptr address of the value to fetch and increment
   2.733 + *
   2.734 + */
   2.735 +extern DECLSPEC Uint32 SDLCALL SDL_AtomicFetchThenIncrement32(Uint32 * ptr);
   2.736 +/**
   2.737 + * \fn  Uint32 SDL_AtomicFetchThenDecrement32(Uint32 * ptr);
   2.738 + *
   2.739 + * \brief fetch *ptr and then decrement the value in place.
   2.740 + *
   2.741 + * \return the value before it was decremented.
   2.742 + *
   2.743 + * \param ptr address of the value to fetch and drement
   2.744 + *
   2.745 + */
   2.746 +extern DECLSPEC Uint32 SDLCALL SDL_AtomicFetchThenDecrement32(Uint32 * ptr);
   2.747 +/**
   2.748 + * \fn  Uint32 SDL_AtomicFetchThenAdd32(Uint32 * ptr, Uint32 value);
   2.749 + *
   2.750 + * \brief fetch the current value at ptr and then add value to *ptr.
   2.751 + *
   2.752 + * \return *ptr before the addition took place.
   2.753 + *
   2.754 + * \param ptr the address of data we are changing.
   2.755 + * \param value the value to add to *ptr. 
   2.756 + *
   2.757 + */
   2.758 +extern DECLSPEC Uint32 SDLCALL SDL_AtomicFetchThenAdd32(Uint32 * ptr, Uint32 value);
   2.759 +/**
   2.760 + * \fn  Uint32 SDL_AtomicFetchThenSubtract32(Uint32 * ptr, Uint32 value);
   2.761 + *
   2.762 + * \brief Fetch *ptr and then subtract value from it.
   2.763 + *
   2.764 + * \return *ptr before the subtraction took place.
   2.765 + *
   2.766 + * \param ptr the address of the data being changed.
   2.767 + * \param value the value to subtract from *ptr.
   2.768 + *
   2.769 + */
   2.770 +extern DECLSPEC Uint32 SDLCALL SDL_AtomicFetchThenSubtract32(Uint32 * ptr, Uint32 value);
   2.771 +/**
   2.772 + * \fn  Uint32 SDL_AtomicIncrementThenFetch32(Uint32 * ptr);
   2.773 + *
   2.774 + * \brief Add one to the data pointed to by ptr and return that value.
   2.775 + *
   2.776 + * \return the incremented value.
   2.777 + *
   2.778 + * \param ptr address of the data to increment.
   2.779 + *
   2.780 + */
   2.781 +extern DECLSPEC Uint32 SDLCALL SDL_AtomicIncrementThenFetch32(Uint32 * ptr);
   2.782 +/**
   2.783 + * \fn  Uint32 SDL_AtomicDecrementThenFetch32(Uint32 * ptr);
   2.784 + *
   2.785 + * \brief Subtract one from data pointed to by ptr and return the new value.
   2.786 + *
   2.787 + * \return The decremented value.
   2.788 + *
   2.789 + * \param ptr The address of the data to decrement.
   2.790 + *
   2.791 + */
   2.792 +extern DECLSPEC Uint32 SDLCALL SDL_AtomicDecrementThenFetch32(Uint32 * ptr);
   2.793 +/**
   2.794 + * \fn  Uint32 SDL_AtomicAddThenFetch32(Uint32 * ptr, Uint32 value);
   2.795 + *
   2.796 + * \brief Add value to the data pointed to by ptr and return result.
   2.797 + *
   2.798 + * \return The sum of *ptr and value.
   2.799 + *
   2.800 + * \param ptr The address of the data to be modified.
   2.801 + * \param value The value to be added.
   2.802 + *
   2.803 + */
   2.804 +extern DECLSPEC Uint32 SDLCALL SDL_AtomicAddThenFetch32(Uint32 * ptr, Uint32 value);
   2.805 +/**
   2.806 + * \fn  Uint32 SDL_AtomicSubtractThenFetch32(Uint32 * ptr, Uint32 value);
   2.807 + *
   2.808 + * \brief Subtract value from the data pointed to by ptr and return the result.
   2.809 + *
   2.810 + * \return the difference between *ptr and value.
   2.811 + *
   2.812 + * \param ptr The address of the data to be modified.
   2.813 + * \param value The value to be subtracted.
   2.814 + *
   2.815 + */
   2.816 +extern DECLSPEC Uint32 SDLCALL SDL_AtomicSubtractThenFetch32(Uint32 * ptr, Uint32 value);
   2.817  
   2.818 -static __inline__ void
   2.819 -SDL_atomic_int_add(volatile int *atomic, int value)
   2.820 -{
   2.821 -    int rv;
   2.822 -    do
   2.823 -        rv = *atomic;
   2.824 -    while (!ATOMIC_INT_CMP_XCHG(atomic, rv, rv + value));
   2.825 -}
   2.826 -#endif /* ATOMIC_CMP_XCHG */
   2.827 +#ifdef SDL_HAS_64BIT_TYPE
   2.828  
   2.829 -#ifdef ATOMIC_MEMORY_BARRIER
   2.830 -# define SDL_atomic_int_get(atomic) \
   2.831 -  (ATOMIC_MEMORY_BARRIER,*(atomic))
   2.832 -# define SDL_atomic_int_set(atomic,value) \
   2.833 -  (*(atomic)=value,ATOMIC_MEMORY_BARRIER)
   2.834 -#else
   2.835 -# define SDL_atomic_int_get(atomic) (*(atomic))
   2.836 -# define SDL_atomic_int_set(atomic, newvalue) ((void)(*(atomic) = (newvalue)))
   2.837 -#endif /* MEMORY_BARRIER_NEEDED */
   2.838 -
   2.839 -#define SDL_atomic_int_inc(atomic) (SDL_atomic_int_add((atomic),1))
   2.840 -#define SDL_atomic_int_dec_test(atomic) (SDL_atomic_int_xchg_add((atomic),-1) == 1)
   2.841 +extern DECLSPEC Uint64 SDLCALL SDL_AtomicExchange64(Uint64 * ptr, Uint64 value);
   2.842 +extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCompareThenSet64(Uint64 * ptr,
   2.843 +                                                            Uint64 oldvalue, Uint64 newvalue);
   2.844 +extern DECLSPEC SDL_bool SDLCALL SDL_AtomicTestThenSet64(Uint64 * ptr);
   2.845 +extern DECLSPEC void SDLCALL SDL_AtomicClear64(Uint64 * ptr);
   2.846 +extern DECLSPEC Uint64 SDLCALL SDL_AtomicFetchThenIncrement64(Uint64 * ptr);
   2.847 +extern DECLSPEC Uint64 SDLCALL SDL_AtomicFetchThenDecrement64(Uint64 * ptr);
   2.848 +extern DECLSPEC Uint64 SDLCALL SDL_AtomicFetchThenAdd64(Uint64 * ptr, Uint64 value);
   2.849 +extern DECLSPEC Uint64 SDLCALL SDL_AtomicFetchThenSubtract64(Uint64 * ptr, Uint64 value);
   2.850 +extern DECLSPEC Uint64 SDLCALL SDL_AtomicIncrementThenFetch64(Uint64 * ptr);
   2.851 +extern DECLSPEC Uint64 SDLCALL SDL_AtomicDecrementThenFetch64(Uint64 * ptr);
   2.852 +extern DECLSPEC Uint64 SDLCALL SDL_AtomicAddThenFetch64(Uint64 * ptr, Uint64 value);
   2.853 +extern DECLSPEC Uint64 SDLCALL SDL_AtomicSubtractThenFetch64(Uint64 * ptr, Uint64 value);
   2.854 +#endif
   2.855  
   2.856  /* Ends C function definitions when using C++ */
   2.857  #ifdef __cplusplus
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/src/atomic/linux/SDL_atomic.c	Wed Jun 24 20:04:08 2009 +0000
     3.3 @@ -0,0 +1,176 @@
     3.4 +/*
     3.5 +    SDL - Simple DirectMedia Layer
     3.6 +    Copyright (C) 1997-2009 Sam Lantinga
     3.7 +
     3.8 +    This library is free software; you can redistribute it and/or
     3.9 +    modify it under the terms of the GNU Lesser General Public
    3.10 +    License as published by the Free Software Foundation; either
    3.11 +    version 2.1 of the License, or (at your option) any later version.
    3.12 +
    3.13 +    This library is distributed in the hope that it will be useful,
    3.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    3.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    3.16 +    Lesser General Public License for more details.
    3.17 +
    3.18 +    You should have received a copy of the GNU Lesser General Public
    3.19 +    License along with this library; if not, write to the Free Software
    3.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    3.21 +
    3.22 +    Sam Lantinga
    3.23 +    slouken@libsdl.org
    3.24 +*/
    3.25 +
    3.26 +#ifdef SDL_ATOMIC_LINUX
    3.27 +
    3.28 +#include "SDL.h"
    3.29 +#include "SDL_config.h"
    3.30 +#include "SDL_atomic.h"
    3.31 +
    3.32 +Uint32
    3.33 +SDL_AtomicExchange32(Uint32 * ptr, Uint32 value)
    3.34 +{
    3.35 +   return 0;
    3.36 +}
    3.37 +
    3.38 +SDL_bool
    3.39 +SDL_AtomicCompareThenSet32(Uint32 * ptr, Uint32 oldvalue, Uint32 newvalue)
    3.40 +{
    3.41 +   return SDL_false;
    3.42 +}
    3.43 +
    3.44 +SDL_bool
    3.45 +SDL_AtomicTestThenSet32(Uint32 * ptr)
    3.46 +{
    3.47 +   return SDL_false;
    3.48 +}
    3.49 +
    3.50 +void
    3.51 +SDL_AtomicClear32(Uint32 * ptr)
    3.52 +{
    3.53 +}
    3.54 +
    3.55 +Uint32
    3.56 +SDL_AtomicFetchThenIncrement32(Uint32 * ptr)
    3.57 +{
    3.58 +   return 0;
    3.59 +}
    3.60 +
    3.61 +Uint32
    3.62 +SDL_AtomicFetchThenDecrement32(Uint32 * ptr)
    3.63 +{
    3.64 +   return 0;
    3.65 +}
    3.66 +
    3.67 +Uint32
    3.68 +SDL_AtomicFetchThenAdd32(Uint32 * ptr, Uint32 value)
    3.69 +{
    3.70 +   return 0;
    3.71 +}
    3.72 +
    3.73 +Uint32
    3.74 +SDL_AtomicFetchThenSubtract32(Uint32 * ptr, Uint32 value)
    3.75 +{
    3.76 +   return 0;
    3.77 +}
    3.78 +
    3.79 +Uint32
    3.80 +SDL_AtomicIncrementThenFetch32(Uint32 * ptr)
    3.81 +{
    3.82 +   return 0;
    3.83 +}
    3.84 +
    3.85 +Uint32
    3.86 +SDL_AtomicDecrementThenFetch32(Uint32 * ptr)
    3.87 +{
    3.88 +   return 0;
    3.89 +}
    3.90 +
    3.91 +Uint32
    3.92 +SDL_AtomicAddThenFetch32(Uint32 * ptr, Uint32 value)
    3.93 +{
    3.94 +   return 0;
    3.95 +}
    3.96 +
    3.97 +Uint32
    3.98 +SDL_AtomicSubtractThenFetch32(Uint32 * ptr, Uint32 value)
    3.99 +{
   3.100 +   return 0;
   3.101 +}
   3.102 +
   3.103 +
   3.104 +#ifdef SDL_HAS_64BIT_TYPE
   3.105 +
   3.106 +Uint64
   3.107 +SDL_AtomicExchange64(Uint64 * ptr, Uint64 value)
   3.108 +{
   3.109 +   return 0;
   3.110 +}
   3.111 +
   3.112 +SDL_bool
   3.113 +SDL_AtomicCompareThenSet64(Uint64 * ptr,
   3.114 +Uint64 oldvalue, Uint64 newvalue)
   3.115 +{
   3.116 +   return SDL_false;
   3.117 +}
   3.118 +
   3.119 +SDL_bool
   3.120 +SDL_AtomicTestThenSet64(Uint64 * ptr)
   3.121 +{
   3.122 +   return SDL_false;
   3.123 +}
   3.124 +
   3.125 +void
   3.126 +SDL_AtomicClear64(Uint64 * ptr)
   3.127 +{
   3.128 +}
   3.129 +
   3.130 +Uint64
   3.131 +SDL_AtomicFetchThenIncrement64(Uint64 * ptr)
   3.132 +{
   3.133 +   return 0;
   3.134 +}
   3.135 +
   3.136 +Uint64
   3.137 +SDL_AtomicFetchThenDecrement64(Uint64 * ptr)
   3.138 +{
   3.139 +   return 0;
   3.140 +}
   3.141 +
   3.142 +Uint64
   3.143 +SDL_AtomicFetchThenAdd64(Uint64 * ptr, Uint64 value)
   3.144 +{
   3.145 +   return 0;
   3.146 +}
   3.147 +
   3.148 +Uint64
   3.149 +SDL_AtomicFetchThenSubtract64(Uint64 * ptr, Uint64 value)
   3.150 +{
   3.151 +   return 0;
   3.152 +}
   3.153 +
   3.154 +Uint64
   3.155 +SDL_AtomicIncrementThenFetch64(Uint64 * ptr)
   3.156 +{
   3.157 +   return 0;
   3.158 +}
   3.159 +
   3.160 +Uint64
   3.161 +SDL_AtomicDecrementThenFetch64(Uint64 * ptr)
   3.162 +{
   3.163 +   return 0;
   3.164 +}
   3.165 +
   3.166 +Uint64
   3.167 +SDL_AtomicAddThenFetch64(Uint64 * ptr, Uint64 value)
   3.168 +{
   3.169 +   return 0;
   3.170 +}
   3.171 +
   3.172 +Uint64
   3.173 +SDL_AtomicSubtractThenFetch64(Uint64 * ptr, Uint64 value)
   3.174 +{
   3.175 +   return 0;
   3.176 +}
   3.177 +
   3.178 +#endif
   3.179 +#endif
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/src/atomic/macosx/SDL_atomic.c	Wed Jun 24 20:04:08 2009 +0000
     4.3 @@ -0,0 +1,176 @@
     4.4 +/*
     4.5 +    SDL - Simple DirectMedia Layer
     4.6 +    Copyright (C) 1997-2009 Sam Lantinga
     4.7 +
     4.8 +    This library is free software; you can redistribute it and/or
     4.9 +    modify it under the terms of the GNU Lesser General Public
    4.10 +    License as published by the Free Software Foundation; either
    4.11 +    version 2.1 of the License, or (at your option) any later version.
    4.12 +
    4.13 +    This library is distributed in the hope that it will be useful,
    4.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    4.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    4.16 +    Lesser General Public License for more details.
    4.17 +
    4.18 +    You should have received a copy of the GNU Lesser General Public
    4.19 +    License along with this library; if not, write to the Free Software
    4.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    4.21 +
    4.22 +    Sam Lantinga
    4.23 +    slouken@libsdl.org
    4.24 +*/
    4.25 +
    4.26 +#ifdef SDL_ATOMIC_LINUX
    4.27 +
    4.28 +#include "SDL.h"
    4.29 +#include "SDL_config.h"
    4.30 +#include "SDL_atomic.h"
    4.31 +
    4.32 +Uint32
    4.33 +SDL_AtomicExchange32(Uint32 * ptr, Uint32 value)
    4.34 +{
    4.35 +   return 0;
    4.36 +}
    4.37 +
    4.38 +SDL_bool
    4.39 +SDL_AtomicCompareThenSet32(Uint32 * ptr, Uint32 oldvalue, Uint32 newvalue)
    4.40 +{
    4.41 +   return SDL_false;
    4.42 +}
    4.43 +
    4.44 +SDL_bool
    4.45 +SDL_AtomicTestThenSet32(Uint32 * ptr)
    4.46 +{
    4.47 +   return SDL_false;
    4.48 +}
    4.49 +
    4.50 +void
    4.51 +SDL_AtomicClear32(Uint32 * ptr)
    4.52 +{
    4.53 +}
    4.54 +
    4.55 +Uint32
    4.56 +SDL_AtomicFetchThenIncrement32(Uint32 * ptr)
    4.57 +{
    4.58 +   return 0;
    4.59 +}
    4.60 +
    4.61 +Uint32
    4.62 +SDL_AtomicFetchThenDecrement32(Uint32 * ptr)
    4.63 +{
    4.64 +   return 0;
    4.65 +}
    4.66 +
    4.67 +Uint32
    4.68 +SDL_AtomicFetchThenAdd32(Uint32 * ptr, Uint32 value)
    4.69 +{
    4.70 +   return 0;
    4.71 +}
    4.72 +
    4.73 +Uint32
    4.74 +SDL_AtomicFetchThenSubtract32(Uint32 * ptr, Uint32 value)
    4.75 +{
    4.76 +   return 0;
    4.77 +}
    4.78 +
    4.79 +Uint32
    4.80 +SDL_AtomicIncrementThenFetch32(Uint32 * ptr)
    4.81 +{
    4.82 +   return 0;
    4.83 +}
    4.84 +
    4.85 +Uint32
    4.86 +SDL_AtomicDecrementThenFetch32(Uint32 * ptr)
    4.87 +{
    4.88 +   return 0;
    4.89 +}
    4.90 +
    4.91 +Uint32
    4.92 +SDL_AtomicAddThenFetch32(Uint32 * ptr, Uint32 value)
    4.93 +{
    4.94 +   return 0;
    4.95 +}
    4.96 +
    4.97 +Uint32
    4.98 +SDL_AtomicSubtractThenFetch32(Uint32 * ptr, Uint32 value)
    4.99 +{
   4.100 +   return 0;
   4.101 +}
   4.102 +
   4.103 +
   4.104 +#ifdef SDL_HAS_64BIT_TYPE
   4.105 +
   4.106 +Uint64
   4.107 +SDL_AtomicExchange64(Uint64 * ptr, Uint64 value)
   4.108 +{
   4.109 +   return 0;
   4.110 +}
   4.111 +
   4.112 +SDL_bool
   4.113 +SDL_AtomicCompareThenSet64(Uint64 * ptr,
   4.114 +Uint64 oldvalue, Uint64 newvalue)
   4.115 +{
   4.116 +   return SDL_false;
   4.117 +}
   4.118 +
   4.119 +SDL_bool
   4.120 +SDL_AtomicTestThenSet64(Uint64 * ptr)
   4.121 +{
   4.122 +   return SDL_false;
   4.123 +}
   4.124 +
   4.125 +void
   4.126 +SDL_AtomicClear64(Uint64 * ptr)
   4.127 +{
   4.128 +}
   4.129 +
   4.130 +Uint64
   4.131 +SDL_AtomicFetchThenIncrement64(Uint64 * ptr)
   4.132 +{
   4.133 +   return 0;
   4.134 +}
   4.135 +
   4.136 +Uint64
   4.137 +SDL_AtomicFetchThenDecrement64(Uint64 * ptr)
   4.138 +{
   4.139 +   return 0;
   4.140 +}
   4.141 +
   4.142 +Uint64
   4.143 +SDL_AtomicFetchThenAdd64(Uint64 * ptr, Uint64 value)
   4.144 +{
   4.145 +   return 0;
   4.146 +}
   4.147 +
   4.148 +Uint64
   4.149 +SDL_AtomicFetchThenSubtract64(Uint64 * ptr, Uint64 value)
   4.150 +{
   4.151 +   return 0;
   4.152 +}
   4.153 +
   4.154 +Uint64
   4.155 +SDL_AtomicIncrementThenFetch64(Uint64 * ptr)
   4.156 +{
   4.157 +   return 0;
   4.158 +}
   4.159 +
   4.160 +Uint64
   4.161 +SDL_AtomicDecrementThenFetch64(Uint64 * ptr)
   4.162 +{
   4.163 +   return 0;
   4.164 +}
   4.165 +
   4.166 +Uint64
   4.167 +SDL_AtomicAddThenFetch64(Uint64 * ptr, Uint64 value)
   4.168 +{
   4.169 +   return 0;
   4.170 +}
   4.171 +
   4.172 +Uint64
   4.173 +SDL_AtomicSubtractThenFetch64(Uint64 * ptr, Uint64 value)
   4.174 +{
   4.175 +   return 0;
   4.176 +}
   4.177 +
   4.178 +#endif
   4.179 +#endif
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/src/atomic/win32/SDL_atomic.c	Wed Jun 24 20:04:08 2009 +0000
     5.3 @@ -0,0 +1,176 @@
     5.4 +/*
     5.5 +    SDL - Simple DirectMedia Layer
     5.6 +    Copyright (C) 1997-2009 Sam Lantinga
     5.7 +
     5.8 +    This library is free software; you can redistribute it and/or
     5.9 +    modify it under the terms of the GNU Lesser General Public
    5.10 +    License as published by the Free Software Foundation; either
    5.11 +    version 2.1 of the License, or (at your option) any later version.
    5.12 +
    5.13 +    This library is distributed in the hope that it will be useful,
    5.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    5.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    5.16 +    Lesser General Public License for more details.
    5.17 +
    5.18 +    You should have received a copy of the GNU Lesser General Public
    5.19 +    License along with this library; if not, write to the Free Software
    5.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    5.21 +
    5.22 +    Sam Lantinga
    5.23 +    slouken@libsdl.org
    5.24 +*/
    5.25 +
    5.26 +#ifdef SDL_ATOMIC_LINUX
    5.27 +
    5.28 +#include "SDL.h"
    5.29 +#include "SDL_config.h"
    5.30 +#include "SDL_atomic.h"
    5.31 +
    5.32 +Uint32
    5.33 +SDL_AtomicExchange32(Uint32 * ptr, Uint32 value)
    5.34 +{
    5.35 +   return 0;
    5.36 +}
    5.37 +
    5.38 +SDL_bool
    5.39 +SDL_AtomicCompareThenSet32(Uint32 * ptr, Uint32 oldvalue, Uint32 newvalue)
    5.40 +{
    5.41 +   return SDL_false;
    5.42 +}
    5.43 +
    5.44 +SDL_bool
    5.45 +SDL_AtomicTestThenSet32(Uint32 * ptr)
    5.46 +{
    5.47 +   return SDL_false;
    5.48 +}
    5.49 +
    5.50 +void
    5.51 +SDL_AtomicClear32(Uint32 * ptr)
    5.52 +{
    5.53 +}
    5.54 +
    5.55 +Uint32
    5.56 +SDL_AtomicFetchThenIncrement32(Uint32 * ptr)
    5.57 +{
    5.58 +   return 0;
    5.59 +}
    5.60 +
    5.61 +Uint32
    5.62 +SDL_AtomicFetchThenDecrement32(Uint32 * ptr)
    5.63 +{
    5.64 +   return 0;
    5.65 +}
    5.66 +
    5.67 +Uint32
    5.68 +SDL_AtomicFetchThenAdd32(Uint32 * ptr, Uint32 value)
    5.69 +{
    5.70 +   return 0;
    5.71 +}
    5.72 +
    5.73 +Uint32
    5.74 +SDL_AtomicFetchThenSubtract32(Uint32 * ptr, Uint32 value)
    5.75 +{
    5.76 +   return 0;
    5.77 +}
    5.78 +
    5.79 +Uint32
    5.80 +SDL_AtomicIncrementThenFetch32(Uint32 * ptr)
    5.81 +{
    5.82 +   return 0;
    5.83 +}
    5.84 +
    5.85 +Uint32
    5.86 +SDL_AtomicDecrementThenFetch32(Uint32 * ptr)
    5.87 +{
    5.88 +   return 0;
    5.89 +}
    5.90 +
    5.91 +Uint32
    5.92 +SDL_AtomicAddThenFetch32(Uint32 * ptr, Uint32 value)
    5.93 +{
    5.94 +   return 0;
    5.95 +}
    5.96 +
    5.97 +Uint32
    5.98 +SDL_AtomicSubtractThenFetch32(Uint32 * ptr, Uint32 value)
    5.99 +{
   5.100 +   return 0;
   5.101 +}
   5.102 +
   5.103 +
   5.104 +#ifdef SDL_HAS_64BIT_TYPE
   5.105 +
   5.106 +Uint64
   5.107 +SDL_AtomicExchange64(Uint64 * ptr, Uint64 value)
   5.108 +{
   5.109 +   return 0;
   5.110 +}
   5.111 +
   5.112 +SDL_bool
   5.113 +SDL_AtomicCompareThenSet64(Uint64 * ptr,
   5.114 +Uint64 oldvalue, Uint64 newvalue)
   5.115 +{
   5.116 +   return SDL_false;
   5.117 +}
   5.118 +
   5.119 +SDL_bool
   5.120 +SDL_AtomicTestThenSet64(Uint64 * ptr)
   5.121 +{
   5.122 +   return SDL_false;
   5.123 +}
   5.124 +
   5.125 +void
   5.126 +SDL_AtomicClear64(Uint64 * ptr)
   5.127 +{
   5.128 +}
   5.129 +
   5.130 +Uint64
   5.131 +SDL_AtomicFetchThenIncrement64(Uint64 * ptr)
   5.132 +{
   5.133 +   return 0;
   5.134 +}
   5.135 +
   5.136 +Uint64
   5.137 +SDL_AtomicFetchThenDecrement64(Uint64 * ptr)
   5.138 +{
   5.139 +   return 0;
   5.140 +}
   5.141 +
   5.142 +Uint64
   5.143 +SDL_AtomicFetchThenAdd64(Uint64 * ptr, Uint64 value)
   5.144 +{
   5.145 +   return 0;
   5.146 +}
   5.147 +
   5.148 +Uint64
   5.149 +SDL_AtomicFetchThenSubtract64(Uint64 * ptr, Uint64 value)
   5.150 +{
   5.151 +   return 0;
   5.152 +}
   5.153 +
   5.154 +Uint64
   5.155 +SDL_AtomicIncrementThenFetch64(Uint64 * ptr)
   5.156 +{
   5.157 +   return 0;
   5.158 +}
   5.159 +
   5.160 +Uint64
   5.161 +SDL_AtomicDecrementThenFetch64(Uint64 * ptr)
   5.162 +{
   5.163 +   return 0;
   5.164 +}
   5.165 +
   5.166 +Uint64
   5.167 +SDL_AtomicAddThenFetch64(Uint64 * ptr, Uint64 value)
   5.168 +{
   5.169 +   return 0;
   5.170 +}
   5.171 +
   5.172 +Uint64
   5.173 +SDL_AtomicSubtractThenFetch64(Uint64 * ptr, Uint64 value)
   5.174 +{
   5.175 +   return 0;
   5.176 +}
   5.177 +
   5.178 +#endif
   5.179 +#endif
     6.1 --- a/test/testatomic.c	Wed Jun 17 04:26:19 2009 +0000
     6.2 +++ b/test/testatomic.c	Wed Jun 24 20:04:08 2009 +0000
     6.3 @@ -3,62 +3,62 @@
     6.4  int
     6.5  main(int argc, char **argv)
     6.6  {
     6.7 -    int rv = 10;
     6.8 -    volatile int atomic;
     6.9 +/*     int rv = 10; */
    6.10 +/*     volatile int atomic; */
    6.11  
    6.12 -    SDL_atomic_int_set(&atomic, 10);
    6.13 -    if (SDL_atomic_int_get(&atomic) != 10)
    6.14 -        printf("Error: ");
    6.15 -    printf("SDL_atomic_int_set(atomic, 10): atomic-> %d\n",
    6.16 -           SDL_atomic_int_get(&atomic));
    6.17 +/*     SDL_atomic_int_set(&atomic, 10); */
    6.18 +/*     if (SDL_atomic_int_get(&atomic) != 10) */
    6.19 +/*         printf("Error: "); */
    6.20 +/*     printf("SDL_atomic_int_set(atomic, 10): atomic-> %d\n", */
    6.21 +/*            SDL_atomic_int_get(&atomic)); */
    6.22  
    6.23 -    SDL_atomic_int_add(&atomic, 10);
    6.24 -    if (SDL_atomic_int_get(&atomic) != 20)
    6.25 -        printf("Error: ");
    6.26 -    printf("SDL_atomic_int_add(atomic, 10): atomic-> %d\n",
    6.27 -           SDL_atomic_int_get(&atomic));
    6.28 +/*     SDL_atomic_int_add(&atomic, 10); */
    6.29 +/*     if (SDL_atomic_int_get(&atomic) != 20) */
    6.30 +/*         printf("Error: "); */
    6.31 +/*     printf("SDL_atomic_int_add(atomic, 10): atomic-> %d\n", */
    6.32 +/*            SDL_atomic_int_get(&atomic)); */
    6.33  
    6.34 -    rv = SDL_atomic_int_cmp_xchg(&atomic, 20, 30);
    6.35 -    if (rv != SDL_TRUE || SDL_atomic_int_get(&atomic) != 30)
    6.36 -        printf("Error: ");
    6.37 -    printf("SDL_atomic_int_cmp_xchg(atomic, 20, 30): rv-> %d, atomic-> %d\n",
    6.38 -           rv, SDL_atomic_int_get(&atomic));
    6.39 +/*     rv = SDL_atomic_int_cmp_xchg(&atomic, 20, 30); */
    6.40 +/*     if (rv != SDL_TRUE || SDL_atomic_int_get(&atomic) != 30) */
    6.41 +/*         printf("Error: "); */
    6.42 +/*     printf("SDL_atomic_int_cmp_xchg(atomic, 20, 30): rv-> %d, atomic-> %d\n", */
    6.43 +/*            rv, SDL_atomic_int_get(&atomic)); */
    6.44  
    6.45 -    rv = SDL_atomic_int_cmp_xchg(&atomic, 20, 30);
    6.46 -    if (rv != SDL_FALSE || SDL_atomic_int_get(&atomic) != 30)
    6.47 -        printf("Error: ");
    6.48 -    printf("SDL_atomic_int_cmp_xchg(atomic, 20, 40): rv-> %d, atomic-> %d\n",
    6.49 -           rv, SDL_atomic_int_get(&atomic));
    6.50 +/*     rv = SDL_atomic_int_cmp_xchg(&atomic, 20, 30); */
    6.51 +/*     if (rv != SDL_FALSE || SDL_atomic_int_get(&atomic) != 30) */
    6.52 +/*         printf("Error: "); */
    6.53 +/*     printf("SDL_atomic_int_cmp_xchg(atomic, 20, 40): rv-> %d, atomic-> %d\n", */
    6.54 +/*            rv, SDL_atomic_int_get(&atomic)); */
    6.55  
    6.56 -    rv = SDL_atomic_int_xchg_add(&atomic, 10);
    6.57 -    if (rv != 30 || SDL_atomic_int_get(&atomic) != 40)
    6.58 -        printf("Error: ");
    6.59 -    printf("SDL_atomic_int_xchg_add(atomic, 10): rv-> %d, atomic-> %d\n",
    6.60 -           rv, SDL_atomic_int_get(&atomic));
    6.61 +/*     rv = SDL_atomic_int_xchg_add(&atomic, 10); */
    6.62 +/*     if (rv != 30 || SDL_atomic_int_get(&atomic) != 40) */
    6.63 +/*         printf("Error: "); */
    6.64 +/*     printf("SDL_atomic_int_xchg_add(atomic, 10): rv-> %d, atomic-> %d\n", */
    6.65 +/*            rv, SDL_atomic_int_get(&atomic)); */
    6.66  
    6.67 -    SDL_atomic_int_inc(&atomic);
    6.68 -    if (SDL_atomic_int_get(&atomic) != 41)
    6.69 -        printf("Error: ");
    6.70 -    printf("SDL_atomic_int_inc(atomic): atomic-> %d\n",
    6.71 -           SDL_atomic_int_get(&atomic));
    6.72 +/*     SDL_atomic_int_inc(&atomic); */
    6.73 +/*     if (SDL_atomic_int_get(&atomic) != 41) */
    6.74 +/*         printf("Error: "); */
    6.75 +/*     printf("SDL_atomic_int_inc(atomic): atomic-> %d\n", */
    6.76 +/*            SDL_atomic_int_get(&atomic)); */
    6.77  
    6.78 -    rv = SDL_atomic_int_dec_test(&atomic);
    6.79 -    if (rv != SDL_FALSE || SDL_atomic_int_get(&atomic) != 40)
    6.80 -        printf("Error: ");
    6.81 -    printf("SDL_atomic_int_dec_test(atomic): rv-> %d, atomic-> %d\n",
    6.82 -           rv, SDL_atomic_int_get(&atomic));
    6.83 +/*     rv = SDL_atomic_int_dec_test(&atomic); */
    6.84 +/*     if (rv != SDL_FALSE || SDL_atomic_int_get(&atomic) != 40) */
    6.85 +/*         printf("Error: "); */
    6.86 +/*     printf("SDL_atomic_int_dec_test(atomic): rv-> %d, atomic-> %d\n", */
    6.87 +/*            rv, SDL_atomic_int_get(&atomic)); */
    6.88  
    6.89 -    SDL_atomic_int_set(&atomic, 1);
    6.90 -    if (SDL_atomic_int_get(&atomic) != 1)
    6.91 -        printf("Error: ");
    6.92 -    printf("SDL_atomic_int_set(atomic, 1): atomic-> %d\n",
    6.93 -           SDL_atomic_int_get(&atomic));
    6.94 +/*     SDL_atomic_int_set(&atomic, 1); */
    6.95 +/*     if (SDL_atomic_int_get(&atomic) != 1) */
    6.96 +/*         printf("Error: "); */
    6.97 +/*     printf("SDL_atomic_int_set(atomic, 1): atomic-> %d\n", */
    6.98 +/*            SDL_atomic_int_get(&atomic)); */
    6.99  
   6.100 -    rv = SDL_atomic_int_dec_test(&atomic);
   6.101 -    if (rv != SDL_TRUE || SDL_atomic_int_get(&atomic) != 0)
   6.102 -        printf("Error: ");
   6.103 -    printf("SDL_atomic_int_dec_test(atomic): rv-> %d, atomic-> %d\n",
   6.104 -           rv, SDL_atomic_int_get(&atomic));
   6.105 +/*     rv = SDL_atomic_int_dec_test(&atomic); */
   6.106 +/*     if (rv != SDL_TRUE || SDL_atomic_int_get(&atomic) != 0) */
   6.107 +/*         printf("Error: "); */
   6.108 +/*     printf("SDL_atomic_int_dec_test(atomic): rv-> %d, atomic-> %d\n", */
   6.109 +/*            rv, SDL_atomic_int_get(&atomic)); */
   6.110  
   6.111      return 0;
   6.112  }