-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathNTypes.h
executable file
·160 lines (129 loc) · 3.8 KB
/
NTypes.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
152
153
154
155
156
157
158
159
160
/*
*
* Copyright (C) 2006-2014 Jürg Müller, CH-5524
*
* This program 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 of the License, or
* (at your option) any later version.
*
* 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#if !defined(NTypes_H)
#define NTypes_H
#if defined(__BIGENDIAN__)
#define cBigEndianMachine true
#else
#define cBigEndianMachine false
#endif
// list predefined macros:
// gcc -arch x86_64 -dM -E - < /dev/null | sort
#if (defined(__APPLE__) || defined(__clang__)) && !defined(__MAC__)
#define __MAC__
#endif
#if defined(__GNUC__) && !defined(__MINGW32__) && !defined(__LINUX__)
#define __LINUX__
#endif
#if !defined(__64__) && defined(__x86_64__)
#define __64__
#endif
// Embarcadero: _WIN64, __WIN32__
// Borland: __WIN32__
// Visual Studio: _WIN32, _MSC_VER
// GNU C: __GNUC__
#if !defined(__WINDOWS__) && !defined(__LINUX__)
#if defined(__WIN64__) || defined(__WIN32__) || defined(_WIN32)
#define __WINDOWS__
#endif
#endif
#if (defined(__x86_64__) || defined(__x86_64) || defined(_WIN64)) && !defined(__64__)
#define __64__
#endif
#if !defined(__ARM__) && (defined(__arm__) || defined(__linux__))
#define __ARM__
#endif
#if (defined(__MAC__) || defined(__ARM__)) && !defined(__LINUX__)
#define __LINUX__
#endif
#if defined(_MSC_VER) && !defined(__VC__)
#define __VC__
#endif
#if (defined(__BORLANDC__) || defined(__VC__)) && !defined(__WINDOWS__)
#define __WINDOWS__
#endif
#if defined(__LINUX__) || defined(__CYGWIN__) || defined(__GNUC__)
#if defined(__64__)
typedef signed long TInt64;
typedef unsigned long TUInt64;
#else
typedef signed long long TInt64;
typedef unsigned long long TUInt64;
#endif
#define GNU_LINUX
#elif defined(__WINDOWS__)
typedef __int64 TInt64;
typedef unsigned __int64 TUInt64;
#endif
#if (_FILE_OFFSET_BITS==64) || defined(__64__)
typedef TUInt64 TFileSize;
#else
typedef unsigned long TFileSize;
#endif
typedef TInt64 TGeneralValue;
#if defined(__64__)
typedef TInt64 TNativeInt;
#else
typedef int TNativeInt;
#endif
#if !defined(__WINDOWS__) && !defined(__CYGWIN__)
#define __stdcall
#endif
#if defined(__VC__)
#define stricmp _stricmp
#define chmod _chmod
#define strnicmp _strnicmp
#define putenv _putenv
#endif
#if defined(__LINUX__)
#define stricmp strcasecmp
#define strnicmp strncasecmp
#endif
#if (_FILE_OFFSET_BITS==64) && !defined(__64__) && !defined(__ARM__)
// #define ftell ftello
// #define fseek fseeko
#define ftell ltell
#endif
#define High(A) (sizeof(A)/sizeof(A[0]) - 1)
#ifdef __cplusplus
template <class T> T Min(const T A, const T B)
{
return (A < B ? A : B);
}
template <class T> T Max(const T A, const T B)
{
return (A >= B ? A : B);
}
template <class T> T sqr(const T x)
{
return x*x;
}
template <class T> T Abs(const T x)
{
if (x < 0)
return -x;
else
return x;
}
template <class T> void xchange(T & v, T & w)
{
T r;
r = v; v = w; w = r;
}
#endif
#endif