ReXGlue SDK
Toggle main menu visibility
Loading...
Searching...
No Matches
platform.h
Go to the documentation of this file.
1
13
14
#pragma once
15
16
#if defined(__APPLE__)
17
#include <TargetConditionals.h>
18
#endif
19
20
#if defined(TARGET_OS_MAC) && TARGET_OS_MAC
21
#define REX_PLATFORM_MAC 1
22
#elif defined(WIN32) || defined(_WIN32)
23
#define REX_PLATFORM_WIN32 1
24
#elif defined(__ANDROID__)
25
#define REX_PLATFORM_ANDROID 1
26
#define REX_PLATFORM_LINUX 1
27
#elif defined(__gnu_linux__)
28
#define REX_PLATFORM_GNU_LINUX 1
29
#define REX_PLATFORM_LINUX 1
30
#else
31
#error Unsupported target OS.
32
#endif
33
38
#ifndef REX_PLATFORM_MAC
39
#define REX_PLATFORM_MAC 0
40
#endif
41
#ifndef REX_PLATFORM_WIN32
42
#define REX_PLATFORM_WIN32 0
43
#endif
44
#ifndef REX_PLATFORM_ANDROID
45
#define REX_PLATFORM_ANDROID 0
46
#endif
47
#ifndef REX_PLATFORM_GNU_LINUX
48
#define REX_PLATFORM_GNU_LINUX 0
49
#endif
50
#ifndef REX_PLATFORM_LINUX
51
#define REX_PLATFORM_LINUX 0
52
#endif
53
54
#if defined(__GNUC__) && !defined(__clang__)
55
#define REX_COMPILER_GNUC 1
56
#endif
57
58
#if defined(_M_AMD64) || defined(__amd64__)
59
#define REX_ARCH_AMD64 1
60
#elif defined(_M_ARM64) || defined(__aarch64__)
61
#define REX_ARCH_ARM64 1
62
#elif defined(_M_IX86) || defined(__i386__) || defined(_M_ARM) || defined(__arm__)
63
#error ReX is not supported on 32 bit platforms.
64
#endif
65
66
#if REX_PLATFORM_WIN32
67
#include <intrin.h>
68
#endif
// REX_PLATFORM_WIN32
69
70
#if REX_PLATFORM_MAC
71
#include <libkern/OSByteOrder.h>
72
#endif
// REX_PLATFORM_MAC
73
74
#include <bit>
75
#include <cstdint>
76
84
// NOLINTBEGIN(bugprone-macro-parentheses): body is a whole declaration
85
#if REX_COMPILER_MSVC
86
#define REX_DETAIL_PACKED_SCOPE(body) __pragma(pack(push, 1)) body __pragma(pack(pop));
87
#else
88
#define REX_DETAIL_PACKED_SCOPE(body) \
89
_Pragma("pack(push, 1)") body; \
90
_Pragma("pack(pop)");
91
#endif
// REX_COMPILER_MSVC
92
// NOLINTEND(bugprone-macro-parentheses)
93
107
#define REX_PACKED_STRUCT(name, value) REX_DETAIL_PACKED_SCOPE(struct name value)
120
#define REX_PACKED_STRUCT_ANONYMOUS(value) REX_DETAIL_PACKED_SCOPE(struct value)
133
#define REX_PACKED_UNION(name, value) REX_DETAIL_PACKED_SCOPE(union name value)
134
142
#define REX_XSTRINGIFY(x) #x
150
#define REX_STRINGIFY(x) REX_XSTRINGIFY(x)
151
153
#if defined(__has_cpp_attribute)
154
#if __has_cpp_attribute(clang::musttail)
155
#define REX_MUSTTAIL [[clang::musttail]]
156
#endif
157
#endif
158
#ifndef REX_MUSTTAIL
159
#define REX_MUSTTAIL
160
#endif
161
170
#if REX_PLATFORM_WIN32
171
#if defined(REX_BUILDING_BASE)
172
#define REX_API __declspec(dllexport)
173
#else
174
#define REX_API __declspec(dllimport)
175
#endif
176
#else
177
#define REX_API __attribute__((visibility("default")))
178
#endif
179
187
#if REX_PLATFORM_WIN32
188
#if defined(REX_BUILDING_PPC)
189
#define REX_PPC_API __declspec(dllexport)
190
#else
191
#define REX_PPC_API __declspec(dllimport)
192
#endif
193
#else
194
#define REX_PPC_API __attribute__((visibility("default")))
195
#endif
196
204
#if REX_PLATFORM_WIN32
205
#if defined(REX_BUILDING_APU)
206
#define REX_APU_API __declspec(dllexport)
207
#else
208
#define REX_APU_API __declspec(dllimport)
209
#endif
210
#else
211
#define REX_APU_API __attribute__((visibility("default")))
212
#endif
213
221
#if REX_PLATFORM_WIN32
222
#if defined(REX_BUILDING_HID)
223
#define REX_HID_API __declspec(dllexport)
224
#else
225
#define REX_HID_API __declspec(dllimport)
226
#endif
227
#else
228
#define REX_HID_API __attribute__((visibility("default")))
229
#endif
230
238
#if REX_PLATFORM_WIN32
239
#if defined(REX_BUILDING_GPU)
240
#define REX_GPU_API __declspec(dllexport)
241
#else
242
#define REX_GPU_API __declspec(dllimport)
243
#endif
244
#else
245
#define REX_GPU_API __attribute__((visibility("default")))
246
#endif
247
255
#if REX_PLATFORM_WIN32
256
#if defined(REX_BUILDING_UI)
257
#define REX_UI_API __declspec(dllexport)
258
#else
259
#define REX_UI_API __declspec(dllimport)
260
#endif
261
#else
262
#define REX_UI_API __attribute__((visibility("default")))
263
#endif
264
272
#if REX_PLATFORM_WIN32
273
#if defined(REX_BUILDING_APP)
274
#define REX_APP_API __declspec(dllexport)
275
#else
276
#define REX_APP_API __declspec(dllimport)
277
#endif
278
#else
279
#define REX_APP_API __attribute__((visibility("default")))
280
#endif
281
290
#if REX_PLATFORM_WIN32
291
#if defined(REX_BUILDING_KERNEL)
292
#define REX_KERNEL_API __declspec(dllexport)
293
#else
294
#define REX_KERNEL_API __declspec(dllimport)
295
#endif
296
#else
297
#define REX_KERNEL_API __attribute__((visibility("default")))
298
#endif
299
307
#if REX_PLATFORM_WIN32
308
#if defined(REX_BUILDING_XAM)
309
#define REX_XAM_API __declspec(dllexport)
310
#else
311
#define REX_XAM_API __declspec(dllimport)
312
#endif
313
#else
314
#define REX_XAM_API __attribute__((visibility("default")))
315
#endif
316
325
#if defined(REX_BUILDING_KERNEL)
326
#define REX_DETAIL_ENTRY_EXPORT REX_KERNEL_API
327
#else
328
#define REX_DETAIL_ENTRY_EXPORT
329
#endif
330
339
#if REX_PLATFORM_WIN32
340
#define REX_DETAIL_EXPORT __declspec(dllexport)
341
#else
342
#define REX_DETAIL_EXPORT __attribute__((visibility("default")))
343
#endif
344
345
namespace
rex::platform
{
346
347
inline
constexpr
bool
kWindows = REX_PLATFORM_WIN32;
348
inline
constexpr
bool
kLinux = REX_PLATFORM_LINUX;
349
inline
constexpr
bool
kMac =
REX_PLATFORM_MAC
;
350
inline
constexpr
bool
kPosix = kLinux || kMac;
351
352
#if REX_PLATFORM_WIN32
353
inline
constexpr
char
kPathSeparator =
'\\'
;
354
#else
355
inline
constexpr
char
kPathSeparator =
'/'
;
356
#endif
// REX_PLATFORM_WIN32
357
358
}
// namespace rex::platform
rex::platform
Definition
platform.h:345
REX_PLATFORM_MAC
#define REX_PLATFORM_MAC
Definition
platform.h:39
rex
platform.h
Generated by
1.18.0