diff --git a/Compiler/runtime/config.h b/Compiler/runtime/config.h index a41612a70f4..b97f7c1fdfd 100644 --- a/Compiler/runtime/config.h +++ b/Compiler/runtime/config.h @@ -63,9 +63,9 @@ * Visual Studio then use the SSE instructions, * not the normal i387 FPU */ - #define DEFAULT_CFLAGS "-msse2 -mfpmath=sse ${MODELICAUSERCFLAGS}" + #define DEFAULT_CFLAGS "${SIM_OR_DYNLOAD_OPT_LEVEL} -falign-functions -msse2 -mfpmath=sse ${MODELICAUSERCFLAGS}" #else - #define DEFAULT_CFLAGS "${MODELICAUSERCFLAGS}" + #define DEFAULT_CFLAGS "${SIM_OR_DYNLOAD_OPT_LEVEL} -falign-functions ${MODELICAUSERCFLAGS}" #endif #if defined(__x86_64__) /* -fPIC needed on x86_64! */ diff --git a/Compiler/runtime/config.unix.h.in b/Compiler/runtime/config.unix.h.in index 6cb4a0591b0..45835a06f4e 100644 --- a/Compiler/runtime/config.unix.h.in +++ b/Compiler/runtime/config.unix.h.in @@ -18,10 +18,10 @@ #endif #ifdef __APPLE_CC__ - #define DEFAULT_CFLAGS "-msse2 -mfpmath=sse ${MODELICAUSERCFLAGS}" + #define DEFAULT_CFLAGS "${SIM_OR_DYNLOAD_OPT_LEVEL} -falign-functions -msse2 -mfpmath=sse ${MODELICAUSERCFLAGS}" #define CONFIG_OS "OSX" #else - #define DEFAULT_CFLAGS "-march=native -mfpmath=sse ${MODELICAUSERCFLAGS}" + #define DEFAULT_CFLAGS "${SIM_OR_DYNLOAD_OPT_LEVEL} -falign-functions -march=native -mfpmath=sse ${MODELICAUSERCFLAGS}" #define CONFIG_OS "linux" #endif diff --git a/Compiler/susan_codegen/SimCode/SimCodeC.tpl b/Compiler/susan_codegen/SimCode/SimCodeC.tpl index 84c81386be4..6a4ea1207a3 100644 --- a/Compiler/susan_codegen/SimCode/SimCodeC.tpl +++ b/Compiler/susan_codegen/SimCode/SimCodeC.tpl @@ -1706,6 +1706,7 @@ template functionDAE( list allEquationsPlusWhen, let reinit = (whenClauses |> when hasindex i0 => + genreinits(when, &varDecls,i0) ;separator="\n") << @@ -2493,6 +2494,8 @@ case SIMCODE(modelInfo=MODELINFO(__), makefileParams=MAKEFILE_PARAMS(__)) then << # Makefile generated by OpenModelica + # Simulations use -O3 by default + SIM_OR_DYNLOAD_OPT_LEVEL=-O3 CC=<%makefileParams.ccompiler%> CXX=<%makefileParams.cxxcompiler%> LINK=<%makefileParams.linker%> @@ -2651,6 +2654,8 @@ case FUNCTIONCODE(makefileParams=MAKEFILE_PARAMS(__)) then << # Makefile generated by OpenModelica + # Dynamic loading uses -O0 by default + SIM_OR_DYNLOAD_OPT_LEVEL=-O0 CC=<%makefileParams.ccompiler%> CXX=<%makefileParams.cxxcompiler%> LINK=<%makefileParams.linker%> diff --git a/c_runtime/Makefile.common b/c_runtime/Makefile.common index 32f68e7701c..f6d2ce2c558 100644 --- a/c_runtime/Makefile.common +++ b/c_runtime/Makefile.common @@ -15,8 +15,8 @@ ddasrt.o dlinpk.o enorm.o hybrd1.o nelmead.o qform.o r1updt.o \ biglag.o ddassl.o dogleg.o fdjac1.o hybrj.o newuoa.o qrfac.o trsapp.o \ daux.o dlamch.o dpmpar.o hybrd.o lsame.o newuob.o r1mpyq.o update.o division.o\ java_interface.o meta_modelica.o meta_modelica_builtin.o meta_modelica_real.o \ -meta_modelica_string_lit.o rtclock.o ModelicaUtilities.o simulation_varinfo.o \ -read_matlab4.o \ +meta_modelica_string_lit.o meta_modelica_catch.o rtclock.o ModelicaUtilities.o \ +simulation_varinfo.o read_matlab4.o \ $(EXTRA_OBJS) SIMOBJS = $(FOBJS) simulation_runtime.o simulation_init.o simulation_input.o \ @@ -120,6 +120,9 @@ libf2c/libf2c.a : cd libf2c && $(MAKE) -f $(LIBF2CMAKEFILE) ranlib $@ +meta_modelica_catch.o : meta_modelica_catch.c + $(CC) $(CPPFLAGS) $(CFLAGS) -c -g $< + install: libc_runtime.a libsim.a libf2c/libf2c.a interactive/libinteractive.a $(LIBSENDDATA) omdevinstall ModelicaExternalC/libModelicaExternalC.a cp $(HFILES) $(builddir_inc)/ cp $(LIBS) $(builddir_lib)/ diff --git a/c_runtime/meta_modelica.c b/c_runtime/meta_modelica.c index a122939fa13..f6391c41111 100644 --- a/c_runtime/meta_modelica.c +++ b/c_runtime/meta_modelica.c @@ -509,10 +509,3 @@ void* boxptr_valueHashMod(void *p, void *mod) { return mmc_mk_icon(mmc_prim_hash(p) % (unsigned long) mmc_unbox_integer(mod)); } - -void mmc_catch_dummy_fn() -{ -#line 1 "Catch.omc" - return; -} -/* Keep mmc_catch_dummy_fn() last in the file since it uses #line */ diff --git a/c_runtime/meta_modelica.h b/c_runtime/meta_modelica.h index ea86d592a24..2bc8b6414f0 100644 --- a/c_runtime/meta_modelica.h +++ b/c_runtime/meta_modelica.h @@ -379,6 +379,7 @@ typedef base_array_t mmc__unbox__array_rettype; #include +void mmc_catch_dummy_fn(); #if 1 /* Use something like this if needed... #define MMC_JMP_BUF_SIZE 8192 @@ -386,7 +387,6 @@ extern jmp_buf mmc_jumper[MMC_JMP_BUF_SIZE]; extern int jmp_buf_index; */ extern jmp_buf *mmc_jumper; -void mmc_catch_dummy_fn(); #define MMC_TRY() {jmp_buf new_mmc_jumper, *old_jumper; old_jumper = mmc_jumper; mmc_jumper = &new_mmc_jumper; if (setjmp(new_mmc_jumper) == 0) { #define MMC_CATCH() } mmc_jumper = old_jumper; mmc_catch_dummy_fn();} #define MMC_THROW() longjmp(*mmc_jumper,1) diff --git a/c_runtime/meta_modelica_catch.c b/c_runtime/meta_modelica_catch.c new file mode 100644 index 00000000000..3c630b1a953 --- /dev/null +++ b/c_runtime/meta_modelica_catch.c @@ -0,0 +1,36 @@ +/* + * This file is part of OpenModelica. + * + * Copyright (c) 1998-CurrentYear, Linköping University, + * Department of Computer and Information Science, + * SE-58183 Linköping, Sweden. + * + * All rights reserved. + * + * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3 + * AND THIS OSMC PUBLIC LICENSE (OSMC-PL). + * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S + * ACCEPTANCE OF THE OSMC PUBLIC LICENSE. + * + * The OpenModelica software and the Open Source Modelica + * Consortium (OSMC) Public License (OSMC-PL) are obtained + * from Linköping University, either from the above address, + * from the URLs: http://www.ida.liu.se/projects/OpenModelica or + * http://www.openmodelica.org, and in the OpenModelica distribution. + * GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html. + * + * This program is distributed WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH + * IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS + * OF OSMC-PL. + * + * See the full OSMC Public License conditions for more details. + * + */ + +void mmc_catch_dummy_fn() +{ +#line 1 "Catch.omc" + return; +}