Skip to content

Commit

Permalink
Handle Modelica.Utilities.Streams.error in simulations
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@19179 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Feb 19, 2014
1 parent 1ea3bb0 commit f992efa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Compiler/Template/CodegenC.tpl
Expand Up @@ -501,10 +501,10 @@ template simulationFile(SimCode simCode, String guid)
match simCode
case simCode as SIMCODE(__) then
let modelNamePrefixStr = modelNamePrefix(simCode)
let mainInit = '<%if boolOr(boolAnd(Flags.isSet(HPCOM), boolNot(stringEq(getConfigString(HPCOM_CODE),"pthreads_spin"))),stringEq(Config.simCodeTarget(),"JavaScript")) then 'mmc_init_nogc();omc_alloc_interface = omc_alloc_interface_pooled;<%\n%>' else "MMC_INIT();"%>omc_alloc_interface.init();'
let mainBody =
<<
<%symbolName(modelNamePrefixStr,"setupDataStruc")%>(&simulation_data);
<%if boolOr(boolAnd(Flags.isSet(HPCOM), boolNot(stringEq(getConfigString(HPCOM_CODE),"pthreads_spin"))),stringEq(Config.simCodeTarget(),"JavaScript")) then 'mmc_init_nogc();omc_alloc_interface = omc_alloc_interface_pooled;<%\n%>' else "MMC_INIT();"%>omc_alloc_interface.init();
simulation_data.threadData = threadData;
res = _main_SimulationRuntime(argc, argv, &simulation_data);
>>
Expand Down Expand Up @@ -648,6 +648,7 @@ template simulationFile(SimCode simCode, String guid)
{
int res;
DATA simulation_data;
<%mainInit%>
<%mainTop(mainBody,"https://trac.openmodelica.org/OpenModelica/newticket")%>
<%if Flags.isSet(HPCOM) then "terminateHpcOmThreads();" %>
Expand Down
2 changes: 2 additions & 0 deletions SimulationRuntime/c/simulation/simulation_runtime.cpp
Expand Up @@ -915,6 +915,7 @@ int _main_SimulationRuntime(int argc, char**argv, DATA *data)
static void omc_assert_simulation(threadData_t *threadData, FILE_INFO info, const char *msg, ...)
{
va_list ap;
threadData = threadData ? threadData : (threadData_t*)pthread_getspecific(mmc_thread_data_key);
switch (threadData->currentErrorStage)
{
case ERROR_SIMULATION:
Expand Down Expand Up @@ -989,6 +990,7 @@ static void omc_throw_simulation(threadData_t* threadData)
va_list ap;
setTermMsg("Assertion triggered by external C function", ap);
set_struct(FILE_INFO, TermInfo, omc_dummyFileInfo);
threadData = threadData ? threadData : (threadData_t*)pthread_getspecific(mmc_thread_data_key);
longjmp(*threadData->globalJumpBuffer, 1);
}

Expand Down

0 comments on commit f992efa

Please sign in to comment.