diff options
author | Lennart Poettering <lennart@poettering.net> | 2009-05-19 22:30:14 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2009-05-20 02:09:32 +0200 |
commit | 9293e823767daee79386cc797510808f4eed01a3 (patch) | |
tree | b1f482f0cdf51c1ef2d78931665db6a7175502a8 /configure.in | |
parent | 74bff5af804817372aece931c792b53c8ec534e1 (diff) |
atomic: implement atomic operations based on gcc's __sync extension
Newer gccs and intel ccs support a __sync extension for making use of
atomic operations. This patch replaces the handcrafted x86 atomic
operation support with usage of __sync.
__sync is supported by more processors and by more compilers than the
old assembler code. Also, this extension has been available on gcc for
quite a while now for x86, so replacing the old assembler code should
only be a loss when very old compiilers are used.
Diffstat (limited to 'configure.in')
-rw-r--r-- | configure.in | 50 |
1 files changed, 16 insertions, 34 deletions
diff --git a/configure.in b/configure.in index b087b003..c2c6a8c9 100644 --- a/configure.in +++ b/configure.in @@ -590,41 +590,23 @@ if test "x$dbus_cv_va_val_copy" = "xno"; then fi -#### Atomic integers (checks by Sebastian Wilhelmi for GLib) -AC_MSG_CHECKING([whether to use inline assembler routines for atomic integers]) -have_atomic_inc_cond=0 -if test x"$GCC" = xyes; then - if test "x$enable_ansi" = "xyes"; then - AC_MSG_RESULT([no]) - else - case $host_cpu in - i386) - AC_MSG_RESULT([no]) - ;; - i?86) - case $host_os in - darwin*) - AC_MSG_RESULT([darwin]) - # check at compile-time, so that it is possible to build universal - # (with multiple architectures at once on the compile line) - have_atomic_inc_cond="(defined(__i386__) || defined(__x86_64__))" - ;; - *) - AC_MSG_RESULT([i486]) - have_atomic_inc_cond=1 - ;; - esac - ;; - *) - AC_MSG_RESULT([no]) - ;; - esac - fi +#### Atomic integers + +AC_CACHE_CHECK([whether $CC knows __sync_sub_and_fetch()], + dbus_cv_sync_sub_and_fetch, + [AC_LINK_IFELSE( + AC_LANG_PROGRAM([], [[int a = 4; __sync_sub_and_fetch(&a, 4);]]), + [dbus_cv_sync_sub_and_fetch=yes], + [dbus_cv_sync_sub_and_fetch=no]) + ]) + +if test "x$dbus_cv_sync_sub_and_fetch" = "xyes" ; then + have_sync=1 +else + have_sync=0 fi -AC_DEFINE_UNQUOTED([DBUS_USE_ATOMIC_INT_486_COND], [$have_atomic_inc_cond], - [Always defined; expands to 1 if we should use atomic integer implementation for 486, else 0]) -AC_DEFINE_UNQUOTED(DBUS_HAVE_ATOMIC_INT_COND, [$have_atomic_inc_cond], - [Always defined; expands to 1 if we have an atomic integer implementation, else 0]) + +AC_DEFINE_UNQUOTED([DBUS_USE_SYNC], [$have_sync], [Use the gcc __sync extension]) #### Various functions AC_CHECK_LIB(socket,socket) |