diff -Naurw boost_1_33_1.orig/boost/archive/basic_archive.hpp boost_1_33_1/boost/archive/basic_archive.hpp --- boost_1_33_1.orig/boost/archive/basic_archive.hpp 2005-09-01 08:55:24.000000000 +0200 +++ boost_1_33_1/boost/archive/basic_archive.hpp 2007-02-08 17:00:17.000000000 +0100 @@ -16,6 +16,8 @@ // See http://www.boost.org for updates, documentation, and revision history. +#define BOOST_CROSS_ARCHITECTURE_COMPATIBLE + #include #include #include diff -Naurw boost_1_33_1.orig/boost/archive/basic_binary_iprimitive.hpp boost_1_33_1/boost/archive/basic_binary_iprimitive.hpp --- boost_1_33_1.orig/boost/archive/basic_binary_iprimitive.hpp 2005-07-02 07:52:14.000000000 +0200 +++ boost_1_33_1/boost/archive/basic_binary_iprimitive.hpp 2007-02-08 17:00:45.000000000 +0100 @@ -51,6 +51,11 @@ namespace boost { namespace archive { +#ifdef BOOST_CROSS_ARCHITECTURE_COMPATIBLE + extern bool iam32andReadDataFrom64; + extern bool iam64andReadDataFrom32; +#endif + ///////////////////////////////////////////////////////////////////////////// // class binary_iarchive - read serialized objects from a input binary stream template @@ -79,6 +84,50 @@ load_binary(& t, sizeof(T)); } +#ifdef BOOST_CROSS_ARCHITECTURE_COMPATIBLE + // Patch: 2006-02-07 by Steve Gury < steve dot gury at gmail dot com > + // If native format is different, read correctly data and store it in + // the architecture native format + void load(unsigned long & t){ + if( boost::archive::iam32andReadDataFrom64 ) + { + unsigned long long tt; //64bits on all architecture + // Warning: Possible loss of precision + load_binary(& tt, sizeof(tt)); + t = static_cast(tt); + } + else if( boost::archive::iam64andReadDataFrom32 ) + { + unsigned int tt; // 32bits on all architecture + load_binary( &tt , sizeof(tt) ); + t = static_cast(tt); + } + else + load_binary(& t, sizeof(t)); + } + + // Patch: 2006-02-07 by Steve Gury < steve dot gury at gmail dot com > + // If native format is different, read correctly data and store it in + // the architecture native format + void load(long & t){ + if( boost::archive::iam32andReadDataFrom64 ) + { + long long tt; //64bits on all architecture + // Warning: Possible loss of precision + load_binary(& tt, sizeof(tt)); + t = static_cast(tt); + } + else if( boost::archive::iam64andReadDataFrom32 ) + { + int tt; // 32bits on all architecture + load_binary( &tt , sizeof(tt) ); + t = static_cast(tt); + } + else + load_binary(& t, sizeof(t)); + } +#endif + BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) load(std::string &s); #ifndef BOOST_NO_STD_WSTRING diff -Naurw boost_1_33_1.orig/boost/archive/binary_iarchive.hpp boost_1_33_1/boost/archive/binary_iarchive.hpp --- boost_1_33_1.orig/boost/archive/binary_iarchive.hpp 2005-04-21 06:51:46.000000000 +0200 +++ boost_1_33_1/boost/archive/binary_iarchive.hpp 2007-02-08 17:01:03.000000000 +0100 @@ -62,9 +62,22 @@ ), basic_binary_iarchive(flags) { - if(0 == (flags & no_header)){ + #ifdef BOOST_CROSS_ARCHITECTURE_COMPATIBLE + if(0 == (flags & no_header)) init(); + else + { + #if ! defined(__MWERKS__) + this->basic_binary_iprimitive::init(); + #else + basic_binary_iprimitive::init(); + #endif + } + #else + if(0 == (flags & no_header)) + init(); + #endif } }; diff -Naurw boost_1_33_1.orig/boost/archive/binary_oarchive.hpp boost_1_33_1/boost/archive/binary_oarchive.hpp --- boost_1_33_1.orig/boost/archive/binary_oarchive.hpp 2005-04-21 06:51:46.000000000 +0200 +++ boost_1_33_1/boost/archive/binary_oarchive.hpp 2007-02-08 17:01:03.000000000 +0100 @@ -62,8 +62,21 @@ ), basic_binary_oarchive(flags) { + #ifdef BOOST_CROSS_ARCHITECTURE_COMPATIBLE if(0 == (flags & no_header)) init(); + else + { + #if ! defined(__MWERKS__) + this->basic_binary_oprimitive::init(); + #else + basic_binary_oprimitive::init(); + #endif + } + #else + if(0 == (flags & no_header)) + init(); + #endif } }; diff -Naurw boost_1_33_1.orig/boost/archive/impl/basic_binary_iprimitive.ipp boost_1_33_1/boost/archive/impl/basic_binary_iprimitive.ipp --- boost_1_33_1.orig/boost/archive/impl/basic_binary_iprimitive.ipp 2005-07-02 07:52:14.000000000 +0200 +++ boost_1_33_1/boost/archive/impl/basic_binary_iprimitive.ipp 2007-02-08 17:01:49.000000000 +0100 @@ -32,6 +32,10 @@ namespace boost { namespace archive { + typedef unsigned int U32; + bool iam64andReadDataFrom32 = false; + bool iam32andReadDataFrom64 = false; + ////////////////////////////////////////////////////////////////////// // implementation of basic_binary_iprimitive @@ -42,6 +46,7 @@ // Detect attempts to pass native binary archives across // incompatible platforms. This is not fool proof but its // better than nothing. + unsigned char size; this->This()->load(size); if(sizeof(int) != size) @@ -49,10 +54,27 @@ archive_exception(archive_exception::incompatible_native_format) ); this->This()->load(size); +#ifdef BOOST_CROSS_ARCHITECTURE_COMPATIBLE + // Patch: 2006-02-07 by Steve Gury < steve dot gury at gmail dot com > + // Detect if native format is different, and allow boost to read data from + // different architecture if(sizeof(long) != size) + { + if( sizeof(long) == 4 && size == 8 ) + iam32andReadDataFrom64 = true; + else if( sizeof(long) == 8 && size == 4 ) + iam64andReadDataFrom32 = true; + else boost::throw_exception( archive_exception(archive_exception::incompatible_native_format) ); + } +#else + if(sizeof(long) != size) + boost::throw_exception( + archive_exception(archive_exception::incompatible_native_format) + ); +#endif this->This()->load(size); if(sizeof(float) != size) boost::throw_exception( @@ -77,7 +99,7 @@ BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) basic_binary_iprimitive::load(wchar_t * ws) { - std::size_t l; + U32 l; this->This()->load(l); load_binary(ws, l); ws[l / sizeof(wchar_t)] = L'\0'; @@ -87,7 +109,7 @@ BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) basic_binary_iprimitive::load(std::string & s) { - std::size_t l; + U32 l; this->This()->load(l); // borland de-allocator fixup #if BOOST_WORKAROUND(_RWSTD_VER, BOOST_TESTED_AT(20101)) @@ -103,7 +125,7 @@ BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) basic_binary_iprimitive::load(char * s) { - std::size_t l; + U32 l; this->This()->load(l); load_binary(s, l); s[l] = '\0'; @@ -115,7 +137,7 @@ BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) basic_binary_iprimitive::load(std::wstring & ws) { - std::size_t l; + U32 l; this->This()->load(l); // borland de-allocator fixup #if BOOST_WORKAROUND(_RWSTD_VER, BOOST_TESTED_AT(20101)) diff -Naurw boost_1_33_1.orig/boost/archive/impl/basic_binary_oprimitive.ipp boost_1_33_1/boost/archive/impl/basic_binary_oprimitive.ipp --- boost_1_33_1.orig/boost/archive/impl/basic_binary_oprimitive.ipp 2005-07-14 18:04:33.000000000 +0200 +++ boost_1_33_1/boost/archive/impl/basic_binary_oprimitive.ipp 2007-02-08 17:01:49.000000000 +0100 @@ -35,6 +35,8 @@ namespace boost { namespace archive { + typedef unsigned int U32; + ////////////////////////////////////////////////////////////////////// // implementation of basic_binary_oprimitive @@ -58,7 +60,7 @@ BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) basic_binary_oprimitive::save(const char * s) { - std::size_t l = std::strlen(s); + U32 l = std::strlen(s); this->This()->save(l); save_binary(s, l); } @@ -67,7 +69,7 @@ BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) basic_binary_oprimitive::save(const std::string &s) { - std::size_t l = static_cast(s.size()); + U32 l = static_cast(s.size()); this->This()->save(l); save_binary(s.data(), l); } @@ -77,7 +79,7 @@ BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) basic_binary_oprimitive::save(const wchar_t * ws) { - std::size_t l = std::wcslen(ws); + U32 l = std::wcslen(ws); this->This()->save(l); save_binary(ws, l * sizeof(wchar_t) / sizeof(char)); } @@ -87,7 +89,7 @@ BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) basic_binary_oprimitive::save(const std::wstring &ws) { - std::size_t l = ws.size(); + U32 l = ws.size(); this->This()->save(l); save_binary(ws.data(), l * sizeof(wchar_t) / sizeof(char)); }