-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
runtime
137 lines (116 loc) · 4.15 KB
/
runtime
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/*
Copyright (C) 2018-2024 Geoffrey Daniels. https://gpdaniels.com/
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, version 3 of the License only.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#ifndef GTL_PLATFORM_RUNTIME_HPP
#define GTL_PLATFORM_RUNTIME_HPP
// Summary: Macros and helper function to get the runtime used for the build.
#if defined(_MSC_VER)
#pragma warning(push, 0)
#endif
#include <cstdlib>
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
#define GTL_PLATFORM_RUNTIME_LIBSTDCPP 0
#define GTL_PLATFORM_RUNTIME_LIBCPP 0
#define GTL_PLATFORM_RUNTIME_MSVC_MT_DLL 0
#define GTL_PLATFORM_RUNTIME_MSVC_MT 0
#define GTL_PLATFORM_RUNTIME_MSVC_ST_DLL 0
#define GTL_PLATFORM_RUNTIME_MSVC_ST 0
#define GTL_PLATFORM_RUNTIME_GLIBC 0
#define GTL_PLATFORM_RUNTIME_INTEL 0
#define GTL_PLATFORM_RUNTIME_UNKNOWN 1
#if (defined(__GLIBCPP__) || defined(__GLIBCXX__))
#undef GTL_PLATFORM_RUNTIME_LIBSTDCPP
#define GTL_PLATFORM_RUNTIME_LIBSTDCPP 1
#endif
#if (defined(_LIBCPP_VERSION))
#undef GTL_PLATFORM_RUNTIME_LIBCPP
#define GTL_PLATFORM_RUNTIME_LIBCPP 1
#endif
#if (defined(_MSC_VER) && defined(_MT) && defined(_DLL))
#undef GTL_PLATFORM_RUNTIME_MSVC_MT_DLL
#define GTL_PLATFORM_RUNTIME_MSVC_MT_DLL 1
#endif
#if (defined(_MSC_VER) && defined(_MT) && !defined(_DLL))
#undef GTL_PLATFORM_RUNTIME_MSVC_MT
#define GTL_PLATFORM_RUNTIME_MSVC_MT 1
#endif
#if (defined(_MSC_VER) && !defined(_MT) && defined(_DLL))
#undef GTL_PLATFORM_RUNTIME_MSVC_ST_DLL
#define GTL_PLATFORM_RUNTIME_MSVC_ST_DLL 1
#endif
#if (defined(_MSC_VER) && !defined(_MT) && !defined(_DLL))
#undef GTL_PLATFORM_RUNTIME_MSVC_ST
#define GTL_PLATFORM_RUNTIME_MSVC_ST 1
#endif
#if (defined(__GLIBC__))
#undef GTL_PLATFORM_RUNTIME_GLIBC
#define GTL_PLATFORM_RUNTIME_GLIBC 1
#endif
#if (defined(__INTEL_CXXLIB_ICC))
#undef GTL_PLATFORM_RUNTIME_INTEL
#define GTL_PLATFORM_RUNTIME_INTEL 1
#endif
#if ( \
(GTL_PLATFORM_RUNTIME_LIBSTDCPP) || \
(GTL_PLATFORM_RUNTIME_LIBCPP) || \
(GTL_PLATFORM_RUNTIME_MSVC_MT_DLL) || \
(GTL_PLATFORM_RUNTIME_MSVC_MT) || \
(GTL_PLATFORM_RUNTIME_MSVC_ST_DLL) || \
(GTL_PLATFORM_RUNTIME_MSVC_ST) || \
(GTL_PLATFORM_RUNTIME_GLIBC) || \
(GTL_PLATFORM_RUNTIME_INTEL) \
)
#undef GTL_PLATFORM_RUNTIME_UNKNOWN
#define GTL_PLATFORM_RUNTIME_UNKNOWN 0
#endif
namespace gtl {
/// @brief Enumeration of the known runtime libraries.
enum class runtime_types {
unknown,
libstdcpp,
libcpp,
mscv_mt_dll,
mscv_mt,
mscv_st_dll,
mscv_st,
glibc,
intel
};
/// @brief Compile time variable holding the detected runtime.
constexpr static const runtime_types runtime = []()constexpr->runtime_types{
#if (GTL_PLATFORM_RUNTIME_LIBSTDCPP)
return runtime_types::libstdcpp;
#elif (GTL_PLATFORM_RUNTIME_LIBCPP)
return runtime_types::libcpp;
#elif (GTL_PLATFORM_RUNTIME_MSVC_MT_DLL)
return runtime_types::mscv_mt_dll;
#elif (GTL_PLATFORM_RUNTIME_MSVC_MT)
return runtime_types::mscv_mt;
#elif (GTL_PLATFORM_RUNTIME_MSVC_ST_DLL)
return runtime_types::mscv_st_dll;
#elif (GTL_PLATFORM_RUNTIME_MSVC_ST)
return runtime_types::mscv_st;
#elif (GTL_PLATFORM_RUNTIME_GLIBC)
return runtime_types::glibc;
#elif (GTL_PLATFORM_RUNTIME_INTEL)
return runtime_types::intel;
#elif (GTL_PLATFORM_RUNTIME_UNKNOWN)
return runtime_types::unknown;
#else
#error "Issue detecting platform runtime."
#endif
}();
}
#endif // GTL_PLATFORM_RUNTIME_HPP