Skip to content

Commit

Permalink
- Made System.int/realMaxLit external "builtin" again (because extern…
Browse files Browse the repository at this point in the history
…al "C" is limited to 32-bit int, while our longs are 64-bit)

  - Plus some fixes to the runtime system (declaring them in a header, since external "builtin" does not do that for us)


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@8161 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Mar 10, 2011
1 parent 33cb4eb commit 913f539
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Compiler/Util/System.mo
Expand Up @@ -755,12 +755,12 @@ end unquoteIdentifier;

public function intMaxLit "Returns the maximum integer that can be represent using this version of the compiler"
output Integer outInt;
external "C" outInt=System_intMaxLit();
external "builtin" outInt=intMaxLit();
end intMaxLit;

public function realMaxLit "Returns the maximum integer that can be represent using this version of the compiler"
output Real outReal;
external "C" outReal=System_realMaxLit();
external "builtin" outReal=realMaxLit();
end realMaxLit;

end System;
10 changes: 0 additions & 10 deletions c_runtime/meta_modelica.c
Expand Up @@ -483,13 +483,3 @@ void* boxptr_valueHashMod(void *p, void *mod)
{
return mmc_mk_icon(mmc_prim_hash(p) % (unsigned long) mmc_unbox_integer(mod));
}

double realMaxLit()
{
return DBL_MAX / 2048; /* in case some non-linear or ODE solver tries to add eps to this value */
}

long intMaxLit()
{
return LONG_MAX / 2;
}
10 changes: 10 additions & 0 deletions c_runtime/meta_modelica_builtin.cpp
Expand Up @@ -633,4 +633,14 @@ modelica_metatype boxptr_listRest(modelica_metatype lst)
return MMC_CDR(lst);
}

realMaxLit_rettype realMaxLit()
{
return DBL_MAX / 2048; /* in case some non-linear or ODE solver tries to add eps to this value */
}

intMaxLit_rettype intMaxLit()
{
return LONG_MAX / 2;
}

}
5 changes: 5 additions & 0 deletions c_runtime/meta_modelica_builtin.h
Expand Up @@ -175,6 +175,11 @@ void boxptr_setGlobalRoot(modelica_metatype, modelica_metatype);
modelica_metatype boxptr_valueConstructor(modelica_metatype);
#define referenceEq(X,Y) ((X) == (Y))

typedef modelica_real realMaxLit_rettype;
typedef modelica_integer intMaxLit_rettype;
realMaxLit_rettype realMaxLit();
intMaxLit_rettype intMaxLit();

#if defined(__cplusplus)
}
#endif
Expand Down

0 comments on commit 913f539

Please sign in to comment.