Added native atomic operations for Windows, Mac OS X, and gcc compiler intrinsics.

Changed the CAS return value to bool, so it's efficient with OSAtomicCompareAndSwap32Barrier()
Added an atomic test adapted from code by Michael Davidsaver
This commit is contained in:
Sam Lantinga 2011-01-16 15:16:39 -08:00
parent 1bc8fe69ce
commit b0e0f61c7e
8 changed files with 301 additions and 62 deletions

View file

@ -181,7 +181,7 @@ if test x$enable_dependency_tracking = xyes; then
DEPENDENCY_TRACKING_OPTIONS="-MMD -MT \$@"
fi
fi
dnl See whether we are allowed to use the system C library
AC_ARG_ENABLE(libc,
AC_HELP_STRING([--enable-libc], [Use the system C library [[default=yes]]]),
@ -285,6 +285,32 @@ if test x$have_inttypes != xyes; then
AC_DEFINE(uintptr_t, unsigned long)
fi
dnl See whether we can use gcc atomic operations on this architecture
AC_ARG_ENABLE(gcc-atomics,
AC_HELP_STRING([--enable-gcc-atomics],
[Use gcc builtin atomics [[default=yes]]]),
, enable_gcc_atomics=yes)
if test x$enable_gcc_atomics = xyes; then
have_gcc_atomics=no
AC_MSG_CHECKING(for GCC builtin atomic operations)
AC_TRY_LINK([
],[
int a;
void *x, *y, *z;
__sync_lock_test_and_set(&a, 4);
__sync_fetch_and_add(&a, 1);
__sync_bool_compare_and_swap(&a, 5, 10);
__sync_bool_compare_and_swap(&x, y, z);
],[
have_gcc_atomics=yes
])
AC_MSG_RESULT($have_gcc_atomics)
if test x$have_gcc_mmd_mt = xyes; then
AC_DEFINE(HAVE_GCC_ATOMICS)
fi
fi
# Standard C sources
SOURCES="$SOURCES $srcdir/src/*.c"
SOURCES="$SOURCES $srcdir/src/audio/*.c"