00001 #ifndef gMAIN_X_H
00002 #define gMAIN_X_H
00003
00004 #define LIB_VERSION_GLIB_MAJOR 0
00005 #define LIB_VERSION_GLIB_MINOR 8
00006
00007 #include <stdlib.h>
00008 #include "gstdtypes.h"
00009
00010 #define GMIN_STAT_OBJ 5
00011
00012
00013 #define false 0
00014 #define true 1
00015
00016 typedef unsigned char t_uchar;
00017 typedef t_uchar t_uint8;
00018 typedef char t_int8;
00019 typedef unsigned short t_uint16;
00020 typedef short t_int16;
00021
00022 typedef unsigned long long t_uint64;
00023
00024 typedef t_uint16 t_gPort;
00025
00026 typedef t_uint64 t_inode;
00027
00028
00029 #ifdef gUINT_IS_32bit
00030
00031 typedef unsigned t_uint32;
00032 typedef int t_int32;
00033 #define MAX_UINT_UL 4294967295UL
00034 #else
00035 #error TODO: doing 16bit OSs
00036 #endif //gUINT_IS_32bit
00037
00038 typedef t_uint32 t_uint4B;
00039 typedef t_uint16 t_uint2B;
00040
00041 typedef t_uint32 t_gTicElapsed;
00042 typedef t_uint32 t_stamp;
00043
00044
00045 #ifdef SWAP_16bit16
00046
00047 #define gENDLITTLE4(x) ((x<<16) | (x>>16))
00048 #else
00049
00050 #define gENDLITTLE2(x) ((x<<8) | (x>>8))
00051 #define gENDLITTLE4(x) ( (x<<24) | ((x&0xFF0000)>>8) | ((x&0xFF00)<<8) | ((x&0xFF000000)>>24) )
00052 #endif //SWAP_16bit16
00053
00054
00055 #define TO_UD2(x) ((t_uint16)gENDLITTLE2(x))
00056 #define TO_UD4(x) ((t_uint32)gENDLITTLE4(x))
00057 #define FROM_UD2(x) TO_UD2(x) // (De-)Coding is symetric
00058 #define FROM_UD4(x) TO_UD4(x) // (De-)Coding is symetric
00059
00060 #define MAX_INT16_I 32767 // 2^15-1
00061 #define MIN_INT16_I -32768
00062 #define MAX_UINT16_U 65535U // 2^16-1
00063
00064 #define MAX_DLINT32 2147483647L
00065 #define MIN_DLINT32 -2147483647L
00066 #define MAX_DUINT32 2147483646UL
00067
00068 #define MAX_LONG_L 2147483648LL
00069 #define MIN_LONG_L -2147483648LL
00070 #define MAX_U4B_ULL 4294967295ULL
00071
00072 #define MAX_STAMP_UL MAX_DUINT32
00073
00074 #ifdef gDOS_SPEC
00075 #define gEND_CLEANUP_WSA WSACleanup()
00076 #else
00077 #define gEND_CLEANUP_WSA //Nothing needed for non-Win32/DOS
00078 #endif //~gDOS_SPEC
00079
00080 #ifdef DEBUG
00081 #define gEND_STATEMENT gFileControl::Self().End()
00082 #else
00083 #define gEND_STATEMENT gFileControl::Self().End( false )
00084 #endif
00085
00086
00087 #ifdef gDOS_SPEC
00088 #ifndef __S_IFIFO
00089 #define __S_IFIFO 0010000
00090 #endif //__S_IFIFO
00091 #endif //gDOS_SPEC
00092 #define gFILE_S_IFIFO __S_IFIFO
00093
00094
00095
00096
00097
00098 #define gEND gEND_STATEMENT;gEND_CLEANUP_WSA
00099
00100 #ifdef SMALL_CTRL //not used
00101 #define gINIT gFileControl::Self().Init()
00102 #else
00103 #define gINIT \
00104 ASSERTION(gStorageControl::Self().StorageKindName(0)!=nil,"gINIT:error(2)"); \
00105 gFileControl::Self().Init();
00106
00107
00108 #endif //SMALL_CTRL
00109
00110
00111
00112
00113 #define gMAX(a,b) ((a>b)?a:b)
00114 #define gMIN(a,b) ((a<b)?a:b)
00115
00116 #define gRANGEX(v,a,b,x) ((v<a)?x:(v>b?x:v))
00117 #define gRANGE0(v,a,b) gRANGEX(v,a,b,0)
00118
00119
00120 #define ISyORn(x) (x ? 'Y' : 'N')
00121
00122 #ifdef gDOS_SPEC
00123 #define gSLASHSTR "\\"
00124 #define gSLASHCHR '\\'
00125 #define gDOS_LIB_CRT_DLL // e.g. getpid on libcrtdll.a
00126 #undef gDOS_LIB_XIO // e.g. mkstemp on libiberty.a
00127 #else
00128 #define gSLASHSTR "/"
00129 #define gSLASHCHR '/'
00130 #ifdef linux
00131 #define gGX_SIG_SUPPORT
00132 #define gGX_USR_SUPPORT
00133 #ifdef FREESCO
00134
00135 typedef unsigned int __socklen_t;
00136 typedef __socklen_t socklen_t;
00137 #endif
00138 #endif //linux (specific self-defines)
00139 #endif //gDOS_SPEC
00140
00141
00142 #ifdef gX_KERN2_0
00143
00144 typedef t_uint32 in_addr_t;
00145 #endif //gX_KERN2_0
00146
00147 #ifdef gX_KERN2_4
00148 ;
00149 #endif //gX_KERN2_4
00150
00151
00152
00153
00154
00155
00156 #ifdef DEBUG
00157 #define DBGPRINT(args...) printf(args)
00158 #else
00159 #define DBGPRINT(args...) ;
00160 #endif //DEBUG
00161
00162 #ifdef DEBUG_MIN
00163 #define DBGPRINT_MIN(args...) printf(args)
00164 #else
00165 #define DBGPRINT_MIN(args...) ;
00166 #endif //DEBUG
00167
00168 #ifdef DEBUG_MEA //Memory all...highly verbose
00169 #define DBGPRINT_MEA(args...) printf(args)
00170 #else
00171 #define DBGPRINT_MEA(args...) ;
00172 #endif //DEBUG
00173
00174 #ifdef DEBUG_LOG
00175 #define DBGPRINT_LOG(args...) printf(args)
00176 #else
00177 #define DBGPRINT_LOG(args...) ;
00178 #endif //DEBUG_LOG
00179
00180
00181
00182
00183
00184 #define ASSERTION_FALSE(y) \
00185 { \
00186 ; \
00187 fprintf(stderr,"ASSERTION[v%d.%d]:%s:%u:%s\n", \
00188 LIB_VERSION_GLIB_MAJOR, LIB_VERSION_GLIB_MINOR, \
00189 __FILE__,__LINE__,y); \
00190 exit(1); \
00191 }
00192 #define ASSERTION(x,y) \
00193 { \
00194 if ( (x)==0 ) { \
00195 ; \
00196 fprintf(stderr,"ASSERTION[v%d.%d]:%s:%u:%s\n", \
00197 LIB_VERSION_GLIB_MAJOR, LIB_VERSION_GLIB_MINOR, \
00198 __FILE__,__LINE__,y); \
00199 exit(1); \
00200 } \
00201 }
00202
00203 #define ASSERTION_USE(x,y) ASSERTION(x,y)
00204
00205
00206 #endif //gMAIN_X_H
00207