summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-09-21 20:58:26 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-09-21 20:58:26 +0000
commit96e278ca784659b109e086928cd69475023a99f1 (patch)
treedc68c377c5347844138e9aa22610ee815677a7a4
parentdb369aa32b7ca3b9b44ca3139ee6a2ace473fc07 (diff)
downloadruby-96e278ca784659b109e086928cd69475023a99f1.tar.gz
ruby-96e278ca784659b109e086928cd69475023a99f1.tar.xz
ruby-96e278ca784659b109e086928cd69475023a99f1.zip
* compile.c, cont.c, gc.c, insns.def, iseq.c, iseq.h, process.c,
thread.c, vm.c, vm_core.h, vm_dump.c, vm_eval.c, vm_insnhelper.c, vm_method.c, template/insns_info.inc.tmpl, tool/instruction.rb: fixed types. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@25030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--compile.c42
-rw-r--r--cont.c2
-rw-r--r--gc.c2
-rw-r--r--insns.def10
-rw-r--r--iseq.c34
-rw-r--r--iseq.h14
-rw-r--r--process.c34
-rw-r--r--template/insns_info.inc.tmpl20
-rw-r--r--thread.c12
-rwxr-xr-xtool/instruction.rb4
-rw-r--r--vm.c4
-rw-r--r--vm_core.h6
-rw-r--r--vm_dump.c23
-rw-r--r--vm_eval.c8
-rw-r--r--vm_insnhelper.c14
-rw-r--r--vm_method.c14
17 files changed, 132 insertions, 118 deletions
diff --git a/ChangeLog b/ChangeLog
index 9ec6d059b..c5892d8a8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Tue Sep 22 05:58:25 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * compile.c, cont.c, gc.c, insns.def, iseq.c, iseq.h, process.c,
+ thread.c, vm.c, vm_core.h, vm_dump.c, vm_eval.c,
+ vm_insnhelper.c, vm_method.c, template/insns_info.inc.tmpl,
+ tool/instruction.rb: fixed types.
+
Tue Sep 22 05:04:08 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/bigdecimal/lib/bigdecimal/{ludcmp,math}.rb: depend on
diff --git a/compile.c b/compile.c
index 0b4eb0d06..87edfeb2c 100644
--- a/compile.c
+++ b/compile.c
@@ -50,7 +50,7 @@ typedef struct iseq_label_data {
typedef struct iseq_insn_data {
LINK_ELEMENT link;
enum ruby_vminsn_type insn_id;
- long line_no;
+ int line_no;
int operand_size;
int sc_state;
VALUE *operands;
@@ -59,7 +59,7 @@ typedef struct iseq_insn_data {
typedef struct iseq_adjust_data {
LINK_ELEMENT link;
LABEL *label;
- long line_no;
+ int line_no;
} ADJUST;
struct ensure_range {
@@ -327,9 +327,9 @@ static int calc_sp_depth(int depth, INSN *iobj);
static void ADD_ELEM(ISEQ_ARG_DECLARE LINK_ANCHOR *anchor, LINK_ELEMENT *elem);
-static INSN *new_insn_body(rb_iseq_t *iseq, long line_no, int insn_id, int argc, ...);
+static INSN *new_insn_body(rb_iseq_t *iseq, int line_no, int insn_id, int argc, ...);
static LABEL *new_label_body(rb_iseq_t *iseq, long line);
-static ADJUST *new_adjust_body(rb_iseq_t *iseq, LABEL *label, long line);
+static ADJUST *new_adjust_body(rb_iseq_t *iseq, LABEL *label, int line);
static int iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *anchor, NODE * n, int);
static int iseq_setup(rb_iseq_t *iseq, LINK_ANCHOR *anchor);
@@ -849,7 +849,7 @@ new_label_body(rb_iseq_t *iseq, long line)
}
static ADJUST *
-new_adjust_body(rb_iseq_t *iseq, LABEL *label, long line)
+new_adjust_body(rb_iseq_t *iseq, LABEL *label, int line)
{
ADJUST *adjust = compile_data_alloc_adjust(iseq);
adjust->link.type = ISEQ_ELEMENT_ADJUST;
@@ -860,7 +860,7 @@ new_adjust_body(rb_iseq_t *iseq, LABEL *label, long line)
}
static INSN *
-new_insn_core(rb_iseq_t *iseq, long line_no,
+new_insn_core(rb_iseq_t *iseq, int line_no,
int insn_id, int argc, VALUE *argv)
{
INSN *iobj = compile_data_alloc_insn(iseq);
@@ -876,7 +876,7 @@ new_insn_core(rb_iseq_t *iseq, long line_no,
}
static INSN *
-new_insn_body(rb_iseq_t *iseq, long line_no, int insn_id, int argc, ...)
+new_insn_body(rb_iseq_t *iseq, int line_no, int insn_id, int argc, ...)
{
VALUE *operands = 0;
va_list argv;
@@ -1283,7 +1283,7 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *anchor)
{
lobj = (LABEL *)list;
lobj->position = pos;
- lobj->set = Qtrue;
+ lobj->set = TRUE;
break;
}
case ISEQ_ELEMENT_NONE:
@@ -1365,7 +1365,7 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *anchor)
{
/* label(destination position) */
lobj = (LABEL *)operands[j];
- if (lobj->set != Qtrue) {
+ if (!lobj->set) {
rb_compile_error(RSTRING_PTR(iseq->filename), iobj->line_no,
"unknown label");
}
@@ -1391,7 +1391,7 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *anchor)
VALUE lv = rb_ary_entry(lits, i+1);
lobj = (LABEL *)(lv & ~1);
- if (lobj->set != Qtrue) {
+ if (!lobj->set) {
rb_compile_error(RSTRING_PTR(iseq->filename), iobj->line_no,
"unknown label");
}
@@ -2655,13 +2655,13 @@ defined_expr(rb_iseq_t *iseq, LINK_ANCHOR *ret,
case NODE_VCALL:
case NODE_FCALL:
case NODE_ATTRASGN:{
- int self = Qtrue;
+ int self = TRUE;
switch (type) {
case NODE_ATTRASGN:
if (node->nd_recv == (NODE *)1) break;
case NODE_CALL:
- self = Qfalse;
+ self = FALSE;
break;
default:
/* through */;
@@ -3167,7 +3167,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
LABEL *prev_start_label = iseq->compile_data->start_label;
LABEL *prev_end_label = iseq->compile_data->end_label;
LABEL *prev_redo_label = iseq->compile_data->redo_label;
- VALUE prev_loopval_popped = iseq->compile_data->loopval_popped;
+ int prev_loopval_popped = iseq->compile_data->loopval_popped;
struct iseq_compile_data_ensure_node_stack enl;
@@ -4700,7 +4700,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
}
case NODE_DOT2:
case NODE_DOT3:{
- int flag = type == NODE_DOT2 ? INT2FIX(0) : INT2FIX(1);
+ VALUE flag = type == NODE_DOT2 ? INT2FIX(0) : INT2FIX(1);
COMPILE(ret, "min", (NODE *) node->nd_beg);
COMPILE(ret, "max", (NODE *) node->nd_end);
if (poped) {
@@ -4924,7 +4924,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
}
default:
rb_bug("iseq_compile_each: unknown node: %s", ruby_node_name(type));
- return Qnil;
+ return COMPILE_NG;
}
debug_node_end();
@@ -5175,8 +5175,8 @@ iseq_build_body(rb_iseq_t *iseq, LINK_ANCHOR *anchor,
{
/* TODO: body should be freezed */
VALUE *ptr = RARRAY_PTR(body);
- int len = RARRAY_LEN(body);
- int i, j;
+ long i, len = RARRAY_LEN(body);
+ int j;
int line_no = 0;
/*
* index -> LABEL *label
@@ -5199,7 +5199,7 @@ iseq_build_body(rb_iseq_t *iseq, LINK_ANCHOR *anchor,
}
else if (TYPE(obj) == T_ARRAY) {
VALUE *argv = 0;
- int argc = (int)RARRAY_LEN(obj) - 1;
+ int argc = RARRAY_LENINT(obj) - 1;
VALUE insn_id;
VALUE insn;
@@ -5286,7 +5286,7 @@ iseq_build_body(rb_iseq_t *iseq, LINK_ANCHOR *anchor,
}
ADD_ELEM(anchor,
(LINK_ELEMENT*)new_insn_core(iseq, line_no,
- insn_id, argc, argv));
+ (enum ruby_vminsn_type)insn_id, argc, argv));
}
else {
rb_raise(rb_eTypeError, "unexpected object for instruction");
@@ -5314,7 +5314,7 @@ rb_iseq_build_from_ary(rb_iseq_t *iseq, VALUE locals, VALUE args,
INIT_ANCHOR(anchor);
- iseq->local_table_size = RARRAY_LEN(locals);
+ iseq->local_table_size = RARRAY_LENINT(locals);
iseq->local_table = tbl = (ID *)ALLOC_N(ID *, iseq->local_table_size);
iseq->local_size = iseq->local_table_size + 1;
@@ -5343,7 +5343,7 @@ rb_iseq_build_from_ary(rb_iseq_t *iseq, VALUE locals, VALUE args,
iseq->arg_post_len = FIX2INT(arg_post_len);
iseq->arg_post_start = FIX2INT(arg_post_start);
iseq->arg_block = FIX2INT(arg_block);
- iseq->arg_opts = RARRAY_LEN(arg_opt_labels);
+ iseq->arg_opts = RARRAY_LENINT(arg_opt_labels);
iseq->arg_opt_table = (VALUE *)ALLOC_N(VALUE, iseq->arg_opts);
if (iseq->arg_block != -1) {
diff --git a/cont.c b/cont.c
index 083c023b4..9021333ba 100644
--- a/cont.c
+++ b/cont.c
@@ -41,7 +41,7 @@ typedef struct rb_context_struct {
#endif
rb_thread_t saved_thread;
rb_jmpbuf_t jmpbuf;
- int machine_stack_size;
+ size_t machine_stack_size;
} rb_context_t;
enum fiber_status {
diff --git a/gc.c b/gc.c
index a7f92806a..0effc4389 100644
--- a/gc.c
+++ b/gc.c
@@ -396,7 +396,7 @@ rb_objspace_free(rb_objspace_t *objspace)
}
}
if (heaps) {
- int i;
+ size_t i;
for (i = 0; i < heaps_used; ++i) {
free(heaps[i].membase);
}
diff --git a/insns.def b/insns.def
index 3b52527e2..8be204cea 100644
--- a/insns.def
+++ b/insns.def
@@ -583,7 +583,7 @@ newhash
(...)
(VALUE val) // inc += 1 - num;
{
- int i;
+ rb_num_t i;
val = rb_hash_new();
for (i = num; i > 0; i -= 2) {
@@ -982,8 +982,8 @@ send
const rb_method_entry_t *me;
VALUE recv, klass;
rb_block_t *blockptr = 0;
- rb_num_t num = caller_setup_args(th, GET_CFP(), op_flag, (int)op_argc,
- (rb_iseq_t *)blockiseq, &blockptr);
+ int num = caller_setup_args(th, GET_CFP(), op_flag, (int)op_argc,
+ (rb_iseq_t *)blockiseq, &blockptr);
rb_num_t flag = op_flag;
ID id = op_id;
@@ -1008,8 +1008,8 @@ invokesuper
(VALUE val) // inc += - (int)(op_argc + ((op_flag & VM_CALL_ARGS_BLOCKARG_BIT) ? 1 : 0));
{
rb_block_t *blockptr = !(op_flag & VM_CALL_ARGS_BLOCKARG_BIT) ? GET_BLOCK_PTR() : 0;
- rb_num_t num = caller_setup_args(th, GET_CFP(), op_flag,
- (int)op_argc, blockiseq, &blockptr);
+ int num = caller_setup_args(th, GET_CFP(), op_flag,
+ (int)op_argc, blockiseq, &blockptr);
VALUE recv, klass;
ID id;
VALUE flag = VM_CALL_SUPER_BIT | VM_CALL_FCALL_BIT;
diff --git a/iseq.c b/iseq.c
index 680ddd1a0..360f283a7 100644
--- a/iseq.c
+++ b/iseq.c
@@ -710,8 +710,8 @@ find_prev_line_no(rb_iseq_t *iseqdat, unsigned long pos)
static VALUE
insn_operand_intern(rb_iseq_t *iseq,
- int insn, int op_no, VALUE op,
- int len, int pos, VALUE *pnop, VALUE child)
+ VALUE insn, int op_no, VALUE op,
+ int len, size_t pos, VALUE *pnop, VALUE child)
{
const char *types = insn_op_types(insn);
char type = types[op_no];
@@ -729,7 +729,7 @@ insn_operand_intern(rb_iseq_t *iseq,
case TS_LINDEX:
{
rb_iseq_t *ip = iseq->local_iseq;
- int lidx = ip->local_size - op;
+ int lidx = ip->local_size - (int)op;
const char *name = rb_id2name(ip->local_table[lidx]);
if (name) {
@@ -743,7 +743,7 @@ insn_operand_intern(rb_iseq_t *iseq,
case TS_DINDEX:{
if (insn == BIN(getdynamic) || insn == BIN(setdynamic)) {
rb_iseq_t *ip = iseq;
- int level = *pnop, i;
+ VALUE level = *pnop, i;
const char *name;
for (i = 0; i < level; i++) {
ip = ip->parent_iseq;
@@ -814,11 +814,11 @@ insn_operand_intern(rb_iseq_t *iseq,
* Disassemble a instruction
* Iseq -> Iseq inspect object
*/
-VALUE
-rb_iseq_disasm_insn(VALUE ret, VALUE *iseq, int pos,
+int
+rb_iseq_disasm_insn(VALUE ret, VALUE *iseq, size_t pos,
rb_iseq_t *iseqdat, VALUE child)
{
- int insn = iseq[pos];
+ VALUE insn = iseq[pos];
int len = insn_len(insn);
int j;
const char *types = insn_op_types(insn);
@@ -827,10 +827,10 @@ rb_iseq_disasm_insn(VALUE ret, VALUE *iseq, int pos,
insn_name_buff = insn_name(insn);
if (1) {
- rb_str_catf(str, "%04d %-16s ", pos, insn_name_buff);
+ rb_str_catf(str, "%04"PRIdSIZE" %-16s ", pos, insn_name_buff);
}
else {
- rb_str_catf(str, "%04d %-16.*s ", pos,
+ rb_str_catf(str, "%04"PRIdSIZE" %-16.*s ", pos,
(int)strcspn(insn_name_buff, "_"), insn_name_buff);
}
@@ -907,6 +907,7 @@ rb_iseq_disasm(VALUE self)
int i;
long l;
ID *tbl;
+ size_t n;
enum {header_minlen = 72};
rb_secure(1);
@@ -986,8 +987,8 @@ rb_iseq_disasm(VALUE self)
}
/* show each line */
- for (i = 0; (size_t)i < size;) {
- i += rb_iseq_disasm_insn(str, iseq, i, iseqdat, child);
+ for (n = 0; n < size;) {
+ n += rb_iseq_disasm_insn(str, iseq, n, iseqdat, child);
}
for (i = 0; i < RARRAY_LEN(child); i++) {
@@ -1032,12 +1033,12 @@ ruby_node_name(int node)
sym_##name = ID2SYM(rb_intern(#name))
static VALUE
-register_label(struct st_table *table, int idx)
+register_label(struct st_table *table, unsigned long idx)
{
VALUE sym;
char buff[8 + (sizeof(idx) * CHAR_BIT * 32 / 100)];
- snprintf(buff, sizeof(buff), "label_%u", idx);
+ snprintf(buff, sizeof(buff), "label_%lu", idx);
sym = ID2SYM(rb_intern(buff));
st_insert(table, idx, sym);
return sym;
@@ -1071,7 +1072,8 @@ cdhash_each(VALUE key, VALUE value, VALUE ary)
static VALUE
iseq_data_to_ary(rb_iseq_t *iseq)
{
- int i, pos, line = 0;
+ long i, pos;
+ int line = 0;
VALUE *seq;
VALUE val = rb_ary_new();
@@ -1183,7 +1185,7 @@ iseq_data_to_ary(rb_iseq_t *iseq)
for (j=0; j<len-1; j++, seq++) {
switch (insn_op_type(insn, j)) {
case TS_OFFSET: {
- unsigned int idx = nseq - iseq->iseq + *seq;
+ unsigned long idx = nseq - iseq->iseq + *seq;
rb_ary_push(ary, register_label(labels_table, idx));
break;
}
@@ -1229,7 +1231,7 @@ iseq_data_to_ary(rb_iseq_t *iseq)
for (i=0; i<RARRAY_LEN(val); i+=2) {
VALUE pos = FIX2INT(rb_ary_entry(val, i+1));
- unsigned int idx = nseq - iseq->iseq + pos;
+ unsigned long idx = nseq - iseq->iseq + pos;
rb_ary_store(val, i+1,
register_label(labels_table, idx));
diff --git a/iseq.h b/iseq.h
index 981b1fca0..27271488c 100644
--- a/iseq.h
+++ b/iseq.h
@@ -32,12 +32,12 @@ struct st_table *ruby_insn_make_insn_table(void);
#define ISEQ_TYPE_MAIN INT2FIX(8)
#define ISEQ_TYPE_DEFINED_GUARD INT2FIX(9)
-#define CATCH_TYPE_RESCUE INT2FIX(1)
-#define CATCH_TYPE_ENSURE INT2FIX(2)
-#define CATCH_TYPE_RETRY INT2FIX(3)
-#define CATCH_TYPE_BREAK INT2FIX(4)
-#define CATCH_TYPE_REDO INT2FIX(5)
-#define CATCH_TYPE_NEXT INT2FIX(6)
+#define CATCH_TYPE_RESCUE ((int)INT2FIX(1))
+#define CATCH_TYPE_ENSURE ((int)INT2FIX(2))
+#define CATCH_TYPE_RETRY ((int)INT2FIX(3))
+#define CATCH_TYPE_BREAK ((int)INT2FIX(4))
+#define CATCH_TYPE_REDO ((int)INT2FIX(5))
+#define CATCH_TYPE_NEXT ((int)INT2FIX(6))
struct iseq_insn_info_entry {
unsigned short position;
@@ -74,10 +74,10 @@ struct iseq_compile_data {
struct iseq_label_data *end_label;
struct iseq_label_data *redo_label;
VALUE current_block;
- VALUE loopval_popped; /* used by NODE_BREAK */
VALUE ensure_node;
VALUE for_iseq;
struct iseq_compile_data_ensure_node_stack *ensure_node_stack;
+ int loopval_popped; /* used by NODE_BREAK */
int cached_const;
struct iseq_compile_data_storage *storage_head;
struct iseq_compile_data_storage *storage_current;
diff --git a/process.c b/process.c
index 8e8694e11..ca715a177 100644
--- a/process.c
+++ b/process.c
@@ -1769,7 +1769,7 @@ rb_f_exec(int argc, VALUE *argv)
#define CHILD_ERRMSG_BUFLEN 80
char errmsg[CHILD_ERRMSG_BUFLEN] = { '\0' };
- rb_exec_arg_init(argc, argv, Qtrue, &earg);
+ rb_exec_arg_init(argc, argv, TRUE, &earg);
if (NIL_P(rb_ary_entry(earg.options, EXEC_OPTION_CLOSE_OTHERS)))
rb_exec_arg_addopt(&earg, ID2SYM(rb_intern("close_others")), Qfalse);
rb_exec_arg_fixup(&earg);
@@ -1924,7 +1924,7 @@ run_exec_dup2(VALUE ary, VALUE save, char *errmsg, size_t errmsg_buflen)
struct fd_pair {
int oldfd;
int newfd;
- int older_index;
+ long older_index;
int num_newer;
} *pairs = 0;
@@ -1969,7 +1969,7 @@ run_exec_dup2(VALUE ary, VALUE save, char *errmsg, size_t errmsg_buflen)
/* non-cyclic redirection: O(n) */
for (i = 0; i < n; i++) {
- int j = i;
+ long j = i;
while (j != -1 && pairs[j].oldfd != -1 && pairs[j].num_newer == 0) {
if (save_redirect_fd(pairs[j].newfd, save, errmsg, errmsg_buflen) < 0)
goto fail;
@@ -1987,7 +1987,7 @@ run_exec_dup2(VALUE ary, VALUE save, char *errmsg, size_t errmsg_buflen)
/* cyclic redirection: O(n) */
for (i = 0; i < n; i++) {
- int j;
+ long j;
if (pairs[i].oldfd == -1)
continue;
if (pairs[i].oldfd == pairs[i].newfd) { /* self cycle */
@@ -2812,7 +2812,7 @@ rb_syswait(rb_pid_t pid)
#endif
RETSIGTYPE (*ifunc)(int) = 0;
int status;
- int i, hooked = Qfalse;
+ int i, hooked = FALSE;
if (!overriding) {
#ifdef SIGHUP
@@ -2822,8 +2822,8 @@ rb_syswait(rb_pid_t pid)
qfunc = signal(SIGQUIT, SIG_IGN);
#endif
ifunc = signal(SIGINT, SIG_IGN);
- overriding = Qtrue;
- hooked = Qtrue;
+ overriding = TRUE;
+ hooked = TRUE;
}
do {
@@ -2838,7 +2838,7 @@ rb_syswait(rb_pid_t pid)
signal(SIGQUIT, qfunc);
#endif
signal(SIGINT, ifunc);
- overriding = Qfalse;
+ overriding = FALSE;
}
}
@@ -2856,7 +2856,7 @@ rb_spawn_internal(int argc, VALUE *argv, int default_close_others,
struct rb_exec_arg sarg;
#endif
- prog = rb_exec_arg_init(argc, argv, Qtrue, &earg);
+ prog = rb_exec_arg_init(argc, argv, TRUE, &earg);
if (NIL_P(rb_ary_entry(earg.options, EXEC_OPTION_CLOSE_OTHERS))) {
VALUE v = default_close_others ? Qtrue : Qfalse;
rb_exec_arg_addopt(&earg, ID2SYM(rb_intern("close_others")), v);
@@ -2899,13 +2899,13 @@ rb_spawn_internal(int argc, VALUE *argv, int default_close_others,
rb_pid_t
rb_spawn_err(int argc, VALUE *argv, char *errmsg, size_t errmsg_buflen)
{
- return rb_spawn_internal(argc, argv, Qtrue, errmsg, errmsg_buflen);
+ return rb_spawn_internal(argc, argv, TRUE, errmsg, errmsg_buflen);
}
rb_pid_t
rb_spawn(int argc, VALUE *argv)
{
- return rb_spawn_internal(argc, argv, Qtrue, NULL, 0);
+ return rb_spawn_internal(argc, argv, TRUE, NULL, 0);
}
/*
@@ -2954,7 +2954,7 @@ rb_f_system(int argc, VALUE *argv)
chfunc = signal(SIGCHLD, SIG_DFL);
#endif
- pid = rb_spawn_internal(argc, argv, Qfalse, NULL, 0);
+ pid = rb_spawn_internal(argc, argv, FALSE, NULL, 0);
#if defined(HAVE_FORK) || defined(HAVE_SPAWNV)
if (pid > 0) {
rb_syswait(pid);
@@ -4348,7 +4348,7 @@ proc_setgid(VALUE obj, VALUE id)
#endif
-static size_t maxgroups = 32;
+static int maxgroups = 32;
#ifdef HAVE_GETGROUPS
@@ -4367,13 +4367,13 @@ static VALUE
proc_getgroups(VALUE obj)
{
VALUE ary;
- size_t i, ngroups;
+ int i, ngroups;
rb_gid_t *groups;
groups = ALLOCA_N(rb_gid_t, maxgroups);
ngroups = getgroups(maxgroups, groups);
- if (ngroups == (size_t)-1)
+ if (ngroups == -1)
rb_sys_fail(0);
ary = rb_ary_new();
@@ -4438,7 +4438,7 @@ proc_setgroups(VALUE obj, VALUE ary)
}
}
- if (setgroups(ngroups, groups) == -1)
+ if (setgroups((int)ngroups, groups) == -1) /* ngroups <= maxgroups */
rb_sys_fail(0);
return proc_getgroups(obj);
@@ -4507,7 +4507,7 @@ proc_getmaxgroups(VALUE obj)
static VALUE
proc_setmaxgroups(VALUE obj, VALUE val)
{
- size_t ngroups = FIX2INT(val);
+ int ngroups = FIX2UINT(val);
if (ngroups > 4096)
ngroups = 4096;
diff --git a/template/insns_info.inc.tmpl b/template/insns_info.inc.tmpl
index 1093e10d0..110e6b518 100644
--- a/template/insns_info.inc.tmpl
+++ b/template/insns_info.inc.tmpl
@@ -49,29 +49,29 @@ insn_stack_increase(int depth, int insn, VALUE *opes)
/* some utilities */
static int
-insn_len(int insn)
+insn_len(VALUE insn)
{
- return insn_len_info[insn];
+ return insn_len_info[(int)insn];
}
static const char *
-insn_name(int insn)
+insn_name(VALUE insn)
{
- return insn_name_info[insn];
+ return insn_name_info[(int)insn];
}
static const char *
-insn_op_types(int insn)
+insn_op_types(VALUE insn)
{
- return insn_operand_info[insn];
+ return insn_operand_info[(int)insn];
}
static int
-insn_op_type(int insn, int pos)
+insn_op_type(VALUE insn, long pos)
{
int len = insn_len(insn) - 1;
if(pos < len){
- return insn_operand_info[insn][pos];
+ return insn_operand_info[(int)insn][pos];
}
else{
return 0;
@@ -80,9 +80,9 @@ insn_op_type(int insn, int pos)
#ifdef USE_INSN_RET_NUM
static int
-insn_ret_num(int insn)
+insn_ret_num(VALUE insn)
{
- return insn_stack_push_num_info[insn];
+ return insn_stack_push_num_info[(int)insn];
}
#endif
diff --git a/thread.c b/thread.c
index caa991337..adaaa8ebe 100644
--- a/thread.c
+++ b/thread.c
@@ -2528,7 +2528,7 @@ int
rb_thread_fd_writable(int fd)
{
rb_thread_wait_fd_rw(fd, 0);
- return Qtrue;
+ return TRUE;
}
int
@@ -3537,7 +3537,7 @@ exec_recursive_i(VALUE tag, struct exec_recursive_params *p)
recursive_push(p->list, p->objid, p->pairid);
PUSH_TAG();
if ((state = EXEC_TAG()) == 0) {
- result = (*p->func) (p->obj, p->arg, Qfalse);
+ result = (*p->func)(p->obj, p->arg, FALSE);
}
POP_TAG();
recursive_pop(p->list, p->objid, p->pairid);
@@ -3570,7 +3570,7 @@ exec_recursive(VALUE (*func) (VALUE, VALUE, int), VALUE obj, VALUE pairid, VALUE
if (outer && !outermost) {
rb_throw_obj(p.list, p.list);
}
- return (*func) (obj, arg, Qtrue);
+ return (*func)(obj, arg, TRUE);
}
else {
VALUE result = Qundef;
@@ -3584,7 +3584,7 @@ exec_recursive(VALUE (*func) (VALUE, VALUE, int), VALUE obj, VALUE pairid, VALUE
result = rb_catch_obj(p.list, exec_recursive_i, (VALUE)&p);
recursive_pop(p.list, ID2SYM(recursive_key), 0);
if (result == p.list) {
- result = (*func) (obj, arg, Qtrue);
+ result = (*func)(obj, arg, TRUE);
}
}
else {
@@ -4004,7 +4004,7 @@ call_trace_func(rb_event_flag_t event, VALUE proc, VALUE self, ID id, VALUE klas
args.self = self;
args.id = id;
args.klass = klass;
- ruby_suppress_tracing(call_trace_proc, (VALUE)&args, Qfalse);
+ ruby_suppress_tracing(call_trace_proc, (VALUE)&args, FALSE);
}
VALUE
@@ -4170,7 +4170,7 @@ ruby_native_thread_p(void)
{
rb_thread_t *th = ruby_thread_from_native();
- return th ? Qtrue : Qfalse;
+ return th != 0;
}
static int
diff --git a/tool/instruction.rb b/tool/instruction.rb
index 653be0d4a..45d57c189 100755
--- a/tool/instruction.rb
+++ b/tool/instruction.rb
@@ -63,12 +63,12 @@ class RubyVM
rets.any?{|t, v| v == '...'})
# user definision
raise "no sp increase definition" if @sp_inc.nil?
- ret = "rb_num_t inc = 0;\n"
+ ret = "int inc = 0;\n"
@opes.each_with_index{|(t, v), i|
if t == 'rb_num_t' && ((re = /\b#{v}\b/n) =~ @sp_inc ||
@defopes.any?{|t, val| re =~ val})
- ret << " #{t} #{v} = FIX2INT(opes[#{i}]);\n"
+ ret << " int #{v} = FIX2INT(opes[#{i}]);\n"
end
}
@defopes.each_with_index{|((t, var), val), i|
diff --git a/vm.c b/vm.c
index 5866f63a1..066fe6f0f 100644
--- a/vm.c
+++ b/vm.c
@@ -729,7 +729,7 @@ vm_backtrace_each(rb_thread_t *th, int lev, rb_backtrace_iter_func *iter, void *
cfp -= 2;
while (lev-- >= 0) {
if (++limit_cfp >= cfp) {
- return Qfalse;
+ return FALSE;
}
}
limit_cfp = RUBY_VM_NEXT_CONTROL_FRAME(limit_cfp);
@@ -750,7 +750,7 @@ vm_backtrace_each(rb_thread_t *th, int lev, rb_backtrace_iter_func *iter, void *
}
cfp = RUBY_VM_NEXT_CONTROL_FRAME(cfp);
}
- return Qtrue;
+ return TRUE;
}
static int
diff --git a/vm_core.h b/vm_core.h
index 9392ab5a1..52105ec9e 100644
--- a/vm_core.h
+++ b/vm_core.h
@@ -125,7 +125,7 @@ typedef struct rb_compile_option_struct {
} rb_compile_option_t;
struct iseq_inline_cache_entry {
- long ic_vmstat;
+ VALUE ic_vmstat;
VALUE ic_class;
union {
VALUE value;
@@ -471,7 +471,7 @@ VALUE rb_iseq_new_with_bopt(NODE*, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE);
VALUE rb_iseq_new_with_opt(NODE*, VALUE, VALUE, VALUE, VALUE, VALUE, const rb_compile_option_t*);
VALUE rb_iseq_compile(VALUE src, VALUE file, VALUE line);
VALUE rb_iseq_disasm(VALUE self);
-VALUE rb_iseq_disasm_insn(VALUE str, VALUE *iseqval, int pos, rb_iseq_t *iseq, VALUE child);
+int rb_iseq_disasm_insn(VALUE str, VALUE *iseqval, size_t pos, rb_iseq_t *iseq, VALUE child);
const char *ruby_node_name(int node);
int rb_iseq_first_lineno(rb_iseq_t *iseq);
@@ -616,7 +616,7 @@ void *rb_thread_call_with_gvl(void *(*func)(void *), void *data1);
int ruby_thread_has_gvl_p(void);
VALUE rb_make_backtrace(void);
typedef int rb_backtrace_iter_func(void *, VALUE, int, VALUE);
-VALUE rb_backtrace_each(rb_backtrace_iter_func *iter, void *arg);
+int rb_backtrace_each(rb_backtrace_iter_func *iter, void *arg);
rb_control_frame_t *rb_vm_get_ruby_level_next_cfp(rb_thread_t *th, rb_control_frame_t *cfp);
NOINLINE(void rb_gc_save_machine_context(rb_thread_t *));
diff --git a/vm_dump.c b/vm_dump.c
index 3addd9ee3..c9c621fe0 100644
--- a/vm_dump.c
+++ b/vm_dump.c
@@ -20,11 +20,12 @@
static void
control_frame_dump(rb_thread_t *th, rb_control_frame_t *cfp)
{
- int pc = -1, bp = -1, line = 0;
+ ptrdiff_t pc = -1, bp = -1;
ptrdiff_t lfp = cfp->lfp - th->stack;
ptrdiff_t dfp = cfp->dfp - th->stack;
char lfp_in_heap = ' ', dfp_in_heap = ' ';
char posbuf[MAX_POSBUF+1];
+ int line = 0;
int nopos = 0;
const char *magic, *iseq_name = "-", *selfstr = "-", *biseq_name = "-";
@@ -124,9 +125,9 @@ control_frame_dump(rb_thread_t *th, rb_control_frame_t *cfp)
fprintf(stderr, "p:---- ");
}
else {
- fprintf(stderr, "p:%04d ", pc);
+ fprintf(stderr, "p:%04"PRIdPTRDIFF" ", pc);
}
- fprintf(stderr, "s:%04"PRIdPTRDIFF" b:%04d ", (cfp->sp - th->stack), bp);
+ fprintf(stderr, "s:%04"PRIdPTRDIFF" b:%04"PRIdPTRDIFF" ", (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);
@@ -329,10 +330,10 @@ void
rb_vmdebug_debug_print_register(rb_thread_t *th)
{
rb_control_frame_t *cfp = th->cfp;
- int pc = -1;
- int lfp = cfp->lfp - th->stack;
- int dfp = cfp->dfp - th->stack;
- int cfpi;
+ ptrdiff_t pc = -1;
+ ptrdiff_t lfp = cfp->lfp - th->stack;
+ ptrdiff_t dfp = cfp->dfp - th->stack;
+ ptrdiff_t cfpi;
if (RUBY_VM_NORMAL_ISEQ_P(cfp->iseq)) {
pc = cfp->pc - cfp->iseq->iseq_encoded;
@@ -344,7 +345,7 @@ rb_vmdebug_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] %04"PRIdPTRDIFF", [LFP] %04d, [DFP] %04d, [CFP] %04d\n",
+ fprintf(stderr, " [PC] %04"PRIdPTRDIFF", [SP] %04"PRIdPTRDIFF", [LFP] %04"PRIdPTRDIFF", [DFP] %04"PRIdPTRDIFF", [CFP] %04"PRIdPTRDIFF"\n",
pc, (cfp->sp - th->stack), lfp, dfp, cfpi);
}
@@ -363,10 +364,12 @@ rb_vmdebug_debug_print_pre(rb_thread_t *th, rb_control_frame_t *cfp)
if (iseq != 0 && VM_FRAME_TYPE(cfp) != VM_FRAME_MAGIC_FINISH) {
VALUE *seq = iseq->iseq;
- int pc = cfp->pc - iseq->iseq_encoded;
+ ptrdiff_t pc = cfp->pc - iseq->iseq_encoded;
printf("%3"PRIdPTRDIFF" ", VM_CFP_CNT(th, cfp));
- rb_iseq_disasm_insn(0, seq, pc, iseq, 0);
+ if (pc >= 0) {
+ rb_iseq_disasm_insn(0, seq, (size_t)pc, iseq, 0);
+ }
}
#if VMDEBUG > 3
diff --git a/vm_eval.c b/vm_eval.c
index c27c2a3b0..befe33adc 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -1265,9 +1265,11 @@ rb_throw(const char *tag, VALUE val)
}
static VALUE
-catch_i(VALUE tag, VALUE data) {
+catch_i(VALUE tag, VALUE data)
+{
return rb_yield_0(1, &tag);
}
+
/*
* call-seq:
* catch([arg]) {|tag| block } => obj
@@ -1403,7 +1405,7 @@ print_backtrace(void *arg, VALUE file, int line, VALUE method)
{
fprintf((FILE *)arg, "\tfrom %s:%d:in `%s'\n",
RSTRING_PTR(file), line, RSTRING_PTR(method));
- return Qfalse;
+ return FALSE;
}
void
@@ -1437,7 +1439,7 @@ rb_thread_backtrace(VALUE thval)
return vm_backtrace(th, 0);
}
-VALUE
+int
rb_backtrace_each(rb_backtrace_iter_func *iter, void *arg)
{
return vm_backtrace_each(GET_THREAD(), -1, iter, arg);
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 3020756d6..8fc7c1dcd 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -778,7 +778,7 @@ vm_yield_setup_block_args(rb_thread_t *th, const rb_iseq_t * iseq,
int argc = orig_argc;
const int m = iseq->argc;
VALUE ary, arg0;
- rb_num_t opt_pc = 0;
+ int opt_pc = 0;
th->mark_stack_len = argc;
@@ -1024,7 +1024,7 @@ vm_getspecial(rb_thread_t *th, VALUE *lfp, VALUE key, rb_num_t type)
}
}
else {
- val = rb_reg_nth_match(type >> 1, backref);
+ val = rb_reg_nth_match((int)(type >> 1), backref);
}
}
return val;
@@ -1212,7 +1212,7 @@ vm_getivar(VALUE obj, ID id, IC ic)
if (iv_index_tbl) {
if (st_lookup(iv_index_tbl, id, &index)) {
- if (index < len) {
+ if ((long)index < len) {
val = ptr[index];
}
ic->ic_class = klass;
@@ -1519,7 +1519,7 @@ vm_expandarray(rb_control_frame_t *cfp, VALUE ary, rb_num_t num, int flag)
rb_num_t space_size = num + is_splat;
VALUE *base = cfp->sp, *ptr;
volatile VALUE tmp_ary;
- long len;
+ rb_num_t len;
if (TYPE(ary) != T_ARRAY) {
ary = rb_ary_to_ary(ary);
@@ -1529,11 +1529,11 @@ vm_expandarray(rb_control_frame_t *cfp, VALUE ary, rb_num_t num, int flag)
tmp_ary = ary;
ptr = RARRAY_PTR(ary);
- len = RARRAY_LEN(ary);
+ len = (rb_num_t)RARRAY_LEN(ary);
if (flag & 0x02) {
/* post: ..., nil ,ary[-1], ..., ary[0..-num] # top */
- long i = 0, j;
+ rb_num_t i = 0, j;
if (len < num) {
for (i=0; i<num-len; i++) {
@@ -1550,7 +1550,7 @@ vm_expandarray(rb_control_frame_t *cfp, VALUE ary, rb_num_t num, int flag)
}
else {
/* normal: ary[num..-1], ary[num-2], ary[num-3], ..., ary[0] # top */
- int i;
+ rb_num_t i;
VALUE *bptr = &base[space_size - 1];
for (i=0; i<num; i++) {
diff --git a/vm_method.c b/vm_method.c
index a2558bc6e..b64dbcc68 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -455,7 +455,7 @@ rb_enable_super(VALUE klass, const char *name)
}
static void
-rb_export_method(VALUE klass, ID name, ID noex)
+rb_export_method(VALUE klass, ID name, rb_method_flag_t noex)
{
rb_method_entry_t *me;
@@ -491,14 +491,14 @@ rb_method_boundp(VALUE klass, ID id, int ex)
if (me != 0) {
if (ex && (me->flag & NOEX_PRIVATE)) {
- return Qfalse;
+ return FALSE;
}
if (!me->def || me->def->type == VM_METHOD_TYPE_NOTIMPLEMENTED) {
- return Qfalse;
+ return FALSE;
}
- return Qtrue;
+ return TRUE;
}
- return Qfalse;
+ return FALSE;
}
void
@@ -879,7 +879,7 @@ secure_visibility(VALUE self)
}
static void
-set_method_visibility(VALUE self, int argc, VALUE *argv, ID ex)
+set_method_visibility(VALUE self, int argc, VALUE *argv, rb_method_flag_t ex)
{
int i;
secure_visibility(self);
@@ -1135,7 +1135,7 @@ rb_obj_respond_to(VALUE obj, ID id, int priv)
int
rb_respond_to(VALUE obj, ID id)
{
- return rb_obj_respond_to(obj, id, Qfalse);
+ return rb_obj_respond_to(obj, id, FALSE);
}
/*