ruby-changes:21296
From: kosaki <ko1@a...>
Date: Tue, 27 Sep 2011 09:50:40 +0900 (JST)
Subject: [ruby-changes:21296] kosaki:r33345 (trunk): * thread.c (do_select): remove cygwin specific hack. It's layer
kosaki 2011-09-27 09:50:29 +0900 (Tue, 27 Sep 2011) New Revision: 33345 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=33345 Log: * thread.c (do_select): remove cygwin specific hack. It's layer violation and too large hack. * thread.c (cmp_tv, subtract_tv): removed. Modified files: trunk/ChangeLog trunk/thread.c Index: ChangeLog =================================================================== --- ChangeLog (revision 33344) +++ ChangeLog (revision 33345) @@ -1,3 +1,9 @@ +Tue Sep 27 09:44:59 2011 KOSAKI Motohiro <kosaki.motohiro@g...> + + * thread.c (do_select): remove cygwin specific hack. It's layer + violation and too large hack. + * thread.c (cmp_tv, subtract_tv): removed. + Tue Sep 27 03:50:19 2011 Ayumu AIZAWA <ayumu.aizawa@g...> * test/rexml/test_sax.rb: add require 'rexml/document'. Index: thread.c =================================================================== --- thread.c (revision 33344) +++ thread.c (revision 33345) @@ -2519,34 +2519,7 @@ #define rb_fd_rcopy(d, s) (*(d) = *(s)) #endif -#if defined(__CYGWIN__) -static long -cmp_tv(const struct timeval *a, const struct timeval *b) -{ - long d = (a->tv_sec - b->tv_sec); - return (d != 0) ? d : (a->tv_usec - b->tv_usec); -} - static int -subtract_tv(struct timeval *rest, const struct timeval *wait) -{ - if (rest->tv_sec < wait->tv_sec) { - return 0; - } - while (rest->tv_usec < wait->tv_usec) { - if (rest->tv_sec <= wait->tv_sec) { - return 0; - } - rest->tv_sec -= 1; - rest->tv_usec += 1000 * 1000; - } - rest->tv_sec -= wait->tv_sec; - rest->tv_usec -= wait->tv_usec; - return rest->tv_sec != 0 || rest->tv_usec != 0; -} -#endif - -static int do_select(int n, rb_fdset_t *read, rb_fdset_t *write, rb_fdset_t *except, struct timeval *timeout) { @@ -2556,17 +2529,9 @@ rb_fdset_t UNINITIALIZED_VAR(orig_except); double limit = 0; struct timeval wait_rest; -# if defined(__CYGWIN__) - struct timeval start_time; -# endif if (timeout) { -# if defined(__CYGWIN__) - gettimeofday(&start_time, NULL); - limit = (double)start_time.tv_sec + (double)start_time.tv_usec*1e-6; -# else limit = timeofday(); -# endif limit += (double)timeout->tv_sec+(double)timeout->tv_usec*1e-6; wait_rest = *timeout; timeout = &wait_rest; @@ -2582,45 +2547,8 @@ retry: lerrno = 0; -#if defined(__CYGWIN__) +#if defined(_WIN32) { - int finish = 0; - /* polling duration: 100ms */ - struct timeval wait_100ms, *wait; - wait_100ms.tv_sec = 0; - wait_100ms.tv_usec = 100 * 1000; /* 100 ms */ - - do { - wait = (timeout == 0 || cmp_tv(&wait_100ms, timeout) < 0) ? &wait_100ms : timeout; - BLOCKING_REGION({ - do { - result = rb_fd_select(n, read, write, except, wait); - if (result < 0) lerrno = errno; - if (result != 0) break; - - if (read) - rb_fd_dup(read, &orig_read); - if (write) - rb_fd_dup(write, &orig_write); - if (except) - rb_fd_dup(except, &orig_except); - if (timeout) { - struct timeval elapsed; - gettimeofday(&elapsed, NULL); - subtract_tv(&elapsed, &start_time); - gettimeofday(&start_time, NULL); - if (!subtract_tv(timeout, &elapsed)) { - finish = 1; - break; - } - if (cmp_tv(&wait_100ms, timeout) > 0) wait = timeout; - } - } while (__th->interrupt_flag == 0); - }, 0, 0); - } while (result == 0 && !finish); - } -#elif defined(_WIN32) - { rb_thread_t *th = GET_THREAD(); BLOCKING_REGION({ result = native_fd_select(n, read, write, except, timeout, th); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/