diff --git a/spec/core/exception/errno_spec.rb b/spec/core/exception/errno_spec.rb index e11e2120ae..1ab4277700 100644 --- a/spec/core/exception/errno_spec.rb +++ b/spec/core/exception/errno_spec.rb @@ -38,9 +38,7 @@ # From http://jira.codehaus.org/browse/JRUBY-4747 it "is the same class as Errno::EWOULDBLOCK if they represent the same errno value" do if Errno::EAGAIN::Errno == Errno::EWOULDBLOCK::Errno - NATFIXME 'it is the same class as Errno::EWOULDBLOCK if they represent the same errno value', exception: SpecFailedException do - Errno::EAGAIN.should == Errno::EWOULDBLOCK - end + Errno::EAGAIN.should == Errno::EWOULDBLOCK else Errno::EAGAIN.should_not == Errno::EWOULDBLOCK end @@ -54,9 +52,7 @@ it "is the same class as Errno::EOPNOTSUPP if they represent the same errno value" do if Errno::ENOTSUP::Errno == Errno::EOPNOTSUPP::Errno - NATFIXME 'it is the same class as Errno::EOPNOTSUPP if they represent the same errno value', exception: SpecFailedException do - Errno::ENOTSUP.should == Errno::EOPNOTSUPP - end + Errno::ENOTSUP.should == Errno::EOPNOTSUPP else Errno::ENOTSUP.should_not == Errno::EOPNOTSUPP end diff --git a/src/errno.rb b/src/errno.rb index 3d9d481cd4..5dc72dc269 100644 --- a/src/errno.rb +++ b/src/errno.rb @@ -420,7 +420,13 @@ module Errno end SystemCallError::ERRORS.each do |name, (number, _desc)| - klass = Class.new(SystemCallError) - klass.const_set(:Errno, number) - Errno.const_set(name, klass) + first_name, = SystemCallError::ERRORS.find { |_name, (number2, _desc)| number == number2 } + if first_name != name + klass = Errno.const_get(first_name) + Errno.const_set(name, klass) + else + klass = Class.new(SystemCallError) + klass.const_set(:Errno, number) + Errno.const_set(name, klass) + end end diff --git a/src/io.rb b/src/io.rb index b082ffc565..97df698e05 100644 --- a/src/io.rb +++ b/src/io.rb @@ -153,12 +153,17 @@ class EAGAINWaitWritable < Errno::EAGAIN include IO::WaitWritable end - class EWOULDBLOCKWaitReadable < Errno::EWOULDBLOCK - include IO::WaitReadable - end + if Errno::EAGAIN.equal?(Errno::EWOULDBLOCK) + EWOULDBLOCKWaitReadable = EAGAINWaitReadable + EWOULDBLOCKWaitWritable = EAGAINWaitWritable + else + class EWOULDBLOCKWaitReadable < Errno::EWOULDBLOCK + include IO::WaitReadable + end - class EWOULDBLOCKWaitWritable < Errno::EWOULDBLOCK - include IO::WaitWritable + class EWOULDBLOCKWaitWritable < Errno::EWOULDBLOCK + include IO::WaitWritable + end end class EINPROGRESSWaitReadable < Errno::EINPROGRESS