diff --git a/configure.in b/configure.in
index 3f1c81f53c38fb92c7d4bbe66f9b2665c29caa21..631a8958d05117f522b5075d0e8ad13cad2df352 100644
--- a/configure.in
+++ b/configure.in
@@ -311,18 +311,18 @@ if test x$enable_gcc_atomics = xyes; then
 
     if test x$have_gcc_atomics = xyes; then
         AC_DEFINE(HAVE_GCC_ATOMICS)
-    fi
-
-    # See if we have the minimum operation needed for GCC atomics
-    AC_TRY_LINK([
-    ],[
-    int a;
-    __sync_lock_test_and_set(&a, 1);
-    ],[
-    have_gcc_sync_lock_test_and_set=yes
-    ])
-    if test x$have_gcc_sync_lock_test_and_set = xyes; then
-        AC_DEFINE(HAVE_GCC_SYNC_LOCK_TEST_AND_SET)
+    else
+        # See if we have the minimum operation needed for GCC atomics
+        AC_TRY_LINK([
+        ],[
+        int a;
+        __sync_lock_test_and_set(&a, 1);
+        ],[
+        have_gcc_sync_lock_test_and_set=yes
+        ])
+        if test x$have_gcc_sync_lock_test_and_set = xyes; then
+            AC_DEFINE(HAVE_GCC_SYNC_LOCK_TEST_AND_SET)
+        fi
     fi
 fi
 
diff --git a/include/SDL_config_iphoneos.h b/include/SDL_config_iphoneos.h
index f575febc7155645b51eecee9a8a466b9a691e82f..bc3d876fcdb2068e9cd78e3d627197d3b6ee4869 100644
--- a/include/SDL_config_iphoneos.h
+++ b/include/SDL_config_iphoneos.h
@@ -44,7 +44,6 @@ typedef unsigned long uintptr_t;
 #define SDL_HAS_64BIT_TYPE	1
 
 #define HAVE_GCC_ATOMICS	1
-#define HAVE_GCC_SYNC_LOCK_TEST_AND_SET	1
 
 #define HAVE_ALLOCA_H		1
 #define HAVE_SYS_TYPES_H	1
diff --git a/src/atomic/SDL_spinlock.c b/src/atomic/SDL_spinlock.c
index 2cbd927d73d2d46d307df5817572a62d8553eb19..61d42fb97d497582d2588275ae0f0ae585bb6643 100644
--- a/src/atomic/SDL_spinlock.c
+++ b/src/atomic/SDL_spinlock.c
@@ -36,7 +36,7 @@ SDL_AtomicTryLock(SDL_SpinLock *lock)
 #elif defined(__MACOSX__)
     return OSAtomicCompareAndSwap32Barrier(0, 1, lock);
 
-#elif defined(HAVE_GCC_SYNC_LOCK_TEST_AND_SET)
+#elif defined(HAVE_GCC_ATOMICS) || defined(HAVE_GCC_SYNC_LOCK_TEST_AND_SET)
     return (__sync_lock_test_and_set(lock, 1) == 0);
 
 #elif defined(__GNUC__) && defined(__arm__) && defined(__ARM_ARCH_5__)