Separated out the minimum functionality that we need from gcc for our spinlock fallback.
authorSam Lantinga <slouken@libsdl.org>
Fri, 21 Jan 2011 21:42:04 -0800
changeset 5069fd125217f00c
parent 5068 231dbbc3e31c
child 5070 042ad5e274ed
Separated out the minimum functionality that we need from gcc for our spinlock fallback.
configure.in
include/SDL_config.h.in
src/atomic/SDL_spinlock.c
     1.1 --- a/configure.in	Fri Jan 21 21:35:43 2011 -0800
     1.2 +++ b/configure.in	Fri Jan 21 21:42:04 2011 -0800
     1.3 @@ -312,6 +312,18 @@
     1.4      if test x$have_gcc_atomics = xyes; then
     1.5          AC_DEFINE(HAVE_GCC_ATOMICS)
     1.6      fi
     1.7 +
     1.8 +    # See if we have the minimum operation needed for GCC atomics
     1.9 +    AC_TRY_LINK([
    1.10 +    ],[
    1.11 +    int a;
    1.12 +    __sync_lock_test_and_set(&a, 1);
    1.13 +    ],[
    1.14 +    have_gcc_sync_lock_test_and_set=yes
    1.15 +    ])
    1.16 +    if test x$have_gcc_sync_lock_test_and_set = xyes; then
    1.17 +        AC_DEFINE(HAVE_GCC_SYNC_LOCK_TEST_AND_SET)
    1.18 +    fi
    1.19  fi
    1.20  
    1.21  # Standard C sources
     2.1 --- a/include/SDL_config.h.in	Fri Jan 21 21:35:43 2011 -0800
     2.2 +++ b/include/SDL_config.h.in	Fri Jan 21 21:42:04 2011 -0800
     2.3 @@ -59,6 +59,7 @@
     2.4  #undef SIZEOF_VOIDP
     2.5  #undef SDL_HAS_64BIT_TYPE
     2.6  #undef HAVE_GCC_ATOMICS
     2.7 +#undef HAVE_GCC_SYNC_LOCK_TEST_AND_SET
     2.8  
     2.9  /* Comment this if you want to build without any C library requirements */
    2.10  #undef HAVE_LIBC
     3.1 --- a/src/atomic/SDL_spinlock.c	Fri Jan 21 21:35:43 2011 -0800
     3.2 +++ b/src/atomic/SDL_spinlock.c	Fri Jan 21 21:42:04 2011 -0800
     3.3 @@ -36,7 +36,7 @@
     3.4  #elif defined(__MACOSX__)
     3.5      return OSAtomicCompareAndSwap32Barrier(0, 1, lock);
     3.6  
     3.7 -#elif defined(HAVE_GCC_ATOMICS)
     3.8 +#elif defined(HAVE_GCC_SYNC_LOCK_TEST_AND_SET)
     3.9      return (__sync_lock_test_and_set(lock, 1) == 0);
    3.10  
    3.11  #elif defined(__GNUC__) && defined(__arm__) && defined(__ARM_ARCH_5__)