Remove ALIGN_32 macro

It's never used in expressions like SIZE_32(T) * n, so it doesn't help to fix any warning issued due to truncation.
This commit is contained in:
Nekotekina 2018-08-31 16:47:30 +03:00
parent dea5193fd7
commit 69f0ad0d68
4 changed files with 6 additions and 9 deletions

View file

@ -43,9 +43,6 @@
// Return 32 bit sizeof() to avoid widening/narrowing conversions with size_t // Return 32 bit sizeof() to avoid widening/narrowing conversions with size_t
#define SIZE_32(...) static_cast<u32>(sizeof(__VA_ARGS__)) #define SIZE_32(...) static_cast<u32>(sizeof(__VA_ARGS__))
// Return 32 bit alignof() to avoid widening/narrowing conversions with size_t
#define ALIGN_32(...) static_cast<u32>(alignof(__VA_ARGS__))
// Variant pattern matching helper // Variant pattern matching helper
#define MATCH(arg, ...) constexpr(std::is_same_v<std::decay_t<decltype(arg)>, __VA_ARGS__>) #define MATCH(arg, ...) constexpr(std::is_same_v<std::decay_t<decltype(arg)>, __VA_ARGS__>)

View file

@ -152,8 +152,8 @@ public:
info.name = name; info.name = name;
info.var = reinterpret_cast<vm::gvar<void>*>(Var); info.var = reinterpret_cast<vm::gvar<void>*>(Var);
info.init = [] {}; info.init = [] {};
info.size = SIZE_32(typename T::type); info.size = sizeof(typename T::type);
info.align = ALIGN_32(typename T::type); info.align = alignof(typename T::type);
info.type = typeid(T).name(); info.type = typeid(T).name();
info.flags = 0; info.flags = 0;
info.addr = 0; info.addr = 0;

View file

@ -121,7 +121,7 @@ namespace vm
// Test address alignment using alignof(T) // Test address alignment using alignof(T)
bool aligned() const bool aligned() const
{ {
return aligned(ALIGN_32(T)); return aligned(alignof(T));
} }
// Get type size // Get type size
@ -133,7 +133,7 @@ namespace vm
// Get type alignment // Get type alignment
static constexpr u32 align() static constexpr u32 align()
{ {
return ALIGN_32(T); return alignof(T);
} }
// Test address for arbitrary alignment: (addr & (align - 1)) != 0 // Test address for arbitrary alignment: (addr & (align - 1)) != 0

View file

@ -40,7 +40,7 @@ namespace vm
public: public:
_var_base() _var_base()
: pointer(A::alloc(SIZE_32(T), ALIGN_32(T))) : pointer(A::alloc(SIZE_32(T), alignof(T)))
{ {
} }
@ -72,7 +72,7 @@ namespace vm
public: public:
_var_base(u32 count) _var_base(u32 count)
: pointer(A::alloc(SIZE_32(T) * count, ALIGN_32(T))) : pointer(A::alloc(SIZE_32(T) * count, alignof(T)))
, m_size(SIZE_32(T) * count) , m_size(SIZE_32(T) * count)
{ {
} }