config.h.in | 9 +++-
configure | 68 +++++++++++++++++++++++++++++++------
configure.ac | 17 ++++-----
ldap/servers/slapd/slapi_counter.c | 18 ++-------
4 files changed, 76 insertions(+), 36 deletions(-)
New commits:
commit de75e6d27839a6a63f0ac7b8a830db5b95813073
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Wed Aug 10 09:46:59 2011 -0600
Bug 723937 - replication failing on RUV errors
https://bugzilla.redhat.com/show_bug.cgi?id=723937
Resolves: bug 723937
Bug Description: replication failing on RUV errors
Reviewed by: nkinder (Thanks!)
Branch: master
Fix Description: I incorrectly assumed I could just revert the patch
that removed the assembler code, but I needed to tweak the #if
condition that decides to use the assembler code or not.
I also added separate configure checks and defines for the 64bit atomic
op functions and the 64bit atomic cas function since they are different
on some platforms.
Platforms tested: RHEL6 x86_64, F15 i686, EL5 i386
Flag Day: no
Doc impact: no
diff --git a/config.h.in b/config.h.in
index 888611a..111c557 100644
--- a/config.h.in
+++ b/config.h.in
@@ -57,6 +57,12 @@
/* enable the presence plugin */
#undef ENABLE_PRESENCE
+/* have 64-bit atomic bool compare and swap function provided by gcc */
+#undef HAVE_64BIT_ATOMIC_CAS_FUNC
+
+/* have 64-bit atomic operation functions provided by gcc */
+#undef HAVE_64BIT_ATOMIC_OP_FUNCS
+
/* Define to 1 if you have the <arpa/inet.h> header file. */
#undef HAVE_ARPA_INET_H
@@ -67,9 +73,6 @@
don't. */
#undef HAVE_DECL_STRERROR_R
-/* do not have 64-bit atomic compare and swap functions provided by gcc */
-#undef HAVE_DECL___SYNC_ADD_AND_FETCH
-
/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
*/
#undef HAVE_DIRENT_H
diff --git a/configure b/configure
index 8ae9dca..ce17c36 100755
--- a/configure
+++ b/configure
@@ -20765,8 +20765,8 @@ _ACEOF
;;
esac
- { $as_echo "$as_me:$LINENO: checking for GCC provided 64-bit atomic
functions ..." >&5
-$as_echo_n "checking for GCC provided 64-bit atomic functions ...... "
>&6; }
+ { $as_echo "$as_me:$LINENO: checking for GCC provided 64-bit atomic bool cas
function ..." >&5
+$as_echo_n "checking for GCC provided 64-bit atomic bool cas function ...... "
>&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
@@ -20803,32 +20803,78 @@ $as_echo "$ac_try_echo") >&5
test "$cross_compiling" = yes ||
$as_test_x conftest$ac_exeext
}; then
- have_gcc_64bit_cas=1; { $as_echo "$as_me:$LINENO: result: yes" >&5
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_64BIT_ATOMIC_CAS_FUNC 1
+_ACEOF
+{ $as_echo "$as_me:$LINENO: result: yes" >&5
$as_echo "yes" >&6; }
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
- have_gcc_64bit_cas=; { $as_echo "$as_me:$LINENO: result: no" >&5
+ { $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
fi
rm -rf conftest.dSYM
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
conftest$ac_exeext conftest.$ac_ext
- if test -n "$have_gcc_64bit_cas" ; then
-
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_DECL___SYNC_ADD_AND_FETCH 1
+ { $as_echo "$as_me:$LINENO: checking for GCC provided 64-bit atomic ops
functions ..." >&5
+$as_echo_n "checking for GCC provided 64-bit atomic ops functions ...... "
>&6; }
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
- else
+int
+main ()
+{
+long long ptrval = 0, val = 0; (void)__sync_add_and_fetch_8(&ptrval, val);
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_link") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext && {
+ test "$cross_compiling" = yes ||
+ $as_test_x conftest$ac_exeext
+ }; then
cat >>confdefs.h <<\_ACEOF
-#define HAVE_DECL___SYNC_ADD_AND_FETCH 0
+#define HAVE_64BIT_ATOMIC_OP_FUNCS 1
_ACEOF
+{ $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
- fi
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+rm -rf conftest.dSYM
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+ conftest$ac_exeext conftest.$ac_ext
# some programs use the native thread library directly
THREADLIB=-lpthread
THREADLIB=$THREADLIB
diff --git a/configure.ac b/configure.ac
index ac4dc82..6d8e277 100644
--- a/configure.ac
+++ b/configure.ac
@@ -407,17 +407,16 @@ case $host in
AC_DEFINE([ATOMIC_64BIT_OPERATIONS], [1], [enabling atomic counter])
;;
esac
- dnl no headers to test for __sync_bool_compare_and_swap_8
- AC_MSG_CHECKING([for GCC provided 64-bit atomic functions ...])
+ AC_MSG_CHECKING([for GCC provided 64-bit atomic bool cas function ...])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
[[long long ptrval = 0, val = 0, newval = 1;
(void)__sync_bool_compare_and_swap_8(&ptrval, val, newval);]])],
- [have_gcc_64bit_cas=1; AC_MSG_RESULT([yes])],
- [have_gcc_64bit_cas=; AC_MSG_RESULT([no])])
- if test -n "$have_gcc_64bit_cas" ; then
- AC_DEFINE([HAVE_DECL___SYNC_ADD_AND_FETCH], [1], [have 64-bit atomic compare and
swap functions provided by gcc])
- else
- AC_DEFINE([HAVE_DECL___SYNC_ADD_AND_FETCH], [0], [do not have 64-bit atomic
compare and swap functions provided by gcc])
- fi
+ [AC_DEFINE([HAVE_64BIT_ATOMIC_CAS_FUNC], [1], [have 64-bit atomic bool
compare and swap function provided by gcc])AC_MSG_RESULT([yes])],
+ [AC_MSG_RESULT([no])])
+ AC_MSG_CHECKING([for GCC provided 64-bit atomic ops functions ...])
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
+ [[long long ptrval = 0, val = 0;
(void)__sync_add_and_fetch_8(&ptrval, val);]])],
+ [AC_DEFINE([HAVE_64BIT_ATOMIC_OP_FUNCS], [1], [have 64-bit atomic
operation functions provided by gcc])AC_MSG_RESULT([yes])],
+ [AC_MSG_RESULT([no])])
# some programs use the native thread library directly
THREADLIB=-lpthread
AC_SUBST([THREADLIB], [$THREADLIB])
diff --git a/ldap/servers/slapd/slapi_counter.c b/ldap/servers/slapd/slapi_counter.c
index c3f1f44..4d2c5cf 100644
--- a/ldap/servers/slapd/slapi_counter.c
+++ b/ldap/servers/slapd/slapi_counter.c
@@ -54,19 +54,11 @@ PRUint64 _sparcv9_AtomicSub(PRUint64 *address, PRUint64 val);
#endif
#ifdef ATOMIC_64BIT_OPERATIONS
-#if defined LINUX && (defined CPU_x86 || !HAVE_DECL___SYNC_ADD_AND_FETCH)
+#if defined(LINUX) && !HAVE_64BIT_ATOMIC_OP_FUNCS
/* On systems that don't have the 64-bit GCC atomic builtins, we need to
* implement our own atomic functions using inline assembly code. */
PRUint64 __sync_add_and_fetch_8(PRUint64 *ptr, PRUint64 addval);
PRUint64 __sync_sub_and_fetch_8(PRUint64 *ptr, PRUint64 subval);
-#endif
-
-#if defined LINUX && !HAVE_DECL___SYNC_ADD_AND_FETCH
-/* Systems that have the atomic builtins defined, but don't have
- * implementations for 64-bit values will automatically try to
- * call the __sync_*_8 versions we provide. If the atomic builtins
- * are not defined at all, we define them here to use our local
- * functions. */
#define __sync_add_and_fetch __sync_add_and_fetch_8
#define __sync_sub_and_fetch __sync_sub_and_fetch_8
#endif
@@ -294,7 +286,7 @@ PRUint64 slapi_counter_set_value(Slapi_Counter *counter, PRUint64
newvalue)
#ifdef LINUX
/* Use our own inline assembly for an atomic set if
* the builtins aren't available. */
-#if defined CPU_x86 || !HAVE_DECL___SYNC_ADD_AND_FETCH
+#if !HAVE_64BIT_ATOMIC_CAS_FUNC
/*
* %0 = counter->value
* %1 = newvalue
@@ -370,7 +362,7 @@ PRUint64 slapi_counter_get_value(Slapi_Counter *counter)
#ifdef LINUX
/* Use our own inline assembly for an atomic get if
* the builtins aren't available. */
-#if defined CPU_x86 || !HAVE_DECL___SYNC_ADD_AND_FETCH
+#if !HAVE_64BIT_ATOMIC_CAS_FUNC
/*
* %0 = counter->value
* %1 = value
@@ -432,7 +424,7 @@ PRUint64 slapi_counter_get_value(Slapi_Counter *counter)
}
#ifdef ATOMIC_64BIT_OPERATIONS
-#if defined LINUX && (defined CPU_x86 || !HAVE_DECL___SYNC_ADD_AND_FETCH)
+#if defined(LINUX) && !HAVE_64BIT_ATOMIC_OP_FUNCS
/* On systems that don't have the 64-bit GCC atomic builtins, we need to
* implement our own atomic add and subtract functions using inline
* assembly code. */
@@ -523,5 +515,5 @@ PRUint64 __sync_sub_and_fetch_8(PRUint64 *ptr, PRUint64 subval)
return retval;
}
-#endif /* LINUX && (defined CPU_x86 || !HAVE_DECL___SYNC_ADD_AND_FETCH) */
+#endif /* LINUX && !HAVE_64BIT_ATOMIC_OP_FUNCS */
#endif /* ATOMIC_64BIT_OPERATIONS */