* configure.in (RUBY_CHECK_SIZEOF): allows qualified name.

* configure.in (RUBY_REPLACE_TYPE): checks more strictly.

* configure.in (struct stat.st_size, struct stat.st_blocks),
  (struct stat.st_ino): check for size.

* lib/mkmf.rb (check_sizeof): allows qualified name.

* file.c (rb_stat_ino, rb_stat_blocks): check by size.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23005 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2009-03-19 09:49:51 +00:00
Родитель 0ff55a1bd2
Коммит b7800329d3
4 изменённых файлов: 60 добавлений и 58 удалений

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

@ -359,14 +359,19 @@ AC_CACHE_CHECK([char bit], [rb_cv_char_bit],
dnl RUBY_CHECK_SIZEOF [typename], [maybe same size types], [macros], [include]
AC_DEFUN([RUBY_CHECK_SIZEOF],
[if test "$universal_binary" = yes; then
[m4_bmatch([$1], [\.], [], [if test "$universal_binary" = yes; then])
AC_CACHE_CHECK([size of $1], [AS_TR_SH([ac_cv_sizeof_$1])], [
unset AS_TR_SH(ac_cv_sizeof_$1)
rbcv_var="
typedef m4_bpatsubst([$1], [\..*]) ac__type_sizeof_;
static ac__type_sizeof_ *rbcv_ptr;
@%:@define AS_TR_CPP(SIZEOF_$1) sizeof((*rbcv_ptr)[]m4_bmatch([$1], [\.], .m4_bpatsubst([$1], [^[^.]*\.])))
"
m4_ifval([$2], [test -z "${AS_TR_SH(ac_cv_sizeof_$1)+set}" && {
for t in $2; do
AC_COMPILE_IFELSE(
[AC_LANG_BOOL_COMPILE_TRY([AC_INCLUDES_DEFAULT],
[sizeof($1) == sizeof($t)])], [
[AC_LANG_BOOL_COMPILE_TRY(AC_INCLUDES_DEFAULT([$rbcv_var]),
[AS_TR_CPP(SIZEOF_$1) == sizeof($t)])], [
AS_TR_SH(ac_cv_sizeof_$1)=AS_TR_CPP([SIZEOF_]$t)
break])
done
@ -384,8 +389,9 @@ AC_CACHE_CHECK([size of $1], [AS_TR_SH([ac_cv_sizeof_$1])], [
@%:@ define AS_TR_CPP(HAVE_$1) 0
@%:@endif])"
AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([$hdr], [!AS_TR_CPP(HAVE_$1)])], [continue])
AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([$hdr],
[AS_TR_CPP(HAVE_$1) == (sizeof($1) == ([$[s / rb_cv_char_bit]]))])],
AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([$hdr]
[$rbcv_var],
[AS_TR_CPP(HAVE_$1) == (AS_TR_CPP(SIZEOF_$1) == ([$[s / rb_cv_char_bit]]))])],
[AS_TR_SH(ac_cv_sizeof_$1)="${AS_TR_SH(ac_cv_sizeof_$1)+${AS_TR_SH(ac_cv_sizeof_$1)-} }${t}${s}"])
done
done
@ -396,8 +402,7 @@ AC_CACHE_CHECK([size of $1], [AS_TR_SH([ac_cv_sizeof_$1])], [
_AC_COMPUTE_INT_COMPILE(AS_TR_CPP(SIZEOF_$1), [t], [AC_INCLUDES_DEFAULT([$4])]
[${cond+$cond
@%:@else}
typedef $1 ac__type_sizeof_;
@%:@define AS_TR_CPP(SIZEOF_$1) sizeof(ac__type_sizeof_)
$rbcv_var
${cond+@%:@endif}
@%:@ifndef AS_TR_CPP(SIZEOF_$1)
@%:@define AS_TR_CPP(SIZEOF_$1) 0
@ -427,9 +432,9 @@ ${cond+@%:@endif}
done
${cond+echo "@%:@endif"}
} >> confdefs.h
else
m4_bmatch([$1], [\.], [], [else
AC_CHECK_SIZEOF([$1], 0, [$4])
fi
fi])
])
RUBY_CHECK_SIZEOF(int, [], [ILP])
@ -454,31 +459,32 @@ AC_DEFUN([RUBY_REPLACE_TYPE], [dnl
u=U;;
when(*)
AC_COMPILE_IFELSE(
[AC_LANG_BOOL_COMPILE_TRY([AC_INCLUDES_DEFAULT]
[$4], [($n)-1 > 0])],
[AC_LANG_BOOL_COMPILE_TRY([AC_INCLUDES_DEFAULT([$4])], [($n)-1 > 0])],
[u=U]);;
esac
if test x"$t" = x; then
for t in "long long" long int short; do
test -n "$u" && t="unsigned $t"
AC_COMPILE_IFELSE(
[AC_LANG_BOOL_COMPILE_TRY([AC_INCLUDES_DEFAULT([$4])]
[typedef $n rbcv_conftest_target_type;
typedef $t rbcv_conftest_replace_type;
extern rbcv_conftest_target_type rbcv_conftest_var;
extern rbcv_conftest_replace_type rbcv_conftest_var;
extern rbcv_conftest_target_type rbcv_conftest_func(void);
extern rbcv_conftest_replace_type rbcv_conftest_func(void);
], [sizeof(rbcv_conftest_target_type) == sizeof(rbcv_conftest_replace_type)])],
[n="$t"; break])
done
fi
case " $n " in
when(*" long long "*)
t=LL;;
when(*" long "*)
t=LONG;;
when(*)
t=INT;;
esac
if test x"$t" = x; then
AC_COMPILE_IFELSE(
[AC_LANG_BOOL_COMPILE_TRY([AC_INCLUDES_DEFAULT]
[$4], [sizeof($n) > sizeof(long)])],
[t=LL])
fi
if test x"$t" = x; then
AC_COMPILE_IFELSE(
[AC_LANG_BOOL_COMPILE_TRY([AC_INCLUDES_DEFAULT]
[$4], [sizeof($n) == sizeof(long)])],
[t=LONG])
fi
if test x"$t" = x; then
t=INT
fi
rb_cv_[$1]_convertible=${u}${t}])
m4_ifval([$2], AC_DEFINE_UNQUOTED(rb_[$1], $n))
AC_DEFINE_UNQUOTED([$3]2NUM[(v)], [${rb_cv_[$1]_convertible}2NUM(v)])
@ -914,33 +920,15 @@ RUBY_CHECK_SIZEOF(rlim_t, [int long "long long"], [], [
#include <stdio.h>
])
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
RUBY_CHECK_SIZEOF(size_t, [int long void*])
RUBY_CHECK_SIZEOF(ptrdiff_t, size_t)
AC_STRUCT_ST_BLKSIZE
AC_STRUCT_ST_BLOCKS
AC_STRUCT_ST_RDEV
RUBY_CHECK_HUGE([struct stat.st_size])
RUBY_CHECK_SIZEOF([struct stat.st_size], [int long "long long"])
if test "$ac_cv_member_struct_stat_st_blocks" = yes; then
RUBY_CHECK_HUGE(struct stat.st_blocks)
RUBY_CHECK_SIZEOF([struct stat.st_blocks], [int long "long long"])
fi
AC_CHECK_MEMBERS([struct stat.st_atim])
AC_CHECK_MEMBERS([struct stat.st_atimespec])
@ -1356,8 +1344,7 @@ else
fi
fi
RUBY_CHECK_HUGE([struct stat.st_ino],
[AC_DEFINE(HUGE_ST_INO)], [], [@%:@include <sys/stat.h>])
RUBY_CHECK_SIZEOF([struct stat.st_ino], [long "long long"], [], [@%:@include <sys/stat.h>])
if test "$ac_cv_func_sysconf" = yes; then
AC_DEFUN([RUBY_CHECK_SYSCONF], [dnl
@ -2364,6 +2351,10 @@ if test "${universal_binary-no}" = yes ; then
RUBY_DEFINE_IF([defined __${archs}__], RUBY_PLATFORM_CPU, ["${cpu}"])
done
fi
ints='long int'
test "$ac_cv_type_long_long" = yes && ints="'long long' $ints"
AC_SUBST(UNIVERSAL_ARCHNAMES, "${universal_archnames}")
AC_SUBST(UNIVERSAL_INTS, "${ints}")
AC_DEFINE_UNQUOTED(RUBY_PLATFORM_OS, "${target_os}")
AC_DEFINE_UNQUOTED(RUBY_ARCH, "universal-"RUBY_PLATFORM_OS)
AC_DEFINE_UNQUOTED(RUBY_PLATFORM, "universal."RUBY_PLATFORM_CPU"-"RUBY_PLATFORM_OS)

4
file.c
Просмотреть файл

@ -310,7 +310,7 @@ rb_stat_dev_minor(VALUE self)
static VALUE
rb_stat_ino(VALUE self)
{
#ifdef HUGE_ST_INO
#if SIZEOF_STRUCT_STAT_ST_INO > SIZEOF_LONG
return ULL2NUM(get_stat(self)->st_ino);
#else
return ULONG2NUM(get_stat(self)->st_ino);
@ -503,7 +503,7 @@ static VALUE
rb_stat_blocks(VALUE self)
{
#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
# ifdef HUGE_STRUCT_STAT_ST_BLOCKS
# if SIZEOF_STRUCT_STAT_ST_BLOCKS > SIZEOF_LONG
return ULL2NUM(get_stat(self)->st_blocks);
# else
return ULONG2NUM(get_stat(self)->st_blocks);

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

@ -65,6 +65,7 @@ $os2 = /os2/ =~ RUBY_PLATFORM
$beos = /beos/ =~ RUBY_PLATFORM
$haiku = /haiku/ =~ RUBY_PLATFORM
$solaris = /solaris/ =~ RUBY_PLATFORM
$universal = /universal/ =~ RUBY_PLATFORM
$dest_prefix_pattern = (File::PATH_SEPARATOR == ';' ? /\A([[:alpha:]]:)?/ : /\A/)
# :stopdoc:
@ -440,7 +441,7 @@ end
def cpp_include(header)
if header
header = [header] unless header.kind_of? Array
header.map {|h| "#include <#{h}>\n"}.join
header.map {|h| String === h ? "#include <#{h}>\n" : h}.join
else
""
end
@ -977,14 +978,23 @@ end
# SIZEOF_MYSTRUCT=12 preprocessor macro would be passed to the compiler.
#
def check_sizeof(type, headers = nil, &b)
expr = "sizeof(#{type})"
fmt = "%d"
typename, member = type.split('.', 2)
prelude = cpp_include(headers).split(/$/)
prelude << "typedef #{typename} rbcv_typedef_;\n"
prelude << "static rbcv_typedef_ *rbcv_ptr_;\n"
prelude = [prelude]
expr = "sizeof((*rbcv_ptr_)#{"."<<member if member})"
fmt = "%s"
def fmt.%(x)
x ? super : "failed"
end
checking_for checking_message("size of #{type}", headers), fmt do
if size = try_constant(expr, headers, &b)
$defs.push(format("-DSIZEOF_%s=%d", type.tr_cpp, size))
if (($universal and
size = UNIVERSAL_INTS.find {|t|
try_static_assert("#{expr} == sizeof(#{t})", prelude, &b)
}) or
size = try_constant(expr, prelude, &b))
$defs.push(format("-DSIZEOF_%s=%s", type.tr_cpp, size))
size
end
end
@ -1725,7 +1735,7 @@ static: $(STATIC_LIB)#{$extout ? " install-rb" : ""}
dirs.uniq!
unless dirs.empty?
mfile.print("clean-rb#{sfx}::\n")
for dir in dirs.sort_by {|dir| -dir.count('/')}
for dir in dirs.sort_by {|d| -d.count('/')}
mfile.print("\t@-$(RMDIRS) #{fseprepl[dir]}\n")
end
end
@ -1936,6 +1946,7 @@ LIBPATHFLAG = config_string('LIBPATHFLAG') || ' -L"%s"'
RPATHFLAG = config_string('RPATHFLAG') || ''
LIBARG = config_string('LIBARG') || '-l%s'
MAIN_DOES_NOTHING = config_string('MAIN_DOES_NOTHING') || 'int main() {return 0;}'
UNIVERSAL_INTS = config_string('UNIVERSAL_INTS') {|s| Shellwords.shellwords(s)} if $universal
sep = config_string('BUILD_FILE_SEPARATOR') {|s| ":/=#{s}" if s != "/"} || ""
CLEANINGS = "

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

@ -1,5 +1,5 @@
#define RUBY_VERSION "1.9.2"
#define RUBY_RELEASE_DATE "2009-03-18"
#define RUBY_RELEASE_DATE "2009-03-19"
#define RUBY_PATCHLEVEL -1
#define RUBY_BRANCH_NAME "trunk"
@ -8,7 +8,7 @@
#define RUBY_VERSION_TEENY 1
#define RUBY_RELEASE_YEAR 2009
#define RUBY_RELEASE_MONTH 3
#define RUBY_RELEASE_DAY 18
#define RUBY_RELEASE_DAY 19
#ifdef RUBY_EXTERN
RUBY_EXTERN const char ruby_version[];