test/testatomic.c
changeset 3186 51750b7a966f
parent 3180 77d6336711fc
child 3199 3e1bf2b8bd81
     1.1 --- a/test/testatomic.c	Wed Jun 10 08:09:04 2009 +0000
     1.2 +++ b/test/testatomic.c	Wed Jun 10 13:34:20 2009 +0000
     1.3 @@ -1,64 +1,64 @@
     1.4  #include "SDL.h"
     1.5  
     1.6  int
     1.7 -main(int argc, char** argv)
     1.8 +main(int argc, char **argv)
     1.9  {
    1.10 -  int rv = 10;
    1.11 -  volatile int atomic;
    1.12 +    int rv = 10;
    1.13 +    volatile int atomic;
    1.14  
    1.15 -  SDL_atomic_int_set(&atomic, 10);
    1.16 -  if(SDL_atomic_int_get(&atomic) != 10)
    1.17 -    printf("Error: ");
    1.18 -  printf("SDL_atomic_int_set(atomic, 10): atomic-> %d\n",
    1.19 -         SDL_atomic_int_get(&atomic));
    1.20 -    
    1.21 -  SDL_atomic_int_add(&atomic, 10);
    1.22 -  if(SDL_atomic_int_get(&atomic) != 20)
    1.23 -    printf("Error: ");
    1.24 -  printf("SDL_atomic_int_add(atomic, 10): atomic-> %d\n",
    1.25 -         SDL_atomic_int_get(&atomic));
    1.26 -  
    1.27 -  rv = SDL_atomic_int_cmp_xchg(&atomic, 20, 30);
    1.28 -  if(rv != SDL_TRUE || SDL_atomic_int_get(&atomic) != 30)
    1.29 -    printf("Error: ");
    1.30 -  printf("SDL_atomic_int_cmp_xchg(atomic, 20, 30): rv-> %d, atomic-> %d\n",
    1.31 -         rv, SDL_atomic_int_get(&atomic));
    1.32 -  
    1.33 -  rv = SDL_atomic_int_cmp_xchg(&atomic, 20, 30);
    1.34 -  if(rv != SDL_FALSE || SDL_atomic_int_get(&atomic) != 30)
    1.35 -    printf("Error: ");
    1.36 -  printf("SDL_atomic_int_cmp_xchg(atomic, 20, 40): rv-> %d, atomic-> %d\n",
    1.37 -         rv, SDL_atomic_int_get(&atomic));
    1.38 -  
    1.39 -  rv = SDL_atomic_int_xchg_add(&atomic, 10);
    1.40 -  if(rv != 30 || SDL_atomic_int_get(&atomic) != 40)
    1.41 -    printf("Error: ");
    1.42 -  printf("SDL_atomic_int_xchg_add(atomic, 10): rv-> %d, atomic-> %d\n",
    1.43 -         rv, SDL_atomic_int_get(&atomic));
    1.44 +    SDL_atomic_int_set(&atomic, 10);
    1.45 +    if (SDL_atomic_int_get(&atomic) != 10)
    1.46 +        printf("Error: ");
    1.47 +    printf("SDL_atomic_int_set(atomic, 10): atomic-> %d\n",
    1.48 +           SDL_atomic_int_get(&atomic));
    1.49  
    1.50 -  SDL_atomic_int_inc(&atomic);
    1.51 -  if(SDL_atomic_int_get(&atomic) != 41)
    1.52 -    printf("Error: ");
    1.53 -  printf("SDL_atomic_int_inc(atomic): atomic-> %d\n",
    1.54 -         SDL_atomic_int_get(&atomic));
    1.55 +    SDL_atomic_int_add(&atomic, 10);
    1.56 +    if (SDL_atomic_int_get(&atomic) != 20)
    1.57 +        printf("Error: ");
    1.58 +    printf("SDL_atomic_int_add(atomic, 10): atomic-> %d\n",
    1.59 +           SDL_atomic_int_get(&atomic));
    1.60  
    1.61 -  rv = SDL_atomic_int_dec_test(&atomic);
    1.62 -  if(rv != SDL_FALSE || SDL_atomic_int_get(&atomic) != 40)
    1.63 -    printf("Error: ");
    1.64 -  printf("SDL_atomic_int_dec_test(atomic): rv-> %d, atomic-> %d\n",
    1.65 -         rv, SDL_atomic_int_get(&atomic));
    1.66 -  
    1.67 -  SDL_atomic_int_set(&atomic, 1);
    1.68 -  if(SDL_atomic_int_get(&atomic) != 1)
    1.69 -    printf("Error: ");    
    1.70 +    rv = SDL_atomic_int_cmp_xchg(&atomic, 20, 30);
    1.71 +    if (rv != SDL_TRUE || SDL_atomic_int_get(&atomic) != 30)
    1.72 +        printf("Error: ");
    1.73 +    printf("SDL_atomic_int_cmp_xchg(atomic, 20, 30): rv-> %d, atomic-> %d\n",
    1.74 +           rv, SDL_atomic_int_get(&atomic));
    1.75 +
    1.76 +    rv = SDL_atomic_int_cmp_xchg(&atomic, 20, 30);
    1.77 +    if (rv != SDL_FALSE || SDL_atomic_int_get(&atomic) != 30)
    1.78 +        printf("Error: ");
    1.79 +    printf("SDL_atomic_int_cmp_xchg(atomic, 20, 40): rv-> %d, atomic-> %d\n",
    1.80 +           rv, SDL_atomic_int_get(&atomic));
    1.81 +
    1.82 +    rv = SDL_atomic_int_xchg_add(&atomic, 10);
    1.83 +    if (rv != 30 || SDL_atomic_int_get(&atomic) != 40)
    1.84 +        printf("Error: ");
    1.85 +    printf("SDL_atomic_int_xchg_add(atomic, 10): rv-> %d, atomic-> %d\n",
    1.86 +           rv, SDL_atomic_int_get(&atomic));
    1.87 +
    1.88 +    SDL_atomic_int_inc(&atomic);
    1.89 +    if (SDL_atomic_int_get(&atomic) != 41)
    1.90 +        printf("Error: ");
    1.91 +    printf("SDL_atomic_int_inc(atomic): atomic-> %d\n",
    1.92 +           SDL_atomic_int_get(&atomic));
    1.93 +
    1.94 +    rv = SDL_atomic_int_dec_test(&atomic);
    1.95 +    if (rv != SDL_FALSE || SDL_atomic_int_get(&atomic) != 40)
    1.96 +        printf("Error: ");
    1.97 +    printf("SDL_atomic_int_dec_test(atomic): rv-> %d, atomic-> %d\n",
    1.98 +           rv, SDL_atomic_int_get(&atomic));
    1.99 +
   1.100 +    SDL_atomic_int_set(&atomic, 1);
   1.101 +    if (SDL_atomic_int_get(&atomic) != 1)
   1.102 +        printf("Error: ");
   1.103      printf("SDL_atomic_int_set(atomic, 1): atomic-> %d\n",
   1.104             SDL_atomic_int_get(&atomic));
   1.105  
   1.106 -  rv = SDL_atomic_int_dec_test(&atomic);
   1.107 -  if(rv != SDL_TRUE || SDL_atomic_int_get(&atomic) != 0)
   1.108 -    printf("Error: ");
   1.109 -  printf("SDL_atomic_int_dec_test(atomic): rv-> %d, atomic-> %d\n",
   1.110 -         rv, SDL_atomic_int_get(&atomic));
   1.111 -  
   1.112 -  return 0;
   1.113 +    rv = SDL_atomic_int_dec_test(&atomic);
   1.114 +    if (rv != SDL_TRUE || SDL_atomic_int_get(&atomic) != 0)
   1.115 +        printf("Error: ");
   1.116 +    printf("SDL_atomic_int_dec_test(atomic): rv-> %d, atomic-> %d\n",
   1.117 +           rv, SDL_atomic_int_get(&atomic));
   1.118 +
   1.119 +    return 0;
   1.120  }