1 2 3 4 5 6 7 8 9 10 11 12 13 14 #pragma once15 16 17 18 19 #ifdef MATH_TUNDRA_INTEROP20 #include "CoreTypes.h"21 #else22 23 #ifndef KNET_NO_FIXEDWIDTH_TYPES24 25 26 27 28 #if (__STDC_VERSION__ >= 199901L) || (_MSC_VER >= 1600)29 30 #include <cstdint>31 32 typedef uint8_t [u8]; 33 typedef uint16_t [u16]; 34 typedef uint32_t u32; 35 typedef uint64_t [u64]; 36 37 typedef int8_t [s8]; 38 typedef int16_t [s16]; 39 typedef int32_t s32; 40 typedef int64_t [s64]; 41 42 43 #elif defined(KNET_USE_BOOST)44 45 #include <boost/cstdint.hpp>46 47 typedef boost::uint8_t [u8]; 48 typedef boost::uint16_t [u16]; 49 typedef boost::uint32_t u32; 50 typedef boost::uint64_t [u64]; 51 52 typedef boost::int8_t [s8]; 53 typedef boost::int16_t [s16]; 54 typedef boost::int32_t s32; 55 typedef boost::int64_t [s64]; 56 57 #else // No boost or unknown if we have C99. Have to guess the following are correct.58 59 #include <limits.h>60 61 62 63 typedef unsigned char [u8]; 64 typedef unsigned short [u16]; 65 typedef unsigned long long [u64]; 66 67 typedef signed char [s8]; 68 typedef signed short [s16]; 69 70 #if ULONG_MAX == 0xffffffff71 typedef unsigned long u32; 72 typedef long s32; 73 #elif UINT_MAX == 0xffffffff74 typedef unsigned int u32; 75 typedef int s32; 76 #endif77 78 typedef signed long long [s64]; 79 80 #endif81 82 #endif // ~KNET_NO_FIXEDWIDTH_TYPES83 84 #endif85 86 #ifdef _MSC_VER87 #define STATIC_ASSERT static_assert88 #else89 90 #define COMPILE_TIME_ASSERT4(COND,MSG) typedef char static_assertion_##MSG[(!!(COND))*2-1]91 #define COMPILE_TIME_ASSERT3(X,L) COMPILE_TIME_ASSERT4(X,static_assertion_at_line_##L)92 #define COMPILE_TIME_ASSERT2(X,L) COMPILE_TIME_ASSERT3(X,L)93 #define STATIC_ASSERT(X, msg) COMPILE_TIME_ASSERT2(X,__LINE__)94 #endif95 96 [STATIC_ASSERT](sizeof([u8]) == 1, "Typedef for fixed-width type u8 is incorrect!");97 [STATIC_ASSERT](sizeof([s8]) == 1, "Typedef for fixed-width type s8 is incorrect!");98 [STATIC_ASSERT](sizeof([u16]) == 2, "Typedef for fixed-width type u16 is incorrect!");99 [STATIC_ASSERT](sizeof([s16]) == 2, "Typedef for fixed-width type s16 is incorrect!");100 [STATIC_ASSERT](sizeof(u32) == 4, "Typedef for fixed-width type u32 is incorrect!");101 [STATIC_ASSERT](sizeof(s32) == 4, "Typedef for fixed-width type s32 is incorrect!");102 [STATIC_ASSERT](sizeof([u64]) == 8, "Typedef for fixed-width type u64 is incorrect!");103 [STATIC_ASSERT](sizeof([s64]) == 8, "Typedef for fixed-width type s64 is incorrect!");104 105 106 107 #if _MSC_VER >= 1700108 109 #define MUST_USE_RESULT _Check_return_110 #elif defined(__clang__) || (defined(__GNUC__) && ((__GNUC__*10000+__GNUC_MINOR*100) >= 30400))111 112 #define MUST_USE_RESULT __attribute__((warn_unused_result))113 #else114 #define MUST_USE_RESULT115 #endif116 117 118 #ifdef _DEBUG119 #define FORCE_INLINE inline120 #elif defined(_MSC_VER)121 #define FORCE_INLINE __forceinline122 #else123 #define FORCE_INLINE inline __attribute__((always_inline))124 #endif Go back to previous page