Main Page | Alphabetical List | Compound List | File List | Compound Members | File Members

utility.h

Go to the documentation of this file.
00001 #ifndef __COMPUTIL_UTILITY_H
00002 #define __COMPUTIL_UTILITY_H
00003 
00004 /****************************************************************************************/
00005 /*  Utility.h                                                                                   */
00006 /*                                                                                      */
00007 /*  Author: Charles Bloom                                                               */
00008 /*  Description:  Macros                                                                                */
00009 /*                                                                                      */
00010 /*  The contents of this file are subject to the Genesis3D Public License               */
00011 /*  Version 1.01 (the "License"); you may not use this file except in                   */
00012 /*  compliance with the License. You may obtain a copy of the License at                */
00013 /*  http://www.genesis3d.com                                                            */
00014 /*                                                                                      */
00015 /*  Software distributed under the License is distributed on an "AS IS"                 */
00016 /*  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.  See                */
00017 /*  the License for the specific language governing rights and limitations              */
00018 /*  under the License.                                                                  */
00019 /*                                                                                      */
00020 /*  The Original Code is Genesis3D, released March 25, 1999.                            */
00021 /*  Genesis3D Version 1.1 released November 15, 1999                                 */
00022 /*  Copyright (C) 1999 WildTangent, Inc. All Rights Reserved           */
00023 /*                                                                                      */
00024 /****************************************************************************************/
00025 
00026 #include "basetype.h"
00027 #include "ram.h"
00028 #include "errorlog.h"
00029 #include <assert.h>
00030 #include <stdlib.h>
00031 #include <string.h>     // for memcpy,memset
00032 
00033 #ifdef __cplusplus
00034 extern "C" {
00035 #endif
00036 
00037 typedef unsigned int uint;
00038 
00039 /****************************************/
00040 
00041 #define BrandoError(str)        geErrorLog_AddString(-1,str,NULL)
00042 
00043 #ifndef NULL
00044 #define NULL (0)
00045 #endif
00046 
00047 #define sizeofpointer sizeof(void *)
00048 
00049 #define PaddedSize(a) (((a)+3) & (~3))
00050 
00051 #define IsOdd(a)  ( ((uint32)a)&1 )
00052 #define SignOf(a) (((a) < 0) ? -1 : 1)
00053 
00054 #ifndef max
00055 #define max(a,b) ((a)>(b)?(a):(b))
00056 #endif
00057 
00058 #ifndef min
00059 #define min(a,b) ((a)<(b)?(a):(b))
00060 #endif
00061 
00062 #define minmax(x,lo,hi) ( (x)<(lo)?(lo):( (x)>(hi)?(hi):(x)) )
00063 #define putminmax(x,lo,hi) x = minmax(x,lo,hi)
00064 #define putmin(x,lo) x = min(x,lo)
00065 #define putmax(x,hi) x = max(x,hi)
00066 #define max3(a,b,c) max(max(a,b),c)
00067 #define max4(a,b,c,d) max(a,max3(b,c,d))
00068 #define min3(a,b,c) min(min(a,b),c)
00069 #define min4(a,b,c,d) min(a,min3(b,c,d))
00070 
00071 #ifndef mabs
00072 #define mabs(i) ((i) < 0 ? -(i) : (i))
00073 #endif
00074 
00075 #define isinrange(x,lo,hi)      ( (x) >= (lo) && (x) <= (hi) )
00076 
00077 #define getuint32(bptr) ( ((((uint8 *)(bptr))[0])<<24) + (((uint8 *)(bptr))[1]<<16) + (((uint8 *)(bptr))[2]<<8) + (((uint8 *)(bptr))[3]) )
00078 #define getuint16(bptr) ( (((uint8 *)(bptr))[0]<<8) + (((uint8 *)(bptr))[1]) )
00079 
00080 /****************************************/
00081 
00082 #ifndef strofval
00083 #define strofval(x)     (#x)
00084 #endif
00085 
00086 #ifndef new
00087 #define new(type)               geRam_AllocateClear(sizeof(type))
00088 #endif
00089 
00090 #ifndef destroy
00091 #define destroy(mem)    do { if ( mem ) { geRam_Free(mem); (mem) = NULL; } } while(0)
00092 #endif
00093 
00094 #ifndef newarray
00095 #define newarray(type,num)      geRam_AllocateClear((num)*sizeof(type))
00096 #endif
00097 
00098 #ifndef memclear
00099 #define memclear(mem,size)      memset(mem,0,size);
00100 #endif
00101 
00102 /****************************************/
00103 
00104 #ifdef __cplusplus
00105 }
00106 #endif
00107 
00108 #endif // __COMPUTIL_UTILITY_H
00109 

Generated on Tue Sep 30 12:36:35 2003 for GTestAndEngine by doxygen 1.3.2