Skip to content

Commit

Permalink
- Made headers more C-friendly
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@8960 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed May 12, 2011
1 parent 8612206 commit e165ab4
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 15 deletions.
3 changes: 2 additions & 1 deletion Compiler/susan_codegen/SimCode/SimCodeC.tpl
Expand Up @@ -4127,7 +4127,8 @@ case RANGE(__) then
<%preExp%>
<%startVar%> = <%startValue%>; <%stepVar%> = <%stepValue%>; <%stopVar%> = <%stopValue%>;
if (!<%stepVar%>) {
MODELICA_ASSERT(omc_dummyFileInfo, "assertion range step != 0 failed");
omc_fileInfo info = omc_dummyFileInfo;
MODELICA_ASSERT(info, "assertion range step != 0 failed");
} else if (!(((<%stepVar%> > 0) && (<%startVar%> > <%stopVar%>)) || ((<%stepVar%> < 0) && (<%startVar%> < <%stopVar%>)))) {
<%type%> <%iterName%>;
for (<%iterName%> = <%startValue%>; in_range_<%shortType%>(<%iterName%>, <%startVar%>, <%stopVar%>); <%iterName%> += <%stepVar%>) {
Expand Down
4 changes: 2 additions & 2 deletions c_runtime/matrix.h
Expand Up @@ -205,11 +205,11 @@ void * hybrj_(void(*) (int *,double*,double*,double *,int*, int*),

#define declare_matrix(A,nrows,ncols) double *A = real_alloc(nrows * ncols); \
assert(A != 0); \
for (int i = 0; i < nrows*ncols; i++) A[i]=0.0;
{int i;for (i = 0; i < nrows*ncols; i++) A[i]=0.0;}

#define declare_vector(v,nelts) double *v=real_alloc(nelts);\
assert(v != 0); \
for (int i = 0; i < nelts; i++) v[i]=0.0;
{int i;for (i = 0; i < nelts; i++) v[i]=0.0;}

/* Matrixes using column major order (as in Fortran) */
#define set_matrix_elt(A,r,c,n_rows,value) A[r + n_rows * c] = value
Expand Down
20 changes: 12 additions & 8 deletions c_runtime/simulation_events.h
Expand Up @@ -41,6 +41,8 @@
#include "integer_array.h"
#include "boolean_array.h"
#include "fortran_types.h"

#ifdef __cplusplus
#include <list>
using namespace std;

Expand Down Expand Up @@ -86,6 +88,14 @@ change(modelica_boolean& var);
bool
change(const char*& var);

double
BiSection(double*, double*, double*, double*, list<int> *);

int
CheckZeroCrossings(list<int>*);

#endif

double
Sample(double t, double start, double interval);
double
Expand Down Expand Up @@ -113,11 +123,11 @@ const int IterationMax = 200;
extern modelica_boolean* gout_res;

#define ZEROCROSSING(ind,exp) { \
if (euler_in_use){ \
if (euler_in_use) { \
gout[ind] = exp; \
} \
else {\
gout[ind] = (zeroCrossingEnabled[ind])?double(zeroCrossingEnabled[ind])*exp:1.0; \
gout[ind] = (zeroCrossingEnabled[ind])?((double)zeroCrossingEnabled[ind])*exp:1.0; \
} \
}

Expand Down Expand Up @@ -164,12 +174,6 @@ initializeZeroCrossings();
void
activateSampleEvents();

double
BiSection(double*, double*, double*, double*, list<int> *);

int
CheckZeroCrossings(list<int>*);

int
function_updateSample();

Expand Down
2 changes: 1 addition & 1 deletion c_runtime/simulation_runtime.h
Expand Up @@ -48,11 +48,11 @@
#include "boolean_array.h"
#include "rtclock.h"
#include <stdlib.h>
#include "simulation_events.h"

#ifdef __cplusplus

#include "linearize.h"
#include "simulation_events.h"
#include "simulation_delay.h"
#include "simulation_result.h"
#include "simulation_inline_solver.h"
Expand Down
2 changes: 0 additions & 2 deletions c_runtime/simulation_varinfo.c
Expand Up @@ -31,8 +31,6 @@

#include "simulation_varinfo.h"

const omc_fileInfo omc_dummyFileInfo = {"",-1,-1,-1,-1,1};

void printErrorEqSyst(equationSystemError err, struct omc_equationInfo eq, double var)
{
switch (err) {
Expand Down
2 changes: 1 addition & 1 deletion c_runtime/simulation_varinfo.h
Expand Up @@ -47,7 +47,7 @@ typedef struct {
int readonly;
} omc_fileInfo;

extern const omc_fileInfo omc_dummyFileInfo;
#define omc_dummyFileInfo {"",-1,-1,-1,-1,1}

struct omc_varInfo {
int id;
Expand Down

0 comments on commit e165ab4

Please sign in to comment.