[前][次][番号順一覧][スレッド一覧]

ruby-changes:21770

From: naruse <ko1@a...>
Date: Wed, 23 Nov 2011 20:25:00 +0900 (JST)
Subject: [ruby-changes:21770] naruse:r33819 (trunk): * io.c (ioctl_narg_len): don't use _IOC_SIZE macro on Linux.

naruse	2011-11-23 20:24:49 +0900 (Wed, 23 Nov 2011)

  New Revision: 33819

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=33819

  Log:
    * io.c (ioctl_narg_len): don't use _IOC_SIZE macro on Linux.
      On Linux some constants for ioctl(2) doesn't include the size of
      its return value and 16bit value; for example FIONREAD 0x541B.
      Moreover the manual, ioctl_list(2),  says "Note  that  the  size
      bits  are  very unreliable: in lots of cases they are wrong,
      either because of buggy macros using sizeof(sizeof(struct)),
      or because of legacy values."
      So we shouldn't use it.

  Modified files:
    trunk/ChangeLog
    trunk/io.c
    trunk/test/ruby/test_io.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 33818)
+++ ChangeLog	(revision 33819)
@@ -1,3 +1,14 @@
+Wed Nov 23 20:03:43 2011  NARUSE, Yui  <naruse@r...>
+
+	* io.c (ioctl_narg_len): don't use _IOC_SIZE macro on Linux.
+	  On Linux some constants for ioctl(2) doesn't include the size of
+	  its return value and 16bit value; for example FIONREAD 0x541B.
+	  Moreover the manual, ioctl_list(2),  says "Note  that  the  size
+	  bits  are  very unreliable: in lots of cases they are wrong,
+	  either because of buggy macros using sizeof(sizeof(struct)),
+	  or because of legacy values."
+	  So we shouldn't use it.
+
 Tue Nov 22 18:07:32 2011  NAKAMURA Usaku  <usa@r...>
 
 	* win32/win32.c (_pioinfo): need to declare _pioinfo() before using
Index: io.c
===================================================================
--- io.c	(revision 33818)
+++ io.c	(revision 33819)
@@ -7956,8 +7956,6 @@
 #endif
 #ifdef IOCPARM_LEN
     len = IOCPARM_LEN(cmd);	/* on BSDish systems we're safe */
-#elif defined(_IOC_SIZE)
-    len = _IOC_SIZE(cmd);
 #else
     len = 256;		/* otherwise guess at what's safe */
 #endif
Index: test/ruby/test_io.rb
===================================================================
--- test/ruby/test_io.rb	(revision 33818)
+++ test/ruby/test_io.rb	(revision 33819)
@@ -2112,5 +2112,14 @@
         f1.ioctl(0x80045200, entropy_count)
       }
     end
+
+    buf = ''
+    assert_nothing_raised do
+      fionread = 0x541B
+      File.open(__FILE__){|f1|
+        f1.ioctl(fionread, buf)
+      }
+    end
+    assert_equal(File.size(__FILE__), buf.unpack('i!')[0])
   end
 end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]