Changeset 15338


Ignore:
Timestamp:
2013-02-26T16:43:56+01:00 (11 years ago)
Author:
hkiel
Message:
  • add some "static" keywords
  • stop file compare when first difference occured
  • use cached WinLibPath
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Compiler/runtime/SimulationResults.c

    r15115 r15338  
    3131} SimulationResult_Globals;
    3232
    33 void SimulationResultsImpl__close(SimulationResult_Globals* simresglob)
     33static void SimulationResultsImpl__close(SimulationResult_Globals* simresglob)
    3434{
    3535  switch (simresglob->curFormat) {
  • trunk/Compiler/runtime/SimulationResultsCmp.c

    r15023 r15338  
    117117}
    118118
    119 double absdouble(double d)
     119static inline double absdouble(double d)
    120120{
    121121  if (d > 0.0)
     
    125125}
    126126
    127 char ** getVars(void *vars, unsigned int* nvars)
     127static char ** getVars(void *vars, unsigned int* nvars)
    128128{
    129129  char **cmpvars=NULL;
     
    170170}
    171171
    172 DataField getData(const char *varname,const char *filename, unsigned int size, SimulationResult_Globals* srg)
     172static DataField getData(const char *varname,const char *filename, unsigned int size, SimulationResult_Globals* srg)
    173173{
    174174  DataField res;
     
    221221
    222222/* see http://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/ */
    223 char AlmostEqualRelativeAndAbs(double A, double B)
     223static char AlmostEqualRelativeAndAbs(double A, double B)
    224224{
    225225  /* Check if the numbers are really close -- needed
     
    238238}
    239239
    240 unsigned int cmpData(char* varname, DataField *time, DataField *reftime, DataField *data, DataField *refdata, double reltol, double abstol, DiffDataField *ddf, char **cmpdiffvars, unsigned int vardiffindx)
     240static unsigned int cmpData(char* varname, DataField *time, DataField *reftime, DataField *data, DataField *refdata, double reltol, double abstol, DiffDataField *ddf, char **cmpdiffvars, unsigned int vardiffindx)
    241241{
    242242  unsigned int i,j,k,j_event;
     
    541541}
    542542
    543 int writeLogFile(const char *filename,DiffDataField *ddf,const char *f,const char *reff,double reltol,double abstol)
     543static int writeLogFile(const char *filename,DiffDataField *ddf,const char *f,const char *reff,double reltol,double abstol)
    544544{
    545545  FILE* fout;
  • trunk/Compiler/runtime/System_rml.c

    r15269 r15338  
    329329
    330330  if(fileSize1 != fileSize2)
     331  {
    331332    res=-1;
     333  }
    332334  else
     335  {
    333336    for(i=0;i<fileSize1;++i)
     337    {
    334338      if(fgetc(fp1) != fgetc(fp2))
     339      {
    335340        res=-1;
     341        break;
     342      }
     343    }
     344  }
    336345  fclose(fp1);fclose(fp2);
    337346
     
    12321241 * helper function for getSymbolicLinkPath
    12331242 **/
    1234 char *mergePathWithLink(char *path,char *linkPath)
     1243static char *mergePathWithLink(char *path,char *linkPath)
    12351244{
    12361245    char *lastSlash;
     
    12551264 *
    12561265 * */
    1257 char *getSymbolicLinkPath(char* path)
     1266static char *getSymbolicLinkPath(char* path)
    12581267{
    12591268    int err,readChars;
     
    12991308 * 4) isLink(/home/bjozac/newDir/a.mo)
    13001309 **/
    1301 char* findSymbolicLinks(char* path)
    1302 {
    1303     int i;
    1304     char *curRes = (char *) malloc(sizeof(char)*MAXPATHLEN);
    1305     char *curPos;
    1306     char *endPos;
    1307     curRes[0]='\0';
    1308     curPos = path;
    1309     if(path[0]=='/'){
    1310   curRes = strcat(curRes,"/");
    1311         curPos = &path[1]; // skip first slash, will add when finished.
    1312     }
    1313 
    1314     for(i=0;i<100;++i){
    1315         endPos = strchr(curPos,'/');
    1316         if(endPos==NULL){ // End OF String
     1310static char* findSymbolicLinks(char* path)
     1311{
     1312  int i;
     1313  char *curRes = (char *) malloc(sizeof(char)*MAXPATHLEN);
     1314  char *curPos;
     1315  char *endPos;
     1316  curRes[0]='\0';
     1317  curPos = path;
     1318  if(path[0]=='/'){
     1319    curRes = strcat(curRes,"/");
     1320    curPos = &path[1]; // skip first slash, will add when finished.
     1321  }
     1322
     1323  for(i=0;i<100;++i){
     1324    endPos = strchr(curPos,'/');
     1325    if(endPos==NULL){ // End OF String
    13171326      endPos = strrchr(curPos,'\0');
    13181327      strncat(curRes,curPos,endPos-curPos); // add filename
     
    13211330      //printf("\tbecame: %s\n",curRes);
    13221331      free(path);
    1323           return curRes;
    1324   }
    1325   strncat(curRes,curPos,endPos-curPos);
    1326   curRes = getSymbolicLinkPath(curRes);
    1327   if(curRes[strlen(curRes)-1] != '/')
    1328           strcat(curRes,"/");
    1329   //printf("path: %s\n",curRes);
    1330   curPos = endPos+1;
     1332      return curRes;
    13311333    }
     1334    strncat(curRes,curPos,endPos-curPos);
     1335    curRes = getSymbolicLinkPath(curRes);
     1336    if(curRes[strlen(curRes)-1] != '/')
     1337    {
     1338      strcat(curRes,"/");
     1339    }
     1340    //printf("path: %s\n",curRes);
     1341    curPos = endPos+1;
     1342  }
    13321343    if(strchr(path,'/')!=NULL)
    13331344  fprintf(stderr,"possible error in save-function\n");
    1334     free(path);
    1335     return curRes;
     1345  free(path);
     1346  return curRes;
    13361347}
    13371348
     
    13411352
    13421353*/
    1343 char* normalizePath(const char* src)
     1354static char* normalizePath(const char* src)
    13441355{
    13451356  const char* srcEnd = src + strlen(src);
     
    15411552    /* adrpo added 2004-10-28 */
    15421553    //free(files[i]->d_name);
    1543   free(files[i]);
     1554    free(files[i]);
    15441555  }
    15451556  rmlA0 = (void*) res;
  • trunk/Compiler/runtime/errorext.h

    r11994 r15338  
    6666char* ErrorImpl__rollBackAndPrint(const char* id); // Returns the error string that we rolled back. free this resource
    6767
     68extern int showErrorMessages;
     69
    6870#ifdef __cplusplus
    6971  }
     
    8082       const char* message,
    8183       std::list<std::string> tokens);
    82        
     84
    8385  void add_source_message(int errorID,
    8486        const char* type,
     
    9395        const char* filename);
    9496
    95 extern int showErrorMessages;
    96 
    9797#endif
    9898
  • trunk/Compiler/runtime/printimpl.c

    r15318 r15338  
    3636#include "systemimpl.h"
    3737
    38 /* adrpo: this is defined in errorext. (enabled with omc +showErrorMessages) */
    39 extern int showErrorMessages;
     38/* adrpo: "int showErrorMessages" is defined in errorext. (enabled with omc +showErrorMessages) */
    4039
    4140#define GROWTH_FACTOR 1.4  /* According to some rumors of buffer growth */
     
    5049#define errorCursize Print_var_errorCursize
    5150
    52 char *buf = NULL;
    53 char *errorBuf = NULL;
    54 
    55 int nfilled=0;
    56 int cursize=0;
    57 
    58 int errorNfilled=0;
    59 int errorCursize=0;
    60 
    61  char** savedBuffers=0;
    62  long* savedCurSize;
    63  long* savedNfilled;
     51static char *buf = NULL;
     52static char *errorBuf = NULL;
     53
     54static int nfilled=0;
     55static int cursize=0;
     56
     57static int errorNfilled=0;
     58static int errorCursize=0;
     59
     60static char** savedBuffers=0;
     61static long* savedCurSize;
     62static long* savedNfilled;
    6463
    6564static int increase_buffer(void)
     
    136135}
    137136
    138 int print_error_buf_impl(const char *str)
     137static int print_error_buf_impl(const char *str)
    139138{
    140139  /*  printf("cursize: %d, nfilled %d, strlen: %d\n",cursize,nfilled,strlen(str));*/
     
    242241
    243242/* returns NULL on failure */
    244 const char* PrintImpl__getString(void)
     243static const char* PrintImpl__getString(void)
    245244{
    246245  if(buf == NULL || buf[0]=='\0' || cursize==0){
     
    360359    savedCurSize[handle] = 0;
    361360    savedNfilled[handle] = 0;
    362     if (buf == 0) { 
     361    if (buf == 0) {
    363362      fprintf(stderr,"Internal error, handle %d does not contain a valid buffer pointer\n",handle);
    364363      return 1;
     
    372371  long freeHandle,foundHandle=0;
    373372
    374   if (! savedBuffers) { 
     373  if (! savedBuffers) {
    375374    savedBuffers = (char**)malloc(MAXSAVEDBUFFERS*sizeof(char*));
    376     if (!savedBuffers) { 
     375    if (!savedBuffers) {
    377376      fprintf(stderr, "Internal error allocating savedBuffers in Print.saveAndClearBuf\n");
    378377      return -1;
     
    380379    memset(savedBuffers,0,MAXSAVEDBUFFERS);
    381380  }
    382   if (! savedCurSize) { 
     381  if (! savedCurSize) {
    383382    savedCurSize = (long*)malloc(MAXSAVEDBUFFERS*sizeof(long*));
    384     if (!savedCurSize) { 
     383    if (!savedCurSize) {
    385384      fprintf(stderr, "Internal error allocating savedCurSize in Print.saveAndClearBuf\n");
    386385      return -1;
     
    388387    memset(savedCurSize,0,MAXSAVEDBUFFERS);
    389388  }
    390   if (! savedNfilled) { 
     389  if (! savedNfilled) {
    391390    savedNfilled = (long*)malloc(MAXSAVEDBUFFERS*sizeof(long*));
    392     if (!savedNfilled) { 
     391    if (!savedNfilled) {
    393392      fprintf(stderr, "Internal error allocating savedNfilled in Print.saveAndClearBuf\n");
    394393      return -1;
  • trunk/Compiler/runtime/settingsimpl.c

    r13235 r15338  
    6666extern int SystemImpl__directoryExists(const char*);
    6767
    68 char* winPath = NULL;
     68static char* winPath = NULL;
    6969
    7070// Do not free or modify the returned variable. It's part of the environment!
     
    9393    i++;
    9494  }
    95   /* set the termination */
    96   winPath[i] = '\0';
    9795  return (const char*)winPath;
    9896#endif
     
    10098}
    10199
    102 char* winLibPath = NULL;
     100static char* winLibPath = NULL;
    103101
    104102// Do not free the returned variable. It's malloc'ed
     
    132130
    133131#if defined(__MINGW32__) || defined(_MSC_VER)
     132  /* already set, set it only once! */
     133  if (winLibPath != NULL)
     134    return winLibPath;
     135
    134136  /* adrpo: translate this to forward slashes! */
    135137  /* duplicate the path */
     
    146148    i++;
    147149  }
    148   /* set the termination */
    149   winLibPath[i] = '\0';
    150150  return winLibPath;
    151151#endif
  • trunk/SimulationRuntime/c/simulation/solver/radau.c

    r15313 r15338  
    3333 */
    3434
     35#include <string.h>
     36
    3537#include "radau.h"
    3638#ifdef WITH_SUNDIALS
    3739
    38 int allocateNlpOde(KINODE *kinOde);
    39 int allocateKINSOLODE(KINODE *kinOde);
    40 
    41 int boundsVars(KINODE *kinOde);
    42 
    43 int radau1Coeff(KINODE *kinOd);
    44 int radau3Coeff(KINODE *kinOde);
    45 int radau5Coeff(KINODE *kinOd);
    46 int lobatto4Coeff(KINODE *kinOd);
    47 int lobatto6Coeff(KINODE *kinOd);
    48 
    49 int radau1Res(N_Vector z, N_Vector f, void* user_data);
    50 int radau3Res(N_Vector z, N_Vector f, void* user_data);
    51 int radau5Res(N_Vector z, N_Vector f, void* user_data);
    52 int lobatto2Res(N_Vector z, N_Vector f, void* user_data);
    53 int lobatto4Res(N_Vector z, N_Vector f, void* user_data);
    54 int lobatto6Res(N_Vector z, N_Vector f, void* user_data);
     40static int allocateNlpOde(KINODE *kinOde);
     41static int allocateKINSOLODE(KINODE *kinOde);
     42
     43static int freeImOde(void *nlpode, int N);
     44static int freeKinsol(void * kOde);
     45
     46static int boundsVars(KINODE *kinOde);
     47
     48static int radau1Coeff(KINODE *kinOd);
     49static int radau3Coeff(KINODE *kinOde);
     50static int radau5Coeff(KINODE *kinOd);
     51static int lobatto4Coeff(KINODE *kinOd);
     52static int lobatto6Coeff(KINODE *kinOd);
     53
     54static int radau1Res(N_Vector z, N_Vector f, void* user_data);
     55static int radau3Res(N_Vector z, N_Vector f, void* user_data);
     56static int radau5Res(N_Vector z, N_Vector f, void* user_data);
     57static int lobatto2Res(N_Vector z, N_Vector f, void* user_data);
     58static int lobatto4Res(N_Vector z, N_Vector f, void* user_data);
     59static int lobatto6Res(N_Vector z, N_Vector f, void* user_data);
    5560
    5661int allocateKinOde(DATA* data, SOLVER_INFO* solverInfo, int flag, int N)
     
    6873}
    6974
    70 int allocateNlpOde(KINODE *kinOde)
     75static int allocateNlpOde(KINODE *kinOde)
    7176{
    7277  NLPODE * nlp = (NLPODE*) kinOde->nlp;
     
    105110}
    106111
    107 int boundsVars(KINODE *kinOde)
     112static int boundsVars(KINODE *kinOde)
    108113{
    109114  int i;
     
    127132}
    128133
    129 int radau5Coeff(KINODE *kinOde)
     134static int radau5Coeff(KINODE *kinOde)
    130135{
    131136  int i, N;
     
    160165}
    161166
    162 int radau3Coeff(KINODE *kinOde)
     167static int radau3Coeff(KINODE *kinOde)
    163168{
    164169  int i, N;
     
    185190}
    186191
    187 int radau1Coeff(KINODE *kinOde)
     192static int radau1Coeff(KINODE *kinOde)
    188193{
    189194  NLPODE * nlp = (NLPODE*) kinOde->nlp;
     
    193198}
    194199
    195 int lobatto4Coeff(KINODE *kinOde)
     200static int lobatto4Coeff(KINODE *kinOde)
    196201{
    197202  NLPODE * nlp = (NLPODE*) kinOde->nlp;
     
    203208}
    204209
    205 int lobatto6Coeff(KINODE *kinOde)
     210static int lobatto6Coeff(KINODE *kinOde)
    206211{
    207212  int i, N;
     
    239244}
    240245
    241 int allocateKINSOLODE(KINODE *kinOde)
     246static int allocateKINSOLODE(KINODE *kinOde)
    242247{
    243248  int N = kinOde->N;
     
    289294}
    290295
    291 int freeImOde(void *nlpode, int N)
     296static int freeImOde(void *nlpode, int N)
    292297{
    293298  int i;
     
    307312}
    308313
    309 int freeKinsol(void * kOde)
     314static int freeKinsol(void * kOde)
    310315{
    311316  KDATAODE *kData = (KDATAODE*) kOde;
     
    317322}
    318323
    319 int initKinsol(KINODE *kinOde)
     324static int initKinsol(KINODE *kinOde)
    320325{
    321326  int i,j,k;
     
    407412}
    408413
    409 int refreshModell(DATA* data, double* x, double time)
     414static int refreshModell(DATA* data, double* x, double time)
    410415{
    411416  int i;
     
    419424}
    420425
    421 int radau5Res(N_Vector x, N_Vector f, void* user_data)
     426static int radau5Res(N_Vector x, N_Vector f, void* user_data)
    422427{
    423428  int i,sub2,sub3;
     
    490495}
    491496
    492 int radau3Res(N_Vector x, N_Vector f, void* user_data)
     497static int radau3Res(N_Vector x, N_Vector f, void* user_data)
    493498{
    494499  int i,sub2, N;
     
    545550
    546551
    547 int radau1Res(N_Vector x, N_Vector f, void* user_data)
     552static int radau1Res(N_Vector x, N_Vector f, void* user_data)
    548553{
    549554  int i,sub2, N;
     
    584589}
    585590
    586 int lobatto2Res(N_Vector x, N_Vector f, void* user_data)
     591static int lobatto2Res(N_Vector x, N_Vector f, void* user_data)
    587592{
    588593  int i, N;
     
    625630}
    626631
    627 int lobatto4Res(N_Vector x, N_Vector f, void* user_data)
     632static int lobatto4Res(N_Vector x, N_Vector f, void* user_data)
    628633{
    629634  int i,sub2, N;
     
    677682}
    678683
    679 int lobatto6Res(N_Vector x, N_Vector f, void* user_data)
     684static int lobatto6Res(N_Vector x, N_Vector f, void* user_data)
    680685{
    681686  int i,sub2, N;
Note: See TracChangeset for help on using the changeset viewer.