1 ////////////////////////////////////////////////////////////////////// 2 // 3 // Pixie 4 // 5 // Copyright � 1999 - 2003, Okan Arikan 6 // 7 // Contact: okan@cs.utexas.edu 8 // 9 // This library is free software; you can redistribute it and/or 10 // modify it under the terms of the GNU Lesser General Public 11 // License as published by the Free Software Foundation; either 12 // version 2.1 of the License, or (at your option) any later version. 13 // 14 // This library is distributed in the hope that it will be useful, 15 // but WITHOUT ANY WARRANTY; without even the implied warranty of 16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 // Lesser General Public License for more details. 18 // 19 // You should have received a copy of the GNU Lesser General Public 20 // License along with this library; if not, write to the Free Software 21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 22 // 23 /////////////////////////////////////////////////////////////////////// 24 /////////////////////////////////////////////////////////////////////// 25 // 26 // File : global.h 27 // Classes : - 28 // Description : Some global definitions 29 // 30 //////////////////////////////////////////////////////////////////////// 31 32 33 // 34 // 35 // 36 // 37 // 38 // 39 // This header has to be included from every file 40 // 41 // 42 // 43 // 44 // 45 // 46 // 47 #ifndef GLOBAL_H 48 #define GLOBAL_H 49 50 // The Pixie version 51 #define VERSION_RELEASE 2 52 #define VERSION_BETA 2 53 #define VERSION_ALPHA 6 54 55 // Some constant definitions 56 57 // Math constants 58 #ifdef C_INFINITY 59 #undef C_INFINITY 60 #endif 61 62 #ifdef C_EPSILON 63 #undef C_EPSILON 64 #endif 65 66 #ifdef C_EPSILON_TINY 67 #undef C_EPSILON_TINY 68 #endif 69 70 #define C_INFINITY 1e30f 71 #define C_EPSILON 1e-6f 72 #define C_EPSILON_TINY 1e-12f 73 #define C_PI 3.141592653589793238462643383279502884197169399375105820974944592308 74 75 // Logic constants 76 #ifndef TRUE 77 #define TRUE 1 78 #endif 79 80 #ifndef FALSE 81 #define FALSE 0 82 #endif 83 84 85 // Misc Options and Attributes constants 86 #ifdef min 87 #undef min 88 #endif 89 90 #ifdef max 91 #undef max 92 #endif 93 94 #ifdef radians 95 #undef radians 96 #endif 97 98 #ifdef degrees 99 #undef degrees 100 #endif 101 102 #define min(a,b) ((a) < (b) ? (a) : (b)) 103 #define max(a,b) ((a) > (b) ? (a) : (b)) 104 #define radians(a) ((a)*C_PI/180.) 105 #define degrees(a) ((a)*180./ C_PI) 106 107 // This structure encapsulates a 32 bit word 108 typedef union { 109 int integer; 110 unsigned int uinteger; 111 float real; 112 char character; 113 } T32; 114 115 // This structure encapsulates a 64 bit word 116 typedef union { 117 long long integer; 118 void *pointer; 119 char *string; 120 double real; 121 } T64; 122 123 124 // Some useful machinery for memory management 125 #ifdef _WINDOWS 126 #ifdef _DEBUG 127 #include <assert.h> 128 129 // Register some junk for memory leak detection 130 #define _CRTDBG_MAP_ALLOC 131 #include <stdlib.h> 132 #include <crtdbg.h> 133 134 #define MYDEBUG_NEW new( _NORMAL_BLOCK, __FILE__, __LINE__) 135 #define new MYDEBUG_NEW 136 #endif 137 #endif 138 139 #ifdef __APPLE__ 140 #include <assert.h> 141 #endif 142 143 // Useful macros for allocating/deallocating untyped memory (aligned to 8 bytes) 144 #define allocate_untyped(__size) (void*) new long long[(__size + sizeof(long long) - 1) / sizeof(long long)] 145 #define free_untyped(__ptr) delete[] ((long long *) __ptr) 146 147 #ifndef assert 148 #define assert(__cond) 149 #endif 150 151 152 // Include the global config file if available 153 #ifdef HAVE_CONFIG_H 154 #include "../../config.h" 155 #else 156 157 // Are we running under Visual Studio? 158 #ifdef _WINDOWS 159 #include "../../config.windows.h" 160 #endif 161 162 // Are we running under XCode? 163 #if defined(__APPLE__) || defined(__APPLE_CC__) 164 #include "../../config.xcode.h" 165 #endif 166 167 #endif 168 169 #endif 170 171