summaryrefslogtreecommitdiff
path: root/thread_pthread.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-14 02:24:37 (GMT)
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-14 02:24:37 (GMT)
commit291afc96bd4909fc3504df196c4370fe745cb9ee (patch)
tree9385a3308b6eeab5cbb36d630d8f0e791a7dea19 /thread_pthread.c
parent1e769ce6eddd0275afa4cecdd7b569f21fd65667 (diff)
thread_pthread.c: use CLOCK_REALTIME on SunOS (Solaris)
timer_create does not seem to support CLOCK_MONOTONIC on Solaris, and CLOCK_HIRES seems like it could fail with insufficient permissions: https://docs.oracle.com/cd/E86824_01/html/E54766/timer-create-3c.html (Only tested on Linux and FreeBSD) [ruby-core:88360] [Misc #14937] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64356 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread_pthread.c')
-rw-r--r--thread_pthread.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/thread_pthread.c b/thread_pthread.c
index bcf412b..75ce110 100644
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -1580,12 +1580,18 @@ static void
rb_timer_create(rb_pid_t current)
{
#if UBF_TIMER == UBF_TIMER_POSIX
+# if defined(__sun)
+# define UBF_TIMER_CLOCK CLOCK_REALTIME
+# else /* Tested Linux and FreeBSD: */
+# define UBF_TIMER_CLOCK CLOCK_MONOTONIC
+# endif
+
struct sigevent sev;
sev.sigev_notify = SIGEV_SIGNAL;
sev.sigev_signo = SIGVTALRM;
sev.sigev_value.sival_ptr = &timer_posix;
- if (!timer_create(CLOCK_MONOTONIC, &sev, &timer_posix.timerid))
+ if (!timer_create(UBF_TIMER_CLOCK, &sev, &timer_posix.timerid))
timer_posix.owner = current;
else
rb_warn("timer_create failed: %s, signals racy", strerror(errno));