Skip to content

Fix more warnings (runtime) #1974

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ocaml/runtime4/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ prims.c : primitives
(echo '#define CAML_INTERNALS'; \
echo '#include "caml/mlvalues.h"'; \
echo '#include "caml/prims.h"'; \
echo '#pragma GCC diagnostic ignored "-Wdeprecated-non-prototype"'; \
sed -e 's/.*/extern value &();/' primitives; \
echo 'c_primitive caml_builtin_cprim[] = {'; \
sed -e 's/.*/ &,/' primitives; \
Expand Down
2 changes: 1 addition & 1 deletion ocaml/runtime4/caml/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ extern void caml_alloc_small_dispatch (intnat wosize, int flags,
CAML_DEPRECATED("Modify", "caml_modify") \
caml_modify((fp), (val))

struct caml_local_arenas* caml_get_local_arenas();
struct caml_local_arenas* caml_get_local_arenas(void);
void caml_set_local_arenas(struct caml_local_arenas* s);

#endif /* CAML_INTERNALS */
Expand Down
3 changes: 1 addition & 2 deletions ocaml/runtime4/instrtrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ intnat caml_icount = 0;

void caml_stop_here () {}

void caml_disasm_instr(pc)
code_t pc;
void caml_disasm_instr(code_t pc)
{
int instr = *pc;
printf("%6ld %s", (long) (pc - caml_start_code),
Expand Down
19 changes: 13 additions & 6 deletions ocaml/runtime4/interp.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,13 @@ static intnat caml_bcodcount;

/* The interpreter itself */

typedef value (*primitive_arity_1)(value);
typedef value (*primitive_arity_2)(value, value);
typedef value (*primitive_arity_3)(value, value, value);
typedef value (*primitive_arity_4)(value, value, value, value);
typedef value (*primitive_arity_5)(value, value, value, value, value);
typedef value (*primitive_arity_n)(value*, int);

value caml_interprete(code_t prog, asize_t prog_size)
{
#ifdef PC_REG
Expand Down Expand Up @@ -959,34 +966,34 @@ value caml_interprete(code_t prog, asize_t prog_size)

Instruct(C_CALL1):
Setup_for_c_call;
accu = Primitive(*pc)(accu);
accu = ((primitive_arity_1) Primitive(*pc))(accu);
Restore_after_c_call;
pc++;
Next;
Instruct(C_CALL2):
Setup_for_c_call;
accu = Primitive(*pc)(accu, sp[2]);
accu = ((primitive_arity_2) Primitive(*pc))(accu, sp[2]);
Restore_after_c_call;
sp += 1;
pc++;
Next;
Instruct(C_CALL3):
Setup_for_c_call;
accu = Primitive(*pc)(accu, sp[2], sp[3]);
accu = ((primitive_arity_3)Primitive(*pc))(accu, sp[2], sp[3]);
Restore_after_c_call;
sp += 2;
pc++;
Next;
Instruct(C_CALL4):
Setup_for_c_call;
accu = Primitive(*pc)(accu, sp[2], sp[3], sp[4]);
accu = ((primitive_arity_4) Primitive(*pc))(accu, sp[2], sp[3], sp[4]);
Restore_after_c_call;
sp += 3;
pc++;
Next;
Instruct(C_CALL5):
Setup_for_c_call;
accu = Primitive(*pc)(accu, sp[2], sp[3], sp[4], sp[5]);
accu = ((primitive_arity_5) Primitive(*pc))(accu, sp[2], sp[3], sp[4], sp[5]);
Restore_after_c_call;
sp += 4;
pc++;
Expand All @@ -995,7 +1002,7 @@ value caml_interprete(code_t prog, asize_t prog_size)
int nargs = *pc++;
*--sp = accu;
Setup_for_c_call;
accu = Primitive(*pc)(sp + 2, nargs);
accu = ((primitive_arity_n) Primitive(*pc))(sp + 2, nargs);
Restore_after_c_call;
sp += nargs;
pc++;
Expand Down