1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* configure.in (RUBY_CHECK_HUGE): checks whether a value range is

larger than long.

* file.c (rb_stat_blocks): struct stat.st_blocks may be larger
  than long.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22903 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2009-03-11 20:27:07 +00:00
parent 748ed24234
commit 2b9df35cd0
3 changed files with 34 additions and 13 deletions

View file

@ -1,4 +1,10 @@
Thu Mar 12 05:22:50 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
Thu Mar 12 05:27:06 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in (RUBY_CHECK_HUGE): checks whether a value range is
larger than long.
* file.c (rb_stat_blocks): struct stat.st_blocks may be larger
than long.
* io.c (copy_stream_fallback_body): off_t may be larger than long.

View file

@ -894,12 +894,32 @@ AC_CHECK_SIZEOF(rlim_t, 0, [
])
dnl Checks for typedefs, structures, and compiler characteristics.
AC_DEFUN([RUBY_CHECK_HUGE],
[AC_CACHE_CHECK([whether $1 is huge], AS_TR_SH(rb_cv_huge_$1),
[AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY(
[AC_INCLUDES_DEFAULT([$4])
static m4_bpatsubst([$1], [\..*]) rbcv_var;],
[dnl
sizeof(rbcv_var[]m4_bmatch([$1], [\.], .m4_bpatsubst([$1], [^[^.]*\.])))>sizeof(long)]
)],
[AS_TR_SH(rb_cv_huge_$1)=yes],
[AS_TR_SH(rb_cv_huge_$1)=no])])
if test "${AS_TR_SH(rb_cv_huge_$1)}" = yes; then
m4_ifval([$2], [$2], [AC_DEFINE(AS_TR_CPP(HUGE_$1))])
m4_ifval([$3], [else
$3
])
fi])
AC_TYPE_SIZE_T
AC_CHECK_SIZEOF(size_t, 0)
AC_CHECK_SIZEOF(ptrdiff_t, $ac_cv_sizeof_size_t)
AC_STRUCT_ST_BLKSIZE
AC_STRUCT_ST_BLOCKS
AC_STRUCT_ST_RDEV
if test "$ac_cv_member_struct_stat_st_blocks" = yes; then
RUBY_CHECK_HUGE(struct stat.st_blocks)
fi
AC_CHECK_MEMBERS([struct stat.st_atim])
AC_CHECK_MEMBERS([struct stat.st_atimespec])
AC_CHECK_MEMBERS([struct stat.st_atimensec])
@ -1314,17 +1334,8 @@ else
fi
fi
AC_CACHE_CHECK([whether st_ino is huge], rb_cv_huge_st_ino,
[AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([
#include <sys/stat.h>
struct stat test_stat;
], [sizeof(test_stat.st_ino)>sizeof(long)])],
rb_cv_huge_st_ino=yes,
rb_cv_huge_st_ino=no)
])
if test $rb_cv_huge_st_ino = yes; then
AC_DEFINE(HUGE_ST_INO)
fi
RUBY_CHECK_HUGE([struct stat.st_ino],
[AC_DEFINE(HUGE_ST_INO)], [], [@%:@include <sys/stat.h>])
if test "$ac_cv_func_sysconf" = yes; then
AC_DEFUN([RUBY_CHECK_SYSCONF], [dnl

6
file.c
View file

@ -502,8 +502,12 @@ rb_stat_blksize(VALUE self)
static VALUE
rb_stat_blocks(VALUE self)
{
#ifdef HAVE_ST_BLOCKS
#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
# ifdef HUGE_STRUCT_STAT_ST_BLOCKS
return ULL2NUM(get_stat(self)->st_blocks);
# else
return ULONG2NUM(get_stat(self)->st_blocks);
# endif
#else
return Qnil;
#endif