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:
Eric Wasylishen 2011-05-28 18:05:14 +00:00
parent 6a4d9fd5ae
commit f2a470d893
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,51 +1023,59 @@ 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
saved_CFLAGS="$CFLAGS";
ATOMIC_CFLAGS="";
if test "$CC" = "gcc"; then
saved_CFLAGS="$CFLAGS";
ATOMIC_CFLAGS="";
# FIXME: Forcing -march=i568 for any i568 or later CPU is a stop gap measure
# to make the compiler emit native assembly for atomic operations on i586 or
# latter processors (GCC by defaults emits code compatible with the original
# i386 and requires library functions to emulate atomic operations). When
# gnustep-make takes care of this kind of target setting, the check can safely
# be removed.
case "$target_cpu" in
i586*|i686*|i786*)
ATOMIC_CFLAGS="-march=i586";
CFLAGS="$saved_CFLAGS $ATOMIC_CFLAGS";
OBJCFLAGS="$OBJCFLAGS $ATOMIC_CFLAGS";
esac
AC_MSG_CHECKING([checking whether atomic operations require an external library]);
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);
# FIXME: Forcing -march=i568 for any i568 or later CPU is a stop gap measure
# to make the compiler emit native assembly for atomic operations on i586 or
# latter processors (GCC by defaults emits code compatible with the original
# i386 and requires library functions to emulate atomic operations). When
# gnustep-make takes care of this kind of target setting, the check can safely
# be removed.
case "$target_cpu" in
i586*|i686*|i786*)
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([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_march=yes,
need_march=no);
if test "$need_linkage" = "no"; then
AC_MSG_RESULT([no]);
else
AC_MSG_RESULT([yes]);
saved_LDFLAGS="$LDFLAGS";
LDFLAGS="$saved_LDFLAGS -lgcc";
AC_MSG_CHECKING([checking for atomic operations from 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,
atomic_in_libgcc=no);
if test "$atomic_in_libgcc" = "yes"; then
AC_MSG_RESULT([yes]);
LIBS="$LIBS -lgcc";
AC_DEFINE(USE_ATOMIC_BUILTINS,1,
[Define if the compiler provides builtins for atomic operations])
else
LDFLAGS="$saved_LDFLAGS";
AC_MSG_RESULT([no]);
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([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,
atomic_in_libgcc=no);
if test "$atomic_in_libgcc" = "yes"; then
AC_MSG_RESULT([yes]);
LIBS="$LIBS -lgcc";
AC_DEFINE(USE_ATOMIC_BUILTINS,1,
[Define if the compiler provides builtins for atomic operations])
else
LDFLAGS="$saved_LDFLAGS";
AC_MSG_RESULT([no]);
fi
fi
fi
fi
fi
fi
AC_LANG_POP(C)