tweak and re-enable atomic ops detection

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@33179 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
ericwa 2011-05-28 18:05:14 +00:00
parent ac4b932048
commit 3aa5c524e6
2 changed files with 51 additions and 51 deletions

View file

@ -194,14 +194,6 @@ static void GSLogZombie(id o, SEL sel)
#undef GSATOMICREAD
#endif
/*
* FIXME: Refrain from using atomic builtins until we know how to reliably check
* whether they do work with GCC.
*/
#ifdef USE_ATOMIC_BUILTINS
#undef USE_ATOMIC_BUILTINS
#endif
#if defined(__MINGW__)
#ifndef _WIN64

View file

@ -1013,7 +1013,7 @@ AC_USE_SYSTEM_EXTENSIONS
AC_LANG_PUSH(C)
AC_MSG_CHECKING([whether the compiler supports atomic operations]);
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[typedef int atomic;]],
AC_LINK_IFELSE([AC_LANG_PROGRAM([[typedef int atomic;]],
[[atomic x; atomic y; __sync_bool_compare_and_swap(&x, y, y + 1);]])],
have_atomic=yes,
have_atomic=no);
@ -1023,8 +1023,7 @@ AC_MSG_CHECKING([whether the compiler supports atomic operations]);
[Define if the compiler provides builtins for atomic operations])
else
AC_MSG_RESULT([no]);
fi
if test "$CC" = "gcc"; then
if test "$CC" = "gcc"; then
saved_CFLAGS="$CFLAGS";
ATOMIC_CFLAGS="";
@ -1036,23 +1035,31 @@ if test "$CC" = "gcc"; then
# be removed.
case "$target_cpu" in
i586*|i686*|i786*)
ATOMIC_CFLAGS="-march=i586";
CFLAGS="$saved_CFLAGS $ATOMIC_CFLAGS";
OBJCFLAGS="$OBJCFLAGS $ATOMIC_CFLAGS";
ATOMIC_CFLAGS="-march=i586"
CFLAGS="$saved_CFLAGS $ATOMIC_CFLAGS"
OBJCFLAGS="$OBJCFLAGS $ATOMIC_CFLAGS"
;;
x86_64)
ATOMIC_CFLAGS="-march=x86-64"
CFLAGS="$saved_CFLAGS $ATOMIC_CFLAGS"
OBJCFLAGS="$OBJCFLAGS $ATOMIC_CFLAGS"
;;
esac
AC_MSG_CHECKING([checking whether atomic operations require an external library]);
AC_MSG_CHECKING([whether gcc supports atomic operations by setting -march]);
AC_LINK_IFELSE([AC_LANG_PROGRAM([[typedef int atomic;]],
[[atomic x; atomic y; __sync_bool_compare_and_swap(&x, y, y + 1);]])],
need_linkage=no,
need_linkage=yes);
need_march=yes,
need_march=no);
if test "$need_linkage" = "no"; then
AC_MSG_RESULT([no]);
else
if test "$need_march" = "yes"; then
AC_MSG_RESULT([yes]);
AC_DEFINE(USE_ATOMIC_BUILTINS,1,
[Define if the compiler provides builtins for atomic operations])
else
AC_MSG_RESULT([no]);
saved_LDFLAGS="$LDFLAGS";
LDFLAGS="$saved_LDFLAGS -lgcc";
AC_MSG_CHECKING([checking for atomic operations from libgcc]);
AC_MSG_CHECKING([whether gcc supports atomic operations by linikng to libgcc]);
AC_LINK_IFELSE([AC_LANG_PROGRAM([[typedef int atomic;]],
[[atomic x; atomic y; __sync_bool_compare_and_swap(&x, y, y + 1);]])],
atomic_in_libgcc=yes,
@ -1067,7 +1074,8 @@ if test "$CC" = "gcc"; then
AC_MSG_RESULT([no]);
fi
fi
fi
fi
fi
AC_LANG_POP(C)