2
* Copyright 2010 Inalogic Inc.
4
* This program is free software: you can redistribute it and/or modify it
5
* under the terms of the GNU Lesser General Public License version 3, as
6
* published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranties of
10
* MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
11
* PURPOSE. See the applicable version of the GNU Lesser General Public
12
* License for more details.
14
* You should have received a copy of both the GNU Lesser General Public
15
* License version 3 along with this program. If not, see
16
* <http://www.gnu.org/licenses/>
18
* Authored by: Jay Taoko <jay.taoko_AT_gmail_DOT_com>
26
#include "Namespace.h"
30
// Note: do not use long: long is 64 bits in LP64 while it remains 32 bits on LLP64
32
typedef unsigned char t_u8, t_byte, t_uchar; // 0 to 255
33
typedef char t_char; // ļæ½128 to 127
34
// signed char is a distinct type. See ANSI C Draft Standard and the keyword "signed"
35
typedef signed char t_s8, t_schar; // ļæ½128 to 127
37
typedef unsigned short t_u16, t_uint16, t_ushort, t_word; // 0 to 65,535
38
typedef short t_s16, t_int16, t_short; // ļæ½32,768 to 32,767
40
typedef unsigned int t_u32, t_uint32, t_uint, t_dword; // 0 to 4,294,967,295
41
typedef int t_s32, t_int32, t_int; // ļæ½2,147,483,648 to 2,147,483,647
43
typedef unsigned long t_ulong; // 0 to 4,294,967,295
44
typedef long t_long; // ļæ½2,147,483,648 to 2,147,483,647
46
typedef unsigned long long t_u64, t_uint64, t_qword, t_ulonglong; // 0 to 18,446,744,073,709,551,615
47
typedef long long t_s64, t_int64, t_sqword, t_slonglong; // ļæ½9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
49
typedef float t_float, t_f32; // 3.4E +/- 38 (7 digits)
50
typedef double t_double, t_f64; // 1.7E +/- 308 (15 digits)
52
typedef char *t_pchar;
53
typedef wchar_t t_wchar;
54
typedef unsigned short t_unicodechar, *t_punicodechar;
57
typedef void t_void, *t_pvoid;
59
typedef unsigned char t_UTF8;
60
typedef unsigned int t_UTF32;
62
typedef wchar_t t_UTF16;
63
#elif defined(__linux)
64
typedef wchar_t t_UTF16;
65
#elif defined (__APPLE__)
66
typedef wchar_t t_UTF16;
68
#error t_UTF16 is undefined for this platform.
71
typedef std::size_t t_size;
75
// typedef long long t_integer; // 64 bits
76
// typedef long long *t_pointer; // 64 bits
77
// const long long t_MaxInteger = 0xFFFFFFFFFFFFFFFF;
78
// typedef long long t_saddress;
79
// typedef unsigned long long t_uaddress;
80
// // #elif defined _WIN32
81
// // typedef long t_integer; // 32 bits
82
// // typedef long *t_pointer; // 32 bits
83
// // const long t_MaxInteger = 0xFFFFFFFF;
84
// // typedef long t_saddress;
85
// // typedef unsigned long t_uaddress;
86
// #elif defined(__linux) && (defined(__ia64__) || defined(__amd64__))
87
// typedef long long t_integer; // 64 bits
88
// typedef long long *t_pointer; // 64 bits
89
// const long long t_MaxInteger = 0xFFFFFFFFFFFFFFFF;
90
// #elif defined __linux
91
// typedef long t_integer; // 32 bits
92
// typedef long *t_pointer; // 32 bits
93
// const long t_MaxInteger = 0xFFFFFFFF;
94
// #elif defined __APPLE__
95
// typedef long long t_integer; // 64 bits
96
// typedef long long *t_pointer; // 64 bits
97
// const long long t_MaxInteger = 0xFFFFFFFFFFFFFFFF;
104
#if defined(__LP64__) || defined(_LP64) || defined(_WIN64)
105
typedef long long t_saddress;
106
typedef unsigned long long t_uaddress;
107
typedef t_u64 NUX_POINTER;
108
typedef long long t_integer;
110
typedef int t_saddress;
111
typedef unsigned int t_uaddress;
112
typedef t_uint32 NUX_POINTER;
113
typedef long t_integer;
116
typedef unsigned long t_addressu32;
117
typedef unsigned long long t_addressu64;
119
#define NUX_ADDRESS_TO_PTR(addr) (void*)(addr)
120
#define NUX_PTR_TO_ADDRESS(ptr) (t_uaddress)(ptr)
122
const t_s8 t_s8_min = -128;
123
const t_s8 t_s8_max = 127;
124
const t_u8 t_u8_min = 0;
125
const t_u8 t_u8_max = 255;
126
const t_s16 t_s16_min = -32768;
127
const t_s16 t_s16_max = 32767;
128
const t_u16 t_u16_min = 0;
129
const t_u16 t_u16_max = 65535;
130
const t_s32 t_s32_min = 0x80000000;
131
const t_s32 t_s32_max = 0x7FFFFFFF;
132
const t_u32 t_u32_min = 0x00000000;
133
const t_u32 t_u32_max = 0xFFFFFFFF;
134
const t_s64 t_s64_min = 0x8000000000000000LL;
135
const t_s64 t_s64_max = 0x7FFFFFFFFFFFFFFFLL;
136
const t_u64 t_u64_min = 0x0000000000000000ULL;
137
const t_u64 t_u64_max = 0xFFFFFFFFFFFFFFFFULL;
139
const t_f32 t_f32_min = 1.175494351E-38F;
140
const t_f32 t_f32_max = 3.402823466E+38F;
141
const t_f64 t_f64_min = 2.2250738585072014E-308;
142
const t_f64 t_f64_max = 1.7976931348623158E+308;
144
const t_f32 MinFloat = 1.175494351E-38F;
145
const t_f32 MaxFloat = 3.402823466E+38F;
146
const t_f64 MinDouble = 2.2250738585072014E-308;
147
const t_f64 MaxDouble = 1.7976931348623158E+308;
149
// ILP32 LP64 LLP64 ILP64
154
// long long 64 64 64 64
155
// pointer 32 64 64 64
157
// Window 64-bit supports LLP64
158
// Linux 64 bit supports LP64
159
// Mac OS 64 bit supports LP64
161
// The size of a long integer in particular depends on the operating system and the targeted architecture as follows:
164
// Windows IA-32 4 bytes
165
// Windows Intel 64 4 bytes
166
// Windows IA-64 4 bytes
167
// Linux IA-32 4 bytes
168
// Linux Intel 64 8 bytes
169
// Linux IA-64 8 bytes
170
// Mac OS X IA-32 4 bytes
171
// Mac OS X Intel 64 8 bytes
174
#define NUX_PTR_TO_INT(ptr) (long)((long)(ptr))
176
#define NUX_PTR_TO_INT(ptr) (long long)((long long)(ptr))
178
#define NUX_PTR_TO_INT(ptr) (long)((long)(ptr))
179
#elif defined(__linux) && (defined(__ia64__) || defined(__amd64__))
180
#define NUX_PTR_TO_INT(ptr) (long long)((long long)(ptr))
182
#define NUX_PTR_TO_INT(ptr) (long long)((long long)(ptr))
185
#define NUX_BYTE_SIZE 1
186
#define NUX_WORD_SIZE 2
187
#define NUX_FLOAT_SIZE 4
188
#define NUX_INT_SIZE 4
189
#define NUX_DOUBLE_SIZE 8
192
#if defined(_WIN32) || defined(_WIN64)
193
#define NUX_PTRSIZE_INT INT_PTR
194
#define NUX_PTRSIZE_UINT UINT_PTR
195
#define NUX_PTRSIZE_DWORD DWORD_PTR
196
#define NUX_PTRSIZE_LONG LONG_PTR
197
#define NUX_PTRSIZE_ULONG ULONG_PTR
198
#define NUX_SIZE_T SIZE_T
199
#define NUX_SSIZE_T SSIZE_T
201
#define NUX_PTRSIZE_INT int
202
#define NUX_PTRSIZE_UINT unsigned int
203
#define NUX_PTRSIZE_DWORD unsigned int
204
#define NUX_PTRSIZE_LONG long
205
#define NUX_PTRSIZE_ULONG unsigned long
206
#define NUX_SIZE_T size_t
207
#define NUX_SSIZE_T int
213
// #define NUX_HARDWARE_BREAK __asm {int 3}
214
// #define NUX_BREAK_ASM_INT3 __asm {int 3}
216
// #define NUX_HARDWARE_BREAK
217
// #define NUX_BREAK_ASM_INT3
220
#define DEGTORAD(d) (d) * 3.1415927f / 180.0f
221
#define RADTODEG(d) (d) * 180.0f / 3.1415927f
225
#endif // SYSTEMTYPES_H
229
C/C++ recognizes the types shown in the table below.
231
Type Name Bytes Other Names Range of Values
232
________________________________________________________________________________________________________________________________
234
signed int System dependent
236
unsigned int * unsigned System dependent
239
signed char -128 to 127
243
signed short int -32768 to 32767
246
signed int -2,147,483,648 to 2,147,483,647
248
__int64 8 none -9,223,372,036,854,775,808
249
to 9,223,372,036,854,775,807
251
char 1 signed char -128 to 127
253
unsigned char 1 none 0 to 255
256
signed short int -32,768 to 32,767
258
unsigned short 2 unsigned short int 0 to 65,535
261
signed long int -2,147,483,648 to 2,147,483,647
263
unsigned long 4 unsigned long int 0 to 4,294,967,295
265
enum * none Same as int
267
float 4 none 3.4E +/- 38 (7 digits)
269
double 8 none 1.7E +/- 308 (15 digits)
271
long double 10 none 1.2E +/- 4932 (19 digits)