Skip to content
This repository has been archived by the owner on May 18, 2019. It is now read-only.

Commit

Permalink
[FMI2] Handle the jump buffers better
Browse files Browse the repository at this point in the history
The catch in try/catch needs execute, so do not return before the
jump buffers have been restored.

Also tries to detect a parent OM calling the FMU. The threadData would
be shared between the two, but the functions now set and restore the
threadData at each call if a parent (using pthread_setspecific) has
been detected.

Belonging to [master]:
  - #2116
  - OpenModelica/OpenModelica-testsuite#829
  • Loading branch information
sjoelund authored and OpenModelica-Hudson committed Jan 29, 2018
1 parent 1b2f2b9 commit 95af275
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 26 deletions.
2 changes: 1 addition & 1 deletion SimulationRuntime/c/fmi/FMI2ModelExchange.c
Expand Up @@ -271,7 +271,7 @@ int fmi2CompletedIntegratorStep_OMC(void* in_fmi2me, double flowStates)
fmi2_boolean_t callEventUpdate = fmi2_false;
fmi2_boolean_t terminateSimulation = fmi2_false;
fmi2_status_t status = fmi2_import_completed_integrator_step(FMI2ME->FMIImportInstance, fmi2_true, &callEventUpdate, &terminateSimulation);
if (status != fmi1_status_ok && status != fmi1_status_warning) {
if (status != fmi2_status_ok && status != fmi2_status_warning) {
ModelicaFormatError("fmi2CompletedIntegratorStep failed with status : %s\n", fmi2_status_to_string(status));
}
return callEventUpdate;
Expand Down
15 changes: 13 additions & 2 deletions SimulationRuntime/c/util/omc_error.c
Expand Up @@ -414,11 +414,22 @@ static inline jmp_buf* getBestJumpBuffer(threadData_t *threadData)
case ERROR_INTEGRATOR:
case ERROR_OPTIMIZE:
#ifndef OMC_EMCC
return threadData->simulationJumpBuffer;
if (threadData->simulationJumpBuffer) {
return threadData->simulationJumpBuffer;
}
fprintf(stderr, "getBestJumpBuffer got simulationJumpBuffer=%p\n", threadData->simulationJumpBuffer);
abort();
#endif
case ERROR_EVENTHANDLING:
default:
return threadData->globalJumpBuffer ? threadData->globalJumpBuffer : threadData->mmc_jumper;
if (threadData->globalJumpBuffer) {
return threadData->globalJumpBuffer;
}
if (threadData->mmc_jumper) {
return threadData->mmc_jumper;
}
fprintf(stderr, "getBestJumpBuffer got mmc_jumper=%p, globalJumpBuffer=%p\n", threadData->globalJumpBuffer, threadData->mmc_jumper);
abort();
}
}

Expand Down
1 change: 1 addition & 0 deletions SimulationRuntime/c/util/utility.c
Expand Up @@ -35,6 +35,7 @@
#include "simulation_data.h"
#include "simulation/options.h"
#include <string.h>
#include <errno.h>

modelica_real real_int_pow(threadData_t *threadData, modelica_real base, modelica_integer n)
{
Expand Down

0 comments on commit 95af275

Please sign in to comment.