-
Notifications
You must be signed in to change notification settings - Fork 5
/
config.hpp
105 lines (73 loc) · 2.05 KB
/
config.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#ifndef ___INANITY_CONFIG_HPP___
#define ___INANITY_CONFIG_HPP___
/*
* Inanity compilation configuration.
*/
/// Determine base platform.
#if defined(_WIN32) || defined(__WIN32__)
#define ___INANITY_PLATFORM_WINDOWS
#if defined(_XBOX_ONE)
#define ___INANITY_PLATFORM_XBOX
#define ___INANITY_PLATFORM_XBOX_ONE
#endif
#elif defined(__EMSCRIPTEN__)
#define ___INANITY_PLATFORM_EMSCRIPTEN
#define ___INANITY_PLATFORM_POSIX
#elif defined(__FreeBSD__)
#define ___INANITY_PLATFORM_FREEBSD
#define ___INANITY_PLATFORM_POSIX
#elif defined(__APPLE__) && defined(__MACH__)
#define ___INANITY_PLATFORM_MACOS
#define ___INANITY_PLATFORM_POSIX
#elif defined(NN_NINTENDO_SDK)
#define ___INANITY_PLATFORM_SWITCH
#define ___INANITY_PLATFORM_POSIX
#elif defined(__ANDROID__)
#define ___INANITY_PLATFORM_ANDROID
#define ___INANITY_PLATFORM_POSIX
#else
#define ___INANITY_PLATFORM_LINUX
#define ___INANITY_PLATFORM_POSIX
#endif
/// Desktop platform?
#if \
(defined(___INANITY_PLATFORM_WINDOWS) && !defined(___INANITY_PLATFORM_XBOX)) || \
defined(___INANITY_PLATFORM_LINUX) || \
defined(___INANITY_PLATFORM_MACOS)
#define ___INANITY_PLATFORM_DESKTOP
#define ___INANITY_PLATFORM_STEAM
#endif
/// "Big data size" type.
/** I.e. that amount of data maybe not fit in memory,
but we want to deal with such amounts. */
#ifdef ___INANITY_PLATFORM_EMSCRIPTEN
// On Emscripten long long is slow.
typedef unsigned int bigsize_t;
#else
typedef unsigned long long bigsize_t;
#define ___INANITY_BIGSIZE_IS_BIG
#endif
#define BEGIN_INANITY namespace Inanity {
#define END_INANITY }
BEGIN_INANITY
/// "Fast" type conversion.
/** dynamic_cast in debug, static_cast in release. */
template <typename ToType, typename FromType>
ToType fast_cast(FromType object)
{
#ifdef _DEBUG
return dynamic_cast<ToType>(object);
#else
return static_cast<ToType>(object);
#endif
}
END_INANITY
//*** Debug checks.
#ifdef _DEBUG
/// Heap tracing enabled.
#define ___INANITY_TRACE_HEAP
/// Managed pointers tracing enabled.
/** Requires enable ___INANITY_TRACE_HEAP. */
#define ___INANITY_TRACE_PTR
#endif
#endif