mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
assigning void* to a function pointer is a POSIXism
No implicit cast is defined between these types. Should be explicit. Also, NULL is defined to be ((void*)0) so not usable as a function pointer value. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62221 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
779c18bf23
commit
8427fca49b
3 changed files with 15 additions and 13 deletions
18
mjit.c
18
mjit.c
|
@ -440,7 +440,7 @@ static void
|
|||
free_unit(struct rb_mjit_unit *unit)
|
||||
{
|
||||
if (unit->iseq) /* ISeq is not GCed */
|
||||
unit->iseq->body->jit_func = NULL;
|
||||
unit->iseq->body->jit_func = 0;
|
||||
if (unit->handle) /* handle is NULL if it's in queue */
|
||||
dlclose(unit->handle);
|
||||
xfree(unit);
|
||||
|
@ -682,7 +682,7 @@ load_func_from_so(const char *so_file, const char *funcname, struct rb_mjit_unit
|
|||
|
||||
/* Compile ISeq in UNIT and return function pointer of JIT-ed code.
|
||||
It may return NOT_COMPILABLE_JIT_ISEQ_FUNC if something went wrong. */
|
||||
static void *
|
||||
static mjit_func_t
|
||||
convert_unit_to_func(struct rb_mjit_unit *unit)
|
||||
{
|
||||
char c_file[70], so_file[70], funcname[35];
|
||||
|
@ -744,7 +744,7 @@ convert_unit_to_func(struct rb_mjit_unit *unit)
|
|||
if (!success) {
|
||||
if (!mjit_opts.save_temps)
|
||||
remove(c_file);
|
||||
return (void *)NOT_COMPILABLE_JIT_ISEQ_FUNC;
|
||||
return (mjit_func_t)NOT_COMPILABLE_JIT_ISEQ_FUNC;
|
||||
}
|
||||
|
||||
start_time = real_ms_time();
|
||||
|
@ -755,7 +755,7 @@ convert_unit_to_func(struct rb_mjit_unit *unit)
|
|||
remove(c_file);
|
||||
if (!success) {
|
||||
verbose(2, "Failed to generate so: %s", so_file);
|
||||
return (void *)NOT_COMPILABLE_JIT_ISEQ_FUNC;
|
||||
return (mjit_func_t)NOT_COMPILABLE_JIT_ISEQ_FUNC;
|
||||
}
|
||||
|
||||
func = load_func_from_so(so_file, funcname, unit);
|
||||
|
@ -771,7 +771,7 @@ convert_unit_to_func(struct rb_mjit_unit *unit)
|
|||
RSTRING_PTR(rb_iseq_path(unit->iseq)), FIX2INT(unit->iseq->body->location.first_lineno), c_file);
|
||||
CRITICAL_SECTION_FINISH(3, "end of jit");
|
||||
}
|
||||
return func;
|
||||
return (mjit_func_t)func;
|
||||
}
|
||||
|
||||
/* Set to TRUE to finish worker. */
|
||||
|
@ -810,7 +810,7 @@ worker(void)
|
|||
CRITICAL_SECTION_FINISH(3, "in worker dequeue");
|
||||
|
||||
if (node) {
|
||||
void *func = convert_unit_to_func(node->unit);
|
||||
mjit_func_t func = convert_unit_to_func(node->unit);
|
||||
|
||||
CRITICAL_SECTION_START(3, "in jit func replace");
|
||||
if (node->unit->iseq) { /* Check whether GCed or not */
|
||||
|
@ -985,7 +985,7 @@ unload_units(void)
|
|||
/* Unload the worst node. */
|
||||
verbose(2, "Unloading unit %d (calls=%lu)", worst_node->unit->id, worst_node->unit->iseq->body->total_calls);
|
||||
unit = worst_node->unit;
|
||||
unit->iseq->body->jit_func = (void *)NOT_READY_JIT_ISEQ_FUNC;
|
||||
unit->iseq->body->jit_func = (mjit_func_t)NOT_READY_JIT_ISEQ_FUNC;
|
||||
remove_from_list(worst_node, &active_units);
|
||||
|
||||
assert(unit->handle != NULL);
|
||||
|
@ -1005,7 +1005,7 @@ mjit_add_iseq_to_process(const rb_iseq_t *iseq)
|
|||
if (!mjit_init_p)
|
||||
return;
|
||||
|
||||
iseq->body->jit_func = (void *)NOT_READY_JIT_ISEQ_FUNC;
|
||||
iseq->body->jit_func = (mjit_func_t)NOT_READY_JIT_ISEQ_FUNC;
|
||||
create_unit(iseq);
|
||||
if (iseq->body->jit_unit == NULL)
|
||||
/* Failure in creating the unit. */
|
||||
|
@ -1177,7 +1177,7 @@ mjit_init(struct mjit_options *opts)
|
|||
/* Initialize worker thread */
|
||||
finish_worker_p = FALSE;
|
||||
worker_finished = FALSE;
|
||||
if (rb_thread_create_mjit_thread(child_after_fork, worker) == FALSE) {
|
||||
if (rb_thread_create_mjit_thread(child_after_fork, (void *)worker) == FALSE) {
|
||||
mjit_init_p = FALSE;
|
||||
rb_native_mutex_destroy(&mjit_engine_mutex);
|
||||
rb_native_cond_destroy(&mjit_pch_wakeup);
|
||||
|
|
|
@ -1777,7 +1777,7 @@ rb_nativethread_self(void)
|
|||
static void *
|
||||
mjit_worker(void *arg)
|
||||
{
|
||||
void (*worker_func)(void) = arg;
|
||||
void (*worker_func)(void) = (void(*)(void))arg;
|
||||
|
||||
if (pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) != 0) {
|
||||
fprintf(stderr, "Cannot enable cancelation in MJIT worker\n");
|
||||
|
@ -1791,7 +1791,7 @@ mjit_worker(void *arg)
|
|||
|
||||
/* Launch MJIT thread. Returns FALSE if it fails to create thread. */
|
||||
int
|
||||
rb_thread_create_mjit_thread(void (*child_hook)(void), void (*worker_func)(void))
|
||||
rb_thread_create_mjit_thread(void (*child_hook)(void), void *worker_func)
|
||||
{
|
||||
pthread_attr_t attr;
|
||||
pthread_t worker_pid;
|
||||
|
|
|
@ -292,8 +292,9 @@ pathobj_realpath(VALUE pathobj)
|
|||
}
|
||||
}
|
||||
|
||||
/* A forward declaration */
|
||||
/* Forward declarations */
|
||||
struct rb_mjit_unit;
|
||||
struct rb_execution_context_struct;
|
||||
|
||||
struct rb_iseq_constant_body {
|
||||
enum iseq_type {
|
||||
|
@ -419,7 +420,8 @@ struct rb_iseq_constant_body {
|
|||
unsigned int stack_max; /* for stack overflow check */
|
||||
|
||||
/* The following fields are MJIT related info. */
|
||||
void *jit_func; /* function pointer for loaded native code */
|
||||
VALUE (*jit_func)(struct rb_execution_context_struct *,
|
||||
struct rb_control_frame_struct *); /* function pointer for loaded native code */
|
||||
long unsigned total_calls; /* number of total calls with `mjit_exec()` */
|
||||
struct rb_mjit_unit *jit_unit;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue