cstypes.h
Go to the documentation of this file.00001 /* 00002 Copyright (C) 1998-2004 by Jorrit Tyberghein 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public 00015 License along with this library; if not, write to the Free 00016 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00017 */ 00018 00019 #ifndef __CS_CSTYPES_H__ 00020 #define __CS_CSTYPES_H__ 00021 00028 #include "csplatform.h" 00029 #include <float.h> 00030 00031 #if defined(CS_HAVE_STDINT_H) 00032 #ifndef __STDC_CONSTANT_MACROS 00033 #define __STDC_CONSTANT_MACROS 00034 #endif 00035 #ifndef __STDC_LIMIT_MACROS 00036 #define __STDC_LIMIT_MACROS 00037 #endif 00038 #include <stdint.h> 00039 #endif 00040 00041 #if defined(CS_HAVE_INTTYPES_H) 00042 #ifndef __STDC_FORMAT_MACROS 00043 #define __STDC_FORMAT_MACROS 00044 #endif 00045 #include <inttypes.h> 00046 #endif 00047 00056 #if !defined(CS_HAVE_STDINT_H) && !defined(CS_HAVE_INTTYPES_H) 00058 typedef unsigned char uint8; 00060 typedef char int8; 00062 typedef unsigned short uint16; 00064 typedef short int16; 00066 typedef unsigned int uint32; 00068 typedef int int32; 00069 #if defined(CS_COMPILER_GCC) 00070 #ifndef __STRICT_ANSI__ 00072 typedef unsigned long long uint64; 00074 typedef long long int64; 00075 #endif 00076 #elif defined(CS_COMPILER_MSVC) || defined(CS_COMPILER_BCC) 00078 typedef unsigned __int64 uint64; 00080 typedef __int64 int64; 00081 #else 00082 #error Do not know how to declare 64-bit integers 00083 #endif // CS_COMPILER_GCC 00084 00085 #else // CS_HAVE_STDINT_H || CS_HAVE_INTTYPES_H 00086 00087 typedef uint8_t uint8; 00088 typedef int8_t int8; 00089 typedef uint16_t uint16; 00090 typedef int16_t int16; 00091 typedef uint32_t uint32; 00092 typedef int32_t int32; 00093 typedef uint64_t uint64; 00094 typedef int64_t int64; 00095 #endif 00096 00097 #ifdef CS_HAVE_INT64_C 00098 00104 #define CONST_INT64(x) INT64_C(x) 00105 00111 #define CONST_UINT64(x) UINT64_C(x) 00112 00113 #else // CS_HAVE_INT64_C 00114 00115 #if defined(CS_COMPILER_GCC) 00116 #define CONST_INT64(x) x ## LL 00117 #define CONST_UINT64(x) x ## ULL 00118 #elif defined(CS_COMPILER_MSVC) || defined(CS_COMPILER_BCC) 00119 #define CONST_INT64(x) x##i64 00120 #define CONST_UINT64(x) x##ui64 00121 #else 00122 #error Do not know how to contruct 64-bit integer constants 00123 #endif // CS_COMPILER_GCC 00124 00125 #endif // CS_HAVE_INT64_C 00126 00132 // Provide intptr_t and uintptr_t. If the configure script determined that 00133 // these types exist in the standard headers, then just employ those types. 00134 // For MSVC, where the configure script is not used, check <stddef.h>, which is 00135 // one of several headers which may provide these types. We can tell if 00136 // <stddef.h> provided the types by checking if _INTPTR_T_DEFINED has been 00137 // #defined; newer versions of MSVC will provide them; older ones will not. If 00138 // all else fails, then we fake up these types on our own. 00139 #include <stddef.h> 00140 #if !defined(CS_HAVE_INTPTR_T) && !defined(_INTPTR_T_DEFINED) 00141 00142 #if CS_PROCESSOR_SIZE == 64 00143 typedef int64 intptr_t; 00144 typedef uint64 uintptr_t; 00145 typedef int64 ptrdiff_t; 00146 #else 00148 typedef int intptr_t; 00150 typedef unsigned int uintptr_t; 00152 typedef int ptrdiff_t; 00153 #endif 00154 00155 #define _INTPTR_T_DEFINED 00156 #define _UINTPTR_T_DEFINED 00157 #define _PTRDIFF_T_DEFINED 00158 #endif 00159 00160 #if !defined(CS_HAVE_INTMAX_T) 00162 typedef int64 intmax_t; 00164 typedef uint64 uintmax_t; 00165 #endif 00166 00167 00168 // Provide wchar_t and wint_t. If the configure script determined that these 00169 // types exist in the standard headers, then just employ those types. For 00170 // MSVC, where the configure script is not used, check <stddef.h>, <wchar.h>, 00171 // and <wctype.h>, which are three of several headers which may provide these 00172 // types. We can tell if these headers provided the types by checking if 00173 // _WCHAR_T_DEFINED and _WCTYPE_T_DEFINED have been #defined; newer versions of 00174 // MSVC will provide them; older ones will not. If all else fails, then we 00175 // fake up these types on our own. glibc also #defines _WINT_T when wint_t is 00176 // available, so we double-check that, as well. 00177 #include <stddef.h> 00178 #if defined(CS_HAVE_WCHAR_H) 00179 #include <wchar.h> 00180 #endif 00181 #if defined(CS_HAVE_WCTYPE_H) 00182 #include <wctype.h> 00183 #endif 00184 #if !defined(CS_HAVE_WCHAR_T) && !defined(_WCHAR_T_DEFINED) 00185 typedef uint16 wchar_t; 00186 #define _WCHAR_T_DEFINED 00187 #define CS_WCHAR_T_SIZE 2 00188 #endif 00189 #if !defined(CS_HAVE_WINT_T) && !defined(_WCTYPE_T_DEFINED) && \ 00190 !defined(_WINT_T) 00191 typedef wchar_t wint_t; 00192 #define _WCTYPE_T_DEFINED 00193 #define _WINT_T 00194 #endif 00195 00196 00197 #if defined(CS_COMPILER_GCC) 00198 #ifndef __STRICT_ANSI__ 00199 00202 typedef long long longlong; 00206 typedef unsigned long long ulonglong; 00207 #else 00208 // @@@ Correct? 00209 typedef int64 longlong; 00210 typedef uint64 ulonglong; 00211 #endif 00212 #elif defined(CS_COMPILER_MSVC) || defined(CS_COMPILER_BCC) 00213 typedef int64 longlong; 00214 typedef uint64 ulonglong; 00215 #else 00216 #ifdef CS_HAVE_STDINT_H 00217 typedef int_least64_t longlong; 00218 typedef uint_least64_t ulonglong; 00219 #else 00220 #error Do not know how to declare (u)longlong types 00221 #endif 00222 #endif 00223 00230 typedef unsigned int csTicks; 00231 00233 typedef unsigned int uint; 00238 #endif // __CS_CSTYPES_H__
Generated for Crystal Space by doxygen 1.4.7