00001
00002 Copyright (c) 2001, Lee Patterson & Ant Works Software
00003 http://ssobjects.sourceforge.net
00004
00005 created : 00/00/2000 00:00am
00006 filename : defs.h
00007 author : Lee Patterson (lee@antws.com)
00008
00009 purpose : common defines
00010 *********************************************************************/
00011
00012 #ifndef CCDEFS_H
00013 #define CCDEFS_H
00014
00015 #include <sys/types.h>
00016 #include "msdefs.h"
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef _WIN32
00028 # ifndef min
00029 # define min(x,y) (((x)<(y))?(x):(y))
00030 # endif
00031
00032 # ifndef max
00033 # define max(x,y) (((x)>(y))?(x):(y))
00034 # endif
00035 #endif
00036
00037 typedef unsigned char byte;
00038 typedef unsigned short word;
00039 typedef short sword;
00040 typedef long dsword;
00041 typedef unsigned long dword;
00042 #ifndef __USE_MISC
00043 typedef unsigned long ulong;
00044 typedef unsigned int uint;
00045 #endif
00046
00047 typedef const char CONSTCHAR;
00048 typedef const char* PCONSTCHAR;
00049 typedef unsigned char unsigned8;
00050 typedef signed char signed8;
00051 typedef unsigned short unsigned16;
00052 typedef signed short signed16;
00053 typedef unsigned long unsigned32;
00054 typedef signed long signed32;
00055
00056
00057 #define ZEROMEMORY(address, numBytes) memset((void*)(address), (int)0, (size_t)(numBytes))
00058 #define FREE_NULL(ptr) {free(ptr);ptr=NULL;}
00059 #ifdef __cplusplus
00060 #define DELETE_NULL(ptr) { delete ptr; ptr = NULL; }
00061 #endif
00062
00063
00064 #define IS_EVEN(n) ((int)((n)/2)*2 == (n))
00065 #define IS_ODD(n) (!((int)((n)/2)*2 == (n)))
00066 #define NULL_TERMINATE(s,n) ((s[(n)-1] = '\0')) //make the last character of a char array a null character
00067
00068
00069
00070 #define RND(min,max) (rand()%(max+1-min)+min)
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080 #ifndef DEBUG
00081 # define BREAK
00082 #else
00083 # define BREAK asm("int $3")
00084 #endif
00085
00086 #define BREAK_ALWAYS asm("int $3")
00087
00088
00089 #ifndef UNUSED
00090 # ifdef DEBUG
00091 # define UNUSED(x) ((void)x) //kills warning when a parameter isn't used
00092 # else
00093 # define UNUSED(x)
00094 # endif
00095 #endif
00096
00097 #ifndef UNUSED_ALWAYS
00098 # define UNUSED_ALWAYS(x) ((void)x)
00099 #endif
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109 #endif //CCDEFS_H