include/SDL_atomic.h
changeset 3216 48a80f2a7ff2
parent 3202 3aa519a5c676
child 3237 916f396fe65d
     1.1 --- a/include/SDL_atomic.h	Tue Jul 07 14:02:57 2009 +0000
     1.2 +++ b/include/SDL_atomic.h	Thu Jul 09 21:31:27 2009 +0000
     1.3 @@ -54,40 +54,40 @@
     1.4  
     1.5  /* 8 bit atomic operations */
     1.6  
     1.7 -extern DECLSPEC Uint8 SDLCALL SDL_AtomicExchange8(Uint8 * ptr, Uint8 value);
     1.8 -extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCompareThenSet8(Uint8 * ptr,
     1.9 +extern DECLSPEC Uint8 SDLCALL SDL_AtomicExchange8(volatile Uint8 * ptr, Uint8 value);
    1.10 +extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCompareThenSet8(volatile Uint8 * ptr,
    1.11                                                              Uint8 oldvalue, Uint8 newvalue);
    1.12 -extern DECLSPEC SDL_bool SDLCALL SDL_AtomicTestThenSet8(Uint8 * ptr);
    1.13 -extern DECLSPEC void SDLCALL SDL_AtomicClear8(Uint8 * ptr);
    1.14 -extern DECLSPEC Uint8 SDLCALL SDL_AtomicFetchThenIncrement8(Uint8 * ptr);
    1.15 -extern DECLSPEC Uint8 SDLCALL SDL_AtomicFetchThenDecrement8(Uint8 * ptr);
    1.16 -extern DECLSPEC Uint8 SDLCALL SDL_AtomicFetchThenAdd8(Uint8 * ptr, Uint8 value);
    1.17 -extern DECLSPEC Uint8 SDLCALL SDL_AtomicFetchThenSubtract8(Uint8 * ptr, Uint8 value);
    1.18 -extern DECLSPEC Uint8 SDLCALL SDL_AtomicIncrementThenFetch8(Uint8 * ptr);
    1.19 -extern DECLSPEC Uint8 SDLCALL SDL_AtomicDecrementThenFetch8(Uint8 * ptr);
    1.20 -extern DECLSPEC Uint8 SDLCALL SDL_AtomicAddThenFetch8(Uint8 * ptr, Uint8 value);
    1.21 -extern DECLSPEC Uint8 SDLCALL SDL_AtomicSubtractThenFetch8(Uint8 * ptr, Uint8 value);
    1.22 +extern DECLSPEC SDL_bool SDLCALL SDL_AtomicTestThenSet8(volatile Uint8 * ptr);
    1.23 +extern DECLSPEC void SDLCALL SDL_AtomicClear8(volatile Uint8 * ptr);
    1.24 +extern DECLSPEC Uint8 SDLCALL SDL_AtomicFetchThenIncrement8(volatile Uint8 * ptr);
    1.25 +extern DECLSPEC Uint8 SDLCALL SDL_AtomicFetchThenDecrement8(volatile Uint8 * ptr);
    1.26 +extern DECLSPEC Uint8 SDLCALL SDL_AtomicFetchThenAdd8(volatile Uint8 * ptr, Uint8 value);
    1.27 +extern DECLSPEC Uint8 SDLCALL SDL_AtomicFetchThenSubtract8(volatile Uint8 * ptr, Uint8 value);
    1.28 +extern DECLSPEC Uint8 SDLCALL SDL_AtomicIncrementThenFetch8(volatile Uint8 * ptr);
    1.29 +extern DECLSPEC Uint8 SDLCALL SDL_AtomicDecrementThenFetch8(volatile Uint8 * ptr);
    1.30 +extern DECLSPEC Uint8 SDLCALL SDL_AtomicAddThenFetch8(volatile Uint8 * ptr, Uint8 value);
    1.31 +extern DECLSPEC Uint8 SDLCALL SDL_AtomicSubtractThenFetch8(volatile Uint8 * ptr, Uint8 value);
    1.32  
    1.33  /* 16 bit atomic operations */
    1.34  
    1.35 -extern DECLSPEC Uint16 SDLCALL SDL_AtomicExchange16(Uint16 * ptr, Uint16 value);
    1.36 -extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCompareThenSet16(Uint16 * ptr,
    1.37 +extern DECLSPEC Uint16 SDLCALL SDL_AtomicExchange16(volatile Uint16 * ptr, Uint16 value);
    1.38 +extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCompareThenSet16(volatile Uint16 * ptr,
    1.39                                                              Uint16 oldvalue, Uint16 newvalue);
    1.40 -extern DECLSPEC SDL_bool SDLCALL SDL_AtomicTestThenSet16(Uint16 * ptr);
    1.41 -extern DECLSPEC void SDLCALL SDL_AtomicClear16(Uint16 * ptr);
    1.42 -extern DECLSPEC Uint16 SDLCALL SDL_AtomicFetchThenIncrement16(Uint16 * ptr);
    1.43 -extern DECLSPEC Uint16 SDLCALL SDL_AtomicFetchThenDecrement16(Uint16 * ptr);
    1.44 -extern DECLSPEC Uint16 SDLCALL SDL_AtomicFetchThenAdd16(Uint16 * ptr, Uint16 value);
    1.45 -extern DECLSPEC Uint16 SDLCALL SDL_AtomicFetchThenSubtract16(Uint16 * ptr, Uint16 value);
    1.46 -extern DECLSPEC Uint16 SDLCALL SDL_AtomicIncrementThenFetch16(Uint16 * ptr);
    1.47 -extern DECLSPEC Uint16 SDLCALL SDL_AtomicDecrementThenFetch16(Uint16 * ptr);
    1.48 -extern DECLSPEC Uint16 SDLCALL SDL_AtomicAddThenFetch16(Uint16 * ptr, Uint16 value);
    1.49 -extern DECLSPEC Uint16 SDLCALL SDL_AtomicSubtractThenFetch16(Uint16 * ptr, Uint16 value);
    1.50 +extern DECLSPEC SDL_bool SDLCALL SDL_AtomicTestThenSet16(volatile Uint16 * ptr);
    1.51 +extern DECLSPEC void SDLCALL SDL_AtomicClear16(volatile Uint16 * ptr);
    1.52 +extern DECLSPEC Uint16 SDLCALL SDL_AtomicFetchThenIncrement16(volatile Uint16 * ptr);
    1.53 +extern DECLSPEC Uint16 SDLCALL SDL_AtomicFetchThenDecrement16(volatile Uint16 * ptr);
    1.54 +extern DECLSPEC Uint16 SDLCALL SDL_AtomicFetchThenAdd16(volatile Uint16 * ptr, Uint16 value);
    1.55 +extern DECLSPEC Uint16 SDLCALL SDL_AtomicFetchThenSubtract16(volatile Uint16 * ptr, Uint16 value);
    1.56 +extern DECLSPEC Uint16 SDLCALL SDL_AtomicIncrementThenFetch16(volatile Uint16 * ptr);
    1.57 +extern DECLSPEC Uint16 SDLCALL SDL_AtomicDecrementThenFetch16(volatile Uint16 * ptr);
    1.58 +extern DECLSPEC Uint16 SDLCALL SDL_AtomicAddThenFetch16(volatile Uint16 * ptr, Uint16 value);
    1.59 +extern DECLSPEC Uint16 SDLCALL SDL_AtomicSubtractThenFetch16(volatile Uint16 * ptr, Uint16 value);
    1.60  
    1.61  /* 32 bit atomic operations */
    1.62  
    1.63  /**
    1.64 - * \fn int SDL_AtomicExchange32(Uint32 * ptr, Uint32 value)
    1.65 + * \fn int SDL_AtomicExchange32(volatile Uint32 * ptr, Uint32 value)
    1.66   *
    1.67   * \brief Atomically exchange two 32 bit values.
    1.68   *
    1.69 @@ -100,9 +100,9 @@
    1.70   * with value. This function can be used to implement SDL_TestThenSet.
    1.71   *
    1.72   */
    1.73 -extern DECLSPEC Uint32 SDLCALL SDL_AtomicExchange32(Uint32 * ptr, Uint32 value);
    1.74 +extern DECLSPEC Uint32 SDLCALL SDL_AtomicExchange32(volatile Uint32 * ptr, Uint32 value);
    1.75  /**
    1.76 - * \fn int SDL_AtomicCompareThenSet32(Uint32 * ptr, Uint32 oldvalue, Uint32 newvalue)
    1.77 + * \fn int SDL_AtomicCompareThenSet32(volatile Uint32 * ptr, Uint32 oldvalue, Uint32 newvalue)
    1.78   *
    1.79   * \brief If *ptr == oldvalue then replace the contents of *ptr by new value. 
    1.80   *
    1.81 @@ -113,10 +113,10 @@
    1.82   * \param newvalue is value to be stored at *ptr.
    1.83   *
    1.84   */
    1.85 -extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCompareThenSet32(Uint32 * ptr,
    1.86 +extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCompareThenSet32(volatile Uint32 * ptr,
    1.87                                                              Uint32 oldvalue, Uint32 newvalue);
    1.88  /**
    1.89 - * \fn  SDL_bool SDL_AtomicTestThenSet32(Uint32 * ptr);
    1.90 + * \fn  SDL_bool SDL_AtomicTestThenSet32(volatile Uint32 * ptr);
    1.91   *
    1.92   * \brief Check to see if *ptr == 0 and set it to non-zero.
    1.93   *
    1.94 @@ -126,18 +126,18 @@
    1.95   * \param ptr points to the value to be tested and set.
    1.96   *
    1.97   */
    1.98 -extern DECLSPEC SDL_bool SDLCALL SDL_AtomicTestThenSet32(Uint32 * ptr);
    1.99 +extern DECLSPEC SDL_bool SDLCALL SDL_AtomicTestThenSet32(volatile Uint32 * ptr);
   1.100  /**
   1.101 - * \fn  void SDL_AtomicClear32(Uint32 * ptr);
   1.102 + * \fn  void SDL_AtomicClear32(volatile Uint32 * ptr);
   1.103   *
   1.104   * \brief set the value pointed to by ptr to be zero.
   1.105   *
   1.106   * \param ptr address of the value to be set to zero
   1.107   *
   1.108   */
   1.109 -extern DECLSPEC void SDLCALL SDL_AtomicClear32(Uint32 * ptr);
   1.110 +extern DECLSPEC void SDLCALL SDL_AtomicClear32(volatile Uint32 * ptr);
   1.111  /**
   1.112 - * \fn  Uint32 SDL_AtomicFetchThenIncrement32(Uint32 * ptr);
   1.113 + * \fn  Uint32 SDL_AtomicFetchThenIncrement32(volatile Uint32 * ptr);
   1.114   *
   1.115   * \brief fetch the current value of *ptr and then increment that
   1.116   * value in place.
   1.117 @@ -147,9 +147,9 @@
   1.118   * \param ptr address of the value to fetch and increment
   1.119   *
   1.120   */
   1.121 -extern DECLSPEC Uint32 SDLCALL SDL_AtomicFetchThenIncrement32(Uint32 * ptr);
   1.122 +extern DECLSPEC Uint32 SDLCALL SDL_AtomicFetchThenIncrement32(volatile Uint32 * ptr);
   1.123  /**
   1.124 - * \fn  Uint32 SDL_AtomicFetchThenDecrement32(Uint32 * ptr);
   1.125 + * \fn  Uint32 SDL_AtomicFetchThenDecrement32(volatile Uint32 * ptr);
   1.126   *
   1.127   * \brief fetch *ptr and then decrement the value in place.
   1.128   *
   1.129 @@ -158,9 +158,9 @@
   1.130   * \param ptr address of the value to fetch and drement
   1.131   *
   1.132   */
   1.133 -extern DECLSPEC Uint32 SDLCALL SDL_AtomicFetchThenDecrement32(Uint32 * ptr);
   1.134 +extern DECLSPEC Uint32 SDLCALL SDL_AtomicFetchThenDecrement32(volatile Uint32 * ptr);
   1.135  /**
   1.136 - * \fn  Uint32 SDL_AtomicFetchThenAdd32(Uint32 * ptr, Uint32 value);
   1.137 + * \fn  Uint32 SDL_AtomicFetchThenAdd32(volatile Uint32 * ptr, Uint32 value);
   1.138   *
   1.139   * \brief fetch the current value at ptr and then add value to *ptr.
   1.140   *
   1.141 @@ -170,9 +170,9 @@
   1.142   * \param value the value to add to *ptr. 
   1.143   *
   1.144   */
   1.145 -extern DECLSPEC Uint32 SDLCALL SDL_AtomicFetchThenAdd32(Uint32 * ptr, Uint32 value);
   1.146 +extern DECLSPEC Uint32 SDLCALL SDL_AtomicFetchThenAdd32(volatile Uint32 * ptr, Uint32 value);
   1.147  /**
   1.148 - * \fn  Uint32 SDL_AtomicFetchThenSubtract32(Uint32 * ptr, Uint32 value);
   1.149 + * \fn  Uint32 SDL_AtomicFetchThenSubtract32(volatile Uint32 * ptr, Uint32 value);
   1.150   *
   1.151   * \brief Fetch *ptr and then subtract value from it.
   1.152   *
   1.153 @@ -182,9 +182,9 @@
   1.154   * \param value the value to subtract from *ptr.
   1.155   *
   1.156   */
   1.157 -extern DECLSPEC Uint32 SDLCALL SDL_AtomicFetchThenSubtract32(Uint32 * ptr, Uint32 value);
   1.158 +extern DECLSPEC Uint32 SDLCALL SDL_AtomicFetchThenSubtract32(volatile Uint32 * ptr, Uint32 value);
   1.159  /**
   1.160 - * \fn  Uint32 SDL_AtomicIncrementThenFetch32(Uint32 * ptr);
   1.161 + * \fn  Uint32 SDL_AtomicIncrementThenFetch32(volatile Uint32 * ptr);
   1.162   *
   1.163   * \brief Add one to the data pointed to by ptr and return that value.
   1.164   *
   1.165 @@ -193,9 +193,9 @@
   1.166   * \param ptr address of the data to increment.
   1.167   *
   1.168   */
   1.169 -extern DECLSPEC Uint32 SDLCALL SDL_AtomicIncrementThenFetch32(Uint32 * ptr);
   1.170 +extern DECLSPEC Uint32 SDLCALL SDL_AtomicIncrementThenFetch32(volatile Uint32 * ptr);
   1.171  /**
   1.172 - * \fn  Uint32 SDL_AtomicDecrementThenFetch32(Uint32 * ptr);
   1.173 + * \fn  Uint32 SDL_AtomicDecrementThenFetch32(volatile Uint32 * ptr);
   1.174   *
   1.175   * \brief Subtract one from data pointed to by ptr and return the new value.
   1.176   *
   1.177 @@ -204,9 +204,9 @@
   1.178   * \param ptr The address of the data to decrement.
   1.179   *
   1.180   */
   1.181 -extern DECLSPEC Uint32 SDLCALL SDL_AtomicDecrementThenFetch32(Uint32 * ptr);
   1.182 +extern DECLSPEC Uint32 SDLCALL SDL_AtomicDecrementThenFetch32(volatile Uint32 * ptr);
   1.183  /**
   1.184 - * \fn  Uint32 SDL_AtomicAddThenFetch32(Uint32 * ptr, Uint32 value);
   1.185 + * \fn  Uint32 SDL_AtomicAddThenFetch32(volatile Uint32 * ptr, Uint32 value);
   1.186   *
   1.187   * \brief Add value to the data pointed to by ptr and return result.
   1.188   *
   1.189 @@ -216,9 +216,9 @@
   1.190   * \param value The value to be added.
   1.191   *
   1.192   */
   1.193 -extern DECLSPEC Uint32 SDLCALL SDL_AtomicAddThenFetch32(Uint32 * ptr, Uint32 value);
   1.194 +extern DECLSPEC Uint32 SDLCALL SDL_AtomicAddThenFetch32(volatile Uint32 * ptr, Uint32 value);
   1.195  /**
   1.196 - * \fn  Uint32 SDL_AtomicSubtractThenFetch32(Uint32 * ptr, Uint32 value);
   1.197 + * \fn  Uint32 SDL_AtomicSubtractThenFetch32(volatile Uint32 * ptr, Uint32 value);
   1.198   *
   1.199   * \brief Subtract value from the data pointed to by ptr and return the result.
   1.200   *
   1.201 @@ -228,24 +228,24 @@
   1.202   * \param value The value to be subtracted.
   1.203   *
   1.204   */
   1.205 -extern DECLSPEC Uint32 SDLCALL SDL_AtomicSubtractThenFetch32(Uint32 * ptr, Uint32 value);
   1.206 +extern DECLSPEC Uint32 SDLCALL SDL_AtomicSubtractThenFetch32(volatile Uint32 * ptr, Uint32 value);
   1.207  
   1.208  /* 64 bit atomic operations */
   1.209  #ifdef SDL_HAS_64BIT_TYPE
   1.210  
   1.211 -extern DECLSPEC Uint64 SDLCALL SDL_AtomicExchange64(Uint64 * ptr, Uint64 value);
   1.212 -extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCompareThenSet64(Uint64 * ptr,
   1.213 +extern DECLSPEC Uint64 SDLCALL SDL_AtomicExchange64(volatile Uint64 * ptr, Uint64 value);
   1.214 +extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCompareThenSet64(volatile Uint64 * ptr,
   1.215                                                              Uint64 oldvalue, Uint64 newvalue);
   1.216 -extern DECLSPEC SDL_bool SDLCALL SDL_AtomicTestThenSet64(Uint64 * ptr);
   1.217 -extern DECLSPEC void SDLCALL SDL_AtomicClear64(Uint64 * ptr);
   1.218 -extern DECLSPEC Uint64 SDLCALL SDL_AtomicFetchThenIncrement64(Uint64 * ptr);
   1.219 -extern DECLSPEC Uint64 SDLCALL SDL_AtomicFetchThenDecrement64(Uint64 * ptr);
   1.220 -extern DECLSPEC Uint64 SDLCALL SDL_AtomicFetchThenAdd64(Uint64 * ptr, Uint64 value);
   1.221 -extern DECLSPEC Uint64 SDLCALL SDL_AtomicFetchThenSubtract64(Uint64 * ptr, Uint64 value);
   1.222 -extern DECLSPEC Uint64 SDLCALL SDL_AtomicIncrementThenFetch64(Uint64 * ptr);
   1.223 -extern DECLSPEC Uint64 SDLCALL SDL_AtomicDecrementThenFetch64(Uint64 * ptr);
   1.224 -extern DECLSPEC Uint64 SDLCALL SDL_AtomicAddThenFetch64(Uint64 * ptr, Uint64 value);
   1.225 -extern DECLSPEC Uint64 SDLCALL SDL_AtomicSubtractThenFetch64(Uint64 * ptr, Uint64 value);
   1.226 +extern DECLSPEC SDL_bool SDLCALL SDL_AtomicTestThenSet64(volatile Uint64 * ptr);
   1.227 +extern DECLSPEC void SDLCALL SDL_AtomicClear64(volatile Uint64 * ptr);
   1.228 +extern DECLSPEC Uint64 SDLCALL SDL_AtomicFetchThenIncrement64(volatile Uint64 * ptr);
   1.229 +extern DECLSPEC Uint64 SDLCALL SDL_AtomicFetchThenDecrement64(volatile Uint64 * ptr);
   1.230 +extern DECLSPEC Uint64 SDLCALL SDL_AtomicFetchThenAdd64(volatile Uint64 * ptr, Uint64 value);
   1.231 +extern DECLSPEC Uint64 SDLCALL SDL_AtomicFetchThenSubtract64(volatile Uint64 * ptr, Uint64 value);
   1.232 +extern DECLSPEC Uint64 SDLCALL SDL_AtomicIncrementThenFetch64(volatile Uint64 * ptr);
   1.233 +extern DECLSPEC Uint64 SDLCALL SDL_AtomicDecrementThenFetch64(volatile Uint64 * ptr);
   1.234 +extern DECLSPEC Uint64 SDLCALL SDL_AtomicAddThenFetch64(volatile Uint64 * ptr, Uint64 value);
   1.235 +extern DECLSPEC Uint64 SDLCALL SDL_AtomicSubtractThenFetch64(volatile Uint64 * ptr, Uint64 value);
   1.236  #endif /*  SDL_HAS_64BIT_TYPE */
   1.237  
   1.238  /* Ends C function definitions when using C++ */