3030
3131#include <stdarg.h>
3232#include <stddef.h>
33- #include "../util/omc_error.h"
3433#include "../util/utility.h"
3534#include "../meta/meta_modelica.h"
35+ #include "simulation_omc_assert.h"
3636#include "simulation_runtime.h"
3737
38+
39+ void (* omc_assert_withEquationIndexes )(threadData_t * , FILE_INFO info , const int * indexes , const char * msg , ...) __attribute__ ((noreturn )) = omc_assert_simulation_withEquationIndexes ;
40+
41+ void (* omc_assert_warning_withEquationIndexes )(FILE_INFO info , const int * indexes , const char * msg , ...) = omc_assert_warning_simulation_withEquationIndexes ;
42+
43+
3844int terminationTerminate = 0 ; /* Becomes non-zero when user terminates simulation. */
3945FILE_INFO TermInfo ; /* message for termination. */
4046char * TermMsg ; /* message for termination. */
@@ -63,11 +69,6 @@ static void setTermMsg(const char *msg, va_list ap)
6369 }
6470}
6571
66- static void omc_assert_simulation (threadData_t * threadData , FILE_INFO info , const char * msg , ...) __attribute__ ((noreturn ));
67- static void omc_assert_simulation_withEquationIndexes (threadData_t * threadData , FILE_INFO info , const int * indexes , const char * msg , ...) __attribute__ ((noreturn ));
68- static void omc_throw_simulation (threadData_t * threadData ) __attribute__ ((noreturn ));
69- static void va_omc_assert_simulation_withEquationIndexes (threadData_t * threadData , FILE_INFO info , const int * indexes , const char * msg , va_list args ) __attribute__ ((noreturn ));
70-
7172static void va_omc_assert_simulation_withEquationIndexes (threadData_t * threadData , FILE_INFO info , const int * indexes , const char * msg , va_list args )
7273{
7374 threadData = threadData ? threadData : (threadData_t * )pthread_getspecific (mmc_thread_data_key );
@@ -105,15 +106,15 @@ static void va_omc_assert_simulation_withEquationIndexes(threadData_t *threadDat
105106 }
106107}
107108
108- static void omc_assert_simulation (threadData_t * threadData , FILE_INFO info , const char * msg , ...)
109+ void omc_assert_simulation (threadData_t * threadData , FILE_INFO info , const char * msg , ...)
109110{
110111 va_list args ;
111112 va_start (args , msg );
112113 va_omc_assert_simulation_withEquationIndexes (threadData , info , NULL , msg , args );
113114 va_end (args );
114115}
115116
116- static void omc_assert_simulation_withEquationIndexes (threadData_t * threadData , FILE_INFO info , const int * indexes , const char * msg , ...)
117+ void omc_assert_simulation_withEquationIndexes (threadData_t * threadData , FILE_INFO info , const int * indexes , const char * msg , ...)
117118{
118119 va_list args ;
119120 va_start (args , msg );
@@ -127,23 +128,23 @@ static void va_omc_assert_warning_simulation(FILE_INFO info, const int *indexes,
127128 va_warningStreamPrintWithEquationIndexes (LOG_ASSERT , 0 , indexes , msg , args );
128129}
129130
130- static void omc_assert_warning_simulation (FILE_INFO info , const char * msg , ...)
131+ void omc_assert_warning_simulation (FILE_INFO info , const char * msg , ...)
131132{
132133 va_list args ;
133134 va_start (args , msg );
134135 va_omc_assert_warning_simulation (info , NULL , msg , args );
135136 va_end (args );
136137}
137138
138- static void omc_assert_warning_simulation_withEquationIndexes (FILE_INFO info , const int * indexes , const char * msg , ...)
139+ void omc_assert_warning_simulation_withEquationIndexes (FILE_INFO info , const int * indexes , const char * msg , ...)
139140{
140141 va_list args ;
141142 va_start (args , msg );
142143 va_omc_assert_warning_simulation (info , indexes , msg , args );
143144 va_end (args );
144145}
145146
146- static void omc_terminate_simulation (FILE_INFO info , const char * msg , ...)
147+ void omc_terminate_simulation (FILE_INFO info , const char * msg , ...)
147148{
148149 va_list ap ;
149150 va_start (ap ,msg );
@@ -164,18 +165,10 @@ void setTermMsg_empty_va_list(const char *msg, ...) {
164165 va_end (dummy );
165166}
166167
167- static void omc_throw_simulation (threadData_t * threadData )
168+ void omc_throw_simulation (threadData_t * threadData )
168169{
169170 setTermMsg_empty_va_list ("Assertion triggered by external C function" );
170171 set_struct (FILE_INFO , TermInfo , omc_dummyFileInfo );
171172 threadData = threadData ? threadData : (threadData_t * )pthread_getspecific (mmc_thread_data_key );
172173 longjmp (* threadData -> globalJumpBuffer , 1 );
173174}
174-
175- void (* omc_assert )(threadData_t * , FILE_INFO info , const char * msg , ...) __attribute__ ((noreturn )) = omc_assert_simulation ;
176- void (* omc_assert_withEquationIndexes )(threadData_t * , FILE_INFO info , const int * indexes , const char * msg , ...) __attribute__ ((noreturn )) = omc_assert_simulation_withEquationIndexes ;
177-
178- void (* omc_assert_warning_withEquationIndexes )(FILE_INFO info , const int * indexes , const char * msg , ...) = omc_assert_warning_simulation_withEquationIndexes ;
179- void (* omc_assert_warning )(FILE_INFO info , const char * msg , ...) = omc_assert_warning_simulation ;
180- void (* omc_terminate )(FILE_INFO info , const char * msg , ...) = omc_terminate_simulation ;
181- void (* omc_throw )(threadData_t * ) __attribute__ ((noreturn )) = omc_throw_simulation ;
0 commit comments