Skip to content

Commit

Permalink
Avoid using main in ext.c
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonyyangdev committed Aug 9, 2023
1 parent 7365f54 commit 60ce685
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion harmony_model_checker/charm/charm.c
Original file line number Diff line number Diff line change
Expand Up @@ -3030,7 +3030,7 @@ static void usage(char *prog){
exit(1);
}

int main(int argc, char **argv){
int exec_model_checker(int argc, char **argv){
bool cflag = false, dflag = false, Dflag = false, Rflag = false;
int i, maxtime = 300000000 /* about 10 years */;
char *outfile = NULL, *dfafile = NULL, *worker_flag = NULL;
Expand Down Expand Up @@ -4097,3 +4097,7 @@ int main(int argc, char **argv){
free(global);
return 0;
}

int main(int argc, char** argv) {
return exec_model_checker(argc, argv);
}
6 changes: 3 additions & 3 deletions harmony_model_checker/charm/python_ext/ext.c
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@

#include "Python.h"

int main(int argc, char** argv);
int exec_model_checker(int argc, char** argv);

static PyObject* run_model_checker(PyObject *self, PyObject *args) {
Py_ssize_t tupleSize = PyTuple_Size(args);
Py_ssize_t argc = tupleSize + 1;
char **argv = malloc(argc * sizeof(char *));
argv[0] = "charm";
for (Py_ssize_t i = 0; i < tupleSize; ++i) {
PyObject *a = PyTuple_GetItem(args, i);
PyObject *a = PyTuple_GetItem(args, i);
char *s;
if (!PyArg_Parse(a, "s", &s)) {
return NULL;
}
argv[i + 1] = s;
}
PyObject *r = PyLong_FromLong(main(argc, argv));
PyObject *r = PyLong_FromLong(exec_model_checker(argc, argv));
free(argv);
return r;
}
Expand Down

0 comments on commit 60ce685

Please sign in to comment.