You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2012/03/08 21:07:43 UTC

svn commit: r1298554 - in /subversion/branches/revprop-cache: build/ac-macros/svn-macros.m4 configure.ac

Author: stefan2
Date: Thu Mar  8 20:07:43 2012
New Revision: 1298554

URL: http://svn.apache.org/viewvc?rev=1298554&view=rev
Log:
Teach subversion to detect the availability of GCC's atomic built-ins
for 64 bit items. This code was taken from APR and tweaked slightly.

* build/ac-macros/svn-macros.m4
  (SVN_CHECK_FOR_ATOMIC_BUILTINS): new macro
* configure.ac
  call the new macro, set SVN_HAS_ATOMIC_BUILTINS #define

Modified:
    subversion/branches/revprop-cache/build/ac-macros/svn-macros.m4
    subversion/branches/revprop-cache/configure.ac

Modified: subversion/branches/revprop-cache/build/ac-macros/svn-macros.m4
URL: http://svn.apache.org/viewvc/subversion/branches/revprop-cache/build/ac-macros/svn-macros.m4?rev=1298554&r1=1298553&r2=1298554&view=diff
==============================================================================
--- subversion/branches/revprop-cache/build/ac-macros/svn-macros.m4 (original)
+++ subversion/branches/revprop-cache/build/ac-macros/svn-macros.m4 Thu Mar  8 20:07:43 2012
@@ -202,3 +202,44 @@ AC_DEFUN([SVN_REMOVE_STANDARD_LIB_DIRS],
     printf "%s" "${output_flags# }"
   fi
 ])
+
+AC_DEFUN([SVN_CHECK_FOR_ATOMIC_BUILTINS],
+[
+  AC_CACHE_CHECK([whether the compiler provides atomic builtins], [ap_cv_atomic_builtins],
+  [AC_TRY_RUN([
+  int main()
+  {
+      unsigned long long val = 1010, tmp, *mem = &val;
+
+      if (__sync_fetch_and_add(&val, 1010) != 1010 || val != 2020)
+          return 1;
+
+      tmp = val;
+
+      if (__sync_fetch_and_sub(mem, 1010) != tmp || val != 1010)
+          return 1;
+
+      if (__sync_sub_and_fetch(&val, 1010) != 0 || val != 0)
+          return 1;
+
+      tmp = 3030;
+
+      if (__sync_val_compare_and_swap(mem, 0, tmp) != 0 || val != tmp)
+          return 1;
+
+      if (__sync_lock_test_and_set(&val, 4040) != 3030)
+          return 1;
+
+      mem = &tmp;
+
+      if (__sync_val_compare_and_swap(&mem, &tmp, &val) != &tmp)
+          return 1;
+
+      __sync_synchronize();
+
+      if (mem != &val)
+          return 1;
+
+      return 0;
+  }], [ap_cv_atomic_builtins=yes], [ap_cv_atomic_builtins=no], [ap_cv_atomic_builtins=no])])
+])

Modified: subversion/branches/revprop-cache/configure.ac
URL: http://svn.apache.org/viewvc/subversion/branches/revprop-cache/configure.ac?rev=1298554&r1=1298553&r2=1298554&view=diff
==============================================================================
--- subversion/branches/revprop-cache/configure.ac (original)
+++ subversion/branches/revprop-cache/configure.ac Thu Mar  8 20:07:43 2012
@@ -184,6 +184,12 @@ if test -n "$sqlite_compat_ver" && test 
   CFLAGS="-DSVN_SQLITE_MIN_VERSION_NUMBER=$sqlite_compat_ver_num $CFLAGS"
 fi
 
+SVN_CHECK_FOR_ATOMIC_BUILTINS
+
+if test "$ap_cv_atomic_builtins" = "yes"; then
+    AC_DEFINE(SVN_HAS_ATOMIC_BUILTINS, 1, [Define if compiler provides atomic builtins])
+fi
+
 dnl Set up a number of directories ---------------------
 
 dnl Create SVN_BINDIR for proper substitution



Re: svn commit: r1298554 - in /subversion/branches/revprop-cache: build/ac-macros/svn-macros.m4 configure.ac

Posted by Stefan Fuhrmann <eq...@web.de>.
On 09.03.2012 15:53, Daniel Shahaf wrote:
> stefan2@apache.org wrote on Thu, Mar 08, 2012 at 20:07:43 -0000:
>> Author: stefan2
>> Date: Thu Mar  8 20:07:43 2012
>> New Revision: 1298554
>>
>> URL: http://svn.apache.org/viewvc?rev=1298554&view=rev
>> Log:
>> Teach subversion to detect the availability of GCC's atomic built-ins
>> for 64 bit items. This code was taken from APR and tweaked slightly.
>>
>> * build/ac-macros/svn-macros.m4
>>    (SVN_CHECK_FOR_ATOMIC_BUILTINS): new macro
>> * configure.ac
>>    call the new macro, set SVN_HAS_ATOMIC_BUILTINS #define
>>
>> Modified:
>>      subversion/branches/revprop-cache/build/ac-macros/svn-macros.m4
>>      subversion/branches/revprop-cache/configure.ac
>>
>> Modified: subversion/branches/revprop-cache/build/ac-macros/svn-macros.m4
>> URL: http://svn.apache.org/viewvc/subversion/branches/revprop-cache/build/ac-macros/svn-macros.m4?rev=1298554&r1=1298553&r2=1298554&view=diff
>> ==============================================================================
>> --- subversion/branches/revprop-cache/build/ac-macros/svn-macros.m4 (original)
>> +++ subversion/branches/revprop-cache/build/ac-macros/svn-macros.m4 Thu Mar  8 20:07:43 2012
>> @@ -202,3 +202,44 @@ AC_DEFUN([SVN_REMOVE_STANDARD_LIB_DIRS],
>>       printf "%s" "${output_flags# }"
>>     fi
>>   ])
>> +
>> +AC_DEFUN([SVN_CHECK_FOR_ATOMIC_BUILTINS],
>> +[
>> +  AC_CACHE_CHECK([whether the compiler provides atomic builtins], [ap_cv_atomic_builtins],
>> +  [AC_TRY_RUN([
>> +  int main()
>> +  {
> ...
>> +  }], [ap_cv_atomic_builtins=yes], [ap_cv_atomic_builtins=no], [ap_cv_atomic_builtins=no])])
> Mostly a nitpick, but this configure variable is in httpd's namespace
> (ap_*), not svn's --- so in principle, we should rename the variable to
> the svn_* namespace.
>
> Daniel
> (Yes, it's not a problem for the majority of downstream consumers.
> Agreed.  But raising it, partially due to similar issues being raised
> on other ASF lists recently.)
>
Thanks for noticing - I've not been aware of the
namespace issue. I simply took the code from
APR, it worked and that was fine with me ;)

Fixed in r1298982.

-- Stefan^2.

Re: svn commit: r1298554 - in /subversion/branches/revprop-cache: build/ac-macros/svn-macros.m4 configure.ac

Posted by Daniel Shahaf <da...@elego.de>.
stefan2@apache.org wrote on Thu, Mar 08, 2012 at 20:07:43 -0000:
> Author: stefan2
> Date: Thu Mar  8 20:07:43 2012
> New Revision: 1298554
> 
> URL: http://svn.apache.org/viewvc?rev=1298554&view=rev
> Log:
> Teach subversion to detect the availability of GCC's atomic built-ins
> for 64 bit items. This code was taken from APR and tweaked slightly.
> 
> * build/ac-macros/svn-macros.m4
>   (SVN_CHECK_FOR_ATOMIC_BUILTINS): new macro
> * configure.ac
>   call the new macro, set SVN_HAS_ATOMIC_BUILTINS #define
> 
> Modified:
>     subversion/branches/revprop-cache/build/ac-macros/svn-macros.m4
>     subversion/branches/revprop-cache/configure.ac
> 
> Modified: subversion/branches/revprop-cache/build/ac-macros/svn-macros.m4
> URL: http://svn.apache.org/viewvc/subversion/branches/revprop-cache/build/ac-macros/svn-macros.m4?rev=1298554&r1=1298553&r2=1298554&view=diff
> ==============================================================================
> --- subversion/branches/revprop-cache/build/ac-macros/svn-macros.m4 (original)
> +++ subversion/branches/revprop-cache/build/ac-macros/svn-macros.m4 Thu Mar  8 20:07:43 2012
> @@ -202,3 +202,44 @@ AC_DEFUN([SVN_REMOVE_STANDARD_LIB_DIRS],
>      printf "%s" "${output_flags# }"
>    fi
>  ])
> +
> +AC_DEFUN([SVN_CHECK_FOR_ATOMIC_BUILTINS],
> +[
> +  AC_CACHE_CHECK([whether the compiler provides atomic builtins], [ap_cv_atomic_builtins],
> +  [AC_TRY_RUN([
> +  int main()
> +  {
...
> +  }], [ap_cv_atomic_builtins=yes], [ap_cv_atomic_builtins=no], [ap_cv_atomic_builtins=no])])

Mostly a nitpick, but this configure variable is in httpd's namespace
(ap_*), not svn's --- so in principle, we should rename the variable to
the svn_* namespace.

Daniel
(Yes, it's not a problem for the majority of downstream consumers.
Agreed.  But raising it, partially due to similar issues being raised
on other ASF lists recently.)

Re: svn commit: r1298554 - in /subversion/branches/revprop-cache: build/ac-macros/svn-macros.m4 configure.ac

Posted by Stefan Fuhrmann <eq...@web.de>.
On 09.03.2012 15:40, Daniel Shahaf wrote:
> stefan2@apache.org wrote on Thu, Mar 08, 2012 at 20:07:43 -0000:
>> Author: stefan2
>> Date: Thu Mar  8 20:07:43 2012
>> New Revision: 1298554
>>
>> URL: http://svn.apache.org/viewvc?rev=1298554&view=rev
>> Log:
>> Teach subversion to detect the availability of GCC's atomic built-ins
>> for 64 bit items. This code was taken from APR and tweaked slightly.
>>
>> * build/ac-macros/svn-macros.m4
>>    (SVN_CHECK_FOR_ATOMIC_BUILTINS): new macro
>> * configure.ac
>>    call the new macro, set SVN_HAS_ATOMIC_BUILTINS #define
>>
>> Modified:
>>      subversion/branches/revprop-cache/build/ac-macros/svn-macros.m4
>>      subversion/branches/revprop-cache/configure.ac
>>
>> Modified: subversion/branches/revprop-cache/build/ac-macros/svn-macros.m4
>> URL: http://svn.apache.org/viewvc/subversion/branches/revprop-cache/build/ac-macros/svn-macros.m4?rev=1298554&r1=1298553&r2=1298554&view=diff
>> ==============================================================================
>> --- subversion/branches/revprop-cache/build/ac-macros/svn-macros.m4 (original)
>> +++ subversion/branches/revprop-cache/build/ac-macros/svn-macros.m4 Thu Mar  8 20:07:43 2012
>> @@ -202,3 +202,44 @@ AC_DEFUN([SVN_REMOVE_STANDARD_LIB_DIRS],
>>       printf "%s" "${output_flags# }"
>>     fi
>>   ])
>> +
>> +AC_DEFUN([SVN_CHECK_FOR_ATOMIC_BUILTINS],
>> +[
>> +  AC_CACHE_CHECK([whether the compiler provides atomic builtins], [ap_cv_atomic_builtins],
> How does this interact with
>   http://subversion.apache.org/docs/release-notes/1.7#rhel-2-issue
> ?  (which says: "Workarounds include using a more recent gcc or
> configuring APR with --disable-nonportable-atomics.")
>
> Should the new code be disabled for old gcc's?

That bug is in APR/atomic/unix/ia32.c. The built-ins that
I check for are similar to APR/atomic/unix/builtins.c.
But I would be fine with disabling this code for older GCCs.

We need to test it on 32 bit unix anyways since the compiler
needs to create a longer instruction sequence on those
machines. Writing a thorough test for the new API will be
some non-trivial task.

-- Stefan^2.

Re: svn commit: r1298554 - in /subversion/branches/revprop-cache: build/ac-macros/svn-macros.m4 configure.ac

Posted by Daniel Shahaf <da...@elego.de>.
stefan2@apache.org wrote on Thu, Mar 08, 2012 at 20:07:43 -0000:
> Author: stefan2
> Date: Thu Mar  8 20:07:43 2012
> New Revision: 1298554
> 
> URL: http://svn.apache.org/viewvc?rev=1298554&view=rev
> Log:
> Teach subversion to detect the availability of GCC's atomic built-ins
> for 64 bit items. This code was taken from APR and tweaked slightly.
> 
> * build/ac-macros/svn-macros.m4
>   (SVN_CHECK_FOR_ATOMIC_BUILTINS): new macro
> * configure.ac
>   call the new macro, set SVN_HAS_ATOMIC_BUILTINS #define
> 
> Modified:
>     subversion/branches/revprop-cache/build/ac-macros/svn-macros.m4
>     subversion/branches/revprop-cache/configure.ac
> 
> Modified: subversion/branches/revprop-cache/build/ac-macros/svn-macros.m4
> URL: http://svn.apache.org/viewvc/subversion/branches/revprop-cache/build/ac-macros/svn-macros.m4?rev=1298554&r1=1298553&r2=1298554&view=diff
> ==============================================================================
> --- subversion/branches/revprop-cache/build/ac-macros/svn-macros.m4 (original)
> +++ subversion/branches/revprop-cache/build/ac-macros/svn-macros.m4 Thu Mar  8 20:07:43 2012
> @@ -202,3 +202,44 @@ AC_DEFUN([SVN_REMOVE_STANDARD_LIB_DIRS],
>      printf "%s" "${output_flags# }"
>    fi
>  ])
> +
> +AC_DEFUN([SVN_CHECK_FOR_ATOMIC_BUILTINS],
> +[
> +  AC_CACHE_CHECK([whether the compiler provides atomic builtins], [ap_cv_atomic_builtins],

How does this interact with
 http://subversion.apache.org/docs/release-notes/1.7#rhel-2-issue
?  (which says: "Workarounds include using a more recent gcc or
configuring APR with --disable-nonportable-atomics.")

Should the new code be disabled for old gcc's?

> +  [AC_TRY_RUN([
> +  int main()
> +  {
> +      unsigned long long val = 1010, tmp, *mem = &val;
> +
> +      if (__sync_fetch_and_add(&val, 1010) != 1010 || val != 2020)
> +          return 1;
> +
> +      tmp = val;
> +
> +      if (__sync_fetch_and_sub(mem, 1010) != tmp || val != 1010)
> +          return 1;
> +
> +      if (__sync_sub_and_fetch(&val, 1010) != 0 || val != 0)
> +          return 1;
> +
> +      tmp = 3030;
> +
> +      if (__sync_val_compare_and_swap(mem, 0, tmp) != 0 || val != tmp)
> +          return 1;
> +
> +      if (__sync_lock_test_and_set(&val, 4040) != 3030)
> +          return 1;
> +
> +      mem = &tmp;
> +
> +      if (__sync_val_compare_and_swap(&mem, &tmp, &val) != &tmp)
> +          return 1;
> +
> +      __sync_synchronize();
> +
> +      if (mem != &val)
> +          return 1;
> +
> +      return 0;
> +  }], [ap_cv_atomic_builtins=yes], [ap_cv_atomic_builtins=no], [ap_cv_atomic_builtins=no])])
> +])
> 
> Modified: subversion/branches/revprop-cache/configure.ac
> URL: http://svn.apache.org/viewvc/subversion/branches/revprop-cache/configure.ac?rev=1298554&r1=1298553&r2=1298554&view=diff
> ==============================================================================
> --- subversion/branches/revprop-cache/configure.ac (original)
> +++ subversion/branches/revprop-cache/configure.ac Thu Mar  8 20:07:43 2012
> @@ -184,6 +184,12 @@ if test -n "$sqlite_compat_ver" && test 
>    CFLAGS="-DSVN_SQLITE_MIN_VERSION_NUMBER=$sqlite_compat_ver_num $CFLAGS"
>  fi
>  
> +SVN_CHECK_FOR_ATOMIC_BUILTINS
> +
> +if test "$ap_cv_atomic_builtins" = "yes"; then
> +    AC_DEFINE(SVN_HAS_ATOMIC_BUILTINS, 1, [Define if compiler provides atomic builtins])
> +fi
> +
>  dnl Set up a number of directories ---------------------
>  
>  dnl Create SVN_BINDIR for proper substitution
> 
> 

Re: svn commit: r1298554 - in /subversion/branches/revprop-cache: build/ac-macros/svn-macros.m4 configure.ac

Posted by Daniel Shahaf <da...@elego.de>.
stefan2@apache.org wrote on Thu, Mar 08, 2012 at 20:07:43 -0000:
> Author: stefan2
> Date: Thu Mar  8 20:07:43 2012
> New Revision: 1298554
> 
> URL: http://svn.apache.org/viewvc?rev=1298554&view=rev
> Log:
> Teach subversion to detect the availability of GCC's atomic built-ins
> for 64 bit items. This code was taken from APR and tweaked slightly.
> 
> * build/ac-macros/svn-macros.m4
>   (SVN_CHECK_FOR_ATOMIC_BUILTINS): new macro
> * configure.ac
>   call the new macro, set SVN_HAS_ATOMIC_BUILTINS #define
> 
> Modified:
>     subversion/branches/revprop-cache/build/ac-macros/svn-macros.m4
>     subversion/branches/revprop-cache/configure.ac
> 
> Modified: subversion/branches/revprop-cache/build/ac-macros/svn-macros.m4
> URL: http://svn.apache.org/viewvc/subversion/branches/revprop-cache/build/ac-macros/svn-macros.m4?rev=1298554&r1=1298553&r2=1298554&view=diff
> ==============================================================================
> --- subversion/branches/revprop-cache/build/ac-macros/svn-macros.m4 (original)
> +++ subversion/branches/revprop-cache/build/ac-macros/svn-macros.m4 Thu Mar  8 20:07:43 2012
> @@ -202,3 +202,44 @@ AC_DEFUN([SVN_REMOVE_STANDARD_LIB_DIRS],
>      printf "%s" "${output_flags# }"
>    fi
>  ])
> +
> +AC_DEFUN([SVN_CHECK_FOR_ATOMIC_BUILTINS],
> +[
> +  AC_CACHE_CHECK([whether the compiler provides atomic builtins], [ap_cv_atomic_builtins],

How does this interact with
 http://subversion.apache.org/docs/release-notes/1.7#rhel-2-issue
?  (which says: "Workarounds include using a more recent gcc or
configuring APR with --disable-nonportable-atomics.")

Should the new code be disabled for old gcc's?

> +  [AC_TRY_RUN([
> +  int main()
> +  {
> +      unsigned long long val = 1010, tmp, *mem = &val;
> +
> +      if (__sync_fetch_and_add(&val, 1010) != 1010 || val != 2020)
> +          return 1;
> +
> +      tmp = val;
> +
> +      if (__sync_fetch_and_sub(mem, 1010) != tmp || val != 1010)
> +          return 1;
> +
> +      if (__sync_sub_and_fetch(&val, 1010) != 0 || val != 0)
> +          return 1;
> +
> +      tmp = 3030;
> +
> +      if (__sync_val_compare_and_swap(mem, 0, tmp) != 0 || val != tmp)
> +          return 1;
> +
> +      if (__sync_lock_test_and_set(&val, 4040) != 3030)
> +          return 1;
> +
> +      mem = &tmp;
> +
> +      if (__sync_val_compare_and_swap(&mem, &tmp, &val) != &tmp)
> +          return 1;
> +
> +      __sync_synchronize();
> +
> +      if (mem != &val)
> +          return 1;
> +
> +      return 0;
> +  }], [ap_cv_atomic_builtins=yes], [ap_cv_atomic_builtins=no], [ap_cv_atomic_builtins=no])])
> +])
> 
> Modified: subversion/branches/revprop-cache/configure.ac
> URL: http://svn.apache.org/viewvc/subversion/branches/revprop-cache/configure.ac?rev=1298554&r1=1298553&r2=1298554&view=diff
> ==============================================================================
> --- subversion/branches/revprop-cache/configure.ac (original)
> +++ subversion/branches/revprop-cache/configure.ac Thu Mar  8 20:07:43 2012
> @@ -184,6 +184,12 @@ if test -n "$sqlite_compat_ver" && test 
>    CFLAGS="-DSVN_SQLITE_MIN_VERSION_NUMBER=$sqlite_compat_ver_num $CFLAGS"
>  fi
>  
> +SVN_CHECK_FOR_ATOMIC_BUILTINS
> +
> +if test "$ap_cv_atomic_builtins" = "yes"; then
> +    AC_DEFINE(SVN_HAS_ATOMIC_BUILTINS, 1, [Define if compiler provides atomic builtins])
> +fi
> +
>  dnl Set up a number of directories ---------------------
>  
>  dnl Create SVN_BINDIR for proper substitution
> 
> 

Re: svn commit: r1298554 - in /subversion/branches/revprop-cache: build/ac-macros/svn-macros.m4 configure.ac

Posted by Daniel Shahaf <da...@elego.de>.
stefan2@apache.org wrote on Thu, Mar 08, 2012 at 20:07:43 -0000:
> Author: stefan2
> Date: Thu Mar  8 20:07:43 2012
> New Revision: 1298554
> 
> URL: http://svn.apache.org/viewvc?rev=1298554&view=rev
> Log:
> Teach subversion to detect the availability of GCC's atomic built-ins
> for 64 bit items. This code was taken from APR and tweaked slightly.
> 
> * build/ac-macros/svn-macros.m4
>   (SVN_CHECK_FOR_ATOMIC_BUILTINS): new macro
> * configure.ac
>   call the new macro, set SVN_HAS_ATOMIC_BUILTINS #define
> 
> Modified:
>     subversion/branches/revprop-cache/build/ac-macros/svn-macros.m4
>     subversion/branches/revprop-cache/configure.ac
> 
> Modified: subversion/branches/revprop-cache/build/ac-macros/svn-macros.m4
> URL: http://svn.apache.org/viewvc/subversion/branches/revprop-cache/build/ac-macros/svn-macros.m4?rev=1298554&r1=1298553&r2=1298554&view=diff
> ==============================================================================
> --- subversion/branches/revprop-cache/build/ac-macros/svn-macros.m4 (original)
> +++ subversion/branches/revprop-cache/build/ac-macros/svn-macros.m4 Thu Mar  8 20:07:43 2012
> @@ -202,3 +202,44 @@ AC_DEFUN([SVN_REMOVE_STANDARD_LIB_DIRS],
>      printf "%s" "${output_flags# }"
>    fi
>  ])
> +
> +AC_DEFUN([SVN_CHECK_FOR_ATOMIC_BUILTINS],
> +[
> +  AC_CACHE_CHECK([whether the compiler provides atomic builtins], [ap_cv_atomic_builtins],
> +  [AC_TRY_RUN([
> +  int main()
> +  {
...
> +  }], [ap_cv_atomic_builtins=yes], [ap_cv_atomic_builtins=no], [ap_cv_atomic_builtins=no])])

Mostly a nitpick, but this configure variable is in httpd's namespace
(ap_*), not svn's --- so in principle, we should rename the variable to
the svn_* namespace.

Daniel
(Yes, it's not a problem for the majority of downstream consumers.
Agreed.  But raising it, partially due to similar issues being raised
on other ASF lists recently.)