diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-09 06:48:15 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-09 06:48:15 +0000 |
commit | 415bef4f3eacec008255573eeb05559f547c83ef (patch) | |
tree | 4553ae951239a25b2d8a5bc7325e9d9e096e1e80 /regint.h | |
parent | 453e2ee6545ba54c8d681a06dd674757f693397b (diff) | |
download | ruby-415bef4f3eacec008255573eeb05559f547c83ef.tar.gz |
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.h | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -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 */ |