nux-0.9.48
|
00001 /* 00002 * Copyright 2010 Inalogic® Inc. 00003 * 00004 * This program is free software: you can redistribute it and/or modify it 00005 * under the terms of the GNU Lesser General Public License, as 00006 * published by the Free Software Foundation; either version 2.1 or 3.0 00007 * of the License. 00008 * 00009 * This program is distributed in the hope that it will be useful, but 00010 * WITHOUT ANY WARRANTY; without even the implied warranties of 00011 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR 00012 * PURPOSE. See the applicable version of the GNU Lesser General Public 00013 * License for more details. 00014 * 00015 * You should have received a copy of both the GNU Lesser General Public 00016 * License along with this program. If not, see <http://www.gnu.org/licenses/> 00017 * 00018 * Authored by: Jay Taoko <jaytaoko@inalogic.com> 00019 * 00020 */ 00021 00022 00023 #ifndef SYSTEMTYPES_H 00024 #define SYSTEMTYPES_H 00025 00026 #include "Namespace.h" 00027 00028 namespace nux 00029 { 00030 // Note: do not use long: long is 64 bits in LP64 while it remains 32 bits on LLP64 00031 00032 typedef unsigned char t_u8, t_byte, t_uchar; // 0 to 255 00033 typedef char t_char; // –128 to 127 00034 // signed char is a distinct type. See ANSI C Draft Standard and the keyword "signed" 00035 typedef signed char t_s8, t_schar; // –128 to 127 00036 00037 typedef unsigned short t_u16, t_uint16, t_ushort, t_word; // 0 to 65,535 00038 typedef short t_s16, t_int16, t_short; // –32,768 to 32,767 00039 00040 typedef unsigned int t_u32, t_uint32, t_uint, t_dword; // 0 to 4,294,967,295 00041 typedef int t_s32, t_int32, t_int; // –2,147,483,648 to 2,147,483,647 00042 00043 typedef unsigned long t_ulong; // 0 to 4,294,967,295 00044 typedef long t_long; // –2,147,483,648 to 2,147,483,647 00045 00046 typedef unsigned long long t_u64, t_uint64, t_qword, t_ulonglong; // 0 to 18,446,744,073,709,551,615 00047 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 00048 00049 typedef float t_float, t_f32; // 3.4E +/- 38 (7 digits) 00050 typedef double t_double, t_f64; // 1.7E +/- 308 (15 digits) 00051 00052 typedef char *t_pchar; 00053 typedef wchar_t t_wchar; 00054 typedef unsigned short t_unicodechar, *t_punicodechar; 00055 typedef bool t_bool; 00056 00057 typedef void t_void, *t_pvoid; 00058 00059 typedef unsigned char t_UTF8; 00060 typedef unsigned int t_UTF32; 00061 #ifdef _WIN32 00062 typedef wchar_t t_UTF16; 00063 #elif defined(__linux) 00064 typedef wchar_t t_UTF16; 00065 #elif defined (__APPLE__) 00066 typedef wchar_t t_UTF16; 00067 #else 00068 #error t_UTF16 is undefined for this platform. 00069 #endif 00070 00071 typedef std::size_t t_size; 00072 00073 // // HARDWARE 00074 // #if defined _M_X64 00075 // typedef long long t_integer; // 64 bits 00076 // typedef long long *t_pointer; // 64 bits 00077 // const long long t_MaxInteger = 0xFFFFFFFFFFFFFFFF; 00078 // typedef long long t_saddress; 00079 // typedef unsigned long long t_uaddress; 00080 // // #elif defined _WIN32 00081 // // typedef long t_integer; // 32 bits 00082 // // typedef long *t_pointer; // 32 bits 00083 // // const long t_MaxInteger = 0xFFFFFFFF; 00084 // // typedef long t_saddress; 00085 // // typedef unsigned long t_uaddress; 00086 // #elif defined(__linux) && (defined(__ia64__) || defined(__amd64__)) 00087 // typedef long long t_integer; // 64 bits 00088 // typedef long long *t_pointer; // 64 bits 00089 // const long long t_MaxInteger = 0xFFFFFFFFFFFFFFFF; 00090 // #elif defined __linux 00091 // typedef long t_integer; // 32 bits 00092 // typedef long *t_pointer; // 32 bits 00093 // const long t_MaxInteger = 0xFFFFFFFF; 00094 // #elif defined __APPLE__ 00095 // typedef long long t_integer; // 64 bits 00096 // typedef long long *t_pointer; // 64 bits 00097 // const long long t_MaxInteger = 0xFFFFFFFFFFFFFFFF; 00098 // #endif 00099 00100 00101 00102 00103 // Compile Time 00104 #if defined(__LP64__) || defined(_LP64) || defined(_WIN64) 00105 typedef long long t_saddress; 00106 typedef unsigned long long t_uaddress; 00107 typedef t_u64 NUX_POINTER; 00108 typedef long long t_integer; 00109 #else 00110 typedef int t_saddress; 00111 typedef unsigned int t_uaddress; 00112 typedef t_uint32 NUX_POINTER; 00113 typedef long t_integer; 00114 #endif 00115 00116 typedef unsigned long t_addressu32; 00117 typedef unsigned long long t_addressu64; 00118 00119 #define NUX_ADDRESS_TO_PTR(addr) (void*)(addr) 00120 #define NUX_PTR_TO_ADDRESS(ptr) (t_uaddress)(ptr) 00121 00122 const t_s8 t_s8_min = -128; 00123 const t_s8 t_s8_max = 127; 00124 const t_u8 t_u8_min = 0; 00125 const t_u8 t_u8_max = 255; 00126 const t_s16 t_s16_min = -32768; 00127 const t_s16 t_s16_max = 32767; 00128 const t_u16 t_u16_min = 0; 00129 const t_u16 t_u16_max = 65535; 00130 const t_s32 t_s32_min = 0x80000000; 00131 const t_s32 t_s32_max = 0x7FFFFFFF; 00132 const t_u32 t_u32_min = 0x00000000; 00133 const t_u32 t_u32_max = 0xFFFFFFFF; 00134 const t_s64 t_s64_min = 0x8000000000000000LL; 00135 const t_s64 t_s64_max = 0x7FFFFFFFFFFFFFFFLL; 00136 const t_u64 t_u64_min = 0x0000000000000000ULL; 00137 const t_u64 t_u64_max = 0xFFFFFFFFFFFFFFFFULL; 00138 00139 const t_f32 t_f32_min = 1.175494351E-38F; 00140 const t_f32 t_f32_max = 3.402823466E+38F; 00141 const t_f64 t_f64_min = 2.2250738585072014E-308; 00142 const t_f64 t_f64_max = 1.7976931348623158E+308; 00143 00144 const t_f32 MinFloat = 1.175494351E-38F; 00145 const t_f32 MaxFloat = 3.402823466E+38F; 00146 const t_f64 MinDouble = 2.2250738585072014E-308; 00147 const t_f64 MaxDouble = 1.7976931348623158E+308; 00148 00149 // ILP32 LP64 LLP64 ILP64 00150 // char 8 8 8 8 00151 // short 16 16 16 16 00152 // int 32 32 32 64 00153 // long 32 64 32 64 00154 // long long 64 64 64 64 00155 // pointer 32 64 64 64 00156 00157 // Window 64-bit supports LLP64 00158 // Linux 64 bit supports LP64 00159 // Mac OS 64 bit supports LP64 00160 00161 // The size of a long integer in particular depends on the operating system and the targeted architecture as follows: 00162 // 00163 // OS arch size 00164 // Windows IA-32 4 bytes 00165 // Windows Intel 64 4 bytes 00166 // Windows IA-64 4 bytes 00167 // Linux IA-32 4 bytes 00168 // Linux Intel 64 8 bytes 00169 // Linux IA-64 8 bytes 00170 // Mac OS X IA-32 4 bytes 00171 // Mac OS X Intel 64 8 bytes 00172 00173 #ifdef _WIN32 00174 #define NUX_PTR_TO_INT(ptr) (long)((long)(ptr)) 00175 #elif _WIN64 00176 #define NUX_PTR_TO_INT(ptr) (long long)((long long)(ptr)) 00177 #elif __linux 00178 #define NUX_PTR_TO_INT(ptr) (long)((long)(ptr)) 00179 #elif defined(__linux) && (defined(__ia64__) || defined(__amd64__)) 00180 #define NUX_PTR_TO_INT(ptr) (long long)((long long)(ptr)) 00181 #elif __APPLE__ 00182 #define NUX_PTR_TO_INT(ptr) (long long)((long long)(ptr)) 00183 #endif 00184 00185 #define NUX_BYTE_SIZE 1 00186 #define NUX_WORD_SIZE 2 00187 #define NUX_FLOAT_SIZE 4 00188 #define NUX_INT_SIZE 4 00189 #define NUX_DOUBLE_SIZE 8 00190 00191 // Polymorphic Types 00192 #if defined(_WIN32) || defined(_WIN64) 00193 #define NUX_PTRSIZE_INT INT_PTR 00194 #define NUX_PTRSIZE_UINT UINT_PTR 00195 #define NUX_PTRSIZE_DWORD DWORD_PTR 00196 #define NUX_PTRSIZE_LONG LONG_PTR 00197 #define NUX_PTRSIZE_ULONG ULONG_PTR 00198 #define NUX_SIZE_T SIZE_T 00199 #define NUX_SSIZE_T SSIZE_T 00200 #else 00201 #define NUX_PTRSIZE_INT int 00202 #define NUX_PTRSIZE_UINT unsigned int 00203 #define NUX_PTRSIZE_DWORD unsigned int 00204 #define NUX_PTRSIZE_LONG long 00205 #define NUX_PTRSIZE_ULONG unsigned long 00206 #define NUX_SIZE_T size_t 00207 #define NUX_SSIZE_T int 00208 #endif 00209 00210 00211 00212 // #ifdef _WIN32 00213 // #define NUX_HARDWARE_BREAK __asm {int 3} 00214 // #define NUX_BREAK_ASM_INT3 __asm {int 3} 00215 // #else 00216 // #define NUX_HARDWARE_BREAK 00217 // #define NUX_BREAK_ASM_INT3 00218 // #endif 00219 00220 #define DEGTORAD(d) (d) * 3.1415927f / 180.0f 00221 #define RADTODEG(d) (d) * 180.0f / 3.1415927f 00222 00223 00224 } 00225 #endif // SYSTEMTYPES_H 00226 00227 /* 00228 00229 C/C++ recognizes the types shown in the table below. 00230 00231 Type Name Bytes Other Names Range of Values 00232 ________________________________________________________________________________________________________________________________ 00233 int * signed, 00234 signed int System dependent 00235 00236 unsigned int * unsigned System dependent 00237 00238 __int8 1 char, 00239 signed char -128 to 127 00240 00241 __int16 2 short, 00242 short int, 00243 signed short int -32768 to 32767 00244 00245 __int32 4 signed, 00246 signed int -2,147,483,648 to 2,147,483,647 00247 00248 __int64 8 none -9,223,372,036,854,775,808 00249 to 9,223,372,036,854,775,807 00250 00251 char 1 signed char -128 to 127 00252 00253 unsigned char 1 none 0 to 255 00254 00255 short 2 short int, 00256 signed short int -32,768 to 32,767 00257 00258 unsigned short 2 unsigned short int 0 to 65,535 00259 00260 long 4 long int, 00261 signed long int -2,147,483,648 to 2,147,483,647 00262 00263 unsigned long 4 unsigned long int 0 to 4,294,967,295 00264 00265 enum * none Same as int 00266 00267 float 4 none 3.4E +/- 38 (7 digits) 00268 00269 double 8 none 1.7E +/- 308 (15 digits) 00270 00271 long double 10 none 1.2E +/- 4932 (19 digits) 00272 00273 00274 00275 *: OS dependant 00276 00277 */