nux-1.16.0
SystemTypes.h
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 <cstddef>
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 // Compile Time
00074 #if defined(__LP64__) || defined(_LP64) || defined(_WIN64)
00075   typedef long long           t_saddress;
00076   typedef unsigned long long  t_uaddress;
00077   typedef t_u64               NUX_POINTER;
00078   typedef long long           t_integer;
00079 #else
00080   typedef int                 t_saddress;
00081   typedef unsigned int        t_uaddress;
00082   typedef t_uint32            NUX_POINTER;
00083   typedef long                t_integer;
00084 #endif
00085 
00086   typedef unsigned long            t_addressu32;
00087   typedef unsigned long long       t_addressu64;
00088 
00089 #define NUX_ADDRESS_TO_PTR(addr) (void*)(addr)
00090 #define NUX_PTR_TO_ADDRESS(ptr)  (t_uaddress)(ptr)
00091 
00092   const t_s8  t_s8_min          =  -128;
00093   const t_s8  t_s8_max          =  127;
00094   const t_u8  t_u8_min          =  0;
00095   const t_u8  t_u8_max          =  255;
00096   const t_s16 t_s16_min         =  -32768;
00097   const t_s16 t_s16_max         =  32767;
00098   const t_u16 t_u16_min         =  0;
00099   const t_u16 t_u16_max         =  65535;
00100   const t_s32 t_s32_min         =  0x80000000;
00101   const t_s32 t_s32_max         =  0x7FFFFFFF;
00102   const t_u32 t_u32_min         =  0x00000000;
00103   const t_u32 t_u32_max         =  0xFFFFFFFF;
00104   const t_s64 t_s64_min         =  0x8000000000000000LL;
00105   const t_s64 t_s64_max         =  0x7FFFFFFFFFFFFFFFLL;
00106   const t_u64 t_u64_min         =  0x0000000000000000ULL;
00107   const t_u64 t_u64_max         =  0xFFFFFFFFFFFFFFFFULL;
00108 
00109   const t_f32 t_f32_min       =  1.175494351E-38F;
00110   const t_f32 t_f32_max         =  3.402823466E+38F;
00111   const t_f64 t_f64_min       =  2.2250738585072014E-308;
00112   const t_f64 t_f64_max         =  1.7976931348623158E+308;
00113 
00114   const t_f32 MinFloat        =  1.175494351E-38F;
00115   const t_f32 MaxFloat          =  3.402823466E+38F;
00116   const t_f64 MinDouble       =  2.2250738585072014E-308;
00117   const t_f64 MaxDouble         =  1.7976931348623158E+308;
00118 
00119 //             ILP32    LP64    LLP64   ILP64
00120 // char         8       8       8       8
00121 // short            16      16      16      16
00122 // int          32          32      32      64
00123 // long         32      64      32      64
00124 // long long    64          64      64      64
00125 // pointer          32      64      64      64
00126 
00127 // Window 64-bit supports LLP64
00128 // Linux 64 bit  supports LP64
00129 // Mac OS 64 bit  supports LP64
00130 
00131 // The size of  a long integer in particular depends on the operating system and the targeted architecture as follows:
00132 //
00133 // OS           arch           size
00134 // Windows       IA-32        4 bytes
00135 // Windows       Intel 64     4 bytes
00136 // Windows       IA-64        4 bytes
00137 // Linux         IA-32        4 bytes
00138 // Linux         Intel 64     8 bytes
00139 // Linux         IA-64        8 bytes
00140 // Mac OS X      IA-32        4 bytes
00141 // Mac OS X      Intel 64     8 bytes
00142 
00143 #define NUX_BYTE_SIZE   1
00144 #define NUX_WORD_SIZE   2
00145 #define NUX_FLOAT_SIZE  4
00146 #define NUX_INT_SIZE    4
00147 #define NUX_DOUBLE_SIZE 8
00148 
00149 // Polymorphic Types
00150 #if defined(_WIN32) || defined(_WIN64)
00151     #define NUX_PTRSIZE_INT     INT_PTR
00152     #define NUX_PTRSIZE_UINT    UINT_PTR
00153     #define NUX_PTRSIZE_DWORD   DWORD_PTR
00154     #define NUX_PTRSIZE_LONG    LONG_PTR
00155     #define NUX_PTRSIZE_ULONG   ULONG_PTR
00156     #define NUX_SIZE_T          SIZE_T
00157     #define NUX_SSIZE_T         SSIZE_T
00158 #else
00159     #define NUX_PTRSIZE_INT     int
00160     #define NUX_PTRSIZE_UINT    unsigned int
00161     #define NUX_PTRSIZE_DWORD   unsigned int
00162     #define NUX_PTRSIZE_LONG    long
00163     #define NUX_PTRSIZE_ULONG   unsigned long
00164     #define NUX_SIZE_T          size_t
00165     #define NUX_SSIZE_T         int
00166 #endif
00167 
00168 
00169 
00170 // #ifdef _WIN32
00171 //     #define NUX_HARDWARE_BREAK __asm {int 3}
00172 //     #define NUX_BREAK_ASM_INT3 __asm {int 3}
00173 // #else
00174 //     #define NUX_HARDWARE_BREAK
00175 //     #define NUX_BREAK_ASM_INT3
00176 // #endif
00177 
00178 #define DEGTORAD(d) (d) * 3.1415927f / 180.0f
00179 #define RADTODEG(d) (d) * 180.0f / 3.1415927f
00180 
00181 
00182 }
00183 #endif // SYSTEMTYPES_H
00184 
00185 /*
00186 
00187  C/C++ recognizes the types shown in the table below.
00188 
00189 Type Name               Bytes               Other Names                         Range of Values
00190 ________________________________________________________________________________________________________________________________
00191 int                     *                   signed,
00192                                             signed int                          System dependent
00193 
00194 unsigned int            *                   unsigned                            System dependent
00195 
00196 __int8                  1                   char,
00197                                             signed char                         -128 to 127
00198 
00199 __int16                 2                   short,
00200                                             short int,
00201                                             signed short int                    -32768 to 32767
00202 
00203 __int32                 4                   signed,
00204                                             signed int                          -2,147,483,648 to 2,147,483,647
00205 
00206 __int64                 8                   none                                -9,223,372,036,854,775,808
00207                                                                                  to 9,223,372,036,854,775,807
00208 
00209 char                    1                   signed char                         -128 to 127
00210 
00211 unsigned char           1                   none                                0 to 255
00212 
00213 short                   2                   short int,
00214                                             signed short int                    -32,768 to 32,767
00215 
00216 unsigned short          2                   unsigned short int                  0 to 65,535
00217 
00218 long                    4                   long int,
00219                                             signed long int                     -2,147,483,648 to 2,147,483,647
00220 
00221 unsigned long           4                   unsigned long int                   0 to 4,294,967,295
00222 
00223 enum                    *                   none                                Same as int
00224 
00225 float                   4                   none                                3.4E +/- 38 (7 digits)
00226 
00227 double                  8                   none                                1.7E +/- 308 (15 digits)
00228 
00229 long double             10                  none                                1.2E +/- 4932 (19 digits)
00230 
00231 
00232 
00233 *: OS dependant
00234 
00235 */
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends