global.h

Go to the documentation of this file.
00001 #ifndef GLOBAL_H
00002 #define GLOBAL_H
00003 
00004 #ifdef HAVE_CONFIG
00005 #include "../configuration.h"
00006 #endif
00007 
00008 #ifndef WIN32
00009 #include <bits/wordsize.h>
00010 #endif
00011 
00012 #ifdef _DEBUG_MEMORY
00013 #include "MercuryMemory.h"
00014 #endif
00015 
00016 #define SAFE_DELETE(p)       { if(p) { delete (p);     (p)=0; } }
00017 #define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p);    (p)=0; } }
00018 #define SAFE_FREE(p)       { if(p) { free(p);     (p)=0; } }
00019 
00020 #ifndef WIN32 
00021 #if __WORDSIZE == 64
00022 #define CPU_X86_64
00023 #endif
00024 #endif
00025 
00026 #if defined(__GNUC__)
00027 #define M_ALIGN(n) __attribute__((aligned(n)))
00028 //In GNU C there is no __fastcall (unless we're using dev-c++)
00029 #if !defined( WIN32 ) 
00030 #define __fastcall
00031 #endif
00032 #else
00033 #define M_ALIGN(n)
00034 #endif
00035 
00036 //We use mercury string now
00037 #include "MercuryString.h"
00038 
00039 #define MStringArray vector<MString>
00040 
00041 #if !defined( WIN32 ) && !defined( _EE )
00042 #include <stdint.h>
00043 #else
00044 typedef signed char int8_t;
00045 typedef unsigned char uint8_t;
00046 typedef signed short int16_t;
00047 typedef unsigned short uint16_t;
00048 typedef int int32_t;
00049 typedef unsigned int uint32_t;
00050 #if defined( WIN32 ) && !defined(__GNUC__)
00051 typedef __int64 int64_t;
00052 typedef unsigned __int64 uint64_t;
00053 #else
00054 typedef long long int64_t;
00055 typedef unsigned long long uint64_t;
00056 #endif
00057 #endif
00058 
00059 #if defined(CPU_X86_64)
00060 typedef long long MVPtr;
00061 #else
00062 typedef unsigned MVPtr;
00063 #endif
00064 
00065 #if defined(_MSC_VER) && (_MSC_VER > 1100)
00066     #pragma warning (disable : 4786) // C++ Identifier trncation (in debug info)
00067     #pragma warning (disable : 4284) // Weird -- look into this
00068     #pragma warning (disable : 4018) // < signed unsigned match
00069     #pragma warning (disable : 4146) // - sign applied to unsigned value (from deque)
00070 #endif
00071 
00072 //Hg Exports, for non-C++ linkage
00073 #if defined( WIN32 ) && defined( MAKE_DLL )
00074 #define HGEXPORT __stdcall 
00075 #define EXPORTPREFIX extern "C" { __declspec( dllexport ) 
00076 #define EXPORTSUFFIX }
00077 #else
00078 #define HGEXPORT
00079 #define EXPORTPREFIX
00080 #define EXPORTSUFFIX
00081 #endif
00082 
00083 //Give a statement to run before main.
00084 //NOTE: You CANNOT include this statement in a .H file!!!
00085 #define RUN_STATEMENT_AT_BOOT( name, statement ) \
00086     class PREBOOT_##name \
00087     { \
00088     public: \
00089         PREBOOT_##name() { statement } \
00090     } PREBOOT_INSTANCE_##name;
00091 
00092 #define MIN( x, y )  ((x<y)?(x):(y))
00093 #define MAX( x, y )  ((x<y)?(x):(y))
00094 
00095 #if defined( PSTHREE )
00096 //4-byte-wide-value
00097 #define TO_ENDIAN( x ) x = ((((unsigned)x)>>24) + (((((unsigned)x)>>16)%256)<<8) + (((((unsigned)x)>>8)%256)<<16) + ((((unsigned)x)%256)<<24))
00098 //2-byte-wide-value
00099 #define TO_ENDIAN2( x ) x = ((x>>8) + (((x)<<8)&0xFF00))
00100 #else
00101 #define TO_ENDIAN( x ) 
00102 #define TO_ENDIAN2( x )
00103 #endif
00104 
00105 #endif
00106 
00107 /*
00108  * (c) 2004-2005 Joshua Allen
00109  * All rights reserved.
00110  * 
00111  * Permission is hereby granted, free of charge, to any person obtaining a
00112  * copy of this software and associated documentation files (the
00113  * "Software"), to deal in the Software without restriction, including
00114  * without limitation the rights to use, copy, modify, merge, publish,
00115  * distribute, and/or sell copies of the Software, and to permit persons to
00116  * whom the Software is furnished to do so, provided that the above
00117  * copyright notice(s) and this permission notice appear in all copies of
00118  * the Software and that both the above copyright notice(s) and this
00119  * permission notice appear in supporting documentation.
00120  * 
00121  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00122  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00123  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
00124  * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
00125  * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
00126  * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
00127  * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
00128  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
00129  * PERFORMANCE OF THIS SOFTWARE.
00130  */

Hosted by SourceForge.net Logo