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
00029 #if !defined( WIN32 )
00030 #define __fastcall
00031 #endif
00032 #else
00033 #define M_ALIGN(n)
00034 #endif
00035
00036
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
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
00084
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
00097 #define TO_ENDIAN( x ) x = ((((unsigned)x)>>24) + (((((unsigned)x)>>16)%256)<<8) + (((((unsigned)x)>>8)%256)<<16) + ((((unsigned)x)%256)<<24))
00098
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
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130