00001 // ZenLib::ZenTypes - To be independant of system 00002 // Copyright (C) 2002-2003 Jérôme Martinez, Zen@MediaArea.net 00003 // 00004 // This software is provided 'as-is', without any express or implied 00005 // warranty. In no event will the authors be held liable for any damages 00006 // arising from the use of this software. 00007 // 00008 // Permission is granted to anyone to use this software for any purpose, 00009 // including commercial applications, and to alter it and redistribute it 00010 // freely, subject to the following restrictions: 00011 // 00012 // 1. The origin of this software must not be misrepresented; you must not 00013 // claim that you wrote the original software. If you use this software 00014 // in a product, an acknowledgment in the product documentation would be 00015 // appreciated but is not required. 00016 // 2. Altered source versions must be plainly marked as such, and must not be 00017 // misrepresented as being the original software. 00018 // 3. This notice may not be removed or altered from any source distribution. 00019 // 00020 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00021 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00022 // ZenTypes 00023 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00024 // 00025 // Version 0.2.0 00026 // ------------- 00027 // Independancies of types 00028 // Windows : 8, 16, 32, 64 00029 // Linux : 8, 16, 32 00030 // 00031 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00032 // 00033 // 0.2.0 (Zen@MediaArea.net) 00034 // Win32 64 bits 00035 // Linux 8-32 bits 00036 // 00037 // 0.1.0 (Zen@MediaArea.net) 00038 // Win32 8-32 bits 00039 // 00040 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00041 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00042 00043 //--------------------------------------------------------------------------- 00044 #ifndef ZenTypesH 00045 #define ZenTypesH 00046 //--------------------------------------------------------------------------- 00047 00048 //--------------------------------------------------------------------------- 00049 #include <limits.h> 00050 //--------------------------------------------------------------------------- 00051 00052 namespace ZenLib 00053 { 00054 00055 //*************************************************************************** 00056 // Defines 00057 //*************************************************************************** 00058 00059 //--------------------------------------------------------------------------- 00060 //Only one definitaion of Win32 plateforms 00061 #if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) 00062 #define WIN32 00063 #endif 00064 00065 //*************************************************************************** 00066 // Types 00067 //*************************************************************************** 00068 00069 //--------------------------------------------------------------------------- 00070 //8-bit types 00071 #if UCHAR_MAX==0xff 00072 #undef MAXTYPES 00073 #define MAXTYPES 8 00074 typedef unsigned char uint8; 00075 typedef signed char int8; 00076 #else 00077 #error This machine has no 8-bit type 00078 #endif 00079 00080 //--------------------------------------------------------------------------- 00081 //16-bit types 00082 #if UINT_MAX == 0xffff 00083 #undef MAXTYPES 00084 #define MAXTYPES 16 00085 typedef unsigned int uint16; 00086 typedef int int16; 00087 #elif USHRT_MAX == 0xffff 00088 #undef MAXTYPES 00089 #define MAXTYPES 16 00090 typedef unsigned short uint16; 00091 typedef short int16; 00092 #else 00093 #error This machine has no 16-bit type 00094 #endif 00095 00096 //--------------------------------------------------------------------------- 00097 //32-bit types 00098 #if UINT_MAX == 0xfffffffful 00099 #undef MAXTYPES 00100 #define MAXTYPES 32 00101 typedef unsigned int uint32; 00102 typedef int int32; 00103 #elif ULONG_MAX == 0xfffffffful 00104 #undef MAXTYPES 00105 #define MAXTYPES 32 00106 typedef unsigned long uint32; 00107 typedef long int32; 00108 #elif USHRT_MAX == 0xfffffffful 00109 #undef MAXTYPES 00110 #define MAXTYPES 32 00111 typedef unsigned short uint32; 00112 typedef short int32; 00113 #else 00114 #error This machine has no 32-bit type 00115 #endif 00116 00117 //--------------------------------------------------------------------------- 00118 //64-bit types 00119 #if defined(__MINGW32__) || defined(__CYGWIN32__) 00120 #undef MAXTYPES 00121 #define MAXTYPES 64 00122 typedef long long int64; //not tested!!! 00123 typedef unsigned long long uint64; //not tested!!! 00124 #else 00125 #ifdef WIN32 00126 #undef MAXTYPES 00127 #define MAXTYPES 64 00128 typedef __int64 int64; 00129 typedef unsigned __int64 uint64; 00130 #endif 00131 #endif 00132 00133 } //namespace 00134 #endif