It will easily be optimized out.
include(CheckLibraryExists)
include(CheckTypeSize)
include(CheckCXXSourceCompiles)
-include(TestBigEndian)
# Check if the size of numeric types are suitable.
message(FATAL_ERROR "TagLib requires that double is 64-bit wide.")
endif()
-# Determine the CPU byte order.
-
-test_big_endian(IS_BIG_ENDIAN)
-
-if(NOT IS_BIG_ENDIAN)
- set(SYSTEM_BYTEORDER 1)
-else()
- set(SYSTEM_BYTEORDER 2)
-endif()
-
# Determine which kind of atomic operations your compiler supports.
check_cxx_source_compiles("
/* config.h. Generated by cmake from config.h.cmake */
-/* Integer byte order of your target system */
-/* 1 if little-endian, 2 if big-endian. */
-#cmakedefine SYSTEM_BYTEORDER ${SYSTEM_BYTEORDER}
-
/* Defined if your compiler supports some byte swap functions */
#cmakedefine HAVE_GCC_BYTESWAP_16 1
#cmakedefine HAVE_GCC_BYTESWAP_32 1
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())
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)
}
const String::Type String::WCharByteOrder
- = (Utils::SystemByteOrder == Utils::BigEndian) ? String::UTF16BE : String::UTF16LE;
+ = (Utils::systemByteOrder() == Utils::BigEndian) ? String::UTF16BE : String::UTF16LE;
}
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 {
return BigEndian;
}
- const ByteOrder SystemByteOrder = systemByteOrder();
-
-#endif
-
/*!
* Returns the IEEE754 byte order of the system.
*/