diff --git a/include/Athena/Types.hpp b/include/Athena/Types.hpp index 8cef4d2..d7f26fe 100644 --- a/include/Athena/Types.hpp +++ b/include/Athena/Types.hpp @@ -44,37 +44,54 @@ typedef unsigned long long atUint64; // Vector types #if __SSE__ #include +#ifndef _WIN32 +#include +#endif #endif -typedef union +#include +#define AT_ALIGNED_ALLOCATOR \ +void* operator new(size_t bytes) noexcept \ +{return _mm_malloc(bytes, 16);} \ +void* operator new[](size_t bytes) noexcept \ +{return _mm_malloc(bytes, 16);} \ +void operator delete(void* buf) noexcept \ +{_mm_free(buf);} \ +void operator delete[](void* buf) noexcept \ +{_mm_free(buf);} \ + +typedef union alignas(16) { #if __clang__ float clangVec __attribute__((__vector_size__(8))); #endif #if __SSE__ __m128 mVec128; + AT_ALIGNED_ALLOCATOR #endif float vec[2]; } atVec2f; -typedef union +typedef union alignas(16) { #if __clang__ float clangVec __attribute__((__vector_size__(12))); #endif #if __SSE__ __m128 mVec128; + AT_ALIGNED_ALLOCATOR #endif float vec[3]; } atVec3f; -typedef union +typedef union alignas(16) { #if __clang__ float clangVec __attribute__((__vector_size__(16))); #endif #if __SSE__ __m128 mVec128; + AT_ALIGNED_ALLOCATOR #endif float vec[4]; } atVec4f; diff --git a/src/aes.cpp b/src/aes.cpp index 268700a..7fd617e 100644 --- a/src/aes.cpp +++ b/src/aes.cpp @@ -39,14 +39,7 @@ static inline void unpack(uint32_t a, uint8_t* b) static inline uint8_t xtime(uint8_t a) { - uint8_t b; - - if (a & 0x80) b = 0x1B; - else b = 0; - - a <<= 1; - a ^= b; - return a; + return ((a << 1) ^ (((a>>7) & 1) * 0x11B)); } static const struct SoftwareAESTables