CrystalSpace

Public API Reference

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 #if defined(CS_HAVE_IEEEFP_H)
00037 #include <ieeefp.h>
00038 #endif
00039 #include <time.h>
00040 #include <signal.h>
00041 #include <errno.h>
00042 #include <string.h>
00043 #include <assert.h>
00044 #ifdef CS_HAVE_SYS_PARAM_H
00045 #include <sys/param.h>
00046 #endif
00047 
00048 #ifndef MIN
00049   #define MIN(a,b) ((a)<(b)?(a):(b))
00050 #endif
00051 
00052 #ifndef MAX
00053   #define MAX(a,b) ((a)>(b)?(a):(b))
00054 #endif
00055 
00056 #ifndef ABS
00057  #define ABS(x) ((x)<0?-(x):(x))
00058 #endif
00059 
00060 #ifndef SIGN
00061   #define SIGN(x) ((x) < 0 ? -1 : ((x) > 0 ? 1 : 0))
00062 #endif
00063 
00064 #ifndef PI
00065  #define PI 3.1415926535897932385f
00066 #endif
00067 #ifndef HALF_PI
00068   #define HALF_PI (PI / 2.0f)
00069 #endif
00070 #ifndef TWO_PI
00071   #define TWO_PI (PI * 2.0f)
00072 #endif
00073 
00074 #undef EPSILON
00075 #define EPSILON 0.001f                  /* Small value */
00076 #undef SMALL_EPSILON
00077 #define SMALL_EPSILON 0.000001f         /* Very small value */
00078 #undef SMALL_EPSILON_D
00079 #define SMALL_EPSILON_D 0.000000000001f /* Very, very small value */
00080 
00081 // Platforms which have floating-point variations of the standard math.h
00082 // cos(), sin(), tan(), sqrt(), etc. functions should define
00083 // CS_HAVE_MATH_H_FLOAT_FUNCS. For platforms which do not provide these
00084 // macros or if strict-ANSI conformance is requested, we fake them up.
00085 #if !defined(CS_HAVE_MATH_H_FLOAT_FUNCS) || defined(__STRICT_ANSI__)
00086   #define acosf(X)    static_cast<float> (acos(X))
00087   #define asinf(X)    static_cast<float> (asin(X))
00088   #define atan2f(X,Y) static_cast<float> (atan2(X,Y))
00089   #define atanf(X)    static_cast<float> (atan(X))
00090   #define cosf(X)     static_cast<float> (cos(X))
00091   #define exp2f(X)    static_cast<float> (exp2(X))
00092   #define expf(X)     static_cast<float> (exp(X))
00093   #define fabsf(X)    static_cast<float> (fabs(X))
00094   #define log10f(X)   static_cast<float> (log10(X))
00095   #define log2f(X)    static_cast<float> (log2(X))
00096   #define logf(X)     static_cast<float> (log(X))
00097   #define powf(X)     static_cast<float> (pow(X))
00098   #define sinf(X)     static_cast<float> (sin(X))
00099   #define sqrtf(X)    static_cast<float> (sqrt(X))
00100   #define tanf(X)     static_cast<float> (tan(X))
00101   #define floorf(X)   static_cast<float> (floor(X))
00102   #define ceilf(X)    static_cast<float> (ceil(X))
00103 #endif
00104 
00105 // Platforms which have the PRIx99 printf()-formatting directives should define
00106 // CS_HAVE_C_FORMAT_MACROS. For platforms which do not provide these macros, we
00107 // fake up the commonly used ones.
00108 #if CS_LONG_SIZE == 8
00109   #define __CS_PRI64_PREFIX     "l"
00110 #else
00111   #define __CS_PRI64_PREFIX     "ll"
00112 #endif
00113 
00114 #define CS_PRId64 __CS_PRI64_PREFIX "d"
00115 #define CS_PRIu64 __CS_PRI64_PREFIX "u"
00116 #define CS_PRIx64 __CS_PRI64_PREFIX "x"
00117 #define CS_PRIX64 __CS_PRI64_PREFIX "X"
00118 
00119 #if !defined(CS_HAVE_C_FORMAT_MACROS)
00120   #ifndef PRId8
00121     #define PRId8  "d"
00122   #endif
00123   #ifndef PRId16
00124     #define PRId16 "d"
00125   #endif
00126   #ifndef PRId32
00127     #define PRId32 "d"
00128   #endif
00129   #ifndef PRId64
00130     #define PRId64 __CS_PRI64_PREFIX "d"
00131   #endif
00132   #ifndef PRIu8
00133     #define PRIu8  "u"
00134   #endif
00135   #ifndef PRIu16
00136     #define PRIu16 "u"
00137   #endif
00138   #ifndef PRIu32
00139     #define PRIu32 "u"
00140   #endif
00141   #ifndef PRIu64
00142     #define PRIu64 __CS_PRI64_PREFIX "u"
00143   #endif
00144   #ifndef PRIx8
00145     #define PRIx8  "x"
00146   #endif
00147   #ifndef PRIx16
00148     #define PRIx16 "x"
00149   #endif
00150   #ifndef PRIx32
00151     #define PRIx32 "x"
00152   #endif
00153   #ifndef PRIx64
00154     #define PRIx64 __CS_PRI64_PREFIX "x"
00155   #endif
00156   #ifndef PRIX8
00157     #define PRIX8  "X"
00158   #endif
00159   #ifndef PRIX16
00160     #define PRIX16 "X"
00161   #endif
00162   #ifndef PRIX32
00163     #define PRIX32 "X"
00164   #endif
00165   #ifndef PRIX64
00166     #define PRIX64 __CS_PRI64_PREFIX "X"
00167   #endif
00168   
00169   #if CS_PROCESSOR_SIZE == 64
00170     #ifndef PRIuPTR
00171       #define PRIuPTR  PRIu64
00172     #endif
00173 
00174     #ifndef PRIxPTR
00175       #define PRIxPTR  PRIx64
00176     #endif
00177     
00178     #ifndef PRIdPTR
00179       #define PRIdPTR  PRId64
00180     #endif
00181     
00182     #ifndef PRIXPTR
00183       #define PRIXPTR  PRIX64
00184     #endif
00185   #else
00186     #ifndef PRIuPTR
00187       #define PRIuPTR  PRIu32
00188     #endif
00189 
00190     #ifndef PRIxPTR
00191       #define PRIxPTR  PRIx32
00192     #endif
00193     
00194     #ifndef PRIdPTR
00195       #define PRIdPTR  PRId32
00196     #endif
00197     
00198     #ifndef PRIXPTR
00199       #define PRIXPTR  PRIX32
00200     #endif
00201   #endif
00202 #endif
00203 
00204 // The smallest Z at which 3D clipping occurs
00205 #define SMALL_Z 0.01f
00206 
00207 #endif // __CS_CSDEF_H__

Generated for Crystal Space 1.0.2 by doxygen 1.4.7