------------------------------------------------------------------------
r1460 | eudoxos | 2008-08-11 14:02:07 +0200 (pon, 11 sie 2008) | 4 lines
Changed paths:
   M /trunk/SConstruct
   M /trunk/lib/serialization/FundamentalHandler.tpp

1. Permit non-zero integeres as bool - sometimes the serializaer confuses bool 
with int; give warning to console about that.
2. the -opt profile (and optimize=1) generates instruction set for the current 
machine (gcc: -march=native) which means that the code may not run on different 
processor (e.g. core2 code will not run on Pentium IV). Please let me know if 
this is problem for someone.


------------------------------------------------------------------------
Index: lib/serialization/FundamentalHandler.tpp
===================================================================
--- lib/serialization/FundamentalHandler.tpp    (revision 1459)
+++ lib/serialization/FundamentalHandler.tpp    (revision 1460)
@@ -99,8 +99,7 @@
                try{
                        *tmp = lexical_cast<Type>(*tmpStr);
                } catch(boost::bad_lexical_cast& e){
-                       if(a.type()==typeid(bool*) && atoi(tmpStr->c_str())!=0) 
{ *tmp=lexical_cast<Type>("true"); cerr<<"Offensive bool value `"<<*tmpStr<<"' 
encountered.!!"<<endl; }
-                       else throw e;
+                       if(typeid(tmp)==typeid(bool*) && 
atoi(tmpStr->c_str())!=0) { cerr<<"warning: offensive bool value 
`"<<*tmpStr<<"' encountered (interpreted as true)."<<endl; 
*tmp=lexical_cast<Type>("1"); /* cerr<<"New value: 
"<<lexical_cast<string>(*tmp)<<endl; cerr<<"Atoi returns 
"<<atoi(tmpStr->c_str())<<", bool !=0 is "<<(atoi(tmpStr->c_str())!=0)<<endl;*/ 
}
                }
        }
        else if (a.type()==typeid(string*)) // serialization - writing to 
string from some Type
@@ -112,33 +111,6 @@
        else
                cerr<<"lexical_cast(XML): (de)serialization format 
mismatch"<<endl;
        }
-       else if(FormatChecker::format==FormatChecker::BIN){
-       // Binary serialization
-       if (a.type()==typeid(const vector<unsigned char>*)) // from binary 
stream to Type
-       {
-               const vector<unsigned char>* tmpBin = any_cast< const 
vector<unsigned char>* >(a);
-               Type * tmp = any_cast<Type*>(ac.getAddress());
-               BOOST_STATIC_ASSERT((boost::is_POD<Type>::value));
-               std::vector<unsigned char>::const_iterator ptr = 
(*tmpBin).begin();
-               std::vector<unsigned char>::const_iterator end = 
(*tmpBin).end();
-               if(sizeof(Type) != (*tmpBin).size())
-                       throw 
HandlerError(SerializationExceptions::LexicalCopyBinError);
-               unsigned char *ptr2 = reinterpret_cast<unsigned char *>(tmp);
-               std::copy(ptr,end,ptr2);
-       }
-       else if (a.type()==typeid(vector<unsigned char>*)) // from Type to 
binary stream
-       { CHK_BIN();
-               vector<unsigned char>* tmpBin = any_cast< vector<unsigned 
char>* >(a);
-               Type * tmp = any_cast<Type*>(ac.getAddress());
-               (*tmpBin).clear();
-               const unsigned char* ptr = reinterpret_cast<const unsigned 
char*>(tmp);
-               const unsigned char* end = ptr + sizeof(Type);
-               (*tmpBin).resize(sizeof(Type));
-               std::copy(ptr, end, (*tmpBin).begin() );
-       }
-       else
-               cerr<<"lexical_cast(BIN): (de)serialization format 
mismatch"<<endl;
-       }
        else // never reached
                throw HandlerError(SerializationExceptions::LexicalCopyError);
 }
Index: SConstruct
===================================================================
--- SConstruct  (revision 1459)
+++ SConstruct  (revision 1460)
@@ -383,7 +383,7 @@
 else: env.Append(CXXFLAGS='-O2')
 if env['openmp']: env.Append(CXXFLAGS='-fopenmp',LIBS='gomp')
 if env['optimize']:
-       env.Append(CXXFLAGS=Split('-O3 -ffast-math'),
+       env.Append(CXXFLAGS=Split('-O3 -ffast-math -march=native'),
                
CPPDEFINES=[('YADE_CAST','static_cast'),('YADE_PTR_CAST','static_pointer_cast'),'NDEBUG'])
        # NDEBUG is used in /usr/include/assert.h: when defined, asserts() are 
no-ops
 

_______________________________________________
Mailing list: https://launchpad.net/~yade-dev
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~yade-dev
More help   : https://help.launchpad.net/ListHelp

Reply via email to