about summary refs log tree commit homepage
path: root/lib/dtas/compat_rbx.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-10-12 21:32:44 +0000
committerEric Wong <normalperson@yhbt.net>2013-10-12 21:32:44 +0000
commitf4dcfabd826ce8a43b9d4c41706fa8b95fb81acd (patch)
treef5328ebdea5af1642852f5932562ffd9b88ea054 /lib/dtas/compat_rbx.rb
parent507ffb38ebbfb64f065df71c50a041624e768991 (diff)
downloaddtas-f4dcfabd826ce8a43b9d4c41706fa8b95fb81acd.tar.gz
We don't deal with user-space buffers, so we should be fine
using this compatibility layer and only checking the kernel
buffers (until rbx implements a proper solution).
Diffstat (limited to 'lib/dtas/compat_rbx.rb')
-rw-r--r--lib/dtas/compat_rbx.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/dtas/compat_rbx.rb b/lib/dtas/compat_rbx.rb
new file mode 100644
index 0000000..a64bf78
--- /dev/null
+++ b/lib/dtas/compat_rbx.rb
@@ -0,0 +1,12 @@
+# Copyright (C) 2013, Eric Wong <normalperson@yhbt.net> and all contributors
+# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
+
+# ref: https://github.com/rubysl/rubysl-io-wait/issues/1
+# this ignores buffers and is Linux-only
+class IO
+  def nread
+    buf = "\0" * 8
+    ioctl(0x541B, buf)
+    buf.unpack("l_")[0]
+  end
+end if ! IO.method_defined?(:nread) && RUBY_PLATFORM =~ /linux/