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

ruby-changes:31381

From: nobu <ko1@a...>
Date: Tue, 29 Oct 2013 15:46:40 +0900 (JST)
Subject: [ruby-changes:31381] nobu:r43460 (trunk): ruby_atomic.h: ATOMIC_SIZE_CAS

nobu	2013-10-29 15:46:33 +0900 (Tue, 29 Oct 2013)

  New Revision: 43460

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

  Log:
    ruby_atomic.h: ATOMIC_SIZE_CAS
    
    * ruby_atomic.h (ATOMIC_SIZE_CAS): new macro, compare and swap size_t.

  Modified files:
    trunk/ChangeLog
    trunk/ruby_atomic.h
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 43459)
+++ ChangeLog	(revision 43460)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Oct 29 15:46:30 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* ruby_atomic.h (ATOMIC_SIZE_CAS): new macro, compare and swap size_t.
+
 Tue Oct 29 12:08:05 2013  Tanaka Akira  <akr@f...>
 
 	* ext/readline/readline.c (readline_getc): Consider
Index: ruby_atomic.h
===================================================================
--- ruby_atomic.h	(revision 43459)
+++ ruby_atomic.h	(revision 43460)
@@ -65,6 +65,7 @@ rb_w32_atomic_cas(volatile rb_atomic_t * https://github.com/ruby/ruby/blob/trunk/ruby_atomic.h#L65
 #  define ATOMIC_SIZE_INC(var) InterlockedIncrement64(&(var))
 #  define ATOMIC_SIZE_DEC(var) InterlockedDecrement64(&(var))
 #  define ATOMIC_SIZE_EXCHANGE(var, val) InterlockedExchange64(&(var), (val))
+#  define ATOMIC_SIZE_CAS(var, oldval, val) InterlockedCompareExchange64(&(var), (oldval), (val))
 # else
 #  define ATOMIC_SIZE_ADD(var, val) InterlockedExchangeAdd((LONG *)&(var), (val))
 #  define ATOMIC_SIZE_SUB(var, val) InterlockedExchangeAdd((LONG *)&(var), -(LONG)(val))
@@ -90,6 +91,7 @@ typedef unsigned int rb_atomic_t; https://github.com/ruby/ruby/blob/trunk/ruby_atomic.h#L91
 #  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))
+#  define ATOMIC_SIZE_CAS(var, oldval, val) atomic_cas_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))
@@ -127,4 +129,8 @@ atomic_size_exchange(size_t *ptr, size_t https://github.com/ruby/ruby/blob/trunk/ruby_atomic.h#L129
 }
 #endif
 
+#ifndef ATOMIC_SIZE_CAS
+# define ATOMIC_SIZE_CAS(var, oldval, val) ATOMIC_CAS(var, oldval, val)
+#endif
+
 #endif /* RUBY_ATOMIC_H */

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

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