0
0
mirror of https://github.com/yse/easy_profiler.git synced 2024-12-26 16:11:02 +08:00

Fixed casting issues and fixed an order of operations error.

This commit is contained in:
Blake Martin 2017-08-22 13:29:19 -05:00
parent 283b835dd8
commit 15323cc8ff

View File

@ -159,7 +159,7 @@ template <uint32_t ALIGNMENT>
EASY_FORCE_INLINE bool is_aligned(void* ptr)
{
static_assert(ALIGNMENT % 2 == 0, "Alignment must be a power of two.");
return (uintptr_t)ptr & (ALIGNMENT-1) == 0;
return ((uintptr_t)ptr & (ALIGNMENT-1)) == 0;
}
EASY_FORCE_INLINE void unaligned_zero16(void* ptr)
@ -213,7 +213,7 @@ EASY_FORCE_INLINE void unaligned_store16(void* ptr, T val)
#ifndef EASY_ENABLE_STRICT_ALIGNMENT
*(T*)ptr = val;
#else
const char* const temp = &val;
const char* const temp = (char*)&val;
((char*)ptr)[0] = temp[0];
((char*)ptr)[1] = temp[1];
#endif
@ -226,7 +226,7 @@ EASY_FORCE_INLINE void unaligned_store32(void* ptr, T val)
#ifndef EASY_ENABLE_STRICT_ALIGNMENT
*(T*)ptr = val;
#else
const char* const temp = &val;
const char* const temp = (char*)&val;
((char*)ptr)[0] = temp[0];
((char*)ptr)[1] = temp[1];
((char*)ptr)[2] = temp[2];
@ -241,7 +241,7 @@ EASY_FORCE_INLINE void unaligned_store64(void* ptr, T val)
#ifndef EASY_ENABLE_STRICT_ALIGNMENT
*(T*)ptr = val;
#else
const char* const temp = &val;
const char* const temp = (char*)&val;
// Assume unaligned is more common.
if (!is_aligned<alignof(T)>(ptr)) {
((char*)ptr)[0] = temp[0];