ruby-changes:32873
From: usa <ko1@a...>
Date: Fri, 14 Feb 2014 19:10:12 +0900 (JST)
Subject: [ruby-changes:32873] usa:r44952 (ruby_1_9_3): merge revision(s) 43851, 43882, 43996:
usa 2014-02-14 19:10:07 +0900 (Fri, 14 Feb 2014) New Revision: 44952 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44952 Log: merge revision(s) 43851,43882,43996: * 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 (ATOMIC_PTR_EXCHANGE): atomic exchange function for a generic pointer. Modified directories: branches/ruby_1_9_3/ Modified files: branches/ruby_1_9_3/ChangeLog branches/ruby_1_9_3/configure.in branches/ruby_1_9_3/ruby_atomic.h branches/ruby_1_9_3/version.h Index: ruby_1_9_3/configure.in =================================================================== --- ruby_1_9_3/configure.in (revision 44951) +++ ruby_1_9_3/configure.in (revision 44952) @@ -887,19 +887,35 @@ if test "$GCC" = yes; then https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/configure.in#L887 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])]) if test "$rb_cv_gcc_atomic_builtins" = yes; then 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 + fi AC_CACHE_CHECK(for exported function attribute, rb_cv_func_exported, [ Index: ruby_1_9_3/ChangeLog =================================================================== --- ruby_1_9_3/ChangeLog (revision 44951) +++ ruby_1_9_3/ChangeLog (revision 44952) @@ -1,3 +1,22 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ChangeLog#L1 +Fri Feb 14 19:07:13 2014 Nobuyoshi Nakada <nobu@r...> + + * ruby_atomic.h (ATOMIC_PTR_EXCHANGE): atomic exchange function for + a generic pointer. + +Fri Feb 14 19:07:13 2014 Masaki Matsushita <glass.saga@g...> + + * ruby_atomic.h: define ATOMIC_SIZE_CAS() with + __atomic_compare_exchange_n() and refactoring. + +Fri Feb 14 19:07:13 2014 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. + Fri Feb 14 16:21:28 2014 NAKAMURA Usaku <usa@r...> * ruby_atomic.h (ATOMIC_CAS): added. Index: ruby_1_9_3/ruby_atomic.h =================================================================== --- ruby_1_9_3/ruby_atomic.h (revision 44951) +++ ruby_1_9_3/ruby_atomic.h (revision 44952) @@ -3,6 +3,30 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/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) +# define ATOMIC_SIZE_INC(var) __atomic_fetch_add(&(var), 1, __ATOMIC_SEQ_CST) +# define ATOMIC_SIZE_DEC(var) __atomic_fetch_sub(&(var), 1, __ATOMIC_SEQ_CST) +# define ATOMIC_SIZE_EXCHANGE(var, val) __atomic_exchange_n(&(var), (val), __ATOMIC_SEQ_CST) +# define ATOMIC_SIZE_CAS(var, oldval, newval) \ +({ size_t oldvaldup = (oldval); \ + __atomic_compare_exchange_n(&(var), &oldvaldup, (newval), 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); \ + oldvaldup; }) + +# define ATOMIC_PTR_EXCHANGE(var, val) __atomic_exchange_n(&(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 */ @@ -22,6 +46,8 @@ typedef unsigned int rb_atomic_t; /* Any https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ruby_atomic.h#L46 # define ATOMIC_SIZE_EXCHANGE(var, val) __sync_lock_test_and_set(&(var), (val)) # define ATOMIC_PTR_EXCHANGE(var, val) __sync_lock_test_and_set(&(var), (val)) +# define ATOMIC_PTR_EXCHANGE(var, val) __sync_lock_test_and_set(&(var), (val)) + #elif defined _WIN32 #if defined _MSC_VER && _MSC_VER > 1200 #pragma intrinsic(_InterlockedOr) Index: ruby_1_9_3/version.h =================================================================== --- ruby_1_9_3/version.h (revision 44951) +++ ruby_1_9_3/version.h (revision 44952) @@ -1,5 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/version.h#L1 #define RUBY_VERSION "1.9.3" -#define RUBY_PATCHLEVEL 531 +#define RUBY_PATCHLEVEL 532 #define RUBY_RELEASE_DATE "2014-02-14" #define RUBY_RELEASE_YEAR 2014 Property changes on: ruby_1_9_3 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r43851,43882,43996 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/