Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages
csdef.h
00001 /* 00002 Copyright (C) 1998-2000 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 #if !defined(CSDEF_FRIEND) 00020 #error You are not allowed to include this file! Include cssysdef.h instead. 00021 #endif 00022 00023 #ifndef __CS_CSDEF_H__ 00024 #define __CS_CSDEF_H__ 00025 00026 #include "csplatform.h" 00027 #include "cstypes.h" 00028 00029 #include <stdio.h> 00030 #include <stdlib.h> 00031 #if defined(CS_HAVE_CMATH_H) 00032 #include <cmath> 00033 #else 00034 #include <math.h> 00035 #endif 00036 #include <time.h> 00037 #include <signal.h> 00038 #include <errno.h> 00039 #include <string.h> 00040 #include <assert.h> 00041 #ifdef CS_HAVE_SYS_PARAM_H 00042 #include <sys/param.h> 00043 #endif 00044 00045 #ifndef MIN 00046 #define MIN(a,b) ((a)<(b)?(a):(b)) 00047 #endif 00048 00049 #ifndef MAX 00050 #define MAX(a,b) ((a)>(b)?(a):(b)) 00051 #endif 00052 00053 #ifndef ABS 00054 #define ABS(x) ((x)<0?-(x):(x)) 00055 #endif 00056 00057 #ifndef SIGN 00058 #define SIGN(x) ((x) < 0 ? -1 : ((x) > 0 ? 1 : 0)) 00059 #endif 00060 00061 #ifndef PI 00062 #define PI 3.1415926535897932385f 00063 #endif 00064 #ifndef HALF_PI 00065 #define HALF_PI (PI / 2.0f) 00066 #endif 00067 #ifndef TWO_PI 00068 #define TWO_PI (PI * 2.0f) 00069 #endif 00070 00071 #undef EPSILON 00072 #define EPSILON 0.001f /* Small value */ 00073 #undef SMALL_EPSILON 00074 #define SMALL_EPSILON 0.000001f /* Very small value */ 00075 #undef SMALL_EPSILON_D 00076 #define SMALL_EPSILON_D 0.000000000001f /* Very, very small value */ 00077 00078 // Platforms with compilers which only understand old-style C++ casting syntax 00079 // should define CS_USE_OLD_STYLE_CASTS. 00080 #if defined(CS_USE_OLD_STYLE_CASTS) 00081 #define CS_CAST(C,T,V) ((T)(V)) 00082 #else 00083 #define CS_CAST(C,T,V) (C<T>(V)) 00084 #endif 00085 00086 #define CS_STATIC_CAST(T,V) CS_CAST(static_cast,T,V) 00087 #define CS_DYNAMIC_CAST(T,V) CS_CAST(dynamic_cast,T,V) 00088 #define CS_REINTERPRET_CAST(T,V) CS_CAST(reinterpret_cast,T,V) 00089 #define CS_CONST_CAST(T,V) CS_CAST(const_cast,T,V) 00090 00091 // DEPRECATED use the CS_ prefix versions instead. 00092 #define STATIC_CAST(T,V) CS_STATIC_CAST(T,V) 00093 #define DYNAMIC_CAST(T,V) CS_DYNAMIC_CAST(T,V) 00094 #define REINTERPRET_CAST(T,V) CS_REINTERPRET_CAST(T,V) 00095 #define CONST_CAST(T,V) CS_CONST_CAST(T,V) 00096 00097 // Platforms which have floating-point variations of the standard math.h 00098 // cos(), sin(), tan(), sqrt(), etc. functions should define 00099 // CS_HAVE_MATH_H_FLOAT_FUNCS. For platforms which do not provide these 00100 // macros or if strict-ANSI conformance is requested, we fake them up. 00101 #if !defined(CS_HAVE_MATH_H_FLOAT_FUNCS) || defined(__STRICT_ANSI__) 00102 #define acosf(X) CS_STATIC_CAST(float,acos(X)) 00103 #define asinf(X) CS_STATIC_CAST(float,asin(X)) 00104 #define atan2f(X,Y) CS_STATIC_CAST(float,atan2(X,Y)) 00105 #define atanf(X) CS_STATIC_CAST(float,atan(X)) 00106 #define cosf(X) CS_STATIC_CAST(float,cos(X)) 00107 #define exp2f(X) CS_STATIC_CAST(float,exp2(X)) 00108 #define expf(X) CS_STATIC_CAST(float,exp(X)) 00109 #define fabsf(X) CS_STATIC_CAST(float,fabs(X)) 00110 #define log10f(X) CS_STATIC_CAST(float,log10(X)) 00111 #define log2f(X) CS_STATIC_CAST(float,log2(X)) 00112 #define logf(X) CS_STATIC_CAST(float,log(X)) 00113 #define powf(X) CS_STATIC_CAST(float,pow(X)) 00114 #define sinf(X) CS_STATIC_CAST(float,sin(X)) 00115 #define sqrtf(X) CS_STATIC_CAST(float,sqrt(X)) 00116 #define tanf(X) CS_STATIC_CAST(float,tan(X)) 00117 #define floorf(X) CS_STATIC_CAST(float,floor(X)) 00118 #define ceilf(X) CS_STATIC_CAST(float,ceil(X)) 00119 #endif 00120 00121 // Platforms which have the PRIx99 printf()-formatting directives should define 00122 // CS_HAVE_C_FORMAT_MACROS. For platforms which do not provide these macros, we 00123 // fake up the commonly used ones. 00124 #if CS_LONG_SIZE == 8 00125 #define __CS_PRI64_PREFIX "l" 00126 #else 00127 #define __CS_PRI64_PREFIX "ll" 00128 #endif 00129 00130 #define CS_PRId64 __CS_PRI64_PREFIX "d" 00131 #define CS_PRIu64 __CS_PRI64_PREFIX "u" 00132 #define CS_PRIx64 __CS_PRI64_PREFIX "x" 00133 #define CS_PRIX64 __CS_PRI64_PREFIX "X" 00134 00135 #if !defined(CS_HAVE_C_FORMAT_MACROS) 00136 #ifndef PRId8 00137 #define PRId8 "d" 00138 #endif 00139 #ifndef PRId16 00140 #define PRId16 "d" 00141 #endif 00142 #ifndef PRId32 00143 #define PRId32 "d" 00144 #endif 00145 #ifndef PRId64 00146 #define PRId64 __CS_PRI64_PREFIX "d" 00147 #endif 00148 #ifndef PRIu8 00149 #define PRIu8 "u" 00150 #endif 00151 #ifndef PRIu16 00152 #define PRIu16 "u" 00153 #endif 00154 #ifndef PRIu32 00155 #define PRIu32 "u" 00156 #endif 00157 #ifndef PRIu64 00158 #define PRIu64 __CS_PRI64_PREFIX "u" 00159 #endif 00160 #ifndef PRIx8 00161 #define PRIx8 "x" 00162 #endif 00163 #ifndef PRIx16 00164 #define PRIx16 "x" 00165 #endif 00166 #ifndef PRIx32 00167 #define PRIx32 "x" 00168 #endif 00169 #ifndef PRIx64 00170 #define PRIx64 __CS_PRI64_PREFIX "x" 00171 #endif 00172 #ifndef PRIX8 00173 #define PRIX8 "X" 00174 #endif 00175 #ifndef PRIX16 00176 #define PRIX16 "X" 00177 #endif 00178 #ifndef PRIX32 00179 #define PRIX32 "X" 00180 #endif 00181 #ifndef PRIX64 00182 #define PRIX64 __CS_PRI64_PREFIX "X" 00183 #endif 00184 00185 #if CS_PROCESSOR_SIZE == 64 00186 #ifndef PRIuPTR 00187 #define PRIuPTR PRIu64 00188 #endif 00189 00190 #ifndef PRIxPTR 00191 #define PRIxPTR PRIx64 00192 #endif 00193 00194 #ifndef PRIdPTR 00195 #define PRIdPTR PRId64 00196 #endif 00197 00198 #ifndef PRIXPTR 00199 #define PRIXPTR PRIX64 00200 #endif 00201 #else 00202 #ifndef PRIuPTR 00203 #define PRIuPTR PRIu32 00204 #endif 00205 00206 #ifndef PRIxPTR 00207 #define PRIxPTR PRIx32 00208 #endif 00209 00210 #ifndef PRIdPTR 00211 #define PRIdPTR PRId32 00212 #endif 00213 00214 #ifndef PRIXPTR 00215 #define PRIXPTR PRIX32 00216 #endif 00217 #endif 00218 #endif 00219 00220 // Platforms with compilers which understand the new C++ keyword `explicit' 00221 // should define CS_HAVE_CXX_KEYWORD_EXPLICIT. 00222 #if !defined(CS_HAVE_CXX_KEYWORD_EXPLICIT) 00223 #define explicit /* nothing */ 00224 #endif 00225 00226 // Platforms with compilers which understand the new C++ keyword `typename' 00227 // should define CS_HAVE_CXX_KEYWORD_TYPENAME. For other compilers, we fake up 00228 // a `typename' keyword which can be used to declare template arguments, such 00229 // as: 00230 // 00231 // template<typename T> class A {...}; 00232 // 00233 // Furthermore, we fake up a synthesized `typename_qualifier' keyword which 00234 // should be used to qualify types within a template declaration rather than 00235 // using `typename'. Usage example: 00236 // 00237 // template<typename T> struct A { 00238 // typedef int B; 00239 // typename_qualifier C::B var; 00240 // typename_qualifier T::Functor get_functor() const; 00241 // }; 00242 #if !defined(CS_HAVE_CXX_KEYWORD_TYPENAME) 00243 #define typename class 00244 #define typename_qualifier 00245 #else 00246 #define typename_qualifier typename 00247 #endif 00248 00249 // Platforms with compilers which do not undersatnd the new C++ explicit 00250 // template specialization syntax `template<>' should define 00251 // CS_USE_OLD_TEMPLATE_SPECIALIZATION. 00252 #if defined(CS_USE_OLD_TEMPLATE_SPECIALIZATION) 00253 #define CS_SPECIALIZE_TEMPLATE 00254 #else 00255 #define CS_SPECIALIZE_TEMPLATE template<> 00256 #endif 00257 00258 // The smallest Z at which 3D clipping occurs 00259 #define SMALL_Z 0.01f 00260 00261 #endif // __CS_CSDEF_H__
Generated for Crystal Space by doxygen 1.4.4