ruby-changes:25597
From: usa <ko1@a...>
Date: Wed, 14 Nov 2012 20:27:12 +0900 (JST)
Subject: [ruby-changes:25597] usa:r37654 (ruby_1_9_3): merge revision(s) 37604:
usa 2012-11-14 20:27:00 +0900 (Wed, 14 Nov 2012) New Revision: 37654 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=37654 Log: merge revision(s) 37604: * ruby_atomic.h: renamed from atomic.h to avoid header file name conflict on Solaris 10. [ruby-dev:46414] [Bug #7287] * gc.c, signal.c, vm_core.h, common.mk: reflect the rename from atomic.h to ruby_atomic.h. Added files: branches/ruby_1_9_3/ruby_atomic.h Removed files: branches/ruby_1_9_3/atomic.h Modified directories: branches/ruby_1_9_3/ Modified files: branches/ruby_1_9_3/ChangeLog branches/ruby_1_9_3/common.mk branches/ruby_1_9_3/gc.c branches/ruby_1_9_3/signal.c branches/ruby_1_9_3/version.h branches/ruby_1_9_3/vm_core.h Index: ruby_1_9_3/atomic.h =================================================================== --- ruby_1_9_3/atomic.h (revision 37653) +++ ruby_1_9_3/atomic.h (revision 37654) @@ -1,56 +0,0 @@ -#ifndef RUBY_ATOMIC_H -#define RUBY_ATOMIC_H - -#ifdef _WIN32 -#if defined _MSC_VER && _MSC_VER > 1200 -#pragma intrinsic(_InterlockedOr) -#endif -typedef LONG rb_atomic_t; - -# define ATOMIC_SET(var, val) InterlockedExchange(&(var), (val)) -# define ATOMIC_INC(var) InterlockedIncrement(&(var)) -# define ATOMIC_DEC(var) InterlockedDecrement(&(var)) -#if defined __GNUC__ -# define ATOMIC_OR(var, val) __asm__("lock\n\t" "orl\t%1, %0" : "=m"(var) : "Ir"(val)) -#elif defined _MSC_VER && _MSC_VER <= 1200 -# define ATOMIC_OR(var, val) rb_w32_atomic_or(&(var), (val)) -static inline void -rb_w32_atomic_or(volatile rb_atomic_t *var, rb_atomic_t val) -{ -#ifdef _M_IX86 - __asm mov eax, var; - __asm mov ecx, val; - __asm lock or [eax], ecx; -#else -#error unsupported architecture -#endif -} -#else -# define ATOMIC_OR(var, val) _InterlockedOr(&(var), (val)) -#endif -# define ATOMIC_EXCHANGE(var, val) InterlockedExchange(&(var), (val)) - -#elif defined HAVE_GCC_ATOMIC_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 */ - -typedef unsigned int rb_atomic_t; /* Anything OK */ -# define ATOMIC_SET(var, val) __sync_lock_test_and_set(&(var), (val)) -# define ATOMIC_INC(var) __sync_fetch_and_add(&(var), 1) -# define ATOMIC_DEC(var) __sync_fetch_and_sub(&(var), 1) -# define ATOMIC_OR(var, val) __sync_or_and_fetch(&(var), (val)) -# define ATOMIC_EXCHANGE(var, val) __sync_lock_test_and_set(&(var), (val)) - -#else -typedef int rb_atomic_t; -extern rb_atomic_t ruby_atomic_exchange(rb_atomic_t *ptr, rb_atomic_t val); - -# define ATOMIC_SET(var, val) ((var) = (val)) -# define ATOMIC_INC(var) (++(var)) -# define ATOMIC_DEC(var) (--(var)) -# define ATOMIC_OR(var, val) ((var) |= (val)) -# define ATOMIC_EXCHANGE(var, val) ruby_atomic_exchange(&(var), (val)) -#endif - -#endif /* RUBY_ATOMIC_H */ Index: ruby_1_9_3/ChangeLog =================================================================== --- ruby_1_9_3/ChangeLog (revision 37653) +++ ruby_1_9_3/ChangeLog (revision 37654) @@ -1,3 +1,11 @@ +Wed Nov 14 20:20:46 2012 Naohisa Goto <ngotogenome@g...> + + * ruby_atomic.h: renamed from atomic.h to avoid header file name + conflict on Solaris 10. [ruby-dev:46414] [Bug #7287] + + * gc.c, signal.c, vm_core.h, common.mk: reflect the rename from + atomic.h to ruby_atomic.h. + Tue Nov 13 18:13:10 2012 Narihiro Nakamura <authornari@g...> * gc.c: Use the non-recursive marking instead of recursion. The Index: ruby_1_9_3/vm_core.h =================================================================== --- ruby_1_9_3/vm_core.h (revision 37653) +++ ruby_1_9_3/vm_core.h (revision 37654) @@ -22,7 +22,7 @@ #include "vm_opts.h" #include "id.h" #include "method.h" -#include "atomic.h" +#include "ruby_atomic.h" #if defined(_WIN32) #include "thread_win32.h" Index: ruby_1_9_3/ruby_atomic.h =================================================================== --- ruby_1_9_3/ruby_atomic.h (revision 0) +++ ruby_1_9_3/ruby_atomic.h (revision 37654) @@ -0,0 +1,115 @@ +#ifndef RUBY_ATOMIC_H +#define RUBY_ATOMIC_H + +#if 0 +#elif defined HAVE_GCC_ATOMIC_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 */ + +typedef unsigned int rb_atomic_t; /* Anything OK */ +# define ATOMIC_SET(var, val) (void)__sync_lock_test_and_set(&(var), (val)) +# define ATOMIC_INC(var) __sync_fetch_and_add(&(var), 1) +# define ATOMIC_DEC(var) __sync_fetch_and_sub(&(var), 1) +# define ATOMIC_OR(var, val) __sync_or_and_fetch(&(var), (val)) +# define ATOMIC_EXCHANGE(var, val) __sync_lock_test_and_set(&(var), (val)) + +# 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 +#pragma intrinsic(_InterlockedOr) +#endif +typedef LONG rb_atomic_t; + +# define ATOMIC_SET(var, val) InterlockedExchange(&(var), (val)) +# define ATOMIC_INC(var) InterlockedIncrement(&(var)) +# define ATOMIC_DEC(var) InterlockedDecrement(&(var)) +#if defined __GNUC__ +# define ATOMIC_OR(var, val) __asm__("lock\n\t" "orl\t%1, %0" : "=m"(var) : "Ir"(val)) +#elif defined _MSC_VER && _MSC_VER <= 1200 +# define ATOMIC_OR(var, val) rb_w32_atomic_or(&(var), (val)) +static inline void +rb_w32_atomic_or(volatile rb_atomic_t *var, rb_atomic_t val) +{ +#ifdef _M_IX86 + __asm mov eax, var; + __asm mov ecx, val; + __asm lock or [eax], ecx; +#else +#error unsupported architecture +#endif +} +#else +# define ATOMIC_OR(var, val) _InterlockedOr(&(var), (val)) +#endif +# define ATOMIC_EXCHANGE(var, val) InterlockedExchange(&(var), (val)) + +# ifdef _M_AMD64 +# define ATOMIC_SIZE_ADD(var, val) InterlockedExchangeAdd64(&(var), (val)) +# define ATOMIC_SIZE_SUB(var, val) InterlockedExchangeAdd64(&(var), -(val)) +# define ATOMIC_SIZE_INC(var) InterlockedIncrement64(&(var)) +# define ATOMIC_SIZE_DEC(var) InterlockedDecrement64(&(var)) +# define ATOMIC_SIZE_EXCHANGE(var, val) InterlockedExchange64(&(var), (val)) +# else +# define ATOMIC_SIZE_ADD(var, val) InterlockedExchangeAdd((LONG *)&(var), (val)) +# define ATOMIC_SIZE_SUB(var, val) InterlockedExchangeAdd((LONG *)&(var), -(val)) +# define ATOMIC_SIZE_INC(var) InterlockedIncrement((LONG *)&(var)) +# define ATOMIC_SIZE_DEC(var) InterlockedDecrement((LONG *)&(var)) +# define ATOMIC_SIZE_EXCHANGE(var, val) InterlockedExchange((LONG *)&(var), (val)) +# endif + +#elif defined(__sun) +#include <atomic.h> +typedef unsigned int rb_atomic_t; + +# define ATOMIC_SET(var, val) (void)atomic_swap_uint(&(var), (val)) +# define ATOMIC_INC(var) atomic_inc_uint(&(var)) +# define ATOMIC_DEC(var) atomic_dec_uint(&(var)) +# define ATOMIC_OR(var, val) atomic_or_uint(&(var), (val)) +# define ATOMIC_EXCHANGE(var, val) atomic_swap_uint(&(var), (val)) + +# if SIZEOF_SIZE_T == SIZEOF_LONG +# define ATOMIC_SIZE_ADD(var, val) atomic_add_long(&(var), (val)) +# define ATOMIC_SIZE_SUB(var, val) atomic_add_long(&(var), -(val)) +# define ATOMIC_SIZE_INC(var) atomic_inc_ulong(&(var)) +# define ATOMIC_SIZE_DEC(var) atomic_dec_ulong(&(var)) +# define ATOMIC_SIZE_EXCHANGE(var, val) atomic_swap_ulong(&(var), (val)) +# else +# define ATOMIC_SIZE_ADD(var, val) atomic_add_int(&(var), (val)) +# define ATOMIC_SIZE_SUB(var, val) atomic_add_int(&(var), -(val)) +# define ATOMIC_SIZE_INC(var) atomic_inc_uint(&(var)) +# define ATOMIC_SIZE_DEC(var) atomic_dec_uint(&(var)) +# define ATOMIC_SIZE_EXCHANGE(var, val) atomic_swap_uint(&(var), (val)) +# endif + +#else +typedef int rb_atomic_t; +#define NEED_RUBY_ATOMIC_EXCHANGE +extern rb_atomic_t ruby_atomic_exchange(rb_atomic_t *ptr, rb_atomic_t val); + +# define ATOMIC_SET(var, val) (void)((var) = (val)) +# define ATOMIC_INC(var) ((var)++) +# define ATOMIC_DEC(var) ((var)--) +# define ATOMIC_OR(var, val) ((var) |= (val)) +# define ATOMIC_EXCHANGE(var, val) ruby_atomic_exchange(&(var), (val)) + +# 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) +{ + size_t old = *ptr; + *ptr = val; + return old; +} +#endif + +#endif /* RUBY_ATOMIC_H */ Property changes on: ruby_1_9_3/ruby_atomic.h ___________________________________________________________________ Added: svn:eol-style + LF Index: ruby_1_9_3/common.mk =================================================================== --- ruby_1_9_3/common.mk (revision 37653) +++ ruby_1_9_3/common.mk (revision 37654) @@ -591,7 +591,7 @@ ENCODING_H_INCLUDES= {$(VPATH)}encoding.h {$(VPATH)}oniguruma.h ID_H_INCLUDES = {$(VPATH)}id.h {$(VPATH)}vm_opts.h VM_CORE_H_INCLUDES = {$(VPATH)}vm_core.h {$(VPATH)}thread_$(THREAD_MODEL).h \ - {$(VPATH)}node.h {$(VPATH)}method.h {$(VPATH)}atomic.h \ + {$(VPATH)}node.h {$(VPATH)}method.h {$(VPATH)}ruby_atomic.h \ $(ID_H_INCLUDES) array.$(OBJEXT): {$(VPATH)}array.c $(RUBY_H_INCLUDES) {$(VPATH)}util.h \ Index: ruby_1_9_3/gc.c =================================================================== --- ruby_1_9_3/gc.c (revision 37653) +++ ruby_1_9_3/gc.c (revision 37654) @@ -21,6 +21,7 @@ #include "internal.h" #include "gc.h" #include "constant.h" +#include "ruby_atomic.h" #include <stdio.h> #include <setjmp.h> #include <sys/types.h> Index: ruby_1_9_3/version.h =================================================================== --- ruby_1_9_3/version.h (revision 37653) +++ ruby_1_9_3/version.h (revision 37654) @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.3" -#define RUBY_PATCHLEVEL 329 +#define RUBY_PATCHLEVEL 330 #define RUBY_RELEASE_DATE "2012-11-14" #define RUBY_RELEASE_YEAR 2012 Index: ruby_1_9_3/signal.c =================================================================== --- ruby_1_9_3/signal.c (revision 37653) +++ ruby_1_9_3/signal.c (revision 37654) @@ -16,7 +16,7 @@ #include <signal.h> #include <stdio.h> #include <errno.h> -#include "atomic.h" +#include "ruby_atomic.h" #if !defined(_WIN32) && !defined(HAVE_GCC_ATOMIC_BUILTINS) rb_atomic_t Property changes on: ruby_1_9_3 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r37604 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/