test/testatomic.c
changeset 3261 72b542f34739
parent 3237 916f396fe65d
child 3299 975fd903466b
     1.1 --- a/test/testatomic.c	Mon Sep 07 16:04:44 2009 +0000
     1.2 +++ b/test/testatomic.c	Thu Sep 17 20:35:12 2009 +0000
     1.3 @@ -29,21 +29,18 @@
     1.4     volatile Uint64 val64 = 0;
     1.5     Uint64 ret64 = 0;
     1.6  
     1.7 +   SDL_SpinLock lock = 0;
     1.8 +
     1.9     SDL_bool tfret = SDL_FALSE;
    1.10  
    1.11 -   printf("32 bit -----------------------------------------\n\n");
    1.12 +   printf("\nspin lock---------------------------------------\n\n");
    1.13  
    1.14 -   ret32 = SDL_AtomicExchange32(&val32, 10);
    1.15 -   printf("Exchange32           ret=%d val=%d\n", ret32, val32);
    1.16 -   ret32 = SDL_AtomicExchange32(&val32, 0);
    1.17 -   printf("Exchange32           ret=%d val=%d\n", ret32, val32);
    1.18 +   SDL_AtomicLock(&lock);
    1.19 +   printf("AtomicLock                   lock=%d\n", lock);
    1.20 +   SDL_AtomicUnlock(&lock);
    1.21 +   printf("AtomicUnlock                 lock=%d\n", lock);
    1.22  
    1.23 -   val32 = 10;
    1.24 -   tfret = SDL_AtomicCompareThenSet32(&val32, 10, 20);
    1.25 -   printf("CompareThenSet32     tfret=%s val=%d\n", tf(tfret), val32);
    1.26 -   val32 = 10;
    1.27 -   tfret = SDL_AtomicCompareThenSet32(&val32, 0, 20);
    1.28 -   printf("CompareThenSet32     tfret=%s val=%d\n", tf(tfret), val32);
    1.29 +   printf("\n32 bit -----------------------------------------\n\n");
    1.30  
    1.31     val32 = 0;
    1.32     tfret = SDL_AtomicTestThenSet32(&val32);
    1.33 @@ -79,19 +76,7 @@
    1.34     printf("SubtractThenFetch32  ret=%d val=%d\n", ret32, val32);
    1.35  
    1.36  #ifdef SDL_HAS_64BIT_TYPE
    1.37 -   printf("64 bit -----------------------------------------\n\n");
    1.38 -
    1.39 -   ret64 = SDL_AtomicExchange64(&val64, 10);
    1.40 -   printf("Exchange64           ret=%lld val=%lld\n", ret64, val64);
    1.41 -   ret64 = SDL_AtomicExchange64(&val64, 0);
    1.42 -   printf("Exchange64           ret=%lld val=%lld\n", ret64, val64);
    1.43 -
    1.44 -   val64 = 10;
    1.45 -   tfret = SDL_AtomicCompareThenSet64(&val64, 10, 20);
    1.46 -   printf("CompareThenSet64     tfret=%s val=%lld\n", tf(tfret), val64);
    1.47 -   val64 = 10;
    1.48 -   tfret = SDL_AtomicCompareThenSet64(&val64, 0, 20);
    1.49 -   printf("CompareThenSet64     tfret=%s val=%lld\n", tf(tfret), val64);
    1.50 +   printf("\n64 bit -----------------------------------------\n\n");
    1.51  
    1.52     val64 = 0;
    1.53     tfret = SDL_AtomicTestThenSet64(&val64);