#ifndef MACROUTILS
#define MACROUTILS

/*
   some ugly (but usefull) defines and things.


   (c) 1996 Steven Pigeon & Les Logiciels Bergama Enr.


*/


/* Defines, macros, etc. */


#define min(a,b) (((a)>(b)) ? (b):(a))
#define max(a,b) (((a)>(b)) ? (a):(b))
#define decnz(x)  if ((x)>0) (x)--
#define inctop(x,y) if ((x)<(y)) (x)++
#define iff(cond,a,b)  ((cond) ? (a):(b))
#define sqr(x)   ((x)*(x))
#define cube(x)  ((x)*(x)*(x))

inline void swapint (int & a, int & b) { int t=a;a=b;b=t; }
inline void swapuint (unsigned int & a, unsigned int & b) { unsigned int t=a;a=b;b=t; }
inline void swapshort (short &a, short &b) { short t=a;a=b;b=t; }
inline void swapushort (unsigned short &a, unsigned short &b) {unsigned short t=a;a=b;b=t; }
inline void swapbyte ( char &a, char & b) { char t=a;a=b;b=t; }
inline void swapubyte (unsigned char &a,unsigned char & b) {unsigned char t=a;a=b;b=t; }
inline void swapmem( void *a, void *b, int c) { int t; for (t=0;t<c;t++) swapbyte(((char *)a)[t],((char *)b)[t]); }


#endif

