summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authorkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-11-12 02:24:51 +0000
committerkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-11-12 02:24:51 +0000
commit7e2f0491ce16d7f15660b0b01be9f23526aa07b9 (patch)
treea6098c5ee9f68e0ad895fc71a666dcecb5da189d /io.c
parentfc7bb927a24ffe60c89f70a00bcc9bbab73ecff6 (diff)
* io.c (ioctl_req_t): Type of req argument of ioctl() depend on platform.
Moreover almost all linux ioctl can't be represented by 32bit integer (i.e. MSB is 1). We need wrap ioctl argument type. [Bug #5429] [ruby-dev:44589] * io.c (struct ioctl_arg): ditto. * io.c (rb_ioctl): ditto. * test/ruby/test_io.rb (test_ioctl_linux): add a testcase for ioctl git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33716 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/io.c b/io.c
index e283613848..d0aceb2c89 100644
--- a/io.c
+++ b/io.c
@@ -7860,9 +7860,17 @@ rb_f_select(int argc, VALUE *argv, VALUE obj)
return rb_ensure(select_call, (VALUE)&args, select_end, (VALUE)&args);
}
+#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
+ typedef unsigned long ioctl_req_t;
+ #define NUM2IOCTLREQ(num) NUM2ULONG(num)
+#else
+ typedef int ioctl_req_t;
+ #define NUM2IOCTLREQ(num) NUM2INT(num)
+#endif
+
struct ioctl_arg {
int fd;
- int cmd;
+ ioctl_req_t cmd;
long narg;
};
@@ -7954,7 +7962,7 @@ setup_narg(int cmd, VALUE *argp, int io_p)
static VALUE
rb_ioctl(VALUE io, VALUE req, VALUE arg)
{
- int cmd = NUM2INT(req);
+ int cmd = NUM2IOCTLREQ(req);
rb_io_t *fptr;
long narg;
int retval;