|
Radium Engine
1.5.0
|
24 #if defined(__clang__)
25 #define COMPILER_CLANG
26 #elif defined(__GNUC__)
28 #elif defined (_MSC_VER)
30 #define _USE_MATH_DEFINES
32 #error unsupported compiler
39 #if defined(_WIN32) || defined(_WIN64)
43 # elif defined(_M_IX86)
46 # error unsupported arch
48 #elif defined(__APPLE__) || defined(__MACH__)
50 #elif defined(__linux__) || defined (__CYGWIN__)
57 #if defined (OS_MACOS) || defined(OS_LINUX)
58 # if defined(__i386__)
60 # elif defined(__x86_64__) || defined (__x86_64)
62 # elif defined(__arm__) || defined (__arm)
64 # elif defined(__aarch64__) || defined(__aarch64)
67 # error unsupported arch
87 #if defined (DEBUG) || defined(_DEBUG) || defined (CORE_DEBUG)
100 # define ON_DEBUG(CODE) CODE
105 #ifndef NO_DEBUG_INFO
113 # if !defined (NDEBUG)
117 # define ON_DEBUG(CODE)
123 #ifndef RA_MAX_THREAD
125 # define RA_MAX_THREAD std::thread::hardware_concurrency() - 1
137 # define MACRO_START do {
138 # define MACRO_END } while (0)
140 # define MACRO_START if(1) {
141 # define MACRO_END } else {}
145 #define CORE_UNUSED(X) \
154 #define CONCATENATE(XX,YY) CONCATENATE2(XX,YY)
155 #define CONCATENATE2(XX,YY) CONCATENATE3(XX,YY)
156 #define CONCATENATE3(XX,YY) XX##YY
160 # define STRINGIFY(X) __STRING(X)
162 # define STRINGIFY(X) STRINGIFY2(X)
163 # define STRINGIFY2(X) #X
173 #if defined (COMPILER_GCC) || defined (COMPILER_CLANG)
174 #define BREAKPOINT(ARG) __builtin_trap();
176 #elif defined (COMPILER_MSVC)
177 #define BREAKPOINT(ARG) __debugbreak()
179 #error unsupported platform
201 #if defined (COMPILER_MSVC)
203 # define ALIGN_OF(X) __alignof(X)
204 # define ALIGNED(DECL,ALIGN) __declspec(align(ALIGN)) DECL
207 # define UNLIKELY(IFEXPR) IFEXPR
208 # define LIKELY(IFEXPR) IFEXPR
210 # define ALWAYS_INLINE __forceinline
211 # define STRONG_INLINE __forceinline
212 # define NO_INLINE __declspec(noinline)
214 # define DLL_EXPORT __declspec(dllexport)
215 # define DLL_IMPORT __declspec(dllimport)
217 # define STDCALL __stdcall
219 # define CDECL __cdecl
221 # define FASTCALL __fastcall
222 #elif defined(COMPILER_GCC) || defined (COMPILER_CLANG)
224 # define ALIGN_OF(X) __alignof__(X)
225 # define ALIGNED(DECL,ALIGN) DECL __attribute__((aligned(ALIGN)))
227 # define UNLIKELY(IFEXPR) __builtin_expect(bool(IFEXPR),0)
228 # define LIKELY(IFEXPR) __builtin_expect(bool(IFEXPR),1)
230 # define ALWAYS_INLINE __attribute((always_inline))
231 # define STRONG_INLINE inline
232 # define NO_INLINE __attribute__((noinline))
237 # define STDCALL __attribute__((stdcall))
239 # define FASTCALL __attribute__((fastcall))
241 # error unsupported platform
249 using uchar =
unsigned char;
250 using ushort =
unsigned short;
251 using uint =
unsigned int;
252 using ulong =
unsigned long;
256 #ifndef CORE_USE_DOUBLE
257 using Scalar = float;
259 using Scalar = double;
270 constexpr Scalar
operator"" _ra (
long double n )
283 constexpr Scalar
operator"" _ra (
unsigned long long n )
292 namespace compile_time_utils
294 template<
int x>
struct size;
298 #define STATIC_SIZEOF(TYPE) compile_time_utils::size<sizeof(TYPE)> static_sizeof
301 #if defined CORE_DEBUG || defined CORE_USE_ASSERT
302 # define CORE_ENABLE_ASSERT
303 # define ON_ASSERT( CODE ) CODE
305 # undef CORE_ENABLE_ASSERT
306 # define ON_ASSERT( CODE )
316 #define REPORT_FAIL( EXP, DESC, FMT ) \
318 std::stringstream stream; \
321 FMT,__FILE__,__LINE__, \
322 #EXP, stream.str().c_str() ); \
333 #ifdef CORE_ENABLE_ASSERT
334 #define CORE_ASSERT( EXP, DESC ) \
336 if (UNLIKELY(!(EXP))) { \
337 REPORT_FAIL(EXP, DESC, "%s:%i: Assertion `%s` failed : %s\n");\
342 #define CORE_WARN_IF( EXP, DESC ) \
344 if (UNLIKELY((EXP))) { \
345 REPORT_FAIL(EXP, DESC, "%s:%i: WARNING `%s` : %s\n");\
349 #define CORE_ASSERT( EXP, DESC )
350 #define CORE_WARN_IF( EXP, DESC )
354 #define CORE_ERROR( DESC ) \
356 REPORT_FAIL(ERROR, DESC, "%s:%i %s: %s\n");\
358 exit(EXIT_FAILURE); \
362 #define CORE_ERROR_IF( EXP, DESC ) \
364 if( UNLIKELY(!(EXP))) { \
365 REPORT_FAIL(EXP, DESC, "%s:%i ERROR `%s`: %s\n");\
367 exit(EXIT_FAILURE); \
381 #if defined(COMPILER_GCC)
383 #pragma GCC diagnostic ignored "-Wunused-local-typedefs"
385 #if defined(COMPILER_MSVC)
386 #pragma warning(disable: 4244)
387 #pragma warning(disable: 4251)
388 #pragma warning(disable: 4267)
389 #pragma warning(disable: 4275)
390 #pragma warning(disable: 4577)
391 #pragma warning(disable: 4838)
392 #pragma warning(disable: 4996)
393 #pragma warning(disable: 4503)
401 #define eigen_assert(XXX) CORE_ASSERT(XXX, "Eigen Assert");