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

ruby-changes:17488

From: naruse <ko1@a...>
Date: Thu, 14 Oct 2010 08:10:04 +0900 (JST)
Subject: [ruby-changes:17488] Ruby:r29493 (trunk): * file.c (DEVT2NUM): added. Size of dev_t is depend on the

naruse	2010-10-14 08:09:56 +0900 (Thu, 14 Oct 2010)

  New Revision: 29493

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

  Log:
    * file.c (DEVT2NUM): added. Size of dev_t is depend on the
      environment even if POSIX defines dev_t as unsigned integer.
      For example, OpenVMS, 64bit Solaris 9, and NetBSD 6 defines
      dev_t as 64bit unsigned integer.
    
    * file.c (rb_stat_dev): use DEVT2NUM.
    
    * file.c (rb_stat_dev_major): dev_t is not long. major(3)'s return
      value is int.
    
    * file.c (rb_stat_dev_minor): dev_t is not long. minor(3)'s return
      value is int.
    
    * configure.in: check size of dev_t.

  Modified files:
    trunk/ChangeLog
    trunk/configure.in
    trunk/file.c

Index: configure.in
===================================================================
--- configure.in	(revision 29492)
+++ configure.in	(revision 29493)
@@ -576,6 +576,7 @@
 RUBY_CHECK_SIZEOF(float)
 RUBY_CHECK_SIZEOF(double)
 RUBY_CHECK_SIZEOF(time_t, [long "long long"], [], [@%:@include <time.h>])
+RUBY_CHECK_SIZEOF(dev_t, [int long "long long"])
 
 dnl RUBY_REPLACE_TYPE [typename] [default type] [macro type] [included]
 AC_DEFUN([RUBY_REPLACE_TYPE], [dnl
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 29492)
+++ ChangeLog	(revision 29493)
@@ -1,3 +1,20 @@
+Thu Oct 14 07:35:07 2010  NARUSE, Yui  <naruse@r...>
+
+	* file.c (DEVT2NUM): added. Size of dev_t is depend on the
+	  environment even if POSIX defines dev_t as unsigned integer.
+	  For example, OpenVMS, 64bit Solaris 9, and NetBSD 6 defines
+	  dev_t as 64bit unsigned integer.
+
+	* file.c (rb_stat_dev): use DEVT2NUM.
+
+	* file.c (rb_stat_dev_major): dev_t is not long. major(3)'s return
+	  value is int.
+
+	* file.c (rb_stat_dev_minor): dev_t is not long. minor(3)'s return
+	  value is int.
+
+	* configure.in: check size of dev_t.
+
 Thu Oct 14 07:22:12 2010  Nobuyoshi Nakada  <nobu@r...>
 
 	* array.c (rb_ary_and, rb_ary_or), class.c (rb_mod_init_copy),
Index: file.c
===================================================================
--- file.c	(revision 29492)
+++ file.c	(revision 29493)
@@ -316,6 +316,14 @@
 
 #define ST2UINT(val) ((val) & ~(~1UL << (sizeof(val) * CHAR_BIT - 1)))
 
+#if SIZEOF_DEV_T > SIZEOF_LONG && defined(HAVE_LONG_LONG)
+# define DEVT2NUM(v) LL2NUM(v)
+#elif SIZEOF_DEV_T == SIZEOF_LONG
+# define DEVT2NUM(v) LONG2NUM(v)
+#else
+# define DEVT2NUM(v) INT2NUM(v)
+#endif
+
 /*
  *  call-seq:
  *     stat.dev    -> fixnum
@@ -329,7 +337,7 @@
 static VALUE
 rb_stat_dev(VALUE self)
 {
-    return INT2NUM(get_stat(self)->st_dev);
+    return DEVT2NUM(get_stat(self)->st_dev);
 }
 
 /*
@@ -347,8 +355,7 @@
 rb_stat_dev_major(VALUE self)
 {
 #if defined(major)
-    long dev = get_stat(self)->st_dev;
-    return ULONG2NUM(major(dev));
+    return INT2NUM(major(get_stat(self)->st_dev));
 #else
     return Qnil;
 #endif
@@ -369,8 +376,7 @@
 rb_stat_dev_minor(VALUE self)
 {
 #if defined(minor)
-    long dev = get_stat(self)->st_dev;
-    return ULONG2NUM(minor(dev));
+    return INT2NUM(minor(get_stat(self)->st_dev));
 #else
     return Qnil;
 #endif

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

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