test/testatomic.c
changeset 3325 bb9c3d04f126
parent 3299 975fd903466b
child 3327 35387815b155
equal deleted inserted replaced
3324:0f19b2fa4125 3325:bb9c3d04f126
    78 #ifdef SDL_HAS_64BIT_TYPE
    78 #ifdef SDL_HAS_64BIT_TYPE
    79    printf("\n64 bit -----------------------------------------\n\n");
    79    printf("\n64 bit -----------------------------------------\n\n");
    80 
    80 
    81    val64 = 0;
    81    val64 = 0;
    82    tfret = SDL_AtomicTestThenSet64(&val64);
    82    tfret = SDL_AtomicTestThenSet64(&val64);
    83    printf("TestThenSet64        tfret=%s val=%lld\n", tf(tfret), val64);
    83    printf("TestThenSet64        tfret=%s val=%llu\n", tf(tfret), ((unsigned long long)val64));
    84    tfret = SDL_AtomicTestThenSet64(&val64);
    84    tfret = SDL_AtomicTestThenSet64(&val64);
    85    printf("TestThenSet64        tfret=%s val=%lld\n", tf(tfret), val64);
    85    printf("TestThenSet64        tfret=%s val=%llu\n", tf(tfret), ((unsigned long long)val64));
    86 
    86 
    87    SDL_AtomicClear64(&val64);
    87    SDL_AtomicClear64(&val64);
    88    printf("Clear64              val=%lld\n", val64);
    88    printf("Clear64              val=%llu\n", ((unsigned long long)val64));
    89 
    89 
    90    ret64 = SDL_AtomicFetchThenIncrement64(&val64);
    90    ret64 = SDL_AtomicFetchThenIncrement64(&val64);
    91    printf("FetchThenIncrement64 ret=%lld val=%lld\n", ret64, val64);
    91    printf("FetchThenIncrement64 ret=%llu val=%llu\n", ((unsigned long long)ret64), ((unsigned long long)val64));
    92 
    92 
    93    ret64 = SDL_AtomicFetchThenDecrement64(&val64);
    93    ret64 = SDL_AtomicFetchThenDecrement64(&val64);
    94    printf("FetchThenDecrement64 ret=%lld val=%lld\n", ret64, val64);
    94    printf("FetchThenDecrement64 ret=%llu val=%llu\n", ((unsigned long long)ret64), ((unsigned long long)val64));
    95 
    95 
    96    ret64 = SDL_AtomicFetchThenAdd64(&val64, 10);
    96    ret64 = SDL_AtomicFetchThenAdd64(&val64, 10);
    97    printf("FetchThenAdd64       ret=%lld val=%lld\n", ret64, val64);
    97    printf("FetchThenAdd64       ret=%llu val=%llu\n", ((unsigned long long)ret64), ((unsigned long long)val64));
    98 
    98 
    99    ret64 = SDL_AtomicFetchThenSubtract64(&val64, 10);
    99    ret64 = SDL_AtomicFetchThenSubtract64(&val64, 10);
   100    printf("FetchThenSubtract64  ret=%lld val=%lld\n", ret64, val64);
   100    printf("FetchThenSubtract64  ret=%llu val=%llu\n", ((unsigned long long)ret64), ((unsigned long long)val64));
   101 
   101 
   102    ret64 = SDL_AtomicIncrementThenFetch64(&val64);
   102    ret64 = SDL_AtomicIncrementThenFetch64(&val64);
   103    printf("IncrementThenFetch64 ret=%lld val=%lld\n", ret64, val64);
   103    printf("IncrementThenFetch64 ret=%llu val=%llu\n", ((unsigned long long)ret64), ((unsigned long long)val64));
   104 
   104 
   105    ret64 = SDL_AtomicDecrementThenFetch64(&val64);
   105    ret64 = SDL_AtomicDecrementThenFetch64(&val64);
   106    printf("DecrementThenFetch64 ret=%lld val=%lld\n", ret64, val64);
   106    printf("DecrementThenFetch64 ret=%llu val=%llu\n", ((unsigned long long)ret64), ((unsigned long long)val64));
   107 
   107 
   108    ret64 = SDL_AtomicAddThenFetch64(&val64, 10);
   108    ret64 = SDL_AtomicAddThenFetch64(&val64, 10);
   109    printf("AddThenFetch64       ret=%lld val=%lld\n", ret64, val64);
   109    printf("AddThenFetch64       ret=%llu val=%llu\n", ((unsigned long long)ret64), ((unsigned long long)val64));
   110 
   110 
   111    ret64 = SDL_AtomicSubtractThenFetch64(&val64, 10);
   111    ret64 = SDL_AtomicSubtractThenFetch64(&val64, 10);
   112    printf("SubtractThenFetch64  ret=%lld val=%lld\n", ret64, val64);
   112    printf("SubtractThenFetch64  ret=%llu val=%llu\n", ((unsigned long long)ret64), ((unsigned long long)val64));
   113 #endif
   113 #endif
   114 
   114 
   115    return 0;
   115    return 0;
   116    }
   116    }