diff options
author | k0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-01-10 14:31:18 +0000 |
---|---|---|
committer | k0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-01-10 14:31:18 +0000 |
commit | 56bf732aaf5a109964b0297b2158372de2e3ae97 (patch) | |
tree | 464da0736c6857af72c7a0f7c352d5bd35ffbec4 /mjit.c | |
parent | efd99b533177d429dbc64ababfe342ebbd3f6502 (diff) |
mjit.c: use boolean type for boolean variables
and functions to clarify the intention and make sure it's not used in a
surprising way (like using 2, 3, ... other than 0, 1 even while it seems
to be a boolean).
This is a retry of r66775. It included some typos...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66778 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'mjit.c')
-rw-r--r-- | mjit.c | 52 |
1 files changed, 26 insertions, 26 deletions
@@ -48,7 +48,7 @@ mjit_copy_job_handler(void *data) memcpy(job->is_entries, body->is_entries, sizeof(union iseq_inline_storage_entry) * body->is_size); } - job->finish_p = TRUE; + job->finish_p = true; rb_native_cond_broadcast(&mjit_worker_wakeup); CRITICAL_SECTION_FINISH(3, "in mjit_copy_job_handler"); } @@ -88,7 +88,7 @@ mjit_gc_start_hook(void) rb_native_cond_wait(&mjit_client_wakeup, &mjit_engine_mutex); verbose(4, "Getting wakeup from a worker for GC"); } - in_gc = TRUE; + in_gc = true; CRITICAL_SECTION_FINISH(4, "mjit_gc_start_hook"); } @@ -100,7 +100,7 @@ mjit_gc_finish_hook(void) if (!mjit_enabled) return; CRITICAL_SECTION_START(4, "mjit_gc_finish_hook"); - in_gc = FALSE; + in_gc = false; verbose(4, "Sending wakeup signal to workers after GC"); rb_native_cond_broadcast(&mjit_gc_wakeup); CRITICAL_SECTION_FINISH(4, "mjit_gc_finish_hook"); @@ -126,7 +126,7 @@ mjit_free_iseq(const rb_iseq_t *iseq) because node of unit_queue and one of active_units may have the same unit during proceeding unit. */ static void -free_list(struct rb_mjit_unit_list *list, int close_handle_p) +free_list(struct rb_mjit_unit_list *list, bool close_handle_p) { struct rb_mjit_unit *unit = 0, *next; @@ -360,8 +360,8 @@ mjit_wait_call(rb_execution_context_t *ec, struct rb_iseq_constant_body *body) extern VALUE ruby_archlibdir_path, ruby_prefix_path; -/* Initialize header_file, pch_file, libruby_pathflag. Return TRUE on success. */ -static int +// Initialize header_file, pch_file, libruby_pathflag. Return true on success. +static bool init_header_filename(void) { int fd; @@ -418,7 +418,7 @@ init_header_filename(void) unsetenv(PRELOADENV); verbose(3, "MJIT_HEADER: %s", hdr); header_file = ruby_strdup(hdr); - if (!header_file) return FALSE; + if (!header_file) return false; } } else @@ -437,7 +437,7 @@ init_header_filename(void) verbose(1, "Cannot access header file: %s", header_file); xfree(header_file); header_file = NULL; - return FALSE; + return false; } (void)close(fd); } @@ -455,7 +455,7 @@ init_header_filename(void) verbose(1, "Cannot access precompiled header file: %s", pch_file); xfree(pch_file); pch_file = NULL; - return FALSE; + return false; } (void)close(fd); } @@ -471,7 +471,7 @@ init_header_filename(void) *p = '\0'; #endif - return TRUE; + return true; } static enum rb_id_table_iterator_result @@ -572,23 +572,23 @@ system_tmpdir(void) #define MIN_CACHE_SIZE 10 /* Start MJIT worker. Return TRUE if worker is sucessfully started. */ -static int +static bool start_worker(void) { - stop_worker_p = FALSE; - worker_stopped = FALSE; + stop_worker_p = false; + worker_stopped = false; if (!rb_thread_create_mjit_thread(mjit_worker)) { - mjit_enabled = FALSE; + mjit_enabled = false; rb_native_mutex_destroy(&mjit_engine_mutex); rb_native_cond_destroy(&mjit_pch_wakeup); rb_native_cond_destroy(&mjit_client_wakeup); rb_native_cond_destroy(&mjit_worker_wakeup); rb_native_cond_destroy(&mjit_gc_wakeup); verbose(1, "Failure in MJIT thread initialization\n"); - return FALSE; + return false; } - return TRUE; + return true; } /* Initialize MJIT. Start a thread creating the precompiled header and @@ -598,8 +598,8 @@ void mjit_init(struct mjit_options *opts) { mjit_opts = *opts; - mjit_enabled = TRUE; - mjit_call_p = TRUE; + mjit_enabled = true; + mjit_call_p = true; /* Normalize options */ if (mjit_opts.min_calls == 0) @@ -635,7 +635,7 @@ mjit_init(struct mjit_options *opts) verbose(2, "MJIT: tmp_dir is %s", tmp_dir); if (!init_header_filename()) { - mjit_enabled = FALSE; + mjit_enabled = false; verbose(1, "Failure in MJIT header file name initialization\n"); return; } @@ -670,7 +670,7 @@ stop_worker(void) while (!worker_stopped) { verbose(3, "Sending cancel signal to worker"); CRITICAL_SECTION_START(3, "in stop_worker"); - stop_worker_p = TRUE; /* Setting this inside loop because RUBY_VM_CHECK_INTS may make this FALSE. */ + stop_worker_p = true; // Setting this inside loop because RUBY_VM_CHECK_INTS may make this false. rb_native_cond_broadcast(&mjit_worker_wakeup); CRITICAL_SECTION_FINISH(3, "in stop_worker"); RUBY_VM_CHECK_INTS(ec); @@ -679,7 +679,7 @@ stop_worker(void) /* Stop JIT-compiling methods but compiled code is kept available. */ VALUE -mjit_pause(int wait_p) +mjit_pause(bool wait_p) { if (!mjit_enabled) { rb_raise(rb_eRuntimeError, "MJIT is not enabled"); @@ -732,7 +732,7 @@ skip_cleaning_object_files(struct rb_mjit_unit_list *list) /* No mutex for list, assuming MJIT worker does not exist yet since it's immediately after fork. */ list_for_each_safe(&list->head, unit, next, unode) { #ifndef _MSC_VER /* Actually mswin does not reach here since it doesn't have fork */ - if (unit->o_file) unit->o_file_inherited_p = TRUE; + if (unit->o_file) unit->o_file_inherited_p = true; #endif #if defined(_WIN32) /* mswin doesn't reach here either. This is for MinGW. */ @@ -775,10 +775,10 @@ mjit_child_after_fork(void) and free MJIT data. It should be called last during MJIT life. - If close_handle_p is TRUE, it calls dlclose() for JIT-ed code. So it should be FALSE + If close_handle_p is true, it calls dlclose() for JIT-ed code. So it should be false if the code can still be on stack. ...But it means to leak JIT-ed handle forever (FIXME). */ void -mjit_finish(int close_handle_p) +mjit_finish(bool close_handle_p) { if (!mjit_enabled) return; @@ -816,13 +816,13 @@ mjit_finish(int close_handle_p) xfree(tmp_dir); tmp_dir = NULL; xfree(pch_file); pch_file = NULL; - mjit_call_p = FALSE; + mjit_call_p = false; free_list(&unit_queue, close_handle_p); free_list(&active_units, close_handle_p); free_list(&compact_units, close_handle_p); finish_conts(); - mjit_enabled = FALSE; + mjit_enabled = false; verbose(1, "Successful MJIT finish"); } |