Commit ea61a49e authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Fix C wrappers to handle filtered PIs

parent 03a7f660
Pipeline #368 skipped
...@@ -486,13 +486,27 @@ void add_RI_to_c_wrappers(Interface * i) ...@@ -486,13 +486,27 @@ void add_RI_to_c_wrappers(Interface * i)
"\t /* This function is passive, thus not have direct access to the VM\n"); "\t /* This function is passive, thus not have direct access to the VM\n");
fprintf(b, fprintf(b,
"\t It must use its calling thread to invoke this asynchronous RI */\n\n"); "\t It must use its calling thread to invoke this asynchronous RI */\n\n");
FOREACH(t, FV, i->parent_fv->calling_threads, {
(void) t; count++;});
/* Build the list of calling threads for this RI */
FV_list *calltmp = NULL;
if (NULL == i->calling_pis) calltmp = i->parent_fv->calling_threads;
else {
FOREACH(calling_pi, Interface, i->calling_pis, {
FOREACH(thread_caller, FV, calling_pi->calling_threads, {
ADD_TO_SET(FV, calltmp, thread_caller);
});
});
}
/* Count the number of calling threads */
FOREACH(ct, FV, calltmp, {
(void) ct;
count ++;
});
/* If there is only one possible caller, no need for stack */ /* If there is only one possible caller, no need for stack */
if (1 == count) { if (1 == count) {
fprintf(b, "\tvm_async_%s_%s_vt(", fprintf(b, "\tvm_async_%s_%s_vt(",
i->parent_fv->calling_threads->value->name, calltmp->value->name,
i->name); i->name);
/* If any, add the IN parameter (async RI) */ /* If any, add the IN parameter (async RI) */
...@@ -502,15 +516,21 @@ void add_RI_to_c_wrappers(Interface * i) ...@@ -502,15 +516,21 @@ void add_RI_to_c_wrappers(Interface * i)
} }
fprintf(b, ");\n"); fprintf(b, ");\n");
} else if (count > 1) { /* Several possible callers: switch-case based on the stack top value */ }
else if (count > 1) { /* Several possible callers: switch-case based on the stack top value */
fprintf(b, "\tswitch(%s_callinglist_get_top_value()) {\n", fprintf(b, "\tswitch(%s_callinglist_get_top_value()) {\n",
i->parent_fv->name); i->parent_fv->name);
FOREACH(t, FV, i->parent_fv->calling_threads, { FOREACH(caller, FV, calltmp, {
fprintf(b, "\t\tcase %d: vm_async_%s_%s_vt(", t->thread_id, t->name, i->name); if (NULL != i->in) { /* Add the unique IN parameter (async RI) */ fprintf(b, "\t\tcase %d: vm_async_%s_%s_vt(",
fprintf(b, "%s, %s_len", i->in->value->name, caller->thread_id,
i->in->value->name);} caller->name,
fprintf(b, "); break;\n");} i->name);
); if (NULL != i->in) { /* Add the unique IN parameter (async RI) */
fprintf(b, "%s, %s_len", i->in->value->name,
i->in->value->name);
}
fprintf(b, "); break;\n");
});
fprintf(b, "\t\tdefault: break;\n"); fprintf(b, "\t\tdefault: break;\n");
fprintf(b, "\t}\n"); fprintf(b, "\t}\n");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment