Skip to content

Commit

Permalink
Fix build issues on MSVC
Browse files Browse the repository at this point in the history
MSVC doesn't support C99 variable sized automatic arrays, so use malloc
instead. It also requires at least one value for struct initializers.
  • Loading branch information
niner committed Aug 3, 2021
1 parent bd2a121 commit 28cdc89
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
5 changes: 4 additions & 1 deletion src/disp/program.c
Original file line number Diff line number Diff line change
Expand Up @@ -1989,7 +1989,8 @@ static void emit_args_ops(MVMThreadContext *tc, MVMCallStackDispatchRecord *reco
Action action;
MVMuint32 index;
} ArgProduction;
ArgProduction arg_prod[num_to_produce];
ArgProduction *arg_prod = MVM_malloc(num_to_produce * sizeof(ArgProduction));

for (i = 0; i < num_to_produce; i++) {
/* Work out the source of this arg in the capture. For the rationale
* for this algorithm, see MVM_disp_program_record_track_arg. */
Expand Down Expand Up @@ -2060,6 +2061,8 @@ static void emit_args_ops(MVMThreadContext *tc, MVMCallStackDispatchRecord *reco
MVM_VECTOR_PUSH(cs->ops, op);
}

MVM_free(arg_prod);

/* Finally, the instruction to copy what we can from the args tail. */
MVMDispProgramOp op;
op.code = MVMDispOpcodeCopyArgsTail;
Expand Down
36 changes: 18 additions & 18 deletions src/disp/syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,9 @@ static MVMDispSysCall dispatcher_get_resume_init_args = {
.implementation = dispatcher_get_resume_init_args_impl,
.min_args = 0,
.max_args = 0,
.expected_kinds = { },
.expected_reprs = { },
.expected_concrete = { },
.expected_kinds = {0},
.expected_reprs = {0},
.expected_concrete = {0},
};

/* dispatcher-set-resume-state */
Expand Down Expand Up @@ -381,9 +381,9 @@ static MVMDispSysCall dispatcher_get_resume_state = {
.implementation = dispatcher_get_resume_state_impl,
.min_args = 0,
.max_args = 0,
.expected_kinds = { },
.expected_reprs = { },
.expected_concrete = { },
.expected_kinds = {0},
.expected_reprs = {0},
.expected_concrete = {0}
};

/* dispatcher-track-resume-state */
Expand All @@ -398,9 +398,9 @@ static MVMDispSysCall dispatcher_track_resume_state = {
.implementation = dispatcher_track_resume_state_impl,
.min_args = 0,
.max_args = 0,
.expected_kinds = { },
.expected_reprs = { },
.expected_concrete = { },
.expected_kinds = {0},
.expected_reprs = {0},
.expected_concrete = {0}
};

/* dispatcher-next-resumption */
Expand All @@ -415,9 +415,9 @@ static MVMDispSysCall dispatcher_next_resumption = {
.implementation = dispatcher_next_resumption_impl,
.min_args = 0,
.max_args = 0,
.expected_kinds = { },
.expected_reprs = { },
.expected_concrete = { },
.expected_kinds = {0},
.expected_reprs = {0},
.expected_concrete = {0}
};

/* dispatcher-resume-on-bind-failure */
Expand Down Expand Up @@ -467,9 +467,9 @@ static MVMDispSysCall dispatcher_inline_cache_size = {
.implementation = dispatcher_inline_cache_size_impl,
.min_args = 0,
.max_args = 0,
.expected_kinds = { },
.expected_reprs = { },
.expected_concrete = { },
.expected_kinds = {0},
.expected_reprs = {0},
.expected_concrete = {0}
};

/* capture-is-literal-arg */
Expand Down Expand Up @@ -945,9 +945,9 @@ static MVMDispSysCall bind_will_resume_on_failure = {
.implementation = bind_will_resume_on_failure_impl,
.min_args = 0,
.max_args = 0,
.expected_kinds = { },
.expected_reprs = { },
.expected_concrete = { },
.expected_kinds = {0},
.expected_reprs = {0},
.expected_concrete = {0},
};

/* Add all of the syscalls into the hash. */
Expand Down

0 comments on commit 28cdc89

Please sign in to comment.