Main Page | Class Hierarchy | Class List | File List | Class Members

stdtp.h

00001 //-< STDTP.H >-------------------------------------------------------*--------*
00002 // FastDB                    Version 1.0         (c) 1999  GARRET    *     ?  *
00003 // (Main Memory 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 FASTDB_DLL
00017 #ifdef INSIDE_FASTDB
00018 #define FASTDB_DLL_ENTRY __declspec(dllexport)
00019 #else
00020 #define FASTDB_DLL_ENTRY __declspec(dllimport)
00021 #endif
00022 #else
00023 #define FASTDB_DLL_ENTRY
00024 #endif
00025 
00026 #ifdef _WIN32
00027 #include <windows.h>
00028 #ifdef _MSC_VER
00029 #pragma warning(disable:4800 4355 4146 4251)
00030 #endif
00031 #else
00032 #ifdef _AIX
00033 #define INT8_IS_DEFINED
00034 #endif
00035 #ifndef NO_PTHREADS
00036 #ifndef _REENTRANT
00037 #define _REENTRANT 
00038 #endif
00039 #endif
00040 #endif
00041 
00042 #include <stdio.h>
00043 #include <stddef.h>
00044 #include <stdlib.h>
00045 #include <string.h>
00046 #include <limits.h>
00047 #include <assert.h>
00048 #include <stdarg.h>
00049 #include <time.h>
00050 
00051 #define DEBUG_NONE  0
00052 #define DEBUG_CHECK 1
00053 #define DEBUG_TRACE 2
00054 
00055 #if FASTDB_DEBUG == DEBUG_TRACE
00056 #define TRACE_MSG(x)  dbTrace x
00057 #else
00058 #define TRACE_MSG(x)
00059 #endif
00060 
00061 #ifndef EXTRA_DEBUG_NEW_PARAMS
00062 #define EXTRA_DEBUG_NEW_PARAMS
00063 #endif
00064 
00065 
00066 #ifndef HAS_TEMPLATE_FRIENDS
00067 #if !defined(_MSC_VER) || _MSC_VER >= 1300
00068 #define HAS_TEMPLATE_FRIENDS
00069 #endif
00070 #endif
00071 
00072 typedef void (*dbTraceFunctionPtr)(char* message);
00073 
00074 extern dbTraceFunctionPtr dbTraceFunction;
00075 extern FASTDB_DLL_ENTRY void dbTrace(char* message, ...);
00076 
00077 
00078 #ifdef PHAR_LAP
00079 #define PHAR_LAP 1
00080 #endif
00081 
00082 #ifdef __QNX__
00083 #define USE_POSIX_API 1
00084 #define POSIX_1003_1d 1
00085 #endif
00086 
00087 // Align value 'x' to boundary 'b' which should be power of 2
00088 #define DOALIGN(x,b)   (((x) + (b) - 1) & ~((b) - 1))
00089 
00090 typedef signed char    db_int1;
00091 typedef unsigned char  db_nat1;
00092 
00093 typedef signed short   db_int2;
00094 typedef unsigned short db_nat2;
00095 
00096 typedef signed int     db_int4;
00097 typedef unsigned int   db_nat4;
00098 
00099 typedef unsigned char  db_byte;
00100 
00101 // This mapping is done for compatibility reasons
00102 typedef db_int1 int1;
00103 typedef db_nat1 nat1;
00104 typedef db_int2 int2;
00105 typedef db_nat2 nat2;
00106 typedef db_int4 int4;
00107 typedef db_nat4 nat4;
00108 
00109 typedef db_byte byte;
00110 
00111 #if defined(_WIN32) && !defined(__MINGW32__)
00112 typedef unsigned __int64 db_nat8;
00113 typedef __int64          db_int8;
00114 #if defined(__IBMCPP__)
00115 #define INT8_FORMAT "%lld"
00116 #else
00117 #define INT8_FORMAT "%I64d"
00118 #endif
00119 #define CONST64(c)  c
00120 #else
00121 #if defined(__osf__ )
00122 typedef unsigned long db_nat8;
00123 typedef signed   long db_int8;
00124 #define INT8_FORMAT "%ld"
00125 #define CONST64(c)  c##L
00126 #else
00127 typedef unsigned long long db_nat8;
00128 typedef signed   long long db_int8;
00129 #if defined(__MINGW32__) && __GNUG__<3
00130 #define INT8_FORMAT "%I64d"
00131 #else
00132 #define INT8_FORMAT "%lld"
00133 #endif
00134 #define CONST64(c)  c##LL
00135 #endif
00136 #endif
00137 
00138 #if !defined(bool) && (defined(__SUNPRO_CC) || defined(__IBMCPP__))
00139 #define bool  char
00140 #define true  (1)
00141 #define false (0)
00142 #endif
00143 
00144 #define nat8_low_part(x)  ((nat4)(x))
00145 #define nat8_high_part(x) ((nat4)((nat8)(x)>>32))
00146 #define int8_low_part(x)  ((int4)(x))
00147 #define int8_high_part(x) ((int4)((db_int8)(x)>>32))
00148 #define cons_nat8(hi, lo) ((((nat8)(hi)) << 32) | (nat4)(lo))
00149 #define cons_int8(hi, lo) ((((db_int8)(hi)) << 32) | (nat4)(lo))
00150  
00151 #define MAX_NAT8  nat8(-1)
00152 
00153 #ifndef INT8_IS_DEFINED
00154 typedef db_int8 int8;
00155 #endif
00156 typedef db_nat8 nat8;
00157 
00158 typedef float  real4;
00159 typedef double real8; 
00160 
00161 #ifndef BIG_ENDIAN
00162 #define BIG_ENDIAN      4321    /* most-significant byte first (IBM, net) */
00163 #endif
00164 #ifndef LITTLE_ENDIAN
00165 #define LITTLE_ENDIAN   1234
00166 #endif
00167 
00168 #ifndef BYTE_ORDER
00169 #if defined(__sparc__) || defined(__m68k__)
00170 #define BYTE_ORDER      BIG_ENDIAN 
00171 #else
00172 #define BYTE_ORDER      LITTLE_ENDIAN
00173 #endif
00174 #endif
00175 
00176 #ifdef _WIN32
00177 typedef HANDLE descriptor_t; 
00178 #else
00179 typedef int descriptor_t; 
00180 #endif
00181 
00182 #if !defined(_fastcall) && (!defined(_WIN32) || defined(__IBMCPP__) || defined(__MINGW32__))
00183 #define _fastcall
00184 #endif
00185 
00186 #if defined(_WIN32) || !defined(NO_PTHREADS)
00187 #define THREADS_SUPPORTED 1
00188 #else
00189 #define THREADS_SUPPORTED 0
00190 #endif
00191 
00192 #define itemsof(array) (sizeof(array)/sizeof*(array))
00193 
00194 
00195 extern FASTDB_DLL_ENTRY byte* dbMalloc(size_t size);
00196 extern FASTDB_DLL_ENTRY void  dbFree(void* ptr);
00197 
00198 #if !defined(USE_POSIX_MMAP) && defined(DISKLESS_CONFIGURATION)
00199 // To enable sharing of database in diskless configuration we have to use
00200 // shmap instead of mmap, which anonymous region is private to process.
00201 #define USE_POSIX_MMAP 0
00202 #endif
00203 
00204 #if defined(USE_POSIX_MMAP) && !USE_POSIX_MMAP
00205 // allocate space for the database using Sys-V shmat
00206 #define USE_SYSV_SHARED_MEMORY 1
00207 #if !defined(NO_MMAP) && !defined(DISKLESS_CONFIGURATION)
00208 #define NO_MMAP 1
00209 #endif
00210 #endif
00211 
00212 #if !defined(_WIN32)
00213 #define NO_STRICMP  1
00214 #define NO_STRICOLL 1
00215 #endif
00216 
00217 #if defined(IGNORE_CASE) && defined(NO_STRICMP) 
00218 #include <ctype.h>
00219 inline int stricmp(const char* p, const char* q)
00220 {
00221     while (toupper(*(unsigned char*)p) == toupper(*(unsigned char*)q)) { 
00222         if (*p == '\0') { 
00223             return 0;
00224         }
00225         p += 1;
00226         q += 1;
00227     }
00228     return toupper(*(unsigned char*)p) - toupper(*(unsigned char*)q);
00229 }
00230 #endif
00231 
00232 #if defined(IGNORE_CASE) && defined(USE_LOCALE_SETTINGS) && defined(NO_STRICOLL) 
00233 #include <ctype.h>
00234 inline int stricoll(const char* p, const char* q)
00235 {
00236     char   p_buf[256];
00237     char   q_buf[256];
00238     size_t p_len = strlen(p);
00239     size_t q_len = strlen(q);
00240     char*  p_dst = p_buf; 
00241     char*  q_dst = q_buf; 
00242     int    i;
00243     if (p_len >= sizeof(p_buf)) { 
00244         p_dst = new char[p_len+1];
00245     }
00246     if (q_len >= sizeof(q_buf)) { 
00247         q_dst = new char[q_len+1];
00248     }
00249     for (i = 0; p[i] != '\0'; i++) { 
00250         p_dst[i] = toupper(p[i] & 0xFF);
00251     }
00252     p_dst[i] = '\0';
00253 
00254     for (i = 0; q[i] != '\0'; i++) { 
00255         q_dst[i] = toupper(q[i] & 0xFF);
00256     }
00257     q_dst[i] = '\0';
00258 
00259     int diff = strcoll(p_dst, q_dst);
00260     if (p_dst != p_buf) { 
00261         delete[] p_dst;
00262     }
00263     if (q_dst != q_buf) { 
00264         delete[] q_dst;
00265     }
00266     return diff;
00267 }
00268 #endif
00269 
00270 #endif
00271 
00272 
00273 
00274 

Generated on Thu Feb 12 13:04:48 2004 for FastDB by doxygen 1.3.5