athena/include/athena/Types.hpp

111 lines
2.0 KiB
C++
Raw Normal View History

2014-04-20 02:14:15 -07:00
#ifndef TYPES_HPP
#define TYPES_HPP
#include <stdint.h>
2013-07-20 20:57:20 -07:00
using atInt8 = int8_t;
using atUint8 = uint8_t;
using atInt16 = int16_t;
using atUint16 = uint16_t;
using atInt32 = int32_t;
using atUint32 = uint32_t;
using atInt64 = int64_t;
using atUint64 = uint64_t;
2013-07-20 20:57:20 -07:00
2015-06-16 17:25:48 -07:00
// Vector types
#if __SSE__
#include <xmmintrin.h>
2015-11-30 19:01:29 -08:00
#include <emmintrin.h>
#ifndef _WIN32
#include <mm_malloc.h>
2015-06-16 17:25:48 -07:00
#endif
#endif
#include <new>
#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);}
2015-06-16 17:25:48 -07:00
typedef union alignas(16)
2015-07-10 18:45:26 -07:00
{
#if __clang__
float clangVec __attribute__((__vector_size__(8)));
#endif
#if __SSE__
__m128 mVec128;
AT_ALIGNED_ALLOCATOR
2015-07-10 18:45:26 -07:00
#endif
float vec[2];
} atVec2f;
typedef union alignas(16)
2015-06-16 17:25:48 -07:00
{
#if __clang__
float clangVec __attribute__((__vector_size__(12)));
#endif
#if __SSE__
__m128 mVec128;
AT_ALIGNED_ALLOCATOR
2015-06-16 17:25:48 -07:00
#endif
float vec[3];
} atVec3f;
typedef union alignas(16)
2015-06-16 17:25:48 -07:00
{
#if __clang__
float clangVec __attribute__((__vector_size__(16)));
#endif
#if __SSE__
__m128 mVec128;
AT_ALIGNED_ALLOCATOR
2015-06-16 17:25:48 -07:00
#endif
float vec[4];
} atVec4f;
2015-10-07 16:50:50 -07:00
typedef union alignas(16)
{
#if __SSE__
__m128d mVec128;
AT_ALIGNED_ALLOCATOR
#endif
double vec[2];
} atVec2d;
typedef union alignas(16)
{
#if __SSE__
__m128d mVec128[2];
AT_ALIGNED_ALLOCATOR
#endif
double vec[3];
} atVec3d;
typedef union alignas(16)
{
#if __SSE__
__m128d mVec128[2];
AT_ALIGNED_ALLOCATOR
#endif
double vec[4];
} atVec4d;
2014-01-04 13:56:03 -08:00
#ifndef UNUSED
#define UNUSED(x) ((void)x)
#endif // UNUSED
2014-01-14 20:13:26 -08:00
#ifdef __GNUC__
#define DEPRECATED(func) func __attribute__ ((deprecated))
#elif defined(_MSC_VER)
#define DEPRECATED(func) __declspec(deprecated) func
#else
#pragma message("WARNING: You need to implement DEPRECATED for this compiler")
#define DEPRECATED(func) func
#endif
2014-04-20 02:14:15 -07:00
#endif // TYPES_HPP