YSTest: Platform.h 源文件

YSTest PreAlpha_b900_20201012 The YSLib Test Project

Platform.h
浏览该文件的文档.
1 /*
2 © 2009-2016, 2018-2020 FrankHB.
3
4 This file is part of the YSLib project, and may only be used,
5 modified, and distributed under the terms of the YSLib project
6 license, LICENSE.TXT. By continuing to use, modify, or distribute
7 this file you indicate that you have read the license and
8 understand and accept it fully.
9 */
10
28 #ifndef YCL_INC_Platform_h_
29 #define YCL_INC_Platform_h_ 1
30
31 #include <ydef.h> // for std::uintmax_t, ystdex::byte, ystdex::octet,
32 // ystdex::ptrdiff_t, ystdex::size_t, ystdex::wint_t, ystdex::nullptr_t;
33
40 #if defined(YF_DLL) && defined(YF_BUILD_DLL)
41 # error "DLL could not be built and used at the same time."
42 #endif
43
44 #if YB_IMPL_MSCPP \
45 || (YB_IMPL_GNUC && (defined(__MINGW32__) || defined(__CYGWIN__)))
46 # ifdef YF_DLL
47 # define YF_API __declspec(dllimport)
48 # elif defined(YF_BUILD_DLL)
49 # define YF_API __declspec(dllexport)
50 # else
51 # define YF_API
52 # endif
53 #elif defined(YF_BUILD_DLL) && (YF_IMPL_GNUCPP >= 40000 || YF_IMPL_CLANGPP)
54 # define YF_API YF_ATTR(__visibility__("default"))
55 #else
56 # define YF_API
57 #endif
58
130 #define YF_Platform_DS 0x4001
131
136 #define YF_Platform_Win32 0x4101
137
142 #define YF_Platform_MinGW32 0x4102
143
150 #define YF_Platform_Win64 0x4111
151
158 #define YF_Platform_MinGW64 0x4112
159
164 #define YF_Platform_Android 0x4200
165
171 #define YF_Platform_Android_ARM 0x4201
172
177 #define YF_Platform_Linux 0x4300
178
185 #define YF_Platform_Linux_x86 0x4301
186
191 #define YF_Platform_Linux_x64 0x4302
192
197 #define YF_Platform_OS_X 0x4401
198
204 #ifdef __MSYS__
205 # error "MSYS is not currently supported. Use MinGW targets instead."
206 #elif defined(__MINGW64__)
207 # define YF_Platform YF_Platform_MinGW64
208 #elif defined(__MINGW32__)
209 # define YF_Platform YF_Platform_MinGW32
210 #elif defined(_WIN64)
211 # define YF_Platform YF_Platform_Win64
212 #elif defined(_WIN32)
213 # define YF_Platform YF_Platform_Win32
214 #elif defined(__ANDROID__)
215 // TODO: Precise architecture detection.
216 # define YF_Platform YF_Platform_Android_ARM
217 #elif defined(__linux__)
218 # ifdef __i386__
219 # define YF_Platform YF_Platform_Linux_x64
220 # elif defined(__x86_64__)
221 # define YF_Platform YF_Platform_Linux_x86
222 # endif
223 #elif defined(__APPLE__)
224 # ifdef __MACH__
225 # define YF_Platform YF_Platform_OS_X
226 # else
227 # error "Apple platforms other than OS X is not supported."
228 # endif
229 #elif !defined(YF_Platform)
230 //当前默认以 DS 作为目标平台。
231 # define YF_Platform YF_Platform_DS
232 #endif
233
234
235
237
238
270
307 #undef YCL_HostedUI_XCB
308
309
318 #ifdef __linux__
319 # define YCL_Linux 1
320 # define YF_Hosted 1
321 # ifndef YF_Use_POSIXThread
322 # define YF_Use_POSIXThread 1
323 # endif
324 # define YCL_API_POSIXFileSystem 1
325 # define YCL_API_Has_dirent_h 1
326 # define YCL_API_Has_semaphore_h 1
327 # define YCL_API_Has_unistd_h 1
328 #elif defined(__MACH__)
329 # define YF_Hosted 1
330 #endif
331 #if YF_Platform == YF_Platform_DS
332 # define YCL_DS 1
333 # define YF_Hosted 0
334 # define YCL_API_POSIXFileSystem 1
335 # define YCL_API_Has_dirent_h 1
336 # define YCL_API_Has_unistd_h 1
337 # define YCL_Device_Cursor_FixedKey 1
338 #elif YF_Platform == YF_Platform_Win32
339 # define YCL_Win32 1
340 # define YF_Hosted 1
341 #elif YF_Platform == YF_Platform_MinGW32
342 # define YCL_MinGW 1
343 # define YCL_Win32 1
344 # define YF_Hosted 1
345 #elif YF_Platform == YF_Platform_Win64
346 # define YCL_Win32 1
347 # define YCL_Win64 1
348 # define YF_Hosted 1
349 # ifndef YF_Use_POSIXThread
350 # define YF_Use_POSIXThread 1
351 # endif
352 #elif YF_Platform == YF_Platform_MinGW64
353 # define YCL_MinGW 1
354 # define YCL_Win32 1
355 # define YCL_Win64 1
356 # define YF_Hosted 1
357 # ifndef YF_Use_POSIXThread
358 # define YF_Use_POSIXThread 1
359 # endif
360 #elif YF_Platform == YF_Platform_Android_ARM
361 # define YCL_Android 1
362 # ifndef YF_Use_POSIXThread
363 # define YF_Use_POSIXThread 1
364 # endif
365 # ifndef YF_Use_JNI
366 # define YF_Use_JNI 0x00010006
367 # endif
368 #elif YF_Platform == YF_Platform_Linux_x86 \
369 || YF_Platform == YF_Platform_Linux_x64
370 # define YCL_HostedUI_XCB 1
371 #elif YF_Platform == YF_Platform_OS_X
372 # define YCL_OS_X 1
373 # ifndef YF_Use_POSIXThread
374 # define YF_Use_POSIXThread 1
375 # endif
376 # define YCL_API_POSIXFileSystem 1
377 # define YCL_API_Has_dirent_h 1
378 # define YCL_API_Has_unistd_h 1
379 #else
380 # error "Unsupported platform found."
381 #endif
382
383 #if YF_Hosted && YCL_API_POSIXFileSystem
384 # if _POSIX_C_SOURCE < 200809L
385 // NOTE: This is required at least for 'at*' functions.
386 # error "POSIX.1-2008 is required for hosted implementations using POSIX \
387 file systems."
388 # endif
389 #endif
390
391 #ifndef YCL_HostedUI_XCB
392 # define YCL_HostedUI_XCB 0
393 #endif
394 #ifndef YCL_HostedUI
395 # if YCL_HostedUI_XCB || YCL_Win32 || YCL_Android
396 # define YCL_HostedUI 1
397 # else
398 # define YCL_HostedUI 0
399 # endif
400 #endif
401
402 #if YCL_HostedUI_XCB && !defined(YF_Use_XCB)
403 # define YF_Use_XCB 0x11100
404 #endif
405
406 // NOTE: See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63287.
407 #if __STDCPP_THREADS__
408 # define YF_Multithread 1
409 #elif YCL_Win32 || YCL_Android || YCL_Linux || YCL_OS_X
410 # define YF_Multithread 1
411 #else
412 # define YF_Multithread 0
413 #endif
414
420 namespace platform
422 {
423
425 inline namespace basic_types
426 {
427
433 using ystdex::byte;
436 using ystdex::octet;
437 using ystdex::ptrdiff_t;
438 using ystdex::size_t;
440 using ystdex::wint_t;
442 using ystdex::nullptr_t;
444
445 } // inline namespace basic_types;
446
447 } // namespace platform;
448
450 namespace platform_ex
451 {
452
453 using namespace platform::basic_types;
454
455 } // namespace platform_ex;
456
457 #endif
458
platform_ex
平台扩展命名空间。
Definition: Android.h:46
platform::size_t
YB_ATTR_nodiscard YF_API size_t
Definition: FileIO.h:1345
platform::basic_types
Definition: Platform.h:426
ystdex::nullptr_t
空指针类。
Definition: ydef.h:1321
ydef.h
语言实现和系统环境相关特性及公用类型和宏的基础定义。
platform
默认平台命名空间。
Definition: Container.h:56
ystdex::octet
void octet
Definition: ydef.h:1294
ystdex::byte
unsigned char byte
字节类型。
Definition: ydef.h:1283