arch.h
Go to the documentation of this file.00001 /**<!--------------------------------------------------------------------> 00002 @file arch.h 00003 @author Travis Fischer (fisch0920@gmail.com) 00004 @date Summer 2008 00005 00006 @brief 00007 Contains architechure-specific definitions 00008 <!-------------------------------------------------------------------->**/ 00009 00010 #ifndef ARCH_H_ 00011 #define ARCH_H_ 00012 00013 #include <boost/static_assert.hpp> 00014 #include <values.h> 00015 #include <limits> 00016 00017 //#define MILTON_SINGLE_PRECISION (1) 00018 #define MILTON_DOUBLE_PRECISION (1) 00019 00020 //#define MILTON_ENABLE_SSE (1) 00021 00022 #ifdef INFINITY 00023 # undef INFINITY 00024 #endif 00025 00026 // define size_t type 00027 #ifndef _SIZE_T_DEFINED 00028 # include "stddef.h" 00029 #endif 00030 00031 00032 #if defined(__GNUC__) 00033 # include <inttypes.h> 00034 // g++ / Linux 00035 //# define ALIGN_PRE(n) __attribute__ ((aligned((n)))) 00036 # define ALIGN_PRE(n) 00037 # define ALIGN_POST(n) __attribute__ ((aligned((n)))) 00038 #elif defined(_WIN16) || defined(__MSDOS__) || defined(_MSDOS) 00039 # warning "untested..." 00040 # warning "alignment properties of this compiler unknown; SSE implementation " \ 00041 "may be unstable or slow" 00042 00043 // 16 bit systems use long int for 32 bit integer 00044 typedef signed long int int32_t; 00045 typedef unsigned long int uint32_t; 00046 00047 # define ALIGN_PRE(n) 00048 # define ALIGN_POST(n) 00049 #elif defined(_MSC_VER) || defined(_WINDOWS_) 00050 // Microsoft has their own builtin types 00051 typedef signed __int32 int32_t; 00052 typedef unsigned __int32 uint32_t; 00053 typedef signed __int64 int64_t; 00054 typedef unsigned __int64 uint64_t; 00055 00056 // Visual C++ / Windows 00057 # define ALIGN_PRE(n) __declspec(align((n))) 00058 # define ALIGN_POST(n) 00059 #else 00060 # warning "alignment properties of this compiler unknown; SSE implementation " \ 00061 "may be unstable or slow" 00062 00063 // This works with most compilers 00064 typedef signed int int32_t; 00065 typedef unsigned int uint32_t; 00066 typedef long long int64_t; 00067 typedef unsigned long long uint64_t; 00068 00069 # define ALIGN_PRE(n) 00070 # define ALIGN_POST(n) 00071 #endif 00072 00073 00074 00075 #if MILTON_SINGLE_PRECISION 00076 # if MILTON_DOUBLE_PRECISION 00077 # error "floating-point precision cannot be both single and double" 00078 # endif // MILTON_DOUBLE_PRECISION 00079 00080 /// consistent floating-point type used pervasively throughout Milton 00081 typedef float real_t; 00082 00083 # define glVertex3real_t glVertex3f 00084 # define glVertex3real_tv glVertex3fv 00085 # define glColor3real_t glColor3f 00086 # define glColor3real_tv glColor3fv 00087 # define glNormal3real_t glNormal3f 00088 # define glNormal3real_tv glNormal3fv 00089 # define glTexCoord2real_t glTexCoord2f 00090 # define glTexCoord2real_tv glTexCoord2fv 00091 # define glMultMatrixreal_t glMultMatrixf 00092 # define glLoadMatrixreal_t glLoadMatrixf 00093 00094 # define INFINITY (FLT_MAX) 00095 # define EPSILON (1e-5) 00096 00097 #elif MILTON_DOUBLE_PRECISION 00098 00099 /// consistent floating-point type used pervasively throughout Milton 00100 typedef double real_t; 00101 00102 # define glVertex3real_t glVertex3d 00103 # define glVertex3real_tv glVertex3dv 00104 # define glColor3real_t glColor3d 00105 # define glColor3real_tv glColor3dv 00106 # define glNormal3real_t glNormal3d 00107 # define glNormal3real_tv glNormal3dv 00108 # define glTexCoord2real_t glTexCoord2d 00109 # define glTexCoord2real_tv glTexCoord2dv 00110 # define glMultMatrixreal_t glMultMatrixd 00111 # define glLoadMatrixreal_t glLoadMatrixd 00112 00113 # define INFINITY (DBL_MAX) 00114 # define EPSILON (1e-7) 00115 00116 # if MILTON_ENABLE_SSE 00117 # warning "SSE is currently only supported when compiled with " \ 00118 "single-precision floating-point" 00119 # undef MILTON_ENABLE_SSE 00120 # define MILTON_ENABLE_SSE (0) 00121 # endif // MILTON_ENABLE_SSE 00122 #else 00123 # error "floating-point precision must be either single or double" 00124 #endif 00125 00126 #define create_real(x) (static_cast<real_t>(x)) 00127 00128 #define M_PI_DIV_2 (M_PI_2) 00129 #define M_INV_PI (M_1_PI) 00130 #define M_INV_2PI (M_2_PI) 00131 #define M_2PI (2.0 * M_PI) 00132 00133 #ifndef restrict 00134 # define restrict __restrict__ 00135 #endif 00136 00137 // assumptions made throughout Milton 00138 BOOST_STATIC_ASSERT(sizeof(unsigned int) == sizeof(int)); 00139 BOOST_STATIC_ASSERT(sizeof(unsigned int) == sizeof(float)); 00140 00141 // 32-bit machine 00142 BOOST_STATIC_ASSERT(std::numeric_limits<unsigned int>::digits == 32); 00143 BOOST_STATIC_ASSERT(std::numeric_limits<unsigned long long>::digits == 64); 00144 00145 00146 // TODO: how to get num processors / amount of RAM / etc.. 00147 00148 #include <common/math/simd/SIMD.h> 00149 00150 #endif // ARCH_H_ 00151
Generated on 28 Feb 2009 for Milton by
1.5.6