test/testatomic.c
author Bob Pendleton <bob@pendleton.com>
Wed, 24 Jun 2009 20:04:08 +0000
changeset 3199 3e1bf2b8bd81
parent 3186 51750b7a966f
child 3201 c297230efc75
permissions -rw-r--r--
This check in updates SDL_atomic.h to reflect the new set of atomic operations in 32 and 64 bit form.
It also update configure.in to compile the linux version of the library. The three versions are all dummies
implementations that do nothing. They are being checked in as place holders. Mostly, I just wanted to get
place holders and the configure.in checked in.
bob@3180
     1
#include "SDL.h"
bob@3180
     2
bob@3180
     3
int
slouken@3186
     4
main(int argc, char **argv)
bob@3180
     5
{
bob@3199
     6
/*     int rv = 10; */
bob@3199
     7
/*     volatile int atomic; */
bob@3180
     8
bob@3199
     9
/*     SDL_atomic_int_set(&atomic, 10); */
bob@3199
    10
/*     if (SDL_atomic_int_get(&atomic) != 10) */
bob@3199
    11
/*         printf("Error: "); */
bob@3199
    12
/*     printf("SDL_atomic_int_set(atomic, 10): atomic-> %d\n", */
bob@3199
    13
/*            SDL_atomic_int_get(&atomic)); */
bob@3180
    14
bob@3199
    15
/*     SDL_atomic_int_add(&atomic, 10); */
bob@3199
    16
/*     if (SDL_atomic_int_get(&atomic) != 20) */
bob@3199
    17
/*         printf("Error: "); */
bob@3199
    18
/*     printf("SDL_atomic_int_add(atomic, 10): atomic-> %d\n", */
bob@3199
    19
/*            SDL_atomic_int_get(&atomic)); */
bob@3180
    20
bob@3199
    21
/*     rv = SDL_atomic_int_cmp_xchg(&atomic, 20, 30); */
bob@3199
    22
/*     if (rv != SDL_TRUE || SDL_atomic_int_get(&atomic) != 30) */
bob@3199
    23
/*         printf("Error: "); */
bob@3199
    24
/*     printf("SDL_atomic_int_cmp_xchg(atomic, 20, 30): rv-> %d, atomic-> %d\n", */
bob@3199
    25
/*            rv, SDL_atomic_int_get(&atomic)); */
slouken@3186
    26
bob@3199
    27
/*     rv = SDL_atomic_int_cmp_xchg(&atomic, 20, 30); */
bob@3199
    28
/*     if (rv != SDL_FALSE || SDL_atomic_int_get(&atomic) != 30) */
bob@3199
    29
/*         printf("Error: "); */
bob@3199
    30
/*     printf("SDL_atomic_int_cmp_xchg(atomic, 20, 40): rv-> %d, atomic-> %d\n", */
bob@3199
    31
/*            rv, SDL_atomic_int_get(&atomic)); */
slouken@3186
    32
bob@3199
    33
/*     rv = SDL_atomic_int_xchg_add(&atomic, 10); */
bob@3199
    34
/*     if (rv != 30 || SDL_atomic_int_get(&atomic) != 40) */
bob@3199
    35
/*         printf("Error: "); */
bob@3199
    36
/*     printf("SDL_atomic_int_xchg_add(atomic, 10): rv-> %d, atomic-> %d\n", */
bob@3199
    37
/*            rv, SDL_atomic_int_get(&atomic)); */
slouken@3186
    38
bob@3199
    39
/*     SDL_atomic_int_inc(&atomic); */
bob@3199
    40
/*     if (SDL_atomic_int_get(&atomic) != 41) */
bob@3199
    41
/*         printf("Error: "); */
bob@3199
    42
/*     printf("SDL_atomic_int_inc(atomic): atomic-> %d\n", */
bob@3199
    43
/*            SDL_atomic_int_get(&atomic)); */
slouken@3186
    44
bob@3199
    45
/*     rv = SDL_atomic_int_dec_test(&atomic); */
bob@3199
    46
/*     if (rv != SDL_FALSE || SDL_atomic_int_get(&atomic) != 40) */
bob@3199
    47
/*         printf("Error: "); */
bob@3199
    48
/*     printf("SDL_atomic_int_dec_test(atomic): rv-> %d, atomic-> %d\n", */
bob@3199
    49
/*            rv, SDL_atomic_int_get(&atomic)); */
slouken@3186
    50
bob@3199
    51
/*     SDL_atomic_int_set(&atomic, 1); */
bob@3199
    52
/*     if (SDL_atomic_int_get(&atomic) != 1) */
bob@3199
    53
/*         printf("Error: "); */
bob@3199
    54
/*     printf("SDL_atomic_int_set(atomic, 1): atomic-> %d\n", */
bob@3199
    55
/*            SDL_atomic_int_get(&atomic)); */
bob@3180
    56
bob@3199
    57
/*     rv = SDL_atomic_int_dec_test(&atomic); */
bob@3199
    58
/*     if (rv != SDL_TRUE || SDL_atomic_int_get(&atomic) != 0) */
bob@3199
    59
/*         printf("Error: "); */
bob@3199
    60
/*     printf("SDL_atomic_int_dec_test(atomic): rv-> %d, atomic-> %d\n", */
bob@3199
    61
/*            rv, SDL_atomic_int_get(&atomic)); */
slouken@3186
    62
slouken@3186
    63
    return 0;
bob@3180
    64
}