OMCompiler/Compiler/.cmake/omc_entry_point.c
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* This is an automatically generated entry point to a MetaModelica function */ | ||
| 2 | |||
| 3 | #if defined(__cplusplus) | ||
| 4 | extern "C" { | ||
| 5 | #endif | ||
| 6 | |||
| 7 | #include <meta/meta_modelica.h> | ||
| 8 | #include <stdio.h> | ||
| 9 | extern void | ||
| 10 | #if defined(OMC_GENERATE_RELOCATABLE_CODE) | ||
| 11 | (*omc_Main_main) | ||
| 12 | #else | ||
| 13 | omc_Main_main | ||
| 14 | #endif | ||
| 15 | (threadData_t*,modelica_metatype); | ||
| 16 | |||
| 17 | #ifdef _OPENMP | ||
| 18 | #include<omp.h> | ||
| 19 | /* Hack to make gcc-4.8 link in the OpenMP runtime if -fopenmp is given */ | ||
| 20 | int (*force_link_omp)(void) = omp_get_num_threads; | ||
| 21 | #endif | ||
| 22 | |||
| 23 | 318 | static int rml_execution_failed() | |
| 24 | { | ||
| 25 | 318 | fflush(NULL); | |
| 26 | 318 | fprintf(stderr, "Execution failed!\n"); | |
| 27 | 318 | fflush(NULL); | |
| 28 | 318 | return 1; | |
| 29 | } | ||
| 30 | |||
| 31 | DLLExport int __omc_main(int argc, char **argv) | ||
| 32 | { | ||
| 33 | MMC_INIT(0); | ||
| 34 | { | ||
| 35 | void *lst = mmc_mk_nil(); | ||
| 36 | int i = 0; | ||
| 37 | |||
| 38 | for (i=argc-1; i>0; i--) { | ||
| 39 | lst = mmc_mk_cons(mmc_mk_scon(argv[i]), lst); | ||
| 40 | } | ||
| 41 | |||
| 42 | { | ||
| 43 | MMC_TRY_TOP() | ||
| 44 | |||
| 45 | MMC_TRY_STACK() | ||
| 46 | |||
| 47 | omc_Main_main(threadData, lst); | ||
| 48 | |||
| 49 | MMC_ELSE() | ||
| 50 | rml_execution_failed(); | ||
| 51 | fprintf(stderr, "Stack overflow detected and was not caught.\nSend us a bug report at https://trac.openmodelica.org/OpenModelica/newticket\n Include the following trace:\n"); | ||
| 52 | printStacktraceMessages(); | ||
| 53 | fflush(NULL); | ||
| 54 | return 1; | ||
| 55 | MMC_CATCH_STACK() | ||
| 56 | |||
| 57 | MMC_CATCH_TOP(return rml_execution_failed()); | ||
| 58 | } | ||
| 59 | } | ||
| 60 | |||
| 61 | fflush(NULL); | ||
| 62 | EXIT(0); | ||
| 63 | return 0; | ||
| 64 | } | ||
| 65 | |||
| 66 | #if defined(__cplusplus) | ||
| 67 | } /* end extern "C" */ | ||
| 68 | #endif | ||
| 69 | |||
| 70 |