Start of redesign, getting rid of 8 and 16 bit operations in .h and test files.
authorBob Pendleton <bob@pendleton.com>
Tue, 11 Aug 2009 21:27:19 +0000
changeset 3237916f396fe65d
parent 3236 d7497988b677
child 3238 96492d29034a
Start of redesign, getting rid of 8 and 16 bit operations in .h and test files.
include/SDL_atomic.h
test/testatomic.c
     1.1 --- a/include/SDL_atomic.h	Tue Aug 11 21:15:18 2009 +0000
     1.2 +++ b/include/SDL_atomic.h	Tue Aug 11 21:27:19 2009 +0000
     1.3 @@ -52,38 +52,6 @@
     1.4  
     1.5  /* Function prototypes */
     1.6  
     1.7 -/* 8 bit atomic operations */
     1.8 -
     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(volatile Uint8 * ptr);
    1.13 -extern DECLSPEC void SDLCALL SDL_AtomicClear8(volatile Uint8 * ptr);
    1.14 -extern DECLSPEC Uint8 SDLCALL SDL_AtomicFetchThenIncrement8(volatile Uint8 * ptr);
    1.15 -extern DECLSPEC Uint8 SDLCALL SDL_AtomicFetchThenDecrement8(volatile Uint8 * ptr);
    1.16 -extern DECLSPEC Uint8 SDLCALL SDL_AtomicFetchThenAdd8(volatile Uint8 * ptr, Uint8 value);
    1.17 -extern DECLSPEC Uint8 SDLCALL SDL_AtomicFetchThenSubtract8(volatile Uint8 * ptr, Uint8 value);
    1.18 -extern DECLSPEC Uint8 SDLCALL SDL_AtomicIncrementThenFetch8(volatile Uint8 * ptr);
    1.19 -extern DECLSPEC Uint8 SDLCALL SDL_AtomicDecrementThenFetch8(volatile Uint8 * ptr);
    1.20 -extern DECLSPEC Uint8 SDLCALL SDL_AtomicAddThenFetch8(volatile Uint8 * ptr, Uint8 value);
    1.21 -extern DECLSPEC Uint8 SDLCALL SDL_AtomicSubtractThenFetch8(volatile Uint8 * ptr, Uint8 value);
    1.22 -
    1.23 -/* 16 bit atomic operations */
    1.24 -
    1.25 -extern DECLSPEC Uint16 SDLCALL SDL_AtomicExchange16(volatile Uint16 * ptr, Uint16 value);
    1.26 -extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCompareThenSet16(volatile Uint16 * ptr,
    1.27 -                                                            Uint16 oldvalue, Uint16 newvalue);
    1.28 -extern DECLSPEC SDL_bool SDLCALL SDL_AtomicTestThenSet16(volatile Uint16 * ptr);
    1.29 -extern DECLSPEC void SDLCALL SDL_AtomicClear16(volatile Uint16 * ptr);
    1.30 -extern DECLSPEC Uint16 SDLCALL SDL_AtomicFetchThenIncrement16(volatile Uint16 * ptr);
    1.31 -extern DECLSPEC Uint16 SDLCALL SDL_AtomicFetchThenDecrement16(volatile Uint16 * ptr);
    1.32 -extern DECLSPEC Uint16 SDLCALL SDL_AtomicFetchThenAdd16(volatile Uint16 * ptr, Uint16 value);
    1.33 -extern DECLSPEC Uint16 SDLCALL SDL_AtomicFetchThenSubtract16(volatile Uint16 * ptr, Uint16 value);
    1.34 -extern DECLSPEC Uint16 SDLCALL SDL_AtomicIncrementThenFetch16(volatile Uint16 * ptr);
    1.35 -extern DECLSPEC Uint16 SDLCALL SDL_AtomicDecrementThenFetch16(volatile Uint16 * ptr);
    1.36 -extern DECLSPEC Uint16 SDLCALL SDL_AtomicAddThenFetch16(volatile Uint16 * ptr, Uint16 value);
    1.37 -extern DECLSPEC Uint16 SDLCALL SDL_AtomicSubtractThenFetch16(volatile Uint16 * ptr, Uint16 value);
    1.38 -
    1.39  /* 32 bit atomic operations */
    1.40  
    1.41  /**
    1.42 @@ -101,6 +69,7 @@
    1.43   *
    1.44   */
    1.45  extern DECLSPEC Uint32 SDLCALL SDL_AtomicExchange32(volatile Uint32 * ptr, Uint32 value);
    1.46 +
    1.47  /**
    1.48   * \fn int SDL_AtomicCompareThenSet32(volatile Uint32 * ptr, Uint32 oldvalue, Uint32 newvalue)
    1.49   *
    1.50 @@ -127,6 +96,7 @@
    1.51   *
    1.52   */
    1.53  extern DECLSPEC SDL_bool SDLCALL SDL_AtomicTestThenSet32(volatile Uint32 * ptr);
    1.54 +
    1.55  /**
    1.56   * \fn  void SDL_AtomicClear32(volatile Uint32 * ptr);
    1.57   *
    1.58 @@ -136,6 +106,7 @@
    1.59   *
    1.60   */
    1.61  extern DECLSPEC void SDLCALL SDL_AtomicClear32(volatile Uint32 * ptr);
    1.62 +
    1.63  /**
    1.64   * \fn  Uint32 SDL_AtomicFetchThenIncrement32(volatile Uint32 * ptr);
    1.65   *
    1.66 @@ -148,6 +119,7 @@
    1.67   *
    1.68   */
    1.69  extern DECLSPEC Uint32 SDLCALL SDL_AtomicFetchThenIncrement32(volatile Uint32 * ptr);
    1.70 +
    1.71  /**
    1.72   * \fn  Uint32 SDL_AtomicFetchThenDecrement32(volatile Uint32 * ptr);
    1.73   *
    1.74 @@ -159,6 +131,7 @@
    1.75   *
    1.76   */
    1.77  extern DECLSPEC Uint32 SDLCALL SDL_AtomicFetchThenDecrement32(volatile Uint32 * ptr);
    1.78 +
    1.79  /**
    1.80   * \fn  Uint32 SDL_AtomicFetchThenAdd32(volatile Uint32 * ptr, Uint32 value);
    1.81   *
    1.82 @@ -171,6 +144,7 @@
    1.83   *
    1.84   */
    1.85  extern DECLSPEC Uint32 SDLCALL SDL_AtomicFetchThenAdd32(volatile Uint32 * ptr, Uint32 value);
    1.86 +
    1.87  /**
    1.88   * \fn  Uint32 SDL_AtomicFetchThenSubtract32(volatile Uint32 * ptr, Uint32 value);
    1.89   *
    1.90 @@ -183,6 +157,7 @@
    1.91   *
    1.92   */
    1.93  extern DECLSPEC Uint32 SDLCALL SDL_AtomicFetchThenSubtract32(volatile Uint32 * ptr, Uint32 value);
    1.94 +
    1.95  /**
    1.96   * \fn  Uint32 SDL_AtomicIncrementThenFetch32(volatile Uint32 * ptr);
    1.97   *
    1.98 @@ -194,6 +169,7 @@
    1.99   *
   1.100   */
   1.101  extern DECLSPEC Uint32 SDLCALL SDL_AtomicIncrementThenFetch32(volatile Uint32 * ptr);
   1.102 +
   1.103  /**
   1.104   * \fn  Uint32 SDL_AtomicDecrementThenFetch32(volatile Uint32 * ptr);
   1.105   *
   1.106 @@ -205,6 +181,7 @@
   1.107   *
   1.108   */
   1.109  extern DECLSPEC Uint32 SDLCALL SDL_AtomicDecrementThenFetch32(volatile Uint32 * ptr);
   1.110 +
   1.111  /**
   1.112   * \fn  Uint32 SDL_AtomicAddThenFetch32(volatile Uint32 * ptr, Uint32 value);
   1.113   *
   1.114 @@ -217,6 +194,7 @@
   1.115   *
   1.116   */
   1.117  extern DECLSPEC Uint32 SDLCALL SDL_AtomicAddThenFetch32(volatile Uint32 * ptr, Uint32 value);
   1.118 +
   1.119  /**
   1.120   * \fn  Uint32 SDL_AtomicSubtractThenFetch32(volatile Uint32 * ptr, Uint32 value);
   1.121   *
     2.1 --- a/test/testatomic.c	Tue Aug 11 21:15:18 2009 +0000
     2.2 +++ b/test/testatomic.c	Tue Aug 11 21:27:19 2009 +0000
     2.3 @@ -23,12 +23,6 @@
     2.4  main(int argc, char **argv)
     2.5  {
     2.6  
     2.7 -   volatile Uint8 val8 = 0;
     2.8 -   Uint8 ret8 = 0;
     2.9 -
    2.10 -   volatile Uint16 val16 = 0;
    2.11 -   Uint16 ret16 = 0;
    2.12 -
    2.13     volatile Uint32 val32 = 0;
    2.14     Uint32 ret32 = 0;
    2.15  
    2.16 @@ -37,102 +31,6 @@
    2.17  
    2.18     SDL_bool tfret = SDL_FALSE;
    2.19  
    2.20 -
    2.21 -   printf("8 bit -----------------------------------------\n\n");
    2.22 -
    2.23 -   ret8 = SDL_AtomicExchange8(&val8, 10);
    2.24 -   printf("Exchange8           ret=%d val=%d\n", ret8, val8);
    2.25 -   ret8 = SDL_AtomicExchange8(&val8, 0);
    2.26 -   printf("Exchange8           ret=%d val=%d\n", ret8, val8);
    2.27 -
    2.28 -   val8 = 10;
    2.29 -   tfret = SDL_AtomicCompareThenSet8(&val8, 10, 20);
    2.30 -   printf("CompareThenSet8     tfret=%s val=%d\n", tf(tfret), val8);
    2.31 -   val8 = 10;
    2.32 -   tfret = SDL_AtomicCompareThenSet8(&val8, 0, 20);
    2.33 -   printf("CompareThenSet8     tfret=%s val=%d\n", tf(tfret), val8);
    2.34 -
    2.35 -   val8 = 0;
    2.36 -   tfret = SDL_AtomicTestThenSet8(&val8);
    2.37 -   printf("TestThenSet8        tfret=%s val=%d\n", tf(tfret), val8);
    2.38 -   tfret = SDL_AtomicTestThenSet8(&val8);
    2.39 -   printf("TestThenSet8        tfret=%s val=%d\n", tf(tfret), val8);
    2.40 -
    2.41 -   SDL_AtomicClear8(&val8);
    2.42 -   printf("Clear8              val=%d\n", val8);
    2.43 -
    2.44 -   ret8 = SDL_AtomicFetchThenIncrement8(&val8);
    2.45 -   printf("FetchThenIncrement8 ret=%d val=%d\n", ret8, val8);
    2.46 -
    2.47 -   ret8 = SDL_AtomicFetchThenDecrement8(&val8);
    2.48 -   printf("FetchThenDecrement8 ret=%d val=%d\n", ret8, val8);
    2.49 -
    2.50 -   ret8 = SDL_AtomicFetchThenAdd8(&val8, 10);
    2.51 -   printf("FetchThenAdd8       ret=%d val=%d\n", ret8, val8);
    2.52 -
    2.53 -   ret8 = SDL_AtomicFetchThenSubtract8(&val8, 10);
    2.54 -   printf("FetchThenSubtract8  ret=%d val=%d\n", ret8, val8);
    2.55 -
    2.56 -   ret8 = SDL_AtomicIncrementThenFetch8(&val8);
    2.57 -   printf("IncrementThenFetch8 ret=%d val=%d\n", ret8, val8);
    2.58 -
    2.59 -   ret8 = SDL_AtomicDecrementThenFetch8(&val8);
    2.60 -   printf("DecrementThenFetch8 ret=%d val=%d\n", ret8, val8);
    2.61 -
    2.62 -   ret8 = SDL_AtomicAddThenFetch8(&val8, 10);
    2.63 -   printf("AddThenFetch8       ret=%d val=%d\n", ret8, val8);
    2.64 -
    2.65 -   ret8 = SDL_AtomicSubtractThenFetch8(&val8, 10);
    2.66 -   printf("SubtractThenFetch8  ret=%d val=%d\n", ret8, val8);
    2.67 -
    2.68 -
    2.69 -   printf("16 bit -----------------------------------------\n\n");
    2.70 -
    2.71 -   ret16 = SDL_AtomicExchange16(&val16, 10);
    2.72 -   printf("Exchange16           ret=%d val=%d\n", ret16, val16);
    2.73 -   ret16 = SDL_AtomicExchange16(&val16, 0);
    2.74 -   printf("Exchange16           ret=%d val=%d\n", ret16, val16);
    2.75 -
    2.76 -   val16 = 10;
    2.77 -   tfret = SDL_AtomicCompareThenSet16(&val16, 10, 20);
    2.78 -   printf("CompareThenSet16     tfret=%s val=%d\n", tf(tfret), val16);
    2.79 -   val16 = 10;
    2.80 -   tfret = SDL_AtomicCompareThenSet16(&val16, 0, 20);
    2.81 -   printf("CompareThenSet16     tfret=%s val=%d\n", tf(tfret), val16);
    2.82 -
    2.83 -   val16 = 0;
    2.84 -   tfret = SDL_AtomicTestThenSet16(&val16);
    2.85 -   printf("TestThenSet16        tfret=%s val=%d\n", tf(tfret), val16);
    2.86 -   tfret = SDL_AtomicTestThenSet16(&val16);
    2.87 -   printf("TestThenSet16        tfret=%s val=%d\n", tf(tfret), val16);
    2.88 -
    2.89 -   SDL_AtomicClear16(&val16);
    2.90 -   printf("Clear16              val=%d\n", val16);
    2.91 -
    2.92 -   ret16 = SDL_AtomicFetchThenIncrement16(&val16);
    2.93 -   printf("FetchThenIncrement16 ret=%d val=%d\n", ret16, val16);
    2.94 -
    2.95 -   ret16 = SDL_AtomicFetchThenDecrement16(&val16);
    2.96 -   printf("FetchThenDecrement16 ret=%d val=%d\n", ret16, val16);
    2.97 -
    2.98 -   ret16 = SDL_AtomicFetchThenAdd16(&val16, 10);
    2.99 -   printf("FetchThenAdd16       ret=%d val=%d\n", ret16, val16);
   2.100 -
   2.101 -   ret16 = SDL_AtomicFetchThenSubtract16(&val16, 10);
   2.102 -   printf("FetchThenSubtract16  ret=%d val=%d\n", ret16, val16);
   2.103 -
   2.104 -   ret16 = SDL_AtomicIncrementThenFetch16(&val16);
   2.105 -   printf("IncrementThenFetch16 ret=%d val=%d\n", ret16, val16);
   2.106 -
   2.107 -   ret16 = SDL_AtomicDecrementThenFetch16(&val16);
   2.108 -   printf("DecrementThenFetch16 ret=%d val=%d\n", ret16, val16);
   2.109 -
   2.110 -   ret16 = SDL_AtomicAddThenFetch16(&val16, 10);
   2.111 -   printf("AddThenFetch16       ret=%d val=%d\n", ret16, val16);
   2.112 -
   2.113 -   ret16 = SDL_AtomicSubtractThenFetch16(&val16, 10);
   2.114 -   printf("SubtractThenFetch16  ret=%d val=%d\n", ret16, val16);
   2.115 -
   2.116     printf("32 bit -----------------------------------------\n\n");
   2.117  
   2.118     ret32 = SDL_AtomicExchange32(&val32, 10);