CrystalSpace

Public API Reference

Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound 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! Use cssysdef.h instead.
00021 #endif
00022 
00023 #ifndef __CS_CSDEF_H__
00024 #define __CS_CSDEF_H__
00025 
00026 #include "platform.h"
00027 #include "cstypes.h"
00028 
00029 #include <stdio.h>
00030 #include <stdlib.h>
00031 #if defined(CS_HAS_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 
00042 // DEPRECATED use "true" instead
00043 #ifndef TRUE
00044   #define TRUE 1
00045 #endif
00046 
00047 // DEPRECATED use "false" instead
00048 #ifndef FALSE
00049   #define FALSE 0
00050 #endif
00051 
00052 #ifndef MIN
00053   #define MIN(a,b) ((a)<(b)?(a):(b))
00054 #endif
00055 
00056 #ifndef MAX
00057   #define MAX(a,b) ((a)>(b)?(a):(b))
00058 #endif
00059 
00060 #ifndef ABS
00061  #define ABS(x) ((x)<0?-(x):(x))
00062 #endif
00063 
00064 #ifndef SIGN
00065   #define SIGN(x) ((x) < 0 ? -1 : ((x) > 0 ? 1 : 0))
00066 #endif
00067 
00068 #ifndef PI
00069  #define PI 3.1415926535897932385f
00070 #endif
00071 #ifndef HALF_PI
00072   #define HALF_PI (PI / 2.0f)
00073 #endif
00074 #ifndef TWO_PI
00075   #define TWO_PI (PI * 2.0f)
00076 #endif
00077 
00078 #undef EPSILON
00079 #define EPSILON 0.001f                  /* Small value */
00080 #undef SMALL_EPSILON
00081 #define SMALL_EPSILON 0.000001f         /* Very small value */
00082 #undef SMALL_EPSILON_D
00083 #define SMALL_EPSILON_D 0.000000000001f /* Very, very small value */
00084 
00085 // Platforms with compilers which only understand old-style C++ casting syntax
00086 // should define CS_USE_OLD_STYLE_CASTS.
00087 #if defined(CS_USE_OLD_STYLE_CASTS)
00088   #define CS_CAST(C,T,V) ((T)(V))
00089 #else
00090   #define CS_CAST(C,T,V) (C<T>(V))
00091 #endif
00092 
00093 #define CS_STATIC_CAST(T,V)      CS_CAST(static_cast,T,V)
00094 #define CS_DYNAMIC_CAST(T,V)     CS_CAST(dynamic_cast,T,V)
00095 #define CS_REINTERPRET_CAST(T,V) CS_CAST(reinterpret_cast,T,V)
00096 #define CS_CONST_CAST(T,V)       CS_CAST(const_cast,T,V)
00097 
00098 // DEPRECATED use the CS_ prefix versions instead.
00099 #define STATIC_CAST(T,V)      CS_STATIC_CAST(T,V)
00100 #define DYNAMIC_CAST(T,V)     CS_DYNAMIC_CAST(T,V)
00101 #define REINTERPRET_CAST(T,V) CS_REINTERPRET_CAST(T,V)
00102 #define CONST_CAST(T,V)       CS_CONST_CAST(T,V)
00103 
00104 // Platforms which do not have floating-point variations of the standard math.h
00105 // cos(), sin(), tan(), sqrt(), etc. functions should define
00106 // CS_USE_FAKE_MATH_H_FLOAT_FUNCS.
00107 #if defined(CS_USE_FAKE_MATH_H_FLOAT_FUNCS)
00108   #define acosf(X)  CS_STATIC_CAST(float,acos(X))
00109   #define asinf(X)  CS_STATIC_CAST(float,asin(X))
00110   #define atan2f(X) CS_STATIC_CAST(float,atan2(X))
00111   #define atanf(X)  CS_STATIC_CAST(float,atan(X))
00112   #define cosf(X)   CS_STATIC_CAST(float,cos(X))
00113   #define exp2f(X)  CS_STATIC_CAST(float,exp2(X))
00114   #define expf(X)   CS_STATIC_CAST(float,exp(X))
00115   #define log10f(X) CS_STATIC_CAST(float,log10(X))
00116   #define log2f(X)  CS_STATIC_CAST(float,log2(X))
00117   #define logf(X)   CS_STATIC_CAST(float,log(X))
00118   #define powf(X)   CS_STATIC_CAST(float,pow(X))
00119   #define sinf(X)   CS_STATIC_CAST(float,sin(X))
00120   #define sqrtf(X)  CS_STATIC_CAST(float,sqrt(X))
00121   #define tanf(X)   CS_STATIC_CAST(float,tan(X))
00122   #define floorf(X) CS_STATIC_CAST(float,floor(X))
00123   #define ceilf(X)  CS_STATIC_CAST(float,ceil(X))
00124 #endif
00125 
00126 // Platforms with compilers which do not understand the new C++ keyword
00127 // `explicit' should define CS_USE_FAKE_EXPLICIT_KEYWORD.
00128 #if defined(CS_USE_FAKE_EXPLICIT_KEYWORD)
00129   #define explicit /* nothing */
00130 #endif
00131 
00132 // Platforms with compilers which do not understand the new C++ keyword
00133 // `typename' should define CS_USE_FAKE_TYPENAME_KEYWORD.
00134 #if defined(CS_USE_FAKE_TYPENAME_KEYWORD)
00135   #define typename /* nothing */
00136 #endif
00137 
00138 // Platforms with compilers which do not undersatnd the new C++ explicit
00139 // template specialization syntax `template<>' should define
00140 // CS_USE_OLD_TEMPLATE_SPECIALIZATION.
00141 #if defined(CS_USE_OLD_TEMPLATE_SPECIALIZATION)
00142   #define CS_SPECIALIZE_TEMPLATE
00143 #else
00144   #define CS_SPECIALIZE_TEMPLATE template<>
00145 #endif
00146 
00147 // The smallest Z at which 3D clipping occurs
00148 #define SMALL_Z 0.01f
00149 
00150 #endif // __CS_CSDEF_H__

Generated for Crystal Space by doxygen 1.2.18