diff --git a/include/Nazara/Core/Endianness.hpp b/include/Nazara/Core/Endianness.hpp index 62cac093d..44a4e9f26 100644 --- a/include/Nazara/Core/Endianness.hpp +++ b/include/Nazara/Core/Endianness.hpp @@ -11,12 +11,12 @@ #include #if !defined(NAZARA_BIG_ENDIAN) && !defined(NAZARA_LITTLE_ENDIAN) - // Détection automatique selon les macros du compilateur + // Automatic detection following macroes of compiler #if defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || (defined(__MIPS__) && defined(__MISPEB__)) || \ defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || defined(__sparc__) || defined(__hppa__) #define NAZARA_BIG_ENDIAN #elif defined(__i386__) || defined(__i386) || defined(__X86__) || defined (__x86_64) || defined(_M_I86) || \ - defined(_M_IX86) || defined(_M_X64) + defined(_M_IX86) || defined(_M_X64) #define NAZARA_LITTLE_ENDIAN #else #error Failed to identify endianness, you must define either NAZARA_BIG_ENDIAN or NAZARA_LITTLE_ENDIAN diff --git a/include/Nazara/Core/Endianness.inl b/include/Nazara/Core/Endianness.inl index 96e4fdf8a..72cb9fc43 100644 --- a/include/Nazara/Core/Endianness.inl +++ b/include/Nazara/Core/Endianness.inl @@ -7,6 +7,11 @@ namespace Nz { + /*! + * \brief Gets the platform endianness + * \return Type of the endianness + */ + inline constexpr Endianness GetPlatformEndianness() { #if defined(NAZARA_BIG_ENDIAN) @@ -16,11 +21,20 @@ namespace Nz #endif } + /*! + * \brief Swaps the byte for endianness operations + * + * \param buffer Raw memory + * \param size Size to change endianness + * + * \remark If size is greather than the preallocated buffer, the behaviour is undefined + */ + inline void SwapBytes(void* buffer, unsigned int size) { UInt8* bytes = reinterpret_cast(buffer); unsigned int i = 0; - unsigned int j = size-1; + unsigned int j = size - 1; while (i < j) std::swap(bytes[i++], bytes[j--]);