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

* configure.in (sizeof ptrdiff_t): check for size of ptrdiff_t.

* include/ruby/ruby.h (PRI?PTRDIFF, PRI?SIZE): printf conversion
  specifiers for ptrdiff_t and size_t/ssize_t.

* insns.def (leave), marshal.c (long_toobig), transcode.c
  (str_transcode), vm_dump.c (control_frame_dump, stack_dump_each),
  (debug_print_register, debug_print_pre): t and z length modifiers
  are C99.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18038 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2008-07-12 13:17:29 +00:00
parent 2c0a3f226a
commit f94f8f351e
7 changed files with 64 additions and 28 deletions

View file

@ -1,3 +1,15 @@
Sat Jul 12 22:17:26 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in (sizeof ptrdiff_t): check for size of ptrdiff_t.
* include/ruby/ruby.h (PRI?PTRDIFF, PRI?SIZE): printf conversion
specifiers for ptrdiff_t and size_t/ssize_t.
* insns.def (leave), marshal.c (long_toobig), transcode.c
(str_transcode), vm_dump.c (control_frame_dump, stack_dump_each),
(debug_print_register, debug_print_pre): t and z length modifiers
are C99.
Sat Jul 12 16:02:31 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/xmlrpc/client.rb (XMLRPC::Client#do_rpc): requires

View file

@ -628,6 +628,7 @@ AC_CHECK_SIZEOF(rlim_t, 0, [
dnl Checks for typedefs, structures, and compiler characteristics.
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

View file

@ -87,28 +87,51 @@ typedef unsigned long VALUE;
typedef unsigned long ID;
# define SIGNED_VALUE long
# define SIZEOF_VALUE SIZEOF_LONG
# define PRIdVALUE "ld"
# define PRIiVALUE "li"
# define PRIoVALUE "lo"
# define PRIuVALUE "lu"
# define PRIxVALUE "lx"
# define PRIXVALUE "lX"
# define PRI_VALUE_PREFIX "l"
#elif SIZEOF_LONG_LONG == SIZEOF_VOIDP
typedef unsigned LONG_LONG VALUE;
typedef unsigned LONG_LONG ID;
# define SIGNED_VALUE LONG_LONG
# define LONG_LONG_VALUE 1
# define SIZEOF_VALUE SIZEOF_LONG_LONG
# define PRIdVALUE "lld"
# define PRIiVALUE "lli"
# define PRIoVALUE "llo"
# define PRIuVALUE "llu"
# define PRIxVALUE "llx"
# define PRIXVALUE "llX"
# define PRI_VALUE_PREFIX "ll"
#else
# error ---->> ruby requires sizeof(void*) == sizeof(long) to be compiled. <<----
#endif
#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"
#if SIZEOF_PTRDIFF_T == SIZEOF_INT
# define PRI_PTDIFF_PREFIX
#elif SIZEOF_PTRDIFF_T == SIZEOF_LONG
# define PRI_PTDIFF_PREFIX "l"
#elif SIZEOF_PTRDIFF_T == SIZEOF_LONG
# define PRI_PTDIFF_PREFIX "ll"
#endif
#define PRIdPTRDIFF PRI_PTRDIFF_PREFIX"d"
#define PRIiPTRDIFF PRI_PTRDIFF_PREFIX"i"
#define PRIoPTRDIFF PRI_PTRDIFF_PREFIX"o"
#define PRIuPTRDIFF PRI_PTRDIFF_PREFIX"u"
#define PRIxPTRDIFF PRI_PTRDIFF_PREFIX"x"
#define PRIXPTRDIFF PRI_PTRDIFF_PREFIX"X"
#if SIZEOF_SIZE_T == SIZEOF_INT
# define PRI_PTDIFF_PREFIX
#elif SIZEOF_SIZE_T == SIZEOF_LONG
# define PRI_PTDIFF_PREFIX "l"
#elif SIZEOF_SIZE_T == SIZEOF_LONG
# define PRI_PTDIFF_PREFIX "ll"
#endif
#define PRIdSIZE PRI_SIZE_PREFIX"d"
#define PRIiSIZE PRI_SIZE_PREFIX"i"
#define PRIoSIZE PRI_SIZE_PREFIX"o"
#define PRIuSIZE PRI_SIZE_PREFIX"u"
#define PRIxSIZE PRI_SIZE_PREFIX"x"
#define PRIXSIZE PRI_SIZE_PREFIX"X"
#ifdef __STDC__
# include <limits.h>

View file

@ -1058,7 +1058,7 @@ leave
{
if (OPT_CHECKED_RUN) {
if (reg_cfp->sp != reg_cfp->bp) {
rb_bug("Stack consistency error (sp: %td, bp: %td)",
rb_bug("Stack consistency error (sp: %"PRIdPTRDIFF", bp: %"PRIdPTRDIFF")",
VM_SP_CNT(th, reg_cfp->sp), VM_SP_CNT(th, reg_cfp->bp));
}
}

View file

@ -941,8 +941,8 @@ r_byte(struct load_arg *arg)
static void
long_toobig(int size)
{
rb_raise(rb_eTypeError, "long too big for this architecture (size %zd, given %d)",
sizeof(long), size);
rb_raise(rb_eTypeError, "long too big for this architecture (size "
STRINGIZE(SIZEOF_LONG)", given %d)", size);
}
#undef SIGN_EXTEND_CHAR

View file

@ -326,7 +326,7 @@ str_transcode(int argc, VALUE *argv, VALUE *self)
my_transcoding.ruby_string_dest = dest;
(*my_transcoder->preprocessor)(&fromp, &bp, (sp+slen), (bp+blen), &my_transcoding);
if (fromp != sp+slen) {
rb_raise(rb_eArgError, "not fully converted, %td bytes left", sp+slen-fromp);
rb_raise(rb_eArgError, "not fully converted, %"PRIdPTRDIFF" bytes left", sp+slen-fromp);
}
buf = (unsigned char *)RSTRING_PTR(dest);
*bp = '\0';
@ -343,7 +343,7 @@ str_transcode(int argc, VALUE *argv, VALUE *self)
transcode_loop(&fromp, &bp, (sp+slen), (bp+blen), my_transcoder, &my_transcoding, options);
if (fromp != sp+slen) {
rb_raise(rb_eArgError, "not fully converted, %td bytes left", sp+slen-fromp);
rb_raise(rb_eArgError, "not fully converted, %"PRIdPTRDIFF" bytes left", sp+slen-fromp);
}
buf = (unsigned char *)RSTRING_PTR(dest);
*bp = '\0';
@ -358,7 +358,7 @@ str_transcode(int argc, VALUE *argv, VALUE *self)
my_transcoding.ruby_string_dest = dest;
(*my_transcoder->postprocessor)(&fromp, &bp, (sp+slen), (bp+blen), &my_transcoding);
if (fromp != sp+slen) {
rb_raise(rb_eArgError, "not fully converted, %td bytes left", sp+slen-fromp);
rb_raise(rb_eArgError, "not fully converted, %"PRIdPTRDIFF" bytes left", sp+slen-fromp);
}
buf = (unsigned char *)RSTRING_PTR(dest);
*bp = '\0';

View file

@ -115,17 +115,17 @@ control_frame_dump(rb_thread_t *th, rb_control_frame_t *cfp)
line = -1;
}
fprintf(stderr, "c:%04td ",
(rb_control_frame_t *)(th->stack + th->stack_size) - cfp);
fprintf(stderr, "c:%04"PRIdPTRDIFF" ",
((rb_control_frame_t *)(th->stack + th->stack_size) - cfp));
if (pc == -1) {
fprintf(stderr, "p:---- ");
}
else {
fprintf(stderr, "p:%04d ", pc);
}
fprintf(stderr, "s:%04td b:%04d ", cfp->sp - th->stack, bp);
fprintf(stderr, lfp_in_heap == ' ' ? "l:%06td " : "l:%06tx ", lfp % 10000);
fprintf(stderr, dfp_in_heap == ' ' ? "d:%06td " : "d:%06tx ", dfp % 10000);
fprintf(stderr, "s:%04"PRIdPTRDIFF" b:%04d ", (cfp->sp - th->stack), bp);
fprintf(stderr, lfp_in_heap == ' ' ? "l:%06"PRIdPTRDIFF" " : "l:%06"PRIxPTRDIFF" ", lfp % 10000);
fprintf(stderr, dfp_in_heap == ' ' ? "d:%06"PRIdPTRDIFF" " : "d:%06"PRIxPTRDIFF" ", dfp % 10000);
fprintf(stderr, "%-6s ", magic);
if (line) {
fprintf(stderr, "%s", posbuf);
@ -308,8 +308,8 @@ stack_dump_each(rb_thread_t *th, rb_control_frame_t *cfp)
else {
rstr = rb_inspect(*ptr);
}
fprintf(stderr, " stack %2d: %8s (%td)\n", i, StringValueCStr(rstr),
ptr - th->stack);
fprintf(stderr, " stack %2d: %8s (%"PRIdPTRDIFF")\n", i, StringValueCStr(rstr),
(ptr - th->stack));
}
}
else if (VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_FINISH) {
@ -345,8 +345,8 @@ debug_print_register(rb_thread_t *th)
dfp = -1;
cfpi = ((rb_control_frame_t *)(th->stack + th->stack_size)) - cfp;
fprintf(stderr, " [PC] %04d, [SP] %04td, [LFP] %04d, [DFP] %04d, [CFP] %04d\n",
pc, cfp->sp - th->stack, lfp, dfp, cfpi);
fprintf(stderr, " [PC] %04d, [SP] %04"PRIdPTRDIFF", [LFP] %04d, [DFP] %04d, [CFP] %04d\n",
pc, (cfp->sp - th->stack), lfp, dfp, cfpi);
}
void
@ -366,7 +366,7 @@ debug_print_pre(rb_thread_t *th, rb_control_frame_t *cfp)
VALUE *seq = iseq->iseq;
int pc = cfp->pc - iseq->iseq_encoded;
printf("%3td ", VM_CFP_CNT(th, cfp));
printf("%3"PRIdPTRDIFF" ", VM_CFP_CNT(th, cfp));
ruby_iseq_disasm_insn(0, seq, pc, iseq, 0);
}