Browse Source

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
Rich Megginson 14 years ago
parent
commit
de75e6d278
4 changed files with 76 additions and 36 deletions
  1. 6 3
      config.h.in
  2. 57 11
      configure
  3. 8 9
      configure.ac
  4. 5 13
      ldap/servers/slapd/slapi_counter.c

+ 6 - 3
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

+ 57 - 11
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

+ 8 - 9
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])

+ 5 - 13
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 */