From: Brian Demsky Date: Fri, 6 Dec 2019 23:02:15 +0000 (-0800) Subject: Get rid of main X-Git-Url: http://plrg.eecs.uci.edu/git/?p=c11tester.git;a=commitdiff_plain;h=67becf49b3c3cbc967a272dd92936812bd571fd4 Get rid of main --- diff --git a/main.cc b/main.cc index ea97d32a..f218b3e6 100644 --- a/main.cc +++ b/main.cc @@ -166,44 +166,3 @@ static void install_trace_analyses(ModelExecution *execution) ta->actionAtInstallation(); } } - -/** - * Main function. Just initializes snapshotting library and the - * snapshotting library calls the model_main function. - */ -int main(int argc, char **argv) -{ - /* - * If this printf statement is removed, C11Tester will fail on an - * assert on some versions of glibc. The first time printf is - * called, it allocated internal buffers. We can't easily snapshot - * libc since we also use it. - */ - - printf("C11Tester\n" - "Copyright (c) 2013 and 2019 Regents of the University of California. All rights reserved.\n" - "Distributed under the GPLv2\n" - "Written by Weiyu Luo, Brian Norris, and Brian Demsky\n\n"); - - - //Initialize snapshotting library and model checker object - if (!model) { - snapshot_system_init(10000, 1024, 1024, 40000); - model = new ModelChecker(); - model->startChecker(); - } - - /* Configure output redirection for the model-checker */ - redirect_output(); - register_plugins(); - - //Stash command line options - model_params *params = model->getParams(); - params->argc = argc; - params->argv = argv; - - install_trace_analyses(model->get_execution()); - - model->startMainThread(); - DEBUG("Exiting\n"); -} diff --git a/model.cc b/model.cc index b5e55867..69df0d22 100644 --- a/model.cc +++ b/model.cc @@ -21,12 +21,6 @@ ModelChecker *model = NULL; -/** Wrapper to run the user's main function, with appropriate arguments */ -void user_main_wrapper(void *) -{ - user_main(model->params.argc, model->params.argv); -} - /** @brief Constructor */ ModelChecker::ModelChecker() : /* Initialize default scheduler */ @@ -39,17 +33,25 @@ ModelChecker::ModelChecker() : trace_analyses(), inspect_plugin(NULL) { + printf("C11Tester\n" + "Copyright (c) 2013 and 2019 Regents of the University of California. All rights reserved.\n" + "Distributed under the GPLv2\n" + "Written by Weiyu Luo, Brian Norris, and Brian Demsky\n\n"); memset(&stats,0,sizeof(struct execution_stats)); - init_thread = new Thread(execution->get_next_id(), (thrd_t *) model_malloc(sizeof(thrd_t)), &user_main_wrapper, NULL, NULL); + init_thread = new Thread(execution->get_next_id(), (thrd_t *) model_malloc(sizeof(thrd_t)), NULL, NULL, NULL); #ifdef TLS init_thread->setTLS((char *)get_tls_addr()); #endif execution->add_thread(init_thread); scheduler->set_current_thread(init_thread); + register_plugins(); execution->setParams(¶ms); param_defaults(¶ms); parse_options(¶ms); initRaceDetector(); + /* Configure output redirection for the model-checker */ + redirect_output(); + install_trace_analyses(model->get_execution()); } /** @brief Destructor */ diff --git a/params.h b/params.h index 7f749cae..d6f5ec9a 100644 --- a/params.h +++ b/params.h @@ -12,12 +12,6 @@ struct model_params { /** @brief Verbosity (0 = quiet; 1 = noisy; 2 = noisier) */ int verbose; - - /** @brief Command-line argument count to pass to user program */ - int argc; - - /** @brief Command-line arguments to pass to user program */ - char **argv; }; void param_defaults(struct model_params *params);