mirror of
https://github.com/taglib/taglib.git
synced 2025-06-04 01:28:21 -04:00
Run-time check for integer byte order rather than CMake check.
It will easily be optimized out.
This commit is contained in:
parent
44d9f2bf25
commit
076e845912
@ -1,7 +1,6 @@
|
||||
include(CheckLibraryExists)
|
||||
include(CheckTypeSize)
|
||||
include(CheckCXXSourceCompiles)
|
||||
include(TestBigEndian)
|
||||
|
||||
# Check if the size of numeric types are suitable.
|
||||
|
||||
@ -35,16 +34,6 @@ if(NOT ${SIZEOF_DOUBLE} EQUAL 8)
|
||||
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("
|
||||
|
@ -1,9 +1,5 @@
|
||||
/* 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
|
||||
|
@ -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.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user