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

* configure.in (RUBY_REPLACE_TYPE): does not define rb_ prefixed

name if no default type is given.

* configure.in (RUBY_DEFINT): checks size.

* include/ruby/ruby.h (VALUE): use uintptr_t if available.

* include/ruby/ruby.h (PRI_PTRDIFF_PREFIX, PRI_SIZE_PREFIX):
  assumes usable if PRIdPTR is defined.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21587 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2009-01-16 02:41:26 +00:00
parent 3e7c34140c
commit 5b6a192755
3 changed files with 67 additions and 14 deletions

View file

@ -1,3 +1,15 @@
Fri Jan 16 11:41:23 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in (RUBY_REPLACE_TYPE): does not define rb_ prefixed
name if no default type is given.
* configure.in (RUBY_DEFINT): checks size.
* include/ruby/ruby.h (VALUE): use uintptr_t if available.
* include/ruby/ruby.h (PRI_PTRDIFF_PREFIX, PRI_SIZE_PREFIX):
assumes usable if PRIdPTR is defined.
Fri Jan 16 02:25:46 2009 Yusuke Endoh <mame@tsg.ne.jp>
* thread.c (rb_thread_execute_interrupts): if signal is already

View file

@ -296,38 +296,51 @@ AC_CHECK_SIZEOF(time_t, 0)
dnl RUBY_REPLACE_TYPE [typename] [default type] [macro type] [included]
AC_DEFUN([RUBY_REPLACE_TYPE], [dnl
AC_CHECK_TYPE([$1],
[AC_DEFINE_UNQUOTED(rb_[$1], [$1])],
[AC_DEFINE_UNQUOTED(rb_[$1], [$2])],
[$4])
AC_CHECK_TYPE([$1], [n=[$1]], [n=[$2]], [$4])
AC_CACHE_CHECK([for convertible type of [$1]], rb_cv_[$1]_convertible, [
u= t=
case "$n " in
dnl (
*" signed "*) ;;
dnl (
*" unsigned "*) u=U;;
dnl (
*)
AC_COMPILE_IFELSE(
[AC_LANG_BOOL_COMPILE_TRY([AC_INCLUDES_DEFAULT]
[$4], [(rb_[$1])-1 > 0])],
[u=U])
[$4], [($n)-1 > 0])],
[u=U]);;
esac
case " $n " in
dnl (
*" long long "*) t=LL;;
dnl (
*" long "*) t=LONG;;
esac
if test x"$t" = x; then
AC_COMPILE_IFELSE(
[AC_LANG_BOOL_COMPILE_TRY([AC_INCLUDES_DEFAULT]
[$4], [sizeof(rb_[$1]) > sizeof(long)])],
[$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(rb_[$1]) == sizeof(long)])],
[$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)])
AC_DEFINE_UNQUOTED(NUM2[$3][(v)], [NUM2${rb_cv_[$1]_convertible}(v)])
])
RUBY_REPLACE_TYPE(pid_t, int, PIDT)
RUBY_REPLACE_TYPE(uid_t, int, UIDT)
RUBY_REPLACE_TYPE(gid_t, int, GIDT)
RUBY_REPLACE_TYPE(time_t, [], TIMET, [@%:@include <time.h>])
AC_CACHE_CHECK(for prototypes, rb_cv_have_prototypes,
[AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],
@ -713,7 +726,12 @@ typedef $1 t; int s = sizeof(t) == 42;])],
esac])])
if test "${rb_cv_type_$1}" != no; then
AC_DEFINE([HAVE_]AS_TR_CPP($1), 1)
test "${rb_cv_type_$1}" = yes || AC_DEFINE_UNQUOTED($1, [$rb_cv_type_$1])
if test "${rb_cv_type_$1}" = yes; then
AC_CHECK_SIZEOF($1)
else
AC_DEFINE_UNQUOTED($1, [$rb_cv_type_$1])
AC_DEFINE_UNQUOTED([SIZEOF_]AS_TR_CPP($1), [SIZEOF_]AS_TR_CPP([$rb_cv_type_$1]))
fi
fi
])

View file

@ -60,6 +60,9 @@ extern "C" {
# include <intrinsics.h>
#endif
#ifdef HAVE_STDINT_H
# include <stdint.h>
#endif
#ifdef HAVE_INTTYPES_H
# include <inttypes.h>
#endif
@ -77,7 +80,13 @@ extern "C" {
# endif
#endif
#if SIZEOF_LONG == SIZEOF_VOIDP
#if defined HAVE_UINTPTR_T
typedef uintptr_t VALUE;
typedef uintptr_t ID;
# define SIGNED_VALUE intptr_t
# define SIZEOF_VALUE SIZEOF_UINTPTR_T
# undef PRI_VALUE_PREFIX
#elif SIZEOF_LONG == SIZEOF_VOIDP
typedef unsigned long VALUE;
typedef unsigned long ID;
# define SIGNED_VALUE long
@ -93,14 +102,26 @@ typedef unsigned LONG_LONG ID;
#else
# error ---->> ruby requires sizeof(void*) == sizeof(long) to be compiled. <<----
#endif
#ifdef PRIdPTR
#define PRIdVALUE PRIdPTR
#define PRIiVALUE PRIiPTR
#define PRIoVALUE PRIoPTR
#define PRIuVALUE PRIuPTR
#define PRIxVALUE PRIxPTR
#define PRIXVALUE PRIXPTR
#else
#define PRIdVALUE PRI_VALUE_PREFIX"d"
#define PRIiVALUE PRI_VALUE_PREFIX"i"
#define PRIoVALUE PRI_VALUE_PREFIX"o"
#define PRIuVALUE PRI_VALUE_PREFIX"u"
#define PRIxVALUE PRI_VALUE_PREFIX"x"
#define PRIXVALUE PRI_VALUE_PREFIX"X"
#endif
#if SIZEOF_PTRDIFF_T == SIZEOF_INT
#if defined PRIdPTR
# define PRI_PTRDIFF_PREFIX "t"
#elif SIZEOF_PTRDIFF_T == SIZEOF_INT
# define PRI_PTRDIFF_PREFIX
#elif SIZEOF_PTRDIFF_T == SIZEOF_LONG
# define PRI_PTRDIFF_PREFIX "l"
@ -114,7 +135,9 @@ typedef unsigned LONG_LONG ID;
#define PRIxPTRDIFF PRI_PTRDIFF_PREFIX"x"
#define PRIXPTRDIFF PRI_PTRDIFF_PREFIX"X"
#if SIZEOF_SIZE_T == SIZEOF_INT
#if defined PRIdPTR
# define PRI_SIZE_PREFIX "z"
#elif SIZEOF_SIZE_T == SIZEOF_INT
# define PRI_SIZE_PREFIX
#elif SIZEOF_SIZE_T == SIZEOF_LONG
# define PRI_SIZE_PREFIX "l"