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 #undef GSATOMICREAD
#endif #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__) #if defined(__MINGW__)
#ifndef _WIN64 #ifndef _WIN64

View file

@ -1013,7 +1013,7 @@ AC_USE_SYSTEM_EXTENSIONS
AC_LANG_PUSH(C) AC_LANG_PUSH(C)
AC_MSG_CHECKING([whether the compiler supports atomic operations]); 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);]])], [[atomic x; atomic y; __sync_bool_compare_and_swap(&x, y, y + 1);]])],
have_atomic=yes, have_atomic=yes,
have_atomic=no); 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]) [Define if the compiler provides builtins for atomic operations])
else else
AC_MSG_RESULT([no]); AC_MSG_RESULT([no]);
fi if test "$CC" = "gcc"; then
if test "$CC" = "gcc"; then saved_CFLAGS="$CFLAGS";
saved_CFLAGS="$CFLAGS"; ATOMIC_CFLAGS="";
ATOMIC_CFLAGS="";
# FIXME: Forcing -march=i568 for any i568 or later CPU is a stop gap measure # 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 # to make the compiler emit native assembly for atomic operations on i586 or
# latter processors (GCC by defaults emits code compatible with the original # latter processors (GCC by defaults emits code compatible with the original
# i386 and requires library functions to emulate atomic operations). When # i386 and requires library functions to emulate atomic operations). When
# gnustep-make takes care of this kind of target setting, the check can safely # gnustep-make takes care of this kind of target setting, the check can safely
# be removed. # be removed.
case "$target_cpu" in case "$target_cpu" in
i586*|i686*|i786*) i586*|i686*|i786*)
ATOMIC_CFLAGS="-march=i586"; ATOMIC_CFLAGS="-march=i586"
CFLAGS="$saved_CFLAGS $ATOMIC_CFLAGS"; CFLAGS="$saved_CFLAGS $ATOMIC_CFLAGS"
OBJCFLAGS="$OBJCFLAGS $ATOMIC_CFLAGS"; OBJCFLAGS="$OBJCFLAGS $ATOMIC_CFLAGS"
esac ;;
AC_MSG_CHECKING([checking whether atomic operations require an external library]); x86_64)
AC_LINK_IFELSE([AC_LANG_PROGRAM([[typedef int atomic;]], ATOMIC_CFLAGS="-march=x86-64"
[[atomic x; atomic y; __sync_bool_compare_and_swap(&x, y, y + 1);]])], CFLAGS="$saved_CFLAGS $ATOMIC_CFLAGS"
need_linkage=no, OBJCFLAGS="$OBJCFLAGS $ATOMIC_CFLAGS"
need_linkage=yes); ;;
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 if test "$need_march" = "yes"; then
AC_MSG_RESULT([no]); AC_MSG_RESULT([yes]);
else AC_DEFINE(USE_ATOMIC_BUILTINS,1,
AC_MSG_RESULT([yes]); [Define if the compiler provides builtins for atomic operations])
saved_LDFLAGS="$LDFLAGS"; else
LDFLAGS="$saved_LDFLAGS -lgcc"; AC_MSG_RESULT([no]);
AC_MSG_CHECKING([checking for atomic operations from libgcc]); saved_LDFLAGS="$LDFLAGS";
AC_LINK_IFELSE([AC_LANG_PROGRAM([[typedef int atomic;]], LDFLAGS="$saved_LDFLAGS -lgcc";
[[atomic x; atomic y; __sync_bool_compare_and_swap(&x, y, y + 1);]])], AC_MSG_CHECKING([whether gcc supports atomic operations by linikng to libgcc]);
atomic_in_libgcc=yes, AC_LINK_IFELSE([AC_LANG_PROGRAM([[typedef int atomic;]],
atomic_in_libgcc=no); [[atomic x; atomic y; __sync_bool_compare_and_swap(&x, y, y + 1);]])],
if test "$atomic_in_libgcc" = "yes"; then atomic_in_libgcc=yes,
AC_MSG_RESULT([yes]); atomic_in_libgcc=no);
LIBS="$LIBS -lgcc"; if test "$atomic_in_libgcc" = "yes"; then
AC_DEFINE(USE_ATOMIC_BUILTINS,1, AC_MSG_RESULT([yes]);
[Define if the compiler provides builtins for atomic operations]) LIBS="$LIBS -lgcc";
else AC_DEFINE(USE_ATOMIC_BUILTINS,1,
LDFLAGS="$saved_LDFLAGS"; [Define if the compiler provides builtins for atomic operations])
AC_MSG_RESULT([no]); else
LDFLAGS="$saved_LDFLAGS";
AC_MSG_RESULT([no]);
fi
fi
fi fi
fi fi
fi
AC_LANG_POP(C) AC_LANG_POP(C)