mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-21 09:43:39 -07:00
boost: fix little/big endian compatibility
When no little/big endian flag is given to the writer, it stores data in host endianness. When loading, if no flag is set, it also assumes host endianness. This works as long as the loading and writing are done on machines with the same endianness. We change this to default to little endian when saving. This will cause the loader to see the little endian flag, and swap endianness when loading on a big endian machine. Similarly, writing on a big endian machine will swap on save, and a little endian machine will load little endian data.
This commit is contained in:
parent
54fd97ae3f
commit
c1fa4a7f8c
@ -258,7 +258,7 @@ portable_binary_iarchive::load_impl(boost::intmax_t & l, char maxsize){
|
||||
this->primitive_base_t::load_binary(cptr, size);
|
||||
|
||||
#if BOOST_ENDIAN_BIG_BYTE
|
||||
if(m_flags & endian_little)
|
||||
if((m_flags & endian_little) || (!(m_flags & endian_big)))
|
||||
#else
|
||||
if(m_flags & endian_big)
|
||||
#endif
|
||||
@ -343,6 +343,8 @@ portable_binary_iarchive::init(unsigned int flags){
|
||||
);
|
||||
#endif
|
||||
}
|
||||
if (!(m_flags & (endian_little | endian_big)))
|
||||
m_flags |= endian_little;
|
||||
unsigned char x;
|
||||
load(x);
|
||||
m_flags = x << CHAR_BIT;
|
||||
|
@ -171,7 +171,7 @@ protected:
|
||||
|
||||
void init(unsigned int flags);
|
||||
public:
|
||||
portable_binary_oarchive(std::ostream & os, unsigned flags = 0) :
|
||||
portable_binary_oarchive(std::ostream & os, unsigned flags = endian_little) :
|
||||
primitive_base_t(
|
||||
* os.rdbuf(),
|
||||
0 != (flags & boost::archive::no_codecvt)
|
||||
|
Loading…
Reference in New Issue
Block a user