[前][次][番号順一覧][スレッド一覧]

ruby-changes:32237

From: nagachika <ko1@a...>
Date: Sat, 21 Dec 2013 16:03:05 +0900 (JST)
Subject: [ruby-changes:32237] nagachika:r44316 (ruby_2_0_0): merge revision(s) 43851, 43882, 43883, 43995:

nagachika	2013-12-21 16:02:57 +0900 (Sat, 21 Dec 2013)

  New Revision: 44316

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44316

  Log:
    merge revision(s) 43851,43882,43883,43995:
    
    * ruby_atomic.h: use __atomic builtin functions supported by GCC.
      __sync family are legacy functions now and it is recommended
      that new code use the __atomic functions.
      http://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html
    
    * configure.in: check existence of __atomic functions.
    
    * ruby_atomic.h: define ATOMIC_SIZE_CAS() with
      __atomic_compare_exchange_n() and refactoring.
    
    * ruby_atomic.h: remove duplicate definisions between ATOMIC_XXX
      and ATOMIC_SIZE_XXX.

  Modified directories:
    branches/ruby_2_0_0/
  Modified files:
    branches/ruby_2_0_0/ChangeLog
    branches/ruby_2_0_0/configure.in
    branches/ruby_2_0_0/ruby_atomic.h
    branches/ruby_2_0_0/version.h
Index: ruby_2_0_0/configure.in
===================================================================
--- ruby_2_0_0/configure.in	(revision 44315)
+++ ruby_2_0_0/configure.in	(revision 44316)
@@ -1340,13 +1340,14 @@ if test "$GCC" = yes; then https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/configure.in#L1340
 	AC_DEFINE_UNQUOTED([RUBY_ALIAS_FUNCTION_VOID(prot, name, args)],
 			   [RUBY_ALIAS_FUNCTION_TYPE(void, prot, name, args)])
     fi
-    AC_CACHE_CHECK([for atomic builtins], [rb_cv_gcc_atomic_builtins], [
+
+    AC_CACHE_CHECK([for __atomic builtins], [rb_cv_gcc_atomic_builtins], [
 	AC_TRY_LINK([unsigned char atomic_var;],
 		    [
-			__sync_lock_test_and_set(&atomic_var, 0);
-			__sync_lock_test_and_set(&atomic_var, 1);
-			__sync_fetch_and_add(&atomic_var, 1);
-			__sync_fetch_and_sub(&atomic_var, 1);
+			__atomic_exchange_n(&atomic_var, 0, __ATOMIC_SEQ_CST);
+			__atomic_exchange_n(&atomic_var, 1, __ATOMIC_SEQ_CST);
+			__atomic_fetch_add(&atomic_var, 1, __ATOMIC_SEQ_CST);
+			__atomic_fetch_sub(&atomic_var, 1, __ATOMIC_SEQ_CST);
 		    ],
 		    [rb_cv_gcc_atomic_builtins=yes],
 		    [rb_cv_gcc_atomic_builtins=no])])
@@ -1354,6 +1355,20 @@ if test "$GCC" = yes; then https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/configure.in#L1355
 	AC_DEFINE(HAVE_GCC_ATOMIC_BUILTINS)
     fi
 
+    AC_CACHE_CHECK([for __sync builtins], [rb_cv_gcc_sync_builtins], [
+	AC_TRY_LINK([unsigned char atomic_var;],
+		    [
+			__sync_lock_test_and_set(&atomic_var, 0);
+			__sync_lock_test_and_set(&atomic_var, 1);
+			__sync_fetch_and_add(&atomic_var, 1);
+			__sync_fetch_and_sub(&atomic_var, 1);
+		    ],
+		    [rb_cv_gcc_sync_builtins=yes],
+		    [rb_cv_gcc_sync_builtins=no])])
+    if test "$rb_cv_gcc_sync_builtins" = yes; then
+	AC_DEFINE(HAVE_GCC_SYNC_BUILTINS)
+    fi
+
     AC_CACHE_CHECK(for __builtin_unreachable, rb_cv_func___builtin_unreachable,
     [RUBY_WERROR_FLAG(
     [AC_TRY_LINK([@%:@include <stdlib.h>],
Index: ruby_2_0_0/ChangeLog
===================================================================
--- ruby_2_0_0/ChangeLog	(revision 44315)
+++ ruby_2_0_0/ChangeLog	(revision 44316)
@@ -1,3 +1,22 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1
+Sat Dec 21 15:50:13 2013  Masaki Matsushita  <glass.saga@g...>
+
+	* ruby_atomic.h: remove duplicate definisions between ATOMIC_XXX
+	  and ATOMIC_SIZE_XXX.
+
+Sat Dec 21 15:50:13 2013  Masaki Matsushita  <glass.saga@g...>
+
+	* ruby_atomic.h: define ATOMIC_SIZE_CAS() with
+	  __atomic_compare_exchange_n() and refactoring.
+
+Sat Dec 21 15:50:13 2013  Masaki Matsushita  <glass.saga@g...>
+
+	* ruby_atomic.h: use __atomic builtin functions supported by GCC.
+	  __sync family are legacy functions now and it is recommended
+	  that new code use the __atomic functions.
+	  http://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html
+
+	* configure.in: check existence of __atomic functions.
+
 Sat Dec 21 15:37:11 2013  Naohisa Goto  <ngotogenome@g...>
 
 	* ruby_atomic.h (ATOMIC_SIZE_CAS): fix compile error on Solaris
Index: ruby_2_0_0/ruby_atomic.h
===================================================================
--- ruby_2_0_0/ruby_atomic.h	(revision 44315)
+++ ruby_2_0_0/ruby_atomic.h	(revision 44316)
@@ -3,6 +3,21 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ruby_atomic.h#L3
 
 #if 0
 #elif defined HAVE_GCC_ATOMIC_BUILTINS
+typedef unsigned int rb_atomic_t;
+# define ATOMIC_SET(var, val)  (void)__atomic_exchange_n(&(var), (val), __ATOMIC_SEQ_CST)
+# define ATOMIC_INC(var) __atomic_fetch_add(&(var), 1, __ATOMIC_SEQ_CST)
+# define ATOMIC_DEC(var) __atomic_fetch_sub(&(var), 1, __ATOMIC_SEQ_CST)
+# define ATOMIC_OR(var, val) __atomic_or_fetch(&(var), (val), __ATOMIC_SEQ_CST)
+# define ATOMIC_EXCHANGE(var, val) __atomic_exchange_n(&(var), (val), __ATOMIC_SEQ_CST)
+# define ATOMIC_CAS(var, oldval, newval) \
+({ __typeof__(oldval) oldvaldup = (oldval); /* oldval should not be modified */ \
+   __atomic_compare_exchange_n(&(var), &oldvaldup, (newval), 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); \
+   oldvaldup; })
+
+# define ATOMIC_SIZE_ADD(var, val) __atomic_fetch_add(&(var), (val), __ATOMIC_SEQ_CST)
+# define ATOMIC_SIZE_SUB(var, val) __atomic_fetch_sub(&(var), (val), __ATOMIC_SEQ_CST)
+
+#elif defined HAVE_GCC_SYNC_BUILTINS
 /* @shyouhei hack to support atomic operations in case of gcc. Gcc
  * has its own pseudo-insns to support them.  See info, or
  * http://gcc.gnu.org/onlinedocs/gcc/Atomic-Builtins.html */
@@ -17,9 +32,6 @@ typedef unsigned int rb_atomic_t; /* Any https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ruby_atomic.h#L32
 
 # define ATOMIC_SIZE_ADD(var, val) __sync_fetch_and_add(&(var), (val))
 # define ATOMIC_SIZE_SUB(var, val) __sync_fetch_and_sub(&(var), (val))
-# define ATOMIC_SIZE_INC(var) __sync_fetch_and_add(&(var), 1)
-# define ATOMIC_SIZE_DEC(var) __sync_fetch_and_sub(&(var), 1)
-# define ATOMIC_SIZE_EXCHANGE(var, val) __sync_lock_test_and_set(&(var), (val))
 
 #elif defined _WIN32
 #if defined _MSC_VER && _MSC_VER > 1200
@@ -117,8 +129,6 @@ extern rb_atomic_t ruby_atomic_compare_a https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ruby_atomic.h#L129
 
 # define ATOMIC_SIZE_ADD(var, val) (void)((var) += (val))
 # define ATOMIC_SIZE_SUB(var, val) (void)((var) -= (val))
-# define ATOMIC_SIZE_INC(var) ((var)++)
-# define ATOMIC_SIZE_DEC(var) ((var)--)
 # define ATOMIC_SIZE_EXCHANGE(var, val) atomic_size_exchange(&(var), (val))
 static inline size_t
 atomic_size_exchange(size_t *ptr, size_t val)
@@ -129,6 +139,15 @@ atomic_size_exchange(size_t *ptr, size_t https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ruby_atomic.h#L139
 }
 #endif
 
+#ifndef ATOMIC_SIZE_INC
+# define ATOMIC_SIZE_INC(var) ATOMIC_INC(var)
+#endif
+#ifndef ATOMIC_SIZE_DEC
+# define ATOMIC_SIZE_DEC(var) ATOMIC_DEC(var)
+#endif
+#ifndef ATOMIC_SIZE_EXCHANGE
+# define ATOMIC_SIZE_EXCHANGE(var, val) ATOMIC_EXCHANGE(var, val)
+#endif
 #ifndef ATOMIC_SIZE_CAS
 # define ATOMIC_SIZE_CAS(var, oldval, val) ATOMIC_CAS(var, oldval, val)
 #endif
Index: ruby_2_0_0/version.h
===================================================================
--- ruby_2_0_0/version.h	(revision 44315)
+++ ruby_2_0_0/version.h	(revision 44316)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1
 #define RUBY_VERSION "2.0.0"
 #define RUBY_RELEASE_DATE "2013-12-21"
-#define RUBY_PATCHLEVEL 362
+#define RUBY_PATCHLEVEL 363
 
 #define RUBY_RELEASE_YEAR 2013
 #define RUBY_RELEASE_MONTH 12

Property changes on: ruby_2_0_0
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r43851,43882-43883,43995


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]