// Copyright (c) 1999 Philip A. Hardin (pahardin@cs.utexas.edu) // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License v2 or later. #ifndef GENERAL_h #define GENERAL_h #ifndef __GNUC__ #ifndef bool #define bool int #endif #endif #ifndef false #define false 0 #endif #ifndef true #define true 1 #endif typedef unsigned char uchar; typedef unsigned int uint; typedef unsigned long ulong; #ifdef __GNUC__ #if __GNUC__ < 3 #define and && #define or || #define not ! #endif // TODO - what about non-GNU C++ compilers? #endif #define forii(limit) for (int i= 0; i // xlC can't handle this for some reason //inline T sqr(T v) {return v*v;} #define sqr(v) ((v)*(v)) template inline bool isBetween(T1 lim1,T2 x,T1 lim2) { return ((lim1 inline bool isBetweenInclusively(T1 lim1,T2 x,T1 lim2) { return ((lim1 <=x and x <=lim2) or (lim2 <=x and x <=lim1));} template inline bool isBetweenExclusively(T1 lim1,T2 x,T1 lim2) { return ((lim1 0)?(x):-(x)) #define roundToLong(x) ((long)(floor(x +0.5))) // These next two func templates allow STL to be used with classes that // don't define operator== and operator< . Just make sure no STL routines // are used that actually _require_ these operators...! #ifndef __GNUC__ template inline bool operator==(const T& a, const T& b) {return false;} template inline bool operator< (const T& a, const T& b) {return false;} #endif extern const int MA_PI; extern double *sinTbl, *cosTbl; void InitFixed(); void SleepFor(int val); double rand(double r); double factorial(int n); #endif