Athena IO Library
Types.hpp
1 #ifndef TYPES_HPP
2 #define TYPES_HPP
3 #include <stdint.h>
4 #include <inttypes.h>
5 
6 using atInt8 = int8_t;
7 using atUint8 = uint8_t;
8 using atInt16 = int16_t;
9 using atUint16 = uint16_t;
10 using atInt32 = int32_t;
11 using atUint32 = uint32_t;
12 using atInt64 = int64_t;
13 using atUint64 = uint64_t;
14 
15 // Vector types
16 #if __SSE__
17 #include <xmmintrin.h>
18 #include <emmintrin.h>
19 #ifndef _WIN32
20 #include <mm_malloc.h>
21 #endif
22 #endif
23 
24 #include <new>
25 #define AT_ALIGNED_ALLOCATOR \
26 void* operator new(size_t bytes) noexcept \
27 {return _mm_malloc(bytes, 16);} \
28 void* operator new[](size_t bytes) noexcept \
29 {return _mm_malloc(bytes, 16);} \
30 void operator delete(void* buf) noexcept \
31 {_mm_free(buf);} \
32 void operator delete[](void* buf) noexcept \
33 {_mm_free(buf);}
34 
35 typedef union alignas(16)
36 {
37 #if __clang__
38  float clangVec __attribute__((__vector_size__(8)));
39 #endif
40 #if __SSE__
41  __m128 mVec128;
42  AT_ALIGNED_ALLOCATOR
43 #endif
44  float vec[2];
45 } atVec2f;
46 
47 typedef union alignas(16)
48 {
49 #if __clang__
50  float clangVec __attribute__((__vector_size__(12)));
51 #endif
52 #if __SSE__
53  __m128 mVec128;
54  AT_ALIGNED_ALLOCATOR
55 #endif
56  float vec[3];
57 } atVec3f;
58 
59 typedef union alignas(16)
60 {
61 #if __clang__
62  float clangVec __attribute__((__vector_size__(16)));
63 #endif
64 #if __SSE__
65  __m128 mVec128;
66  AT_ALIGNED_ALLOCATOR
67 #endif
68  float vec[4];
69 } atVec4f;
70 
71 typedef union alignas(16)
72 {
73 #if __SSE__
74  __m128d mVec128;
75  AT_ALIGNED_ALLOCATOR
76 #endif
77  double vec[2];
78 } atVec2d;
79 
80 typedef union alignas(16)
81 {
82 #if __SSE__
83  __m128d mVec128[2];
84  AT_ALIGNED_ALLOCATOR
85 #endif
86  double vec[3];
87 } atVec3d;
88 
89 typedef union alignas(16)
90 {
91 #if __SSE__
92  __m128d mVec128[2];
93  AT_ALIGNED_ALLOCATOR
94 #endif
95  double vec[4];
96 } atVec4d;
97 
98 #ifndef UNUSED
99 #define UNUSED(x) ((void)x)
100 #endif // UNUSED
101 
102 #ifdef __GNUC__
103 #define DEPRECATED(func) func __attribute__ ((deprecated))
104 #elif defined(_MSC_VER)
105 #define DEPRECATED(func) __declspec(deprecated) func
106 #else
107 #pragma message("WARNING: You need to implement DEPRECATED for this compiler")
108 #define DEPRECATED(func) func
109 #endif
110 
111 #endif // TYPES_HPP