* 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
Родитель 2c0a3f226a
Коммит f94f8f351e
7 изменённых файлов: 64 добавлений и 28 удалений

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

@ -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> Sat Jul 12 16:02:31 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/xmlrpc/client.rb (XMLRPC::Client#do_rpc): requires * lib/xmlrpc/client.rb (XMLRPC::Client#do_rpc): requires

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

@ -628,6 +628,7 @@ AC_CHECK_SIZEOF(rlim_t, 0, [
dnl Checks for typedefs, structures, and compiler characteristics. dnl Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_SIZE_T AC_TYPE_SIZE_T
AC_CHECK_SIZEOF(size_t, 0) AC_CHECK_SIZEOF(size_t, 0)
AC_CHECK_SIZEOF(ptrdiff_t, $ac_cv_sizeof_size_t)
AC_STRUCT_ST_BLKSIZE AC_STRUCT_ST_BLKSIZE
AC_STRUCT_ST_BLOCKS AC_STRUCT_ST_BLOCKS
AC_STRUCT_ST_RDEV AC_STRUCT_ST_RDEV

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

@ -87,28 +87,51 @@ typedef unsigned long VALUE;
typedef unsigned long ID; typedef unsigned long ID;
# define SIGNED_VALUE long # define SIGNED_VALUE long
# define SIZEOF_VALUE SIZEOF_LONG # define SIZEOF_VALUE SIZEOF_LONG
# define PRIdVALUE "ld" # define PRI_VALUE_PREFIX "l"
# define PRIiVALUE "li"
# define PRIoVALUE "lo"
# define PRIuVALUE "lu"
# define PRIxVALUE "lx"
# define PRIXVALUE "lX"
#elif SIZEOF_LONG_LONG == SIZEOF_VOIDP #elif SIZEOF_LONG_LONG == SIZEOF_VOIDP
typedef unsigned LONG_LONG VALUE; typedef unsigned LONG_LONG VALUE;
typedef unsigned LONG_LONG ID; typedef unsigned LONG_LONG ID;
# define SIGNED_VALUE LONG_LONG # define SIGNED_VALUE LONG_LONG
# define LONG_LONG_VALUE 1 # define LONG_LONG_VALUE 1
# define SIZEOF_VALUE SIZEOF_LONG_LONG # define SIZEOF_VALUE SIZEOF_LONG_LONG
# define PRIdVALUE "lld" # define PRI_VALUE_PREFIX "ll"
# define PRIiVALUE "lli"
# define PRIoVALUE "llo"
# define PRIuVALUE "llu"
# define PRIxVALUE "llx"
# define PRIXVALUE "llX"
#else #else
# error ---->> ruby requires sizeof(void*) == sizeof(long) to be compiled. <<---- # error ---->> ruby requires sizeof(void*) == sizeof(long) to be compiled. <<----
#endif #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__ #ifdef __STDC__
# include <limits.h> # include <limits.h>

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

@ -1058,7 +1058,7 @@ leave
{ {
if (OPT_CHECKED_RUN) { if (OPT_CHECKED_RUN) {
if (reg_cfp->sp != reg_cfp->bp) { 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)); VM_SP_CNT(th, reg_cfp->sp), VM_SP_CNT(th, reg_cfp->bp));
} }
} }

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

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

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

@ -326,7 +326,7 @@ str_transcode(int argc, VALUE *argv, VALUE *self)
my_transcoding.ruby_string_dest = dest; my_transcoding.ruby_string_dest = dest;
(*my_transcoder->preprocessor)(&fromp, &bp, (sp+slen), (bp+blen), &my_transcoding); (*my_transcoder->preprocessor)(&fromp, &bp, (sp+slen), (bp+blen), &my_transcoding);
if (fromp != sp+slen) { 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); buf = (unsigned char *)RSTRING_PTR(dest);
*bp = '\0'; *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); transcode_loop(&fromp, &bp, (sp+slen), (bp+blen), my_transcoder, &my_transcoding, options);
if (fromp != sp+slen) { 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); buf = (unsigned char *)RSTRING_PTR(dest);
*bp = '\0'; *bp = '\0';
@ -358,7 +358,7 @@ str_transcode(int argc, VALUE *argv, VALUE *self)
my_transcoding.ruby_string_dest = dest; my_transcoding.ruby_string_dest = dest;
(*my_transcoder->postprocessor)(&fromp, &bp, (sp+slen), (bp+blen), &my_transcoding); (*my_transcoder->postprocessor)(&fromp, &bp, (sp+slen), (bp+blen), &my_transcoding);
if (fromp != sp+slen) { 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); buf = (unsigned char *)RSTRING_PTR(dest);
*bp = '\0'; *bp = '\0';

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

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