Main Page   Class Hierarchy   Compound List   File List   Compound Members  

stdtp.h

00001 //-< STDTP.H >-------------------------------------------------------*--------*
00002 // GigaBASE                  Version 1.0         (c) 1999  GARRET    *     ?  *
00003 // (Post Relational Database Management System)                      *   /\|  *
00004 //                                                                   *  /  \  *
00005 //                          Created:     20-Nov-98    K.A. Knizhnik  * / [] \ *
00006 //                          Last update: 10-Dec-98    K.A. Knizhnik  * GARRET *
00007 //-------------------------------------------------------------------*--------*
00008 // Standart type and macro definitions
00009 //-------------------------------------------------------------------*--------*
00010 
00011 #ifndef __STDTP_H__
00012 #define __STDTP_H__
00013 
00014 #include "config.h"
00015 
00016 #ifdef GIGABASE_DLL
00017 #ifdef INSIDE_GIGABASE
00018 #define GIGABASE_DLL_ENTRY __declspec(dllexport)
00019 #else
00020 #define GIGABASE_DLL_ENTRY __declspec(dllimport)
00021 #endif
00022 #else
00023 #define GIGABASE_DLL_ENTRY
00024 #endif
00025 
00026 #ifdef USE_NAMESPACES
00027 #define BEGIN_GIGABASE_NAMESPACE namespace gigabase {
00028 #define END_GIGABASE_NAMESPACE }
00029 #define USE_GIGABASE_NAMESPACE using namespace gigabase;
00030 #else
00031 #define BEGIN_GIGABASE_NAMESPACE
00032 #define END_GIGABASE_NAMESPACE
00033 #define USE_GIGABASE_NAMESPACE 
00034 #endif
00035 
00036 #define GNUC_BEFORE(major,minor) (defined(__GNUC__) && (major > __GNUC__ || (major == __GNUC__ && minor > __GNUC_MINOR__)))
00037 
00038 #if defined(__MINGW32__) && !defined(_WIN32)
00039 #define _WIN32
00040 #endif
00041 
00042 #if defined(_WIN32_WCE) && !defined(_WINCE)
00043 #define _WINCE
00044 #endif
00045 
00046 #if defined(__APPLE__) && !defined(__FreeBSD__)
00047 // MAC OS X is Free BSD
00048 #define __FreeBSD__ 5
00049 #endif
00050 
00051 #if defined(USE_MFC_STRING) && !defined(USE_MFC) && !defined(USE_ATL)
00052 #define USE_ATL 1
00053 #endif
00054 
00055 #if defined(USE_MFC_STRING)
00056 #ifndef MFC_STRING
00057 #define MFC_STRING CString
00058 #endif
00059 #endif
00060 
00061 #ifdef USE_STD_STRING
00062 #include <string>
00063 #endif
00064 
00065 #if defined(_WIN32)
00066 
00067 #ifdef USE_MFC
00068 #include <afx.h>
00069 #include <winsock2.h>
00070 #else
00071 #include <windows.h>
00072 #if defined(USE_ATL) && defined(USE_MFC_STRING)
00073 #include <atlstr.h>
00074 #endif
00075 #endif
00076 
00077 #ifdef _MSC_VER
00078 #pragma warning(disable:4800 4355 4146 4251)
00079 #endif
00080 #else
00081 #ifdef _AIX
00082 #define INT8_IS_DEFINED
00083 #endif
00084 #ifndef NO_PTHREADS
00085 #ifndef _REENTRANT
00086 #define _REENTRANT
00087 #endif
00088 #endif
00089 #endif
00090 
00091 
00092 
00093 #if defined(__VACPP_MULTI__) // IBM compiler produce a lot of stupid warnings
00094 #pragma report(disable, "CPPC1608")
00095 #pragma report(disable, "CPPC1281")
00096 #endif /* __VACPP_MULTI__ */
00097 
00098 
00099 #ifdef _WINCE
00100 #include <stdio.h>
00101 #include <stdlib.h>
00102 #include <string.h>
00103 #include <limits.h>
00104 #include <stdarg.h>
00105 #include <tchar.h>
00106 #include "wince.h"
00107 
00108 #else
00109 
00110 #include <stdio.h>
00111 #include <stddef.h>
00112 #include <stdlib.h>
00113 #include <string.h>
00114 #include <limits.h>
00115 #include <assert.h>
00116 #include <stdarg.h>
00117 #include <time.h>
00118 #ifdef UNICODE
00119 #include <wchar.h>
00120 #include <wctype.h>
00121 #else
00122 #include <ctype.h>
00123 #endif
00124 
00125 #endif
00126 
00127 #ifndef __IBMCPP__
00128 BEGIN_GIGABASE_NAMESPACE
00129 #endif
00130 
00131 //#ifndef __BCPLUSPLUS__
00132 #if !defined(_WIN32) && !defined(__cdecl)
00133 #define __cdecl
00134 #endif
00135 
00136 
00137 // Align value 'x' to boundary 'b' which should be power of 2
00138 #define DOALIGN(x,b)   (((x) + (b) - 1) & ~((b) - 1))
00139 
00140 
00141 #ifdef UNICODE
00142 typedef wchar_t char_t;
00143 #define STRLEN(x)     wcslen(x)
00144 #define STRCMP(x, y)  wcscmp(x, y)
00145 #define STRCHR(x, y)  wcschr(x, y)
00146 #define STRCPY(x, y)  wcscpy(x, y)
00147 #define STRNCPY(x,y,z) wcsncpy(x, y, z)
00148 #define STRCOLL(x, y) wcscoll(x, y)
00149 #define STRNCMP(x,y,z) wcsncmp(x, y, z)
00150 #define STRLITERAL(x) (wchar_t*)L##x
00151 #define PRINTF        wprintf
00152 #define FPRINTF       fwprintf
00153 #define SPRINTF       swprintf
00154 #define VSPRINTF      vswprintf
00155 #define FSCANF        fwscanf
00156 #define SSCANF        swscanf
00157 #define GETC(x)       getwc(x)
00158 #define UNGETC(x, y)  ungetwc(x, y)
00159 #define TOLOWER(x)    towlower((x) & 0xFFFF)
00160 #define TOUPPER(x)    towlower((x) & 0xFFFF)
00161 #define ISALNUM(x)    iswalnum((x) & 0xFFFF)
00162 #define STRSTR(x, y)  wcsstr(x, y)
00163 #define STRXFRM(x,y,z) wcsxfrm(x, y, z)
00164 #define STRFTIME(a,b,c,d) wcsftime(a,b,c,d)
00165 #ifdef _WINCE
00166 #define REMOVE_FILE(s) DeleteFile(s)
00167 #define RENAME_FILE(p, q) MoveFile(p, q)
00168 #else
00169 #define REMOVE_FILE(s) _wremove(s)
00170 #define RENAME_FILE(p, q) _wrename(p, q)
00171 #endif
00172 #define GETENV(x)     _wgetenv(x)
00173 #define T_EOF         WEOF
00174 #ifndef STD_STRING
00175 #define STD_STRING    std::wstring
00176 #endif
00177 #ifndef _T
00178 #define _T(x) L##x
00179 #endif
00180 #else
00181 typedef char char_t;
00182 #define STRLEN(x)     strlen(x)
00183 #define STRCHR(x, y)  strchr(x, y)
00184 #define STRCMP(x, y)  strcmp(x, y)
00185 #define STRCPY(x, y)  strcpy(x, y)
00186 #define STRNCPY(x,y,z) strncpy(x, y, z)
00187 #define STRCOLL(x, y) strcoll(x, y)
00188 #define STRNCMP(x,y,z) strncmp(x, y, z)
00189 #define STRLITERAL(x) (char*)x
00190 #define PRINTF        printf
00191 #define FPRINTF       fprintf
00192 #define SPRINTF       sprintf
00193 #define VSPRINTF      vsprintf
00194 #define FSCANF        fscanf
00195 #define SSCANF        sscanf
00196 #define GETC(x)       getc(x)
00197 #define UNGETC(x, y)  ungetc(x, y)
00198 #define TOLOWER(x)    tolower((x) & 0xFF)
00199 #define TOUPPER(x)    toupper((x) & 0xFF)
00200 #define ISALNUM(x)    isalnum((x) & 0xFF)
00201 #define STRSTR(x, y)  strstr(x, y)
00202 #define STRXFRM(x,y,z) strxfrm(x, y, z)
00203 #define STRFTIME(a,b,c,d) strftime(a,b,c,d)
00204 #define REMOVE_FILE(s)     remove(s)
00205 #define RENAME_FILE(p, q)  rename(p, q)
00206 #define GETENV(x)     getenv(x)
00207 #ifndef STD_STRING
00208 #define STD_STRING    std::string
00209 #endif
00210 #define T_EOF         EOF
00211 #ifdef _T
00212 #undef _T
00213 #endif
00214 #define _T(x) x
00215 #endif
00216 
00217 inline void strlower(char_t* dst, const char_t* src)
00218 {
00219     int ch;
00220     do {
00221         ch = *src++;
00222         *dst++ = TOLOWER(ch);
00223     } while (ch != 0);
00224 }
00225 
00226 typedef signed char    db_int1;
00227 typedef unsigned char  db_nat1;
00228 
00229 typedef signed short   db_int2;
00230 typedef unsigned short db_nat2;
00231 
00232 typedef signed int     db_int4;
00233 typedef unsigned int   db_nat4;
00234 
00235 typedef unsigned char  db_byte;
00236 
00237 typedef float  db_real4;
00238 typedef double db_real8;
00239 
00240 #if !defined(SIZEOF_LONG) && defined(L64) && ! defined(WIN64)
00241 #define SIZEOF_LONG 8
00242 #endif
00243 
00244 #if defined(_WIN32) && !defined(__MINGW32__)
00245 typedef unsigned __int64 db_nat8;
00246 typedef __int64          db_int8;
00247 #if defined(__IBMCPP__)
00248 #define INT8_FORMAT_PREFIX "%ll"
00249 #define T_INT8_FORMAT_PREFIX _T("%ll")
00250 #else
00251 #define INT8_FORMAT_PREFIX "%I64"
00252 #define T_INT8_FORMAT_PREFIX _T("%I64")
00253 #endif
00254 #define CONST64(c)  c
00255 #else
00256 #if SIZEOF_LONG == 8
00257 typedef unsigned long db_nat8;
00258 typedef signed   long db_int8;
00259 #define INT8_FORMAT_PREFIX "%l"
00260 #define T_INT8_FORMAT_PREFIX _T("%l")
00261 #define CONST64(c)  c##L
00262 #else
00263 typedef unsigned long long db_nat8;
00264 typedef signed   long long db_int8;
00265 #ifdef __MINGW32__
00266 #define INT8_FORMAT_PREFIX "%I64"
00267 #define T_INT8_FORMAT_PREFIX _T("%I64")
00268 #else
00269 #define INT8_FORMAT_PREFIX "%ll"
00270 #define T_INT8_FORMAT_PREFIX _T("%ll")
00271 #endif
00272 #define CONST64(c)  c##LL
00273 #endif
00274 #endif
00275 
00276 #define INT8_FORMAT INT8_FORMAT_PREFIX "d"
00277 #define T_INT8_FORMAT T_INT8_FORMAT_PREFIX _T("d")
00278 
00279 
00280 // This mapping is done for compatibility reasons
00281 typedef db_int1 int1;
00282 typedef db_nat1 nat1;
00283 typedef db_int2 int2;
00284 typedef db_nat2 nat2;
00285 typedef db_int4 int4;
00286 typedef db_nat4 nat4;
00287 
00288 typedef db_byte byte;
00289 
00290 typedef db_real4 real4;
00291 typedef db_real8 real8;
00292 
00293 typedef db_nat8 nat8;
00294 
00295 #ifndef INT8_IS_DEFINED
00296 typedef db_int8 int8;
00297 #endif
00298 
00299 
00300 #if !defined(bool) && ((defined(__SUNPRO_CC) && __SUNPRO_CC_COMPAT < 5) || defined(__IBMCPP__))
00301 #define bool  char
00302 #define true  (1)
00303 #define false (0)
00304 #endif
00305 
00306 #define nat8_low_part(x)  ((db_nat4)(x))
00307 #define int8_low_part(x)  ((db_int4)(x))
00308 #if defined(_MSC_VER) // bug in MVC 6.0
00309 #define nat8_high_part(x) (sizeof(x) < 8 ? 0 : ((db_nat4)((db_nat8)(x)>>32)))
00310 #define int8_high_part(x) (sizeof(x) < 8 ? 0 : ((db_int4)((db_int8)(x)>>32)))
00311 #else
00312 #define nat8_high_part(x) ((db_nat4)((db_nat8)(x)>>32))
00313 #define int8_high_part(x) ((db_int4)((db_int8)(x)>>32))
00314 #endif
00315 
00316 #define cons_nat8(hi, lo) ((((db_nat8)(hi)) << 32) | (db_nat4)(lo))
00317 #define cons_int8(hi, lo) ((((db_int8)(hi)) << 32) | (db_nat4)(lo))
00318 
00319 #define MAX_NAT8  db_nat8(-1)
00320 
00321 #ifndef BIG_ENDIAN
00322 #define BIG_ENDIAN      4321    /* most-significant byte first (IBM, net) */
00323 #endif
00324 #ifndef LITTLE_ENDIAN
00325 #define LITTLE_ENDIAN   1234
00326 #endif
00327 
00328 #ifndef BYTE_ORDER
00329 #if defined(__sparc__) || defined(__m68k__)
00330 #define BYTE_ORDER      BIG_ENDIAN
00331 #else
00332 #define BYTE_ORDER      LITTLE_ENDIAN
00333 #endif
00334 #endif
00335 
00336 #if defined(_WIN32)
00337 typedef HANDLE descriptor_t;
00338 #else
00339 typedef int descriptor_t;
00340 #endif
00341 
00342 #if !defined(_fastcall) && (!defined(_WIN32) || defined(__IBMCPP__) || defined(__MINGW32__))
00343 #define _fastcall
00344 #endif
00345 
00346 #if defined(_WIN32) || !defined(NO_PTHREADS)
00347 #define THREADS_SUPPORTED 1
00348 #else
00349 #define THREADS_SUPPORTED 0
00350 #endif
00351 
00352 #define itemsof(array) (sizeof(array)/sizeof*(array))
00353 
00354 #define DEBUG_NONE  0
00355 #define DEBUG_CHECK 1
00356 #define DEBUG_TRACE 2
00357 
00358 #if GIGABASE_DEBUG == DEBUG_TRACE
00359 #define TRACE_MSG(x)  dbTrace x
00360 #else
00361 #define TRACE_MSG(x)
00362 #endif
00363 
00364 // User defined trace functions
00365 typedef void (*dbTraceFunctionPtr)(char_t* message);
00366 
00367 // Pointer to trace function (default implementation just prints message to stderr)
00368 extern dbTraceFunctionPtr dbTraceFunction;
00369 
00370 // Enable or disable trace at runtime
00371 extern bool dbTraceEnable;
00372 
00373 extern GIGABASE_DLL_ENTRY void dbTrace(char_t* message, ...);
00374 
00375 extern GIGABASE_DLL_ENTRY byte* dbMalloc(size_t size);
00376 extern GIGABASE_DLL_ENTRY void  dbFree(void* ptr);
00377 
00378 #if defined(__BCPLUSPLUS__)
00379 #define qsort(arr, n, s, cmp) std::qsort(arr, n, s, cmp)
00380 #endif
00381 
00382 #ifndef __IBMCPP__
00383 END_GIGABASE_NAMESPACE
00384 #endif
00385 
00386 #endif
00387 
00388 

Generated on Mon Oct 23 13:22:59 2006 for GigaBASE by doxygen1.2.18