-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcheckBitSize.h
More file actions
60 lines (55 loc) · 1.78 KB
/
checkBitSize.h
File metadata and controls
60 lines (55 loc) · 1.78 KB
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
/* Sebastian Burkhart, 2019 */
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#define BITS_32 4
#define BITS_64 8
#if defined __GNUC__
#if defined __i386
#define TARGET_SIZE BITS_32
#define PLATFORM "i386 linux"
#elif defined __x86_64
#define TARGET_SIZE BITS_64
#define PLATFORM "x86_64 linux"
#elif defined __arm__
#define TARGET_SIZE BITS_32
#define PLATFORM "arm linux"
#elif defined __aarch64__
#define TARGET_SIZE BITS_64
#define PLATFORM "arm (64 bit) linux"
#else
#define PLATFORM "invalid"
#error "unsupported architecture"
#endif
#elif defined _MSC_VER && _MSC_VER >= 1800
#if defined _WIN64 && !defined _M_ARM
#define TARGET_SIZE BITS_64
#define PLATFORM "win64"
#elif defined _WIN32 && !defined _M_ARM
#define TARGET_SIZE BITS_32
#define PLATFORM "win32"
#else
#define PLATFORM "invalid"
#error "unsupported architecture"
#endif
#else
#define PLATFORM "invalid compiler"
#error "unsupported compiler"
#endif
#if defined _MSC_VER && _MSC_VER <= 1800 /* MSVC */
#define SIZE_T_FORMAT "Iu"
#define SIZE_T_CAST(x) ((size_t)(x))
#elif defined(__GNUC__) /* gcc */
#define SIZE_T_FORMAT PRIuMAX
#define SIZE_T_CAST(x) ((uintmax_t)(x))
#else /* fallback */
#define SIZE_T_FORMAT "zu"
#define SIZE_T_CAST(x) ((size_t)(x))
#endif
#define SIZE_T_FORMAT_STRING "%" SIZE_T_FORMAT
#if defined _DEBUG && defined _MSC_VER
#define MSVC_DEBUG_PAUSE system("pause")
#else
#define MSVC_DEBUG_PAUSE
#endif