CrystalSpace

Public API Reference

Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

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 
00027 #include "csplatform.h"
00028 #include <float.h>
00029 
00030 #if defined(CS_HAVE_STDINT_H)
00031 #ifndef __STDC_CONSTANT_MACROS
00032 #define __STDC_CONSTANT_MACROS
00033 #endif
00034 #ifndef __STDC_LIMIT_MACROS
00035 #define __STDC_LIMIT_MACROS
00036 #endif
00037 #include <stdint.h>
00038 #endif
00039 
00040 #if defined(CS_HAVE_INTTYPES_H)
00041 #ifndef __STDC_FORMAT_MACROS
00042 #define __STDC_FORMAT_MACROS
00043 #endif
00044 #include <inttypes.h>
00045 #endif
00046 
00055 #ifndef CS_HAVE_STDINT_H
00056 
00057 typedef unsigned char uint8;
00059 typedef char int8;
00061 typedef unsigned short uint16;
00063 typedef short int16;
00065 typedef unsigned int uint32;
00067 typedef int int32;
00068 #if defined(CS_COMPILER_GCC)
00069 
00070 typedef unsigned long long uint64;
00072 typedef long long int64;
00073 #elif defined(CS_COMPILER_MSVC) || defined(CS_COMPILER_BCC)
00074 
00075 typedef unsigned __int64 uint64;
00077 typedef __int64 int64;
00078 #else
00079 #error Do not know how to declare 64-bit integers
00080 #endif // CS_COMPILER_GCC
00081 
00082 #else // CS_HAVE_STDINT_H
00083 
00084 typedef uint8_t uint8;
00085 typedef int8_t int8;
00086 typedef uint16_t uint16;
00087 typedef int16_t int16;
00088 typedef uint32_t uint32;
00089 typedef int32_t int32;
00090 typedef uint64_t uint64;
00091 typedef int64_t int64;
00092 #endif
00093 
00094 #ifdef CS_HAVE_INT64_C
00095 
00101 #define CONST_INT64(x) INT64_C(x)
00102 
00108 #define CONST_UINT64(x) UINT64_C(x)
00109 
00110 #else // CS_HAVE_INT64_C
00111 
00112 #if defined(CS_COMPILER_GCC)
00113 #define CONST_INT64(x)  x ## LL
00114 #define CONST_UINT64(x) x ## ULL
00115 #elif defined(CS_COMPILER_MSVC) || defined(CS_COMPILER_BCC)
00116 #define CONST_INT64(x)  x##i64
00117 #define CONST_UINT64(x) x##ui64
00118 #else
00119 #error Do not know how to contruct 64-bit integer constants
00120 #endif // CS_COMPILER_GCC
00121 
00122 #endif // CS_HAVE_INT64_C
00123 
00129 // Provide intptr_t and uintptr_t. If the configure script determined that
00130 // these types exist in the standard headers, then just employ those types.
00131 // For MSVC, where the configure script is not used, check <stddef.h>, which is
00132 // one of several headers which may provide these types. We can tell if
00133 // <stddef.h> provided the types by checking if _INTPTR_T_DEFINED has been
00134 // #defined; newer versions of MSVC will provide them; older ones will not.  If
00135 // all else fails, then we fake up these types on our own.
00136 #include <stddef.h>
00137 #if !defined(CS_HAVE_INTPTR_T) && !defined(_INTPTR_T_DEFINED)
00138 
00139 #if CS_PROCESSOR_SIZE == 64
00140 typedef int64 intptr_t;
00141 typedef uint64 uintptr_t;
00142 typedef int64 ptrdiff_t;
00143 #else
00144 
00145 typedef int intptr_t;
00147 typedef unsigned int uintptr_t;
00149 typedef int ptrdiff_t;
00150 #endif
00151 
00152 #define _INTPTR_T_DEFINED
00153 #define _UINTPTR_T_DEFINED
00154 #define _PTRDIFF_T_DEFINED
00155 #endif
00156 
00157 #if !defined(CS_HAVE_INTMAX_T)
00158 
00159 typedef int64 intmax_t;
00161 typedef uint64 uintmax_t;
00162 #endif
00163 
00164 
00165 // Provide wchar_t and wint_t. If the configure script determined that these
00166 // types exist in the standard headers, then just employ those types.  For
00167 // MSVC, where the configure script is not used, check <stddef.h>, <wchar.h>,
00168 // and <wctype.h>, which are three of several headers which may provide these
00169 // types. We can tell if these headers provided the types by checking if
00170 // _WCHAR_T_DEFINED and _WCTYPE_T_DEFINED have been #defined; newer versions of
00171 // MSVC will provide them; older ones will not.  If all else fails, then we
00172 // fake up these types on our own. glibc also #defines _WINT_T when wint_t is
00173 // available, so we double-check that, as well.
00174 #include <stddef.h>
00175 #if defined(CS_HAVE_WCHAR_H)
00176 #include <wchar.h>
00177 #endif
00178 #if defined(CS_HAVE_WCTYPE_H)
00179 #include <wctype.h>
00180 #endif
00181 #if !defined(CS_HAVE_WCHAR_T) && !defined(_WCHAR_T_DEFINED)
00182 typedef uint16 wchar_t;
00183 #define _WCHAR_T_DEFINED
00184 #define CS_WCHAR_T_SIZE 2
00185 #endif
00186 #if !defined(CS_HAVE_WINT_T) && !defined(_WCTYPE_T_DEFINED) && \
00187     !defined(_WINT_T)
00188 typedef wchar_t wint_t;
00189 #define _WCTYPE_T_DEFINED
00190 #define _WINT_T
00191 #endif
00192 
00193 
00194 #if defined(CS_COMPILER_GCC)
00195 #ifndef __STRICT_ANSI__
00196 
00199 typedef long long longlong;
00203 typedef unsigned long long ulonglong;
00204 #else
00205 // @@@ Correct?
00206 typedef int64 longlong;
00207 typedef uint64 ulonglong;
00208 #endif
00209 #elif defined(CS_COMPILER_MSVC) || defined(CS_COMPILER_BCC)
00210 typedef int64 longlong;
00211 typedef uint64 ulonglong;
00212 #else
00213 #ifdef CS_HAVE_STDINT_H
00214 typedef int_least64_t longlong;
00215 typedef uint_least64_t ulonglong;
00216 #else 
00217 #error Do not know how to declare (u)longlong types
00218 #endif 
00219 #endif 
00220 
00227 typedef unsigned int csTicks;
00228 
00230 typedef unsigned int uint;
00235 #endif // __CS_CSTYPES_H__

Generated for Crystal Space by doxygen 1.4.4