From 28a2105a554d875cc5c6fc2b5ac20e0e6c04966e Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 8 Aug 2023 00:32:45 +0900 Subject: [PATCH] Prefer `enum ruby_tag_type` over `int` --- eval.c | 12 ++++++------ eval_intern.h | 4 ++-- ractor.c | 4 ++-- thread.c | 2 +- vm.c | 4 ++-- vm_trace.c | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/eval.c b/eval.c index 38f38de61dd954..858890b83fa210 100644 --- a/eval.c +++ b/eval.c @@ -463,7 +463,7 @@ rb_class_modify_check(VALUE klass) } } -NORETURN(static void rb_longjmp(rb_execution_context_t *, int, volatile VALUE, VALUE)); +NORETURN(static void rb_longjmp(rb_execution_context_t *, enum ruby_tag_type, volatile VALUE, VALUE)); static VALUE get_errinfo(void); #define get_ec_errinfo(ec) rb_ec_get_errinfo(ec) @@ -541,7 +541,7 @@ exc_setup_message(const rb_execution_context_t *ec, VALUE mesg, VALUE *cause) } static void -setup_exception(rb_execution_context_t *ec, int tag, volatile VALUE mesg, VALUE cause) +setup_exception(rb_execution_context_t *ec, enum ruby_tag_type tag, volatile VALUE mesg, VALUE cause) { VALUE e; int line; @@ -645,7 +645,7 @@ rb_ec_setup_exception(const rb_execution_context_t *ec, VALUE mesg, VALUE cause) } static void -rb_longjmp(rb_execution_context_t *ec, int tag, volatile VALUE mesg, VALUE cause) +rb_longjmp(rb_execution_context_t *ec, enum ruby_tag_type tag, volatile VALUE mesg, VALUE cause) { mesg = exc_setup_message(ec, mesg, &cause); setup_exception(ec, tag, mesg, cause); @@ -655,10 +655,10 @@ rb_longjmp(rb_execution_context_t *ec, int tag, volatile VALUE mesg, VALUE cause static VALUE make_exception(int argc, const VALUE *argv, int isstr); -NORETURN(static void rb_exc_exception(VALUE mesg, int tag, VALUE cause)); +NORETURN(static void rb_exc_exception(VALUE mesg, enum ruby_tag_type tag, VALUE cause)); static void -rb_exc_exception(VALUE mesg, int tag, VALUE cause) +rb_exc_exception(VALUE mesg, enum ruby_tag_type tag, VALUE cause) { if (!NIL_P(mesg)) { mesg = make_exception(1, &mesg, FALSE); @@ -985,7 +985,7 @@ rb_protect(VALUE (* proc) (VALUE), VALUE data, int *pstate) VALUE rb_ensure(VALUE (*b_proc)(VALUE), VALUE data1, VALUE (*e_proc)(VALUE), VALUE data2) { - int state; + enum ruby_tag_type state; volatile VALUE result = Qnil; VALUE errinfo; rb_execution_context_t * volatile ec = GET_EC(); diff --git a/eval_intern.h b/eval_intern.h index aac72e172c683b..fa02f229122d54 100644 --- a/eval_intern.h +++ b/eval_intern.h @@ -290,9 +290,9 @@ NORETURN(void rb_print_undef(VALUE, ID, rb_method_visibility_t)); NORETURN(void rb_print_undef_str(VALUE, VALUE)); NORETURN(void rb_print_inaccessible(VALUE, ID, rb_method_visibility_t)); NORETURN(void rb_vm_localjump_error(const char *,VALUE, int)); -NORETURN(void rb_vm_jump_tag_but_local_jump(int)); +NORETURN(void rb_vm_jump_tag_but_local_jump(enum ruby_tag_type)); -VALUE rb_vm_make_jump_tag_but_local_jump(int state, VALUE val); +VALUE rb_vm_make_jump_tag_but_local_jump(enum ruby_tag_type state, VALUE val); rb_cref_t *rb_vm_cref(void); rb_cref_t *rb_vm_cref_replace_with_duplicated_cref(void); VALUE rb_vm_call_cfunc(VALUE recv, VALUE (*func)(VALUE), VALUE arg, VALUE block_handler, VALUE filename); diff --git a/ractor.c b/ractor.c index fbdca947af7efd..4eee3cc73115d9 100644 --- a/ractor.c +++ b/ractor.c @@ -590,7 +590,7 @@ ractor_check_ints(rb_execution_context_t *ec, rb_ractor_t *cr, ractor_sleep_clea RACTOR_UNLOCK(cr); { if (cf_func) { - int state; + enum ruby_tag_type state; EC_PUSH_TAG(ec); if ((state = EC_EXEC_TAG()) == TAG_NONE) { rb_thread_check_ints(); @@ -1319,7 +1319,7 @@ ractor_try_yield(rb_execution_context_t *ec, rb_ractor_t *cr, struct rb_ractor_q type = basket_type_will; } else { - int state; + enum ruby_tag_type state; // begin EC_PUSH_TAG(ec); diff --git a/thread.c b/thread.c index 1ef4849c221748..e6363fc7cef4ef 100644 --- a/thread.c +++ b/thread.c @@ -4364,7 +4364,7 @@ rb_thread_wait_for_single_fd(int fd, int events, struct timeval *timeout) int result = 0; nfds_t nfds; struct waiting_fd wfd; - int state; + enum ruby_tag_type state; volatile int lerrno; rb_execution_context_t *ec = GET_EC(); diff --git a/vm.c b/vm.c index 0f7d986d4eb75b..82bf1ac658d3f3 100644 --- a/vm.c +++ b/vm.c @@ -1981,7 +1981,7 @@ rb_vm_localjump_error(const char *mesg, VALUE value, int reason) } VALUE -rb_vm_make_jump_tag_but_local_jump(int state, VALUE val) +rb_vm_make_jump_tag_but_local_jump(enum ruby_tag_type state, VALUE val) { const char *mesg; @@ -2013,7 +2013,7 @@ rb_vm_make_jump_tag_but_local_jump(int state, VALUE val) } void -rb_vm_jump_tag_but_local_jump(int state) +rb_vm_jump_tag_but_local_jump(enum ruby_tag_type state) { VALUE exc = rb_vm_make_jump_tag_but_local_jump(state, Qundef); if (!NIL_P(exc)) rb_exc_raise(exc); diff --git a/vm_trace.c b/vm_trace.c index 037050de187013..0f99e34e7bb8cb 100644 --- a/vm_trace.c +++ b/vm_trace.c @@ -435,7 +435,7 @@ rb_exec_event_hooks(rb_trace_arg_t *trace_arg, rb_hook_list_t *hooks, int pop_p) trace_arg->self != rb_mRubyVMFrozenCore /* skip special methods. TODO: remove it. */) { const VALUE errinfo = ec->errinfo; const VALUE old_recursive = ec->local_storage_recursive_hash; - int state = 0; + enum ruby_tag_type state = 0; /* setup */ ec->local_storage_recursive_hash = ec->local_storage_recursive_hash_for_trace;