Documentation for Endiannes
Former-commit-id: e45c5026b84aa8b354e29d760eff56d13f2dc745
This commit is contained in:
parent
0a4381a95b
commit
61542b59d6
|
|
@ -11,7 +11,7 @@
|
|||
#include <Nazara/Core/Enums.hpp>
|
||||
|
||||
#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
|
||||
|
|
|
|||
|
|
@ -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<UInt8*>(buffer);
|
||||
unsigned int i = 0;
|
||||
unsigned int j = size-1;
|
||||
unsigned int j = size - 1;
|
||||
|
||||
while (i < j)
|
||||
std::swap(bytes[i++], bytes[j--]);
|
||||
|
|
|
|||
Loading…
Reference in New Issue