test/testatomic.c
author Bob Pendleton <bob@pendleton.com>
Wed, 24 Jun 2009 22:24:23 +0000
changeset 3201 c297230efc75
parent 3199 3e1bf2b8bd81
child 3202 3aa519a5c676
permissions -rw-r--r--
Disabling 64 bit atomics operations until I figure out why they do not link.
bob@3180
     1
#include "SDL.h"
bob@3180
     2
bob@3201
     3
/*
bob@3201
     4
  Absolutely basic test just to see if we get the expected value after
bob@3201
     5
  calling each function.
bob@3201
     6
*/
bob@3201
     7
bob@3180
     8
int
slouken@3186
     9
main(int argc, char **argv)
bob@3180
    10
{
bob@3180
    11
bob@3201
    12
   Uint32 val32 = 0;
bob@3201
    13
   Uint32 ret32 = 0;
bob@3180
    14
bob@3201
    15
   Uint64 val64 = 0;
bob@3201
    16
   Uint64 ret64 = 0;
bob@3180
    17
bob@3201
    18
   SDL_bool tfval = SDL_FALSE;
slouken@3186
    19
bob@3201
    20
   ret32 = SDL_AtomicExchange32(&val32, 10);
bob@3201
    21
   tfval = SDL_AtomicCompareThenSet32(&val32, 10, 20);
bob@3201
    22
   tfval = SDL_AtomicTestThenSet32(&val32);
bob@3201
    23
   SDL_AtomicClear32(&val32);
bob@3201
    24
   ret32 = SDL_AtomicFetchThenIncrement32(&val32);
bob@3201
    25
   ret32 = SDL_AtomicFetchThenDecrement32(&val32);
bob@3201
    26
   ret32 = SDL_AtomicFetchThenAdd32(&val32, 10);
bob@3201
    27
   ret32 = SDL_AtomicFetchThenSubtract32(&val32, 10);
bob@3201
    28
   ret32 = SDL_AtomicIncrementThenFetch32(&val32);
bob@3201
    29
   ret32 = SDL_AtomicDecrementThenFetch32(&val32);
bob@3201
    30
   ret32 = SDL_AtomicAddThenFetch32(&val32, 10);
bob@3201
    31
   ret32 = SDL_AtomicSubtractThenFetch32(&val32, 10);
slouken@3186
    32
bob@3201
    33
/* #ifdef SDL_HAS_64BIT_TYPE */
bob@3201
    34
#if 0
slouken@3186
    35
bob@3201
    36
   ret64 = SDL_AtomicExchange64(&val64, 10);
bob@3201
    37
   tfval = SDL_AtomicCompareThenSet64(&val64, 10, 20);
bob@3201
    38
   tfval = SDL_AtomicTestThenSet64(&val64);
bob@3201
    39
   SDL_AtomicClear64(&val64);
bob@3201
    40
   ret64 = SDL_AtomicFetchThenIncrement64(&val64);
bob@3201
    41
   ret64 = SDL_AtomicFetchThenDecrement64(&val64);
bob@3201
    42
   ret64 = SDL_AtomicFetchThenAdd64(&val64, 10);
bob@3201
    43
   ret64 = SDL_AtomicFetchThenSubtract64(&val64, 10);
bob@3201
    44
   ret64 = SDL_AtomicIncrementThenFetch64(&val64);
bob@3201
    45
   ret64 = SDL_AtomicDecrementThenFetch64(&val64);
bob@3201
    46
   ret64 = SDL_AtomicAddThenFetch64(&val64, 10);
bob@3201
    47
   ret64 = SDL_AtomicSubtractThenFetch64(&val64, 10);
bob@3201
    48
#endif
slouken@3186
    49
bob@3201
    50
   return 0;
bob@3201
    51
   }