ruby-changes:28151
From: nobu <ko1@a...>
Date: Tue, 9 Apr 2013 09:42:44 +0900 (JST)
Subject: [ruby-changes:28151] nobu:r40203 (trunk): io.c: define EWOULDBLOCK
nobu 2013-04-09 09:42:33 +0900 (Tue, 09 Apr 2013) New Revision: 40203 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=40203 Log: io.c: define EWOULDBLOCK * io.c (Init_IO): define EWOULDBLOCK alway as it is needed always. and turn runtime branch into preprocessor condition. Modified files: trunk/io.c Index: io.c =================================================================== --- io.c (revision 40202) +++ io.c (revision 40203) @@ -110,6 +110,10 @@ https://github.com/ruby/ruby/blob/trunk/io.c#L110 # endif #endif +#ifndef EWOULDBLOCK +# define EWOULDBLOCK EAGAIN +#endif + #if defined(HAVE___SYSCALL) && (defined(__APPLE__) || defined(__OpenBSD__)) /* Mac OS X and OpenBSD have __syscall but don't define it in headers */ off_t __syscall(quad_t number, ...); @@ -11471,38 +11475,39 @@ rb_readwrite_sys_fail(int writable, cons https://github.com/ruby/ruby/blob/trunk/io.c#L11475 arg = mesg ? rb_str_new2(mesg) : Qnil; if (writable == RB_IO_WAIT_WRITABLE) { switch (n) { - case EAGAIN: - rb_exc_raise(rb_class_new_instance(1, &arg, rb_eEAGAINWaitWritable)); - break; + case EAGAIN: + rb_exc_raise(rb_class_new_instance(1, &arg, rb_eEAGAINWaitWritable)); + break; #if EAGAIN != EWOULDBLOCK - case EWOULDBLOCK: - rb_exc_raise(rb_class_new_instance(1, &arg, rb_eEWOULDBLOCKWaitWritable)); - break; -#endif - case EINPROGRESS: - rb_exc_raise(rb_class_new_instance(1, &arg, rb_eEINPROGRESSWaitWritable)); - break; - default: - rb_mod_sys_fail_str(rb_mWaitWritable, arg); + case EWOULDBLOCK: + rb_exc_raise(rb_class_new_instance(1, &arg, rb_eEWOULDBLOCKWaitWritable)); + break; +#endif + case EINPROGRESS: + rb_exc_raise(rb_class_new_instance(1, &arg, rb_eEINPROGRESSWaitWritable)); + break; + default: + rb_mod_sys_fail_str(rb_mWaitWritable, arg); } } else if (writable == RB_IO_WAIT_READABLE) { switch (n) { - case EAGAIN: - rb_exc_raise(rb_class_new_instance(1, &arg, rb_eEAGAINWaitReadable)); - break; + case EAGAIN: + rb_exc_raise(rb_class_new_instance(1, &arg, rb_eEAGAINWaitReadable)); + break; #if EAGAIN != EWOULDBLOCK - case EWOULDBLOCK: - rb_exc_raise(rb_class_new_instance(1, &arg, rb_eEWOULDBLOCKWaitReadable)); - break; -#endif - case EINPROGRESS: - rb_exc_raise(rb_class_new_instance(1, &arg, rb_eEINPROGRESSWaitReadable)); - break; - default: - rb_mod_sys_fail_str(rb_mWaitReadable, arg); + case EWOULDBLOCK: + rb_exc_raise(rb_class_new_instance(1, &arg, rb_eEWOULDBLOCKWaitReadable)); + break; +#endif + case EINPROGRESS: + rb_exc_raise(rb_class_new_instance(1, &arg, rb_eEINPROGRESSWaitReadable)); + break; + default: + rb_mod_sys_fail_str(rb_mWaitReadable, arg); } - } else { + } + else { rb_bug("invalid read/write type passed to rb_readwrite_sys_fail: %d", writable); } } @@ -11719,17 +11724,17 @@ Init_IO(void) https://github.com/ruby/ruby/blob/trunk/io.c#L11724 rb_include_module(rb_eEAGAINWaitReadable, rb_mWaitReadable); rb_eEAGAINWaitWritable = rb_define_class_under(rb_cIO, "EAGAINWaitWritable", rb_eEAGAIN); rb_include_module(rb_eEAGAINWaitWritable, rb_mWaitWritable); - if (EAGAIN == EWOULDBLOCK) { - rb_eEWOULDBLOCKWaitReadable = rb_eEAGAINWaitReadable; - rb_define_const(rb_cIO, "EWOULDBLOCKWaitReadable", rb_eEAGAINWaitReadable); - rb_eEWOULDBLOCKWaitWritable = rb_eEAGAINWaitWritable; - rb_define_const(rb_cIO, "EWOULDBLOCKWaitWritable", rb_eEAGAINWaitWritable); - } else { - rb_eEWOULDBLOCKWaitReadable = rb_define_class_under(rb_cIO, "EWOULDBLOCKRWaiteadable", rb_eEWOULDBLOCK); - rb_include_module(rb_eEWOULDBLOCKWaitReadable, rb_mWaitReadable); - rb_eEWOULDBLOCKWaitWritable = rb_define_class_under(rb_cIO, "EWOULDBLOCKWaitWritable", rb_eEWOULDBLOCK); - rb_include_module(rb_eEWOULDBLOCKWaitWritable, rb_mWaitWritable); - } +#if EAGAIN == EWOULDBLOCK + rb_eEWOULDBLOCKWaitReadable = rb_eEAGAINWaitReadable; + rb_define_const(rb_cIO, "EWOULDBLOCKWaitReadable", rb_eEAGAINWaitReadable); + rb_eEWOULDBLOCKWaitWritable = rb_eEAGAINWaitWritable; + rb_define_const(rb_cIO, "EWOULDBLOCKWaitWritable", rb_eEAGAINWaitWritable); +#else + rb_eEWOULDBLOCKWaitReadable = rb_define_class_under(rb_cIO, "EWOULDBLOCKRWaiteadable", rb_eEWOULDBLOCK); + rb_include_module(rb_eEWOULDBLOCKWaitReadable, rb_mWaitReadable); + rb_eEWOULDBLOCKWaitWritable = rb_define_class_under(rb_cIO, "EWOULDBLOCKWaitWritable", rb_eEWOULDBLOCK); + rb_include_module(rb_eEWOULDBLOCKWaitWritable, rb_mWaitWritable); +#endif rb_eEINPROGRESSWaitReadable = rb_define_class_under(rb_cIO, "EINPROGRESSWaitReadable", rb_eEINPROGRESS); rb_include_module(rb_eEINPROGRESSWaitReadable, rb_mWaitReadable); rb_eEINPROGRESSWaitWritable = rb_define_class_under(rb_cIO, "EINPROGRESSWaitWritable", rb_eEINPROGRESS); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/