summaryrefslogtreecommitdiff
path: root/regint.h
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-09 06:48:15 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-09 06:48:15 (GMT)
commit0599d7de5844a2f838cdf631b9c88b05010ebe5d (patch)
tree4553ae951239a25b2d8a5bc7325e9d9e096e1e80 /regint.h
parente48adae2b3e7dfab79fb5a72467a559749edebd5 (diff)
use atomic operations
* regcomp.c (onig_chain_link_add): use atomic operation instead of mutex. * regint.h (ONIG_STATE_{INC,DEC}_THREAD): ditto. * regparse.c (PopFreeNode, node_recycle): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52995 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'regint.h')
-rw-r--r--regint.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/regint.h b/regint.h
index 9fda550..79867f7 100644
--- a/regint.h
+++ b/regint.h
@@ -95,6 +95,7 @@
#ifndef RUBY_DEFINES_H
#include "ruby/ruby.h"
+#include "ruby_atomic.h"
#undef xmalloc
#undef xrealloc
#undef xcalloc
@@ -238,6 +239,10 @@ extern pthread_mutex_t gOnigMutex;
#define ONIG_STATE_INC(reg) (reg)->state++
#define ONIG_STATE_DEC(reg) (reg)->state--
+#if SIZEOF_ATOMIC_T == SIZEOF_INT
+#define ONIG_STATE_INC_THREAD(reg) (ATOMIC_INC((reg)->state))
+#define ONIG_STATE_DEC_THREAD(reg) (ATOMIC_DEC((reg)->state))
+#else
#define ONIG_STATE_INC_THREAD(reg) do {\
THREAD_ATOMIC_START;\
(reg)->state++;\
@@ -248,6 +253,7 @@ extern pthread_mutex_t gOnigMutex;
(reg)->state--;\
THREAD_ATOMIC_END;\
} while(0)
+#endif
#else
#define ONIG_STATE_INC(reg) /* Nothing */
#define ONIG_STATE_DEC(reg) /* Nothing */