* 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.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29493 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2010-10-13 23:09:56 +00:00
Родитель 7735e63593
Коммит 51427700cc
3 изменённых файлов: 29 добавлений и 5 удалений

Просмотреть файл

@ -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),

Просмотреть файл

@ -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

16
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