VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Platform/Memory.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/Platform/Memory.h')
-rw-r--r--src/Platform/Memory.h28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/Platform/Memory.h b/src/Platform/Memory.h
index e0d4bfe3..b124022f 100644
--- a/src/Platform/Memory.h
+++ b/src/Platform/Memory.h
@@ -58,123 +58,123 @@
# define LITTLE_ENDIAN __LITTLE_ENDIAN
# endif
# ifndef BIG_ENDIAN
# define BIG_ENDIAN __BIG_ENDIAN
# endif
#endif // !BYTE_ORDER
#if BYTE_ORDER != BIG_ENDIAN && BYTE_ORDER != LITTLE_ENDIAN
# error Unsupported byte ordering detected.
#endif
namespace VeraCrypt
{
class Memory
{
public:
static void *Allocate (size_t size);
static void *AllocateAligned (size_t size, size_t alignment);
static int Compare (const void *memory1, size_t size1, const void *memory2, size_t size2);
static void Copy (void *memoryDestination, const void *memorySource, size_t size);
static void Free (void *memory);
static void FreeAligned (void *memory);
static void Zero (void *memory, size_t size);
};
class Endian
{
public:
- static byte Big (const byte &x)
+ static uint8 Big (const uint8 &x)
{
return x;
}
static uint16 Big (const uint16 &x)
{
#if BYTE_ORDER == BIG_ENDIAN
return x;
#else
return MirrorBytes (x);
#endif
}
static uint32 Big (const uint32 &x)
{
#if BYTE_ORDER == BIG_ENDIAN
return x;
#else
return MirrorBytes (x);
#endif
}
static uint64 Big (const uint64 &x)
{
#if BYTE_ORDER == BIG_ENDIAN
return x;
#else
return MirrorBytes (x);
#endif
}
- static byte Little (const byte &x)
+ static uint8 Little (const uint8 &x)
{
return x;
}
static uint16 Little (const uint16 &x)
{
#if BYTE_ORDER == LITTLE_ENDIAN
return x;
#else
return MirrorBytes (x);
#endif
}
static uint32 Little (const uint32 &x)
{
#if BYTE_ORDER == LITTLE_ENDIAN
return x;
#else
return MirrorBytes (x);
#endif
}
static uint64 Little (const uint64 &x)
{
#if BYTE_ORDER == LITTLE_ENDIAN
return x;
#else
return MirrorBytes (x);
#endif
}
protected:
static uint16 MirrorBytes (const uint16 &x)
{
return (x << 8) | (x >> 8);
}
static uint32 MirrorBytes (const uint32 &x)
{
- uint32 n = (byte) x;
- n <<= 8; n |= (byte) (x >> 8);
- n <<= 8; n |= (byte) (x >> 16);
- return (n << 8) | (byte) (x >> 24);
+ uint32 n = (uint8) x;
+ n <<= 8; n |= (uint8) (x >> 8);
+ n <<= 8; n |= (uint8) (x >> 16);
+ return (n << 8) | (uint8) (x >> 24);
}
static uint64 MirrorBytes (const uint64 &x)
{
- uint64 n = (byte) x;
- n <<= 8; n |= (byte) (x >> 8);
- n <<= 8; n |= (byte) (x >> 16);
- n <<= 8; n |= (byte) (x >> 24);
- n <<= 8; n |= (byte) (x >> 32);
- n <<= 8; n |= (byte) (x >> 40);
- n <<= 8; n |= (byte) (x >> 48);
- return (n << 8) | (byte) (x >> 56);
+ uint64 n = (uint8) x;
+ n <<= 8; n |= (uint8) (x >> 8);
+ n <<= 8; n |= (uint8) (x >> 16);
+ n <<= 8; n |= (uint8) (x >> 24);
+ n <<= 8; n |= (uint8) (x >> 32);
+ n <<= 8; n |= (uint8) (x >> 40);
+ n <<= 8; n |= (uint8) (x >> 48);
+ return (n << 8) | (uint8) (x >> 56);
}
};
}
#endif // TC_HEADER_Platform_Memory