mirror of
https://github.com/taglib/taglib.git
synced 2026-04-05 21:52:43 -04:00
Run-time check for integer byte order rather than CMake check.
It will easily be optimized out.
This commit is contained in:
@ -209,7 +209,7 @@ T toNumber(const ByteVector &v, size_t offset, size_t length, bool mostSignifica
|
||||
template <class T>
|
||||
T toNumber(const ByteVector &v, size_t offset, bool mostSignificantByteFirst)
|
||||
{
|
||||
static const bool isBigEndian = (Utils::SystemByteOrder == Utils::BigEndian);
|
||||
const bool isBigEndian = (Utils::systemByteOrder() == Utils::BigEndian);
|
||||
const bool swap = (mostSignificantByteFirst != isBigEndian);
|
||||
|
||||
if(offset + sizeof(T) > v.size())
|
||||
@ -228,7 +228,7 @@ T toNumber(const ByteVector &v, size_t offset, bool mostSignificantByteFirst)
|
||||
template <class T>
|
||||
ByteVector fromNumber(T value, bool mostSignificantByteFirst)
|
||||
{
|
||||
static const bool isBigEndian = (Utils::SystemByteOrder == Utils::BigEndian);
|
||||
const bool isBigEndian = (Utils::systemByteOrder() == Utils::BigEndian);
|
||||
const bool swap = (mostSignificantByteFirst != isBigEndian);
|
||||
|
||||
if(swap)
|
||||
|
||||
@ -828,7 +828,7 @@ void String::copyFromUTF16(const char *s, size_t length, Type t)
|
||||
}
|
||||
|
||||
const String::Type String::WCharByteOrder
|
||||
= (Utils::SystemByteOrder == Utils::BigEndian) ? String::UTF16BE : String::UTF16LE;
|
||||
= (Utils::systemByteOrder() == Utils::BigEndian) ? String::UTF16BE : String::UTF16LE;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -216,20 +216,9 @@ namespace TagLib
|
||||
BigEndian
|
||||
};
|
||||
|
||||
#ifdef SYSTEM_BYTEORDER
|
||||
|
||||
# if SYSTEM_BYTEORDER == 1
|
||||
|
||||
const ByteOrder SystemByteOrder = LittleEndian;
|
||||
|
||||
# else
|
||||
|
||||
const ByteOrder SystemByteOrder = BigEndian;
|
||||
|
||||
# endif
|
||||
|
||||
#else
|
||||
|
||||
/*!
|
||||
* Returns the integer byte order of the system.
|
||||
*/
|
||||
inline ByteOrder systemByteOrder()
|
||||
{
|
||||
union {
|
||||
@ -244,10 +233,6 @@ namespace TagLib
|
||||
return BigEndian;
|
||||
}
|
||||
|
||||
const ByteOrder SystemByteOrder = systemByteOrder();
|
||||
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* Returns the IEEE754 byte order of the system.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user