From: caremoli Date: Wed, 12 Jan 2011 16:12:04 +0000 (+0000) Subject: CCAR: protect Fortran Calcium calls against unneeded float arguments incorrectly... X-Git-Tag: Start_BR_19998_21191~101 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6154bba6020465244a40f05f034ba93aabf304a2;p=modules%2Fkernel.git CCAR: protect Fortran Calcium calls against unneeded float arguments incorrectly initialized --- diff --git a/src/Basics/Basics_Utils.cxx b/src/Basics/Basics_Utils.cxx index 6ff3cf36c..161bc5923 100644 --- a/src/Basics/Basics_Utils.cxx +++ b/src/Basics/Basics_Utils.cxx @@ -23,10 +23,12 @@ // #include "Basics_Utils.hxx" #include +#include #ifndef WIN32 #include #include +#include #else #include #endif @@ -103,4 +105,24 @@ namespace Kernel_Utils return guid; } +#ifndef WIN32 + void print_traceback() + { + void *array[50]; + size_t size; + char **strings; + size_t i; + + size = backtrace (array, 40); + strings = backtrace_symbols (array, size); + + for (i = 0; i < size; i++) + { + std::cerr << strings[i] << std::endl; + } + + free (strings); + } +#endif + } diff --git a/src/Basics/Basics_Utils.hxx b/src/Basics/Basics_Utils.hxx index ce0513c49..b4aa5e241 100644 --- a/src/Basics/Basics_Utils.hxx +++ b/src/Basics/Basics_Utils.hxx @@ -52,6 +52,9 @@ namespace Kernel_Utils //! Get predefined GUID BASICS_EXPORT std::string GetGUID( GUIDtype ); +#ifndef WIN32 + BASICS_EXPORT void print_traceback(); +#endif } #define START_TIMING(name) static long name##tcount=0;static long name##cumul;long name##tt0; timeval name##tv; gettimeofday(&name##tv,0); \ diff --git a/src/Container/SALOME_Container.cxx b/src/Container/SALOME_Container.cxx index 45ff4e069..fb89c99f5 100644 --- a/src/Container/SALOME_Container.cxx +++ b/src/Container/SALOME_Container.cxx @@ -106,7 +106,7 @@ void AttachDebugger() void Handler(int theSigId) { - std::cerr << "SIGSEGV: " << std::endl; + std::cerr << "Signal= "<< theSigId << std::endl; AttachDebugger(); //to exit or not to exit _exit(1); @@ -136,6 +136,7 @@ int main(int argc, char* argv[]) if(getenv ("DEBUGGER")) { setsig(SIGSEGV,&Handler); + setsig(SIGFPE,&Handler); std::set_terminate(&terminateHandler); std::set_unexpected(&unexpectedHandler); } diff --git a/src/DSC/DSC_User/Datastream/Calcium/CalciumMacroCInterface.hxx b/src/DSC/DSC_User/Datastream/Calcium/CalciumMacroCInterface.hxx index 7773759f7..0ce1a1844 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/CalciumMacroCInterface.hxx +++ b/src/DSC/DSC_User/Datastream/Calcium/CalciumMacroCInterface.hxx @@ -65,8 +65,13 @@ Id : $Id$ size_t * nRead, _type _qual ** data ) \ { \ Superv_Component_i * _component = static_cast(component); \ - double _ti=*ti; \ - double _tf=*tf; \ + double _ti=0.; \ + double _tf=0.; \ + if(dependencyType == CalciumTypes::CP_TEMPS) \ + { \ + _ti=*ti; \ + _tf=*tf; \ + } \ size_t _nRead=0; \ size_t _bufferLength=bufferLength; \ \ @@ -118,7 +123,9 @@ Id : $Id$ DEBTRACE( "-------- CalciumInterface(ecriture Inter Part) MARK 0 ------------------" ) \ Superv_Component_i * _component = static_cast(component); \ /* Je ne sais pas pourquoi, je n'arrive pas à passer t par valeur : corruption de la pile*/ \ - double _t=*t; \ + double _t=0.; \ + if(dependencyType == CalciumTypes::CP_TEMPS) \ + _t=*t; \ size_t _bufferLength=bufferLength; \ if ( IsSameType< _porttype , cplx >::value ) _bufferLength=_bufferLength*2; \ DEBTRACE( "-------- CalciumInterface(ecriture Inter Part) MARK 1 ------------------" ) \ diff --git a/src/DSC/DSC_User/Datastream/Calcium/calciumf.c b/src/DSC/DSC_User/Datastream/Calcium/calciumf.c index 8986e1c47..6470a87f5 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/calciumf.c +++ b/src/DSC/DSC_User/Datastream/Calcium/calciumf.c @@ -63,6 +63,24 @@ static void free_str1(char *nom) free(nom); } +#define FLOAT_OK 0 +#define POS_INFINITY 1 +#define NEG_INFINITY 2 +#define QUIET_NAN 3 +#define SIGNALING_NAN 4 + +int CheckFloat(float* value) +{ + unsigned long L1 = *(unsigned long*)value; + unsigned long L2 = L1 & 0x7fffffff; + if (L2 < 0x7f800000) return (FLOAT_OK); // Short circuit for most values + if (L1 == 0x7f800000) return (POS_INFINITY); + else if (L1 == 0xff800000) return (NEG_INFINITY); + else if (L2 >= 0x7fc00000) return (QUIET_NAN); + else if ((L2 >= 0x7f800001) && (L2 <= 0x7fbfffff)) return (SIGNALING_NAN); + else return (FLOAT_OK); +} + /**********************************************/ /* INTERFACES DE DÉBUT ET DE FIN DE COUPLAGE */ /**********************************************/ @@ -284,6 +302,8 @@ void F_FUNC(cpech,CPECH)(long *compo,cal_int *dep,float *ti,cal_int *iter,STR_PS char ** tabChaine=NULL; cal_int index=0,index2=0; char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom)); + float tti=0.; + if(*dep == CP_TEMPS)tti=*ti; tabChaine = (char **) malloc(sizeof(char *) * *n); for (index = 0; index < *n; index++) @@ -298,7 +318,7 @@ void F_FUNC(cpech,CPECH)(long *compo,cal_int *dep,float *ti,cal_int *iter,STR_PS } } - *err=cp_ech_fort_((void *)*compo,*dep,*ti,*iter,cnom,*n,tabChaine,STR_LEN(tab) ); + *err=cp_ech_fort_((void *)*compo,*dep,tti,*iter,cnom,*n,tabChaine,STR_LEN(tab) ); if (tabChaine != (char **) NULL) { @@ -311,34 +331,41 @@ void F_FUNC(cpech,CPECH)(long *compo,cal_int *dep,float *ti,cal_int *iter,STR_PS void F_FUNC(cpedb,CPEDB)(long *compo,cal_int *dep,double *ti,cal_int *iter,STR_PSTR(nom),cal_int *n, double *tab,cal_int *err STR_PLEN(nom)) { + double tti=0.; + if(*dep == CP_TEMPS)tti=*ti; char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom)); - *err=cp_edb_fort_((void *)*compo,*dep,*ti,*iter,cnom,*n,tab); + *err=cp_edb_fort_((void *)*compo,*dep,tti,*iter,cnom,*n,tab); free_str1(cnom); } void F_FUNC(cpere,CPERE)(long *compo,cal_int *dep,float *ti,cal_int *iter,STR_PSTR(nom),cal_int *n, float *tab,cal_int *err STR_PLEN(nom)) { + float tti=0.; + if(*dep == CP_TEMPS)tti=*ti; char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom)); - *err=cp_ere_fort_((void *)*compo,*dep,*ti,*iter,cnom,*n,tab); + *err=cp_ere_fort_((void *)*compo,*dep,tti,*iter,cnom,*n,tab); free_str1(cnom); } void F_FUNC(cpecp,CPECP)(long *compo,cal_int *dep,float *ti,cal_int *iter,STR_PSTR(nom),cal_int *n, float *tab,cal_int *err STR_PLEN(nom)) { + float tti=0.; + if(*dep == CP_TEMPS)tti=*ti; char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom)); - *err=cp_ecp_fort_((void *)*compo,*dep,*ti,*iter,cnom,*n,tab); + *err=cp_ecp_fort_((void *)*compo,*dep,tti,*iter,cnom,*n,tab); free_str1(cnom); } void F_FUNC(cpein,CPEIN)(long *compo,cal_int *dep,float *ti,cal_int *iter,STR_PSTR(nom),cal_int *n, int *tab,cal_int *err STR_PLEN(nom)) { - + float tti=0.; + if(*dep == CP_TEMPS)tti=*ti; char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom)); #if !SIZEOF_INT #error "The macro SIZEOF_INT must be defined." #elif SIZEOF_INT == 4 - *err=cp_ein_fort_((void *)*compo,*dep,*ti,*iter,cnom,*n,tab); + *err=cp_ein_fort_((void *)*compo,*dep,tti,*iter,cnom,*n,tab); #else fprintf(stderr,"CPEIN: %s %f %d : Can't use fortran INTEGER*4 because int C is not 32bits long on this machine.\n", cnom, *ti,*iter); @@ -348,12 +375,13 @@ void F_FUNC(cpein,CPEIN)(long *compo,cal_int *dep,float *ti,cal_int *iter,STR_PS void F_FUNC(cpelg,CPELG)(long *compo,cal_int *dep,float *ti,cal_int *iter,STR_PSTR(nom),cal_int *n, long *tab,cal_int *err STR_PLEN(nom)) { - + float tti=0.; + if(*dep == CP_TEMPS)tti=*ti; char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom)); #if !SIZEOF_LONG #error "The macro SIZEOF_LONG must be defined." #elif SIZEOF_LONG == 8 - *err=cp_elg_fort_((void *)*compo,*dep,*ti,*iter,cnom,*n,tab); + *err=cp_elg_fort_((void *)*compo,*dep,tti,*iter,cnom,*n,tab); #else fprintf(stderr,"CPELG: %s %f %d : Can't use fortran INTEGER*8 because long C is not 64bits long on this machine.\n", cnom, *ti,*iter); @@ -363,12 +391,13 @@ void F_FUNC(cpelg,CPELG)(long *compo,cal_int *dep,float *ti,cal_int *iter,STR_PS void F_FUNC(cpeln,CPELN)(long *compo,cal_int *dep,float *ti,cal_int *iter,STR_PSTR(nom),cal_int *n, long *tab,cal_int *err STR_PLEN(nom)) { - + float tti=0.; + if(*dep == CP_TEMPS)tti=*ti; char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom)); #if !SIZEOF_LONG #error "The macro SIZEOF_LONG must be defined." #elif SIZEOF_LONG == 8 - *err=cp_eln_fort_((void *)*compo,*dep,*ti,*iter,cnom,*n,tab); + *err=cp_eln_fort_((void *)*compo,*dep,tti,*iter,cnom,*n,tab); #else fprintf(stderr,"CPELN: %s %f %d : Can't use fortran INTEGER*8 because long C is not 64bits long on this machine.\n", cnom, *ti,*iter); @@ -379,15 +408,19 @@ void F_FUNC(cpeln,CPELN)(long *compo,cal_int *dep,float *ti,cal_int *iter,STR_PS void F_FUNC(cpeen,CPEEN)(long *compo,cal_int *dep,float *ti,cal_int *iter,STR_PSTR(nom),cal_int *n, cal_int *tab,cal_int *err STR_PLEN(nom)) { + float tti=0.; + if(*dep == CP_TEMPS)tti=*ti; char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom)); - *err=cp_een_fort_((void *)*compo,*dep,*ti,*iter,cnom,*n,tab); + *err=cp_een_fort_((void *)*compo,*dep,tti,*iter,cnom,*n,tab); free_str1(cnom); } void F_FUNC(cpelo,CPELO)(long *compo,cal_int *dep,float *ti,cal_int *iter,STR_PSTR(nom),cal_int *n, int *tab,cal_int *err STR_PLEN(nom)) { + float tti=0.; + if(*dep == CP_TEMPS)tti=*ti; char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom)); - *err=cp_elo_fort_((void *)*compo,*dep,*ti,*iter,cnom,*n,tab); + *err=cp_elo_fort_((void *)*compo,*dep,tti,*iter,cnom,*n,tab); free_str1(cnom); }