2014-04-20 09:14:15 +00:00
|
|
|
#ifndef TYPES_HPP
|
|
|
|
#define TYPES_HPP
|
2013-07-21 03:57:20 +00:00
|
|
|
#include <limits.h>
|
|
|
|
|
|
|
|
// 8 bits integer types
|
|
|
|
#if UCHAR_MAX == 0xFF
|
2015-05-19 03:24:56 +00:00
|
|
|
typedef signed char atInt8;
|
|
|
|
typedef unsigned char atUint8;
|
2013-07-21 03:57:20 +00:00
|
|
|
#else
|
2015-05-19 03:24:56 +00:00
|
|
|
#error No 8 bits integer type for this platform
|
2013-07-21 03:57:20 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// 16 bits integer types
|
|
|
|
#if USHRT_MAX == 0xFFFF
|
2015-05-19 03:24:56 +00:00
|
|
|
typedef signed short atInt16;
|
|
|
|
typedef unsigned short atUint16;
|
2013-07-21 03:57:20 +00:00
|
|
|
#elif UINT_MAX == 0xFFFF
|
2015-05-19 03:24:56 +00:00
|
|
|
typedef signed int atInt16;
|
|
|
|
typedef unsigned int atUint16;
|
2013-07-21 03:57:20 +00:00
|
|
|
#elif ULONG_MAX == 0xFFFF
|
2015-05-19 03:24:56 +00:00
|
|
|
typedef signed long atInt16;
|
|
|
|
typedef unsigned long atUint16;
|
2013-07-21 03:57:20 +00:00
|
|
|
#else
|
2015-05-19 03:24:56 +00:00
|
|
|
#error No 16 bits integer type for this platform
|
2013-07-21 03:57:20 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// 32 bits integer types
|
|
|
|
#if USHRT_MAX == 0xFFFFFFFF
|
2015-05-19 03:24:56 +00:00
|
|
|
typedef signed short atInt32;
|
|
|
|
typedef unsigned short atUint32;
|
2013-07-21 03:57:20 +00:00
|
|
|
#elif UINT_MAX == 0xFFFFFFFF
|
2015-05-19 03:24:56 +00:00
|
|
|
typedef signed int atInt32;
|
|
|
|
typedef unsigned int atUint32;
|
2013-07-21 03:57:20 +00:00
|
|
|
#elif ULONG_MAX == 0xFFFFFFFF
|
2015-05-19 03:24:56 +00:00
|
|
|
typedef signed long atInt32;
|
|
|
|
typedef unsigned long atUint32;
|
2013-07-21 03:57:20 +00:00
|
|
|
#else
|
2015-05-19 03:24:56 +00:00
|
|
|
#error No 32 bits integer type for this platform
|
2013-07-21 03:57:20 +00:00
|
|
|
#endif
|
|
|
|
|
2014-06-18 04:51:18 +00:00
|
|
|
typedef signed long long atInt64;
|
|
|
|
typedef unsigned long long atUint64;
|
2013-07-21 03:57:20 +00:00
|
|
|
|
2015-06-17 00:25:48 +00:00
|
|
|
// Vector types
|
|
|
|
#if __SSE__
|
|
|
|
#include <xmmintrin.h>
|
2015-12-01 03:01:29 +00:00
|
|
|
#include <emmintrin.h>
|
2015-07-27 00:17:35 +00:00
|
|
|
#ifndef _WIN32
|
|
|
|
#include <mm_malloc.h>
|
2015-06-17 00:25:48 +00:00
|
|
|
#endif
|
2015-07-27 00:17:35 +00:00
|
|
|
#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 \
|
2015-11-14 05:53:13 +00:00
|
|
|
{_mm_free(buf);}
|
2015-06-17 00:25:48 +00:00
|
|
|
|
2015-07-27 00:17:35 +00:00
|
|
|
typedef union alignas(16)
|
2015-07-11 01:45:26 +00:00
|
|
|
{
|
|
|
|
#if __clang__
|
|
|
|
float clangVec __attribute__((__vector_size__(8)));
|
|
|
|
#endif
|
|
|
|
#if __SSE__
|
|
|
|
__m128 mVec128;
|
2015-07-27 00:17:35 +00:00
|
|
|
AT_ALIGNED_ALLOCATOR
|
2015-07-11 01:45:26 +00:00
|
|
|
#endif
|
|
|
|
float vec[2];
|
|
|
|
} atVec2f;
|
|
|
|
|
2015-07-27 00:17:35 +00:00
|
|
|
typedef union alignas(16)
|
2015-06-17 00:25:48 +00:00
|
|
|
{
|
|
|
|
#if __clang__
|
|
|
|
float clangVec __attribute__((__vector_size__(12)));
|
|
|
|
#endif
|
|
|
|
#if __SSE__
|
|
|
|
__m128 mVec128;
|
2015-07-27 00:17:35 +00:00
|
|
|
AT_ALIGNED_ALLOCATOR
|
2015-06-17 00:25:48 +00:00
|
|
|
#endif
|
|
|
|
float vec[3];
|
|
|
|
} atVec3f;
|
|
|
|
|
2015-07-27 00:17:35 +00:00
|
|
|
typedef union alignas(16)
|
2015-06-17 00:25:48 +00:00
|
|
|
{
|
|
|
|
#if __clang__
|
|
|
|
float clangVec __attribute__((__vector_size__(16)));
|
|
|
|
#endif
|
|
|
|
#if __SSE__
|
|
|
|
__m128 mVec128;
|
2015-07-27 00:17:35 +00:00
|
|
|
AT_ALIGNED_ALLOCATOR
|
2015-06-17 00:25:48 +00:00
|
|
|
#endif
|
|
|
|
float vec[4];
|
|
|
|
} atVec4f;
|
|
|
|
|
2015-10-07 23:50:50 +00: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;
|
|
|
|
|
2015-06-17 00:25:48 +00:00
|
|
|
|
2013-07-21 03:57:20 +00:00
|
|
|
#ifndef NULL
|
|
|
|
#ifdef __cplusplus
|
|
|
|
#define NULL 0
|
|
|
|
#else // __cplusplus
|
|
|
|
#define NULL (void*)0
|
|
|
|
#endif
|
|
|
|
#endif // NULL
|
|
|
|
|
2014-01-04 21:56:03 +00:00
|
|
|
#ifndef UNUSED
|
|
|
|
#define UNUSED(x) ((void)x)
|
|
|
|
#endif // UNUSED
|
|
|
|
|
2014-01-15 04:13:26 +00: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 09:14:15 +00:00
|
|
|
#endif // TYPES_HPP
|