diff --git a/src/sfizz/SIMDHelpers.h b/src/sfizz/SIMDHelpers.h index 5bce8a78..b8915297 100644 --- a/src/sfizz/SIMDHelpers.h +++ b/src/sfizz/SIMDHelpers.h @@ -74,30 +74,30 @@ enum class SIMDOps { void setSIMDOpStatus(SIMDOps op, bool status); bool getSIMDOpStatus(SIMDOps op); -constexpr uintptr_t ByteAlignmentMask { config::defaultAlignment - 1 }; +constexpr uintptr_t ByteAlignmentMask(unsigned N) { return N - 1; } -template +template T* nextAligned(const T* ptr) { - return reinterpret_cast(reinterpret_cast(ptr) + ByteAlignmentMask & (~ByteAlignmentMask)); + return reinterpret_cast(reinterpret_cast(ptr) + ByteAlignmentMask(N) & (~ByteAlignmentMask(N))); } -template +template T* prevAligned(const T* ptr) { - return reinterpret_cast(reinterpret_cast(ptr) & (~ByteAlignmentMask)); + return reinterpret_cast(reinterpret_cast(ptr) & (~ByteAlignmentMask(N))); } -template +template bool unaligned(const T* ptr) { - return (reinterpret_cast(ptr) & ByteAlignmentMask )!= 0; + return (reinterpret_cast(ptr) & ByteAlignmentMask(N) )!= 0; } -template +template bool unaligned(const T* ptr1, Args... rest) { - return unaligned(ptr1) || unaligned(rest...); + return unaligned(ptr1) || unaligned(rest...); } /**