diff test/testatomic.c @ 3261:72b542f34739

The new, cleaner, version of the atomic operations. The dummy code is what you should start working with to port atomic ops. The linux code appears to be complete and *should* be the base of all Unix and GCC based versions. The macosx and win32 versions are currently just copies of the dummy code. I will begin working on the windows version as soon as this check in is done. I need someone to work on the Mac OS X version. I'm afraid that this check in will break QNX (Sorry!)
author Bob Pendleton <bob@pendleton.com>
date Thu, 17 Sep 2009 20:35:12 +0000
parents 916f396fe65d
children 975fd903466b
line wrap: on
line diff
--- a/test/testatomic.c	Mon Sep 07 16:04:44 2009 +0000
+++ b/test/testatomic.c	Thu Sep 17 20:35:12 2009 +0000
@@ -29,21 +29,18 @@
    volatile Uint64 val64 = 0;
    Uint64 ret64 = 0;
 
+   SDL_SpinLock lock = 0;
+
    SDL_bool tfret = SDL_FALSE;
 
-   printf("32 bit -----------------------------------------\n\n");
-
-   ret32 = SDL_AtomicExchange32(&val32, 10);
-   printf("Exchange32           ret=%d val=%d\n", ret32, val32);
-   ret32 = SDL_AtomicExchange32(&val32, 0);
-   printf("Exchange32           ret=%d val=%d\n", ret32, val32);
+   printf("\nspin lock---------------------------------------\n\n");
 
-   val32 = 10;
-   tfret = SDL_AtomicCompareThenSet32(&val32, 10, 20);
-   printf("CompareThenSet32     tfret=%s val=%d\n", tf(tfret), val32);
-   val32 = 10;
-   tfret = SDL_AtomicCompareThenSet32(&val32, 0, 20);
-   printf("CompareThenSet32     tfret=%s val=%d\n", tf(tfret), val32);
+   SDL_AtomicLock(&lock);
+   printf("AtomicLock                   lock=%d\n", lock);
+   SDL_AtomicUnlock(&lock);
+   printf("AtomicUnlock                 lock=%d\n", lock);
+
+   printf("\n32 bit -----------------------------------------\n\n");
 
    val32 = 0;
    tfret = SDL_AtomicTestThenSet32(&val32);
@@ -79,19 +76,7 @@
    printf("SubtractThenFetch32  ret=%d val=%d\n", ret32, val32);
 
 #ifdef SDL_HAS_64BIT_TYPE
-   printf("64 bit -----------------------------------------\n\n");
-
-   ret64 = SDL_AtomicExchange64(&val64, 10);
-   printf("Exchange64           ret=%lld val=%lld\n", ret64, val64);
-   ret64 = SDL_AtomicExchange64(&val64, 0);
-   printf("Exchange64           ret=%lld val=%lld\n", ret64, val64);
-
-   val64 = 10;
-   tfret = SDL_AtomicCompareThenSet64(&val64, 10, 20);
-   printf("CompareThenSet64     tfret=%s val=%lld\n", tf(tfret), val64);
-   val64 = 10;
-   tfret = SDL_AtomicCompareThenSet64(&val64, 0, 20);
-   printf("CompareThenSet64     tfret=%s val=%lld\n", tf(tfret), val64);
+   printf("\n64 bit -----------------------------------------\n\n");
 
    val64 = 0;
    tfret = SDL_AtomicTestThenSet64(&val64);