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.
     1 #include "SDL.h"
     2 
     3 /*
     4   Absolutely basic test just to see if we get the expected value after
     5   calling each function.
     6 */
     7 
     8 int
     9 main(int argc, char **argv)
    10 {
    11 
    12    Uint32 val32 = 0;
    13    Uint32 ret32 = 0;
    14 
    15    Uint64 val64 = 0;
    16    Uint64 ret64 = 0;
    17 
    18    SDL_bool tfval = SDL_FALSE;
    19 
    20    ret32 = SDL_AtomicExchange32(&val32, 10);
    21    tfval = SDL_AtomicCompareThenSet32(&val32, 10, 20);
    22    tfval = SDL_AtomicTestThenSet32(&val32);
    23    SDL_AtomicClear32(&val32);
    24    ret32 = SDL_AtomicFetchThenIncrement32(&val32);
    25    ret32 = SDL_AtomicFetchThenDecrement32(&val32);
    26    ret32 = SDL_AtomicFetchThenAdd32(&val32, 10);
    27    ret32 = SDL_AtomicFetchThenSubtract32(&val32, 10);
    28    ret32 = SDL_AtomicIncrementThenFetch32(&val32);
    29    ret32 = SDL_AtomicDecrementThenFetch32(&val32);
    30    ret32 = SDL_AtomicAddThenFetch32(&val32, 10);
    31    ret32 = SDL_AtomicSubtractThenFetch32(&val32, 10);
    32 
    33 /* #ifdef SDL_HAS_64BIT_TYPE */
    34 #if 0
    35 
    36    ret64 = SDL_AtomicExchange64(&val64, 10);
    37    tfval = SDL_AtomicCompareThenSet64(&val64, 10, 20);
    38    tfval = SDL_AtomicTestThenSet64(&val64);
    39    SDL_AtomicClear64(&val64);
    40    ret64 = SDL_AtomicFetchThenIncrement64(&val64);
    41    ret64 = SDL_AtomicFetchThenDecrement64(&val64);
    42    ret64 = SDL_AtomicFetchThenAdd64(&val64, 10);
    43    ret64 = SDL_AtomicFetchThenSubtract64(&val64, 10);
    44    ret64 = SDL_AtomicIncrementThenFetch64(&val64);
    45    ret64 = SDL_AtomicDecrementThenFetch64(&val64);
    46    ret64 = SDL_AtomicAddThenFetch64(&val64, 10);
    47    ret64 = SDL_AtomicSubtractThenFetch64(&val64, 10);
    48 #endif
    49 
    50    return 0;
    51    }