Skip to content

Commit

Permalink
Use correct signature for pthread_once
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@18654 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Jan 16, 2014
1 parent e4d809e commit 0c00097
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Compiler/Template/CodegenC.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ template simulationFile(SimCode simCode, String guid)
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(0);omc_alloc_interface = omc_alloc_interface_pooled;<%\n%>' else "MMC_INIT(1);"%>omc_alloc_interface.init();
<%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();
res = _main_SimulationRuntime(argc, argv, &simulation_data);
>>
<<
Expand Down
12 changes: 8 additions & 4 deletions SimulationRuntime/c/meta/meta_modelica.c
Original file line number Diff line number Diff line change
Expand Up @@ -852,12 +852,16 @@ void* boxptr_valueHashMod(threadData_t *threadData,void *p, void *mod)
}

pthread_once_t mmc_init_once = PTHREAD_ONCE_INIT;
void mmc_init(int withgc)

void mmc_init_nogc()
{
pthread_key_create(&mmc_thread_data_key,NULL);
init_metamodelica_segv_handler();
if (withgc) {
mmc_GC_init(mmc_GC_settings_default);
}
MMC_INIT_STACK_OVERFLOW();
}

void mmc_init(int withgc)
{
mmc_init_nogc();
mmc_GC_init(mmc_GC_settings_default);
}
3 changes: 2 additions & 1 deletion SimulationRuntime/c/meta/meta_modelica.h
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,8 @@ void mmc_catch_dummy_fn();

extern pthread_key_t mmc_thread_data_key;
extern pthread_once_t mmc_init_once;
extern void mmc_init(int withgc);
extern void mmc_init();
extern void mmc_init_nogc();
#define MMC_INIT(X) pthread_once(&mmc_init_once,mmc_init)
#define MMC_TRY_INTERNAL(X) { jmp_buf new_mmc_jumper, *old_jumper = threadData->X; threadData->X = &new_mmc_jumper; if (setjmp(new_mmc_jumper) == 0) {
#define MMC_TRY() { threadData_t *threadData = pthread_getspecific(mmc_thread_data_key); MMC_TRY_INTERNAL(mmc_jumper)
Expand Down

0 comments on commit 0c00097

Please sign in to comment.