summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog17
-rw-r--r--configure.in1
-rw-r--r--file.c16
3 files changed, 29 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 15a69ba520..2290a17680 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+Thu Oct 14 07:35:07 2010 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * 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@ruby-lang.org>
* array.c (rb_ary_and, rb_ary_or), class.c (rb_mod_init_copy),
diff --git a/configure.in b/configure.in
index 859e85752f..74a32715e2 100644
--- a/configure.in
+++ b/configure.in
@@ -576,6 +576,7 @@ RUBY_CHECK_SIZEOF(void*, [int long "long long"], [ILP LP LLP])
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
diff --git a/file.c b/file.c
index 03f40942d8..edce3c86b5 100644
--- a/file.c
+++ b/file.c
@@ -316,6 +316,14 @@ rb_stat_cmp(VALUE self, VALUE other)
#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 @@ rb_stat_cmp(VALUE self, VALUE other)
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 @@ static VALUE
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 @@ static VALUE
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