diff --git a/ChangeLog b/ChangeLog index a8a24d6216..8966f88528 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Tue Apr 6 23:01:35 2010 KOSAKI Motohiro + + * vm_core.h: Introduce UNINITIALIZED_VAR() macro. + * thread.c (do_select): Use UNINITIALIZED_VAR() instead FAKE_FD_ZERO(). + Also, remove FAKE_FD_ZERO completely. [Feature #3018] + Tue Apr 6 21:55:25 2010 Tanaka Akira * configure.in: test localtime(3) overflow. [ruby-dev:40910] diff --git a/thread.c b/thread.c index a94b81569b..10d6047c74 100644 --- a/thread.c +++ b/thread.c @@ -2415,12 +2415,9 @@ do_select(int n, fd_set *read, fd_set *write, fd_set *except, struct timeval *timeout) { int result, lerrno; - fd_set orig_read, orig_write, orig_except; -#if defined __GNUC__ && defined __x86_64__ -#define FAKE_FD_ZERO(f) (*(int *)&(f)=0) /* suppress lots of warnings */ -#else -#define FAKE_FD_ZERO(f) ((void)0) -#endif + fd_set UNINITIALIZED_VAR(orig_read); + fd_set UNINITIALIZED_VAR(orig_write); + fd_set UNINITIALIZED_VAR(orig_except); #ifndef linux double limit = 0; @@ -2442,11 +2439,9 @@ do_select(int n, fd_set *read, fd_set *write, fd_set *except, } #endif - if (read) orig_read = *read; else FAKE_FD_ZERO(orig_read); - if (write) orig_write = *write; else FAKE_FD_ZERO(orig_write); - if (except) orig_except = *except; else FAKE_FD_ZERO(orig_except); - -#undef FAKE_FD_ZERO + if (read) orig_read = *read; + if (write) orig_write = *write; + if (except) orig_except = *except; retry: lerrno = 0; diff --git a/vm_core.h b/vm_core.h index 7bf199b68a..b5c1bf0ad9 100644 --- a/vm_core.h +++ b/vm_core.h @@ -106,6 +106,12 @@ #define UNLIKELY(x) (x) #endif /* __GNUC__ >= 3 */ +#if __GNUC__ >= 3 +#define UNINITIALIZED_VAR(x) x = x +#else +#define UNINITIALIZED_VAR(x) x +#endif + typedef unsigned long rb_num_t; /* iseq data type */