summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-12-02 08:07:32 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-12-02 08:07:32 +0000
commit8633eacb30f87eb629fd1fff163cba8c9b70d52e (patch)
treeb0a09302bfb612a10c60ba101386e1c334c7c129 /file.c
parentfaeed9b54c7b4085d0c6018d27afe5d755a8eb27 (diff)
merges r29493,r29494,r29505 and r29509 from trunk into ruby_1_9_2.
-- * 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. -- Refix for r29493; it is unsigned. -- * configure.in (dev_t): use RUBY_REPLACE_TYPE. * file.c (rb_stat_inspect): use PRI_DEVT_PREFIX. -- * file.c (NUM2DEVT, DEVT2NUM, PRI_DEVT_PREFIX): fallback to unsigned int. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@30047 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r--file.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/file.c b/file.c
index 6232f7f46e..adc49ef017 100644
--- a/file.c
+++ b/file.c
@@ -311,6 +311,16 @@ rb_stat_cmp(VALUE self, VALUE other)
#define ST2UINT(val) ((val) & ~(~1UL << (sizeof(val) * CHAR_BIT - 1)))
+#ifndef NUM2DEVT
+# define NUM2DEVT(v) NUM2UINT(v)
+#endif
+#ifndef DEVT2NUM
+# define DEVT2NUM(v) UINT2NUM(v)
+#endif
+#ifndef PRI_DEVT_PREFIX
+# define PRI_DEVT_PREFIX ""
+#endif
+
/*
* call-seq:
* stat.dev -> fixnum
@@ -324,7 +334,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);
}
/*
@@ -342,8 +352,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
@@ -364,8 +373,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
@@ -768,10 +776,10 @@ rb_stat_inspect(VALUE self)
rb_str_buf_cat2(str, "=");
v = (*member[i].func)(self);
if (i == 2) { /* mode */
- rb_str_catf(str, "0%lo", NUM2ULONG(v));
+ rb_str_catf(str, "0%lo", (unsigned long)NUM2ULONG(v));
}
else if (i == 0 || i == 6) { /* dev/rdev */
- rb_str_catf(str, "0x%lx", NUM2ULONG(v));
+ rb_str_catf(str, "0x%"PRI_DEVT_PREFIX"x", NUM2DEVT(v));
}
else {
rb_str_append(str, rb_inspect(v));