diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-05-07 09:28:43 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-05-07 09:28:43 +0000 |
commit | 1bd2c78b05b05f7868cd3b5bfc1e02ae11fb9eaf (patch) | |
tree | 6578a5f6b91bb6f4a96189c7ea011bc454aa295e /thread_pthread.c | |
parent | 562a1a79297d00b9ac92498173ad1fcba9fc5f51 (diff) | |
download | ruby-1bd2c78b05b05f7868cd3b5bfc1e02ae11fb9eaf.tar.gz |
* thread_pthread.c (USE_MONOTONIC_COND): check the availability
more strictly.
* thread_pthread.h (rb_thread_cond_t): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31462 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread_pthread.c')
-rw-r--r-- | thread_pthread.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/thread_pthread.c b/thread_pthread.c index 866caac9d0..8554414a1c 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -30,8 +30,11 @@ static void native_cond_destroy(rb_thread_cond_t *cond); #define RB_CONDATTR_CLOCK_MONOTONIC 1 -#if defined(HAVE_PTHREAD_CONDATTR_SETCLOCK) && defined(CLOCK_MONOTONIC) && defined(HAVE_CLOCK_GETTIME) +#if defined(HAVE_PTHREAD_CONDATTR_SETCLOCK) && defined(HAVE_CLOCKID_T) && \ + defined(CLOCK_REALTIME) && defined(CLOCK_MONOTONIC) && defined(HAVE_CLOCK_GETTIME) #define USE_MONOTONIC_COND 1 +#else +#define USE_MONOTONIC_COND 0 #endif #define GVL_SIMPLE_LOCK 0 @@ -230,10 +233,10 @@ native_cond_initialize(rb_thread_cond_t *cond, int flags) int r; pthread_condattr_t attr; - cond->clockid = CLOCK_REALTIME; pthread_condattr_init(&attr); #if USE_MONOTONIC_COND + cond->clockid = CLOCK_REALTIME; if (flags & RB_CONDATTR_CLOCK_MONOTONIC) { r = pthread_condattr_setclock(&attr, CLOCK_MONOTONIC); if (r == 0) { @@ -323,10 +326,10 @@ native_cond_timeout(rb_thread_cond_t *cond, struct timespec timeout_rel) rb_sys_fail("clock_gettime()"); goto out; } -#endif if (cond->clockid != CLOCK_REALTIME) rb_bug("unsupported clockid %d", cond->clockid); +#endif ret = gettimeofday(&tv, 0); if (ret != 0) |