-
Notifications
You must be signed in to change notification settings - Fork 0
/
GTypes.h
151 lines (122 loc) · 4.94 KB
/
GTypes.h
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
////////////////////////////////////////////////////////////////////////////////
// /
// 2012-2020 (c) Baical /
// /
// This library is free software; you can redistribute it and/or /
// modify it under the terms of the GNU Lesser General Public /
// License as published by the Free Software Foundation; either /
// version 3.0 of the License, or (at your option) any later version. /
// /
// This library 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 /
// Lesser General Public License for more details. /
// /
// You should have received a copy of the GNU Lesser General Public /
// License along with this library. /
// /
////////////////////////////////////////////////////////////////////////////////
#ifndef GTYPE_H
#define GTYPE_H
#if defined(_M_X64)\
|| defined(__amd64__)\
|| defined(__amd64)\
|| defined(_WIN64)\
|| defined(_WIN64_)\
|| defined(WIN64)\
|| defined(__LP64__)\
|| defined(_LP64)\
|| defined(__x86_64__)\
|| defined(__ppc64__)\
|| defined(__aarch64__)
#define GTX64
#else
#define GTX32
#endif
#define CONCATENATE_DETAIL(x, y) x##y
#define CONCATENATE(x, y) CONCATENATE_DETAIL(x, y)
#define MAKE_UNIQUE(x) CONCATENATE(x, __COUNTER__)
////////////////////////////////////////////////////////////////////////////////
//WINDOWS specific definitions & types
#if defined(_WIN32) || defined(_WIN64)
#define G_OS_WINDOWS
#if !defined(_WINSOCKAPI_)
#include <winsock2.h>
#endif
#include <windows.h>
//Text marco, allow to use wchar_t automatically
#define TM(i_pStr) L##i_pStr
#define XCHAR wchar_t
typedef wchar_t tWCHAR;
#define WND_HANDLE HWND
#define SHARED_EXT L"dll"
#define P7_EXPORT __declspec(dllexport)
#define OS_PATH_SEPARATOR TM("\\")
////////////////////////////////////////////////////////////////////////////////
//LINUX specific definitions & types
#elif defined(__linux__) || defined(__wasm__)
#define UTF8_ENCODING
#define G_OS_LINUX
//Text marco, allow to use char automatically
#define TM(i_pStr) i_pStr
#define XCHAR char
typedef unsigned short tWCHAR;
#define WND_HANDLE void*
#define SHARED_EXT "so"
typedef struct _GUID
{
unsigned int Data1;
unsigned short Data2;
unsigned short Data3;
unsigned char Data4[ 8 ];
} GUID;
#define __stdcall
#define __cdecl
#ifndef __forceinline
#if defined(GTX64) || defined(__PIC__)
#define __forceinline
#else
#define __forceinline __attribute__((always_inline))
#endif
#endif
#define P7_EXPORT __attribute__ ((visibility ("default")))
#define OS_PATH_SEPARATOR TM("/")
#endif
#ifdef _MSC_VER
#define PRAGMA_PACK_ENTER(x) __pragma(pack(push, x))
#define PRAGMA_PACK_EXIT() __pragma(pack(pop))
#define ATTR_PACK(x)
#define ATTR_ALIGN(x)
#define UNUSED_FUNC
#else
#define PRAGMA_PACK_ENTER(x)
#define PRAGMA_PACK_EXIT(x)
#define ATTR_PACK(x) __attribute__ ((aligned(x), packed))
#define ATTR_ALIGN(x) __attribute__ ((aligned(x)))
#define UNUSED_FUNC __attribute__ ((unused))
#endif
#ifndef TRUE
#define TRUE 1
#define FALSE 0
#endif
#define UNUSED_ARG(x) (void)(x)
#define STR_HELPER(x) #x
#define TOSTR(x) STR_HELPER(x)
#define TMM(i_pStr) TM(i_pStr)
typedef unsigned long long tUINT64;
typedef long long tINT64;
typedef unsigned int tUINT32;
typedef int tINT32;
typedef unsigned short tUINT16;
typedef short tINT16;
typedef unsigned char tUINT8;
typedef char tINT8;
typedef char tACHAR;
//platfrorm specific char, Windows - wchar_t, Linix - char,
//XCHAR defined in PTypes.hpp specific for each platform or project.
#define tXCHAR XCHAR
//typedef XCHAR tXCHAR;
typedef unsigned int tBOOL;
typedef double tDOUBLE;
#define GASSERT(cond) typedef int assert_type[(cond) ? 1 : -1]
#endif //GTYPE_H