mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* configure.in (RUBY_REPLACE_TYPE): cache convertible type info.
* intern.h (rb_detach_process): use rb_pid_t instead of pid_t. * ruby.h (PIDT2NUM, NUM2PIDT, UIDT2NUM, NUM2UIDT, GIDT2NUM, NUM2GIDT): defaulted to conversion using long. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11786 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
085fee9087
commit
128cc954d0
3 changed files with 49 additions and 36 deletions
64
configure.in
64
configure.in
|
@ -239,46 +239,40 @@ AC_CHECK_SIZEOF(float, 4)
|
|||
AC_CHECK_SIZEOF(double, 8)
|
||||
AC_CHECK_SIZEOF(time_t, 0)
|
||||
|
||||
dnl RUBY_REPLACE_TYPE [typename] [default type] [macro type] [included]
|
||||
AC_DEFUN([RUBY_REPLACE_TYPE], [dnl
|
||||
AC_CHECK_SIZEOF($1, 0, $3)
|
||||
u=
|
||||
size=$ac_cv_sizeof_[$1]
|
||||
if test $size -gt 0; then
|
||||
typ=$1
|
||||
AC_CHECK_TYPE([$1],
|
||||
[AC_DEFINE_UNQUOTED(rb_[$1], [$1])],
|
||||
[AC_DEFINE_UNQUOTED(rb_[$1], [$2])],
|
||||
[$4])
|
||||
AC_CACHE_CHECK([for convertible type of [$1]], rb_cv_[$1]_convertible, [
|
||||
u= t=
|
||||
AC_COMPILE_IFELSE(
|
||||
[AC_LANG_BOOL_COMPILE_TRY([AC_INCLUDES_DEFAULT]
|
||||
[$3], [($typ)-1 > 0])],
|
||||
[$4], [(rb_[$1])-1 > 0])],
|
||||
[u=U])
|
||||
else
|
||||
typ=$2
|
||||
size=$ac_cv_sizeof_[$2]
|
||||
fi
|
||||
if test $size -gt $ac_cv_sizeof_long; then
|
||||
f=LL
|
||||
elif test $size = $ac_cv_sizeof_long; then
|
||||
f=LONG
|
||||
else
|
||||
f=INT
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED(rb_$1, $typ)
|
||||
AC_DEFINE_UNQUOTED(SIZEOF_RB_`echo $1 | tr a-z A-Z`,
|
||||
SIZEOF_`echo $typ | tr a-z A-Z`)
|
||||
typ=`echo $1 | tr a-z A-Z | tr -d _`
|
||||
AC_DEFINE_UNQUOTED(${typ}2NUM, ${u}${f}2NUM)
|
||||
AC_DEFINE_UNQUOTED(NUM2${typ}, NUM2${u}${f})
|
||||
])
|
||||
RUBY_REPLACE_TYPE(pid_t, int, [
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
])
|
||||
RUBY_REPLACE_TYPE(uid_t, int, [
|
||||
#include <sys/types.h>
|
||||
#include <pwd.h>
|
||||
])
|
||||
RUBY_REPLACE_TYPE(gid_t, int, [
|
||||
#include <sys/types.h>
|
||||
#include <grp.h>
|
||||
if test x"$t" = x; then
|
||||
AC_COMPILE_IFELSE(
|
||||
[AC_LANG_BOOL_COMPILE_TRY([AC_INCLUDES_DEFAULT]
|
||||
[$4], [sizeof(rb_[$1]) > 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)])],
|
||||
[t=LONG])
|
||||
fi
|
||||
if test x"$t" = x; then
|
||||
t=INT
|
||||
fi
|
||||
rb_cv_[$1]_convertible=${u}${t}])
|
||||
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)
|
||||
|
||||
AC_CACHE_CHECK(for prototypes, rb_cv_have_prototypes,
|
||||
[AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],
|
||||
|
|
2
intern.h
2
intern.h
|
@ -430,7 +430,7 @@ rb_pid_t rb_waitpid(rb_pid_t pid, int *status, int flags);
|
|||
void rb_syswait(rb_pid_t pid);
|
||||
rb_pid_t rb_spawn(int, VALUE*);
|
||||
VALUE rb_proc_times(VALUE);
|
||||
VALUE rb_detach_process(pid_t pid);
|
||||
VALUE rb_detach_process(rb_pid_t pid);
|
||||
/* range.c */
|
||||
VALUE rb_range_new(VALUE, VALUE, int);
|
||||
VALUE rb_range_beg_len(VALUE, long*, long*, long, int);
|
||||
|
|
19
ruby.h
19
ruby.h
|
@ -187,6 +187,25 @@ VALUE rb_ull2inum(unsigned LONG_LONG);
|
|||
# define OFFT2NUM(v) INT2NUM(v)
|
||||
#endif
|
||||
|
||||
#ifndef PIDT2NUM
|
||||
#define PIDT2NUM(v) LONG2NUM(v)
|
||||
#endif
|
||||
#ifndef NUM2PIDT
|
||||
#define NUM2PIDT(v) NUM2LONG(v)
|
||||
#endif
|
||||
#ifndef UIDT2NUM
|
||||
#define UIDT2NUM(v) LONG2NUM(v)
|
||||
#endif
|
||||
#ifndef NUM2UIDT
|
||||
#define NUM2UIDT(v) NUM2LONG(v)
|
||||
#endif
|
||||
#ifndef GIDT2NUM
|
||||
#define GIDT2NUM(v) LONG2NUM(v)
|
||||
#endif
|
||||
#ifndef NUM2GIDT
|
||||
#define NUM2GIDT(v) NUM2LONG(v)
|
||||
#endif
|
||||
|
||||
#define FIX2LONG(x) RSHIFT((SIGNED_VALUE)x,1)
|
||||
#define FIX2ULONG(x) (((VALUE)(x))>>1)
|
||||
#define FIXNUM_P(f) (((SIGNED_VALUE)(f))&FIXNUM_FLAG)
|
||||
|
|
Loading…
Reference in a new issue