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

ruby-changes:51895

From: normal <ko1@a...>
Date: Mon, 30 Jul 2018 07:54:50 +0900 (JST)
Subject: [ruby-changes:51895] normal:r64109 (trunk): thread.c: move ppoll wrapper before thread_pthread.c

normal	2018-07-30 07:54:44 +0900 (Mon, 30 Jul 2018)

  New Revision: 64109

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=64109

  Log:
    thread.c: move ppoll wrapper before thread_pthread.c
    
    thread_pthread.c relies on ppoll for rb_sigwait_sleep, so ensure
    the compatibility wrapper is available for it.
    
    Reported-by: SHIBATA Hiroshi <hsbt@r...>

  Modified files:
    trunk/thread.c
Index: thread.c
===================================================================
--- thread.c	(revision 64108)
+++ thread.c	(revision 64109)
@@ -361,6 +361,49 @@ ubf_sigwait(void *ignore) https://github.com/ruby/ruby/blob/trunk/thread.c#L361
     rb_thread_wakeup_timer_thread(0);
 }
 
+#ifdef USE_POLL
+
+/* The same with linux kernel. TODO: make platform independent definition. */
+#define POLLIN_SET (POLLRDNORM | POLLRDBAND | POLLIN | POLLHUP | POLLERR)
+#define POLLOUT_SET (POLLWRBAND | POLLWRNORM | POLLOUT | POLLERR)
+#define POLLEX_SET (POLLPRI)
+
+#ifndef POLLERR_SET /* defined for FreeBSD for now */
+#  define POLLERR_SET (0)
+#endif
+
+#ifndef HAVE_PPOLL
+/* TODO: don't ignore sigmask */
+static int
+ruby_ppoll(struct pollfd *fds, nfds_t nfds,
+      const struct timespec *ts, const sigset_t *sigmask)
+{
+    int timeout_ms;
+
+    if (ts) {
+	int tmp, tmp2;
+
+	if (ts->tv_sec > INT_MAX/1000)
+	    timeout_ms = INT_MAX;
+	else {
+	    tmp = (int)(ts->tv_sec * 1000);
+	    /* round up 1ns to 1ms to avoid excessive wakeups for <1ms sleep */
+	    tmp2 = (int)((ts->tv_nsec + 999999L) / (1000L * 1000L));
+	    if (INT_MAX - tmp < tmp2)
+		timeout_ms = INT_MAX;
+	    else
+		timeout_ms = (int)(tmp + tmp2);
+	}
+    }
+    else
+	timeout_ms = -1;
+
+    return poll(fds, nfds, timeout_ms);
+}
+#  define ppoll(fds,nfds,ts,sigmask) ruby_ppoll((fds),(nfds),(ts),(sigmask))
+#endif
+
+
 #if   defined(_WIN32)
 #include "thread_win32.c"
 
@@ -4021,48 +4064,6 @@ rb_thread_fd_select(int max, rb_fdset_t https://github.com/ruby/ruby/blob/trunk/thread.c#L4064
     return (int)rb_ensure(do_select, (VALUE)&set, select_set_free, (VALUE)&set);
 }
 
-#ifdef USE_POLL
-
-/* The same with linux kernel. TODO: make platform independent definition. */
-#define POLLIN_SET (POLLRDNORM | POLLRDBAND | POLLIN | POLLHUP | POLLERR)
-#define POLLOUT_SET (POLLWRBAND | POLLWRNORM | POLLOUT | POLLERR)
-#define POLLEX_SET (POLLPRI)
-
-#ifndef POLLERR_SET /* defined for FreeBSD for now */
-#  define POLLERR_SET (0)
-#endif
-
-#ifndef HAVE_PPOLL
-/* TODO: don't ignore sigmask */
-static int
-ruby_ppoll(struct pollfd *fds, nfds_t nfds,
-      const struct timespec *ts, const sigset_t *sigmask)
-{
-    int timeout_ms;
-
-    if (ts) {
-	int tmp, tmp2;
-
-	if (ts->tv_sec > INT_MAX/1000)
-	    timeout_ms = INT_MAX;
-	else {
-	    tmp = (int)(ts->tv_sec * 1000);
-	    /* round up 1ns to 1ms to avoid excessive wakeups for <1ms sleep */
-	    tmp2 = (int)((ts->tv_nsec + 999999L) / (1000L * 1000L));
-	    if (INT_MAX - tmp < tmp2)
-		timeout_ms = INT_MAX;
-	    else
-		timeout_ms = (int)(tmp + tmp2);
-	}
-    }
-    else
-	timeout_ms = -1;
-
-    return poll(fds, nfds, timeout_ms);
-}
-#  define ppoll(fds,nfds,ts,sigmask) ruby_ppoll((fds),(nfds),(ts),(sigmask))
-#endif
-
 /*
  * returns a mask of events
  */

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

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