00001
00002
00003
00004
00005 #ifndef IBIS_CONST_H
00006 #define IBIS_CONST_H
00007
00008
00014
00015 #if defined(DEBUG) && !defined(_DEBUG)
00016 # define _DEBUG DEBUG
00017 #elif !defined(DEBUG) && defined(_DEBUG) && _DEBUG + 0 > 1
00018 # define DEBUG _DEBUG - 1
00019 #endif
00020
00021 #ifndef _PTHREADS
00022 # define _PTHREADS
00023 #endif
00024
00025 #ifndef _REENTRANT
00026 # define _REENTRANT
00027 #endif
00028 #if defined(__SUNPRO_CC)
00029 # ifndef __EXTENSIONS__
00030 # define __EXTENSIONS__
00031 # endif
00032 #elif defined(__KCC)
00033
00034 # ifdef _POSIX_C_SOURCE
00035 # undef _POSIX_C_SOURCE
00036 # endif
00037 # ifndef _XOPEN_VERSION
00038 # define _XOPEN_VERSION 4
00039 # else
00040 # undef _XOPEN_VERSION
00041 # define _XOPEN_VERSION 4
00042 # endif
00043 #endif
00044
00045
00046
00047 #if defined(__CYGWIN__) && !defined(HAVE_STRUCT_TIMESPEC)
00048 # define HAVE_STRUCT_TIMESPEC
00049 #endif
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069 #include <errno.h>
00070 #include <pthread.h>
00071 #if !defined(WITHOUT_FASTBIT_CONFIG_H) && !(defined(_WIN32)&&defined(_MSC_VER))
00072 # include "fastbit-config.h"
00073 # ifdef HAVE_STRING_H
00074 # if !STDC_HEADERS && HAVE_MEMORY_H
00075 # include <memory.h>
00076 # endif
00077 # include <string.h>
00078 # endif
00079 # ifdef HAVE_SYS_TYPES_H
00080 # include <sys/types.h>
00081 # endif
00082 # ifdef HAVE_STDINT_H
00083 # include <stdint.h>
00084 # endif
00085 #else
00086 # if defined(unix)||defined(linux)||defined(__APPLE__)||defined(__CYGWIN__)
00087 # define HAVE_VPRINTF 1
00088 # define HAVE_DIRENT_H 1
00089 # endif
00090 # if !defined(_MSC_VER)
00091 # include <sys/types.h>
00092 # endif
00093 # include <string.h>
00094 #endif
00095 #ifndef FASTBIT_STRING
00096 #define FASTBIT_STRING "FastBit ibis"
00097 #endif
00098 #include <vector>
00099 #include <functional>
00100
00101
00102 #if defined(__SUNPRO_CC)
00103 # if defined(_REENTRANT)
00104 # ifdef errno
00105 # undef errno
00106 # endif
00107 # define errno (*(::___errno()))
00108 # endif // defined(_REENTRANT)
00109
00110
00111
00112
00113
00114
00115
00116 #endif
00117
00118
00119
00120 #ifndef MAX_LINE
00121 #define MAX_LINE 2048
00122 #endif
00123
00124
00125
00126
00132 #ifndef PREFERRED_BLOCK_SIZE
00133 #define PREFERRED_BLOCK_SIZE 1048576
00134
00135 #endif
00136
00137 #if defined(__SUNPRO_CC)
00138 #if (__SUNPRO_CC < 0x500)
00139 # include <iostream.h>
00140 typedef int bool;
00141 # define false 0
00142 # define true 1
00143 # define std
00144 # define mutable
00145 # define explicit
00146 #else
00147 # include <iosfwd>
00148 #endif
00149
00150
00151 #else
00152 # include <iosfwd>
00153 #endif
00154
00155
00156
00157 #if defined(_CRAY) | defined(__KCC)
00158 # define __LIM_H_PARAM_
00159 # include <sys/param.h>
00160
00161 #elif defined(sun)
00162 # include <limits.h>
00163 # include <inttypes.h>
00164
00165
00166 # ifndef PTHREAD_RWLOCK_INITIALIZER
00167 # include <synch.h>
00168 # define pthread_rwlock_t rwlock_t
00169 # define pthread_rwlock_init(lk, attr) rwlock_init(lk, attr, 0)
00170 # define pthread_rwlock_destroy rwlock_destroy
00171 # define pthread_rwlock_rdlock rw_rdlock
00172 # define pthread_rwlock_wrlock rw_wrlock
00173 # define pthread_rwlock_tryrdlock rw_tryrdlock
00174 # define pthread_rwlock_trywrlock rw_trywrlock
00175 # define pthread_rwlock_unlock rw_unlock
00176 # define PTHREAD_RWLOCK_INITIALIZER DEFAULTRWLOCK;
00177 # endif
00178
00179 #elif defined(unix) || defined(__HOS_AIX__)
00180 # include <stdint.h>
00181 # include <limits.h>
00182 # ifdef __CYGWIN__ // cygwin port of gcc compiler
00183
00184 # include <cygwin/types.h>
00185 # endif
00186
00187 #elif defined(_WIN32)
00188
00189 # define WIN32_LEAN_AND_MEAN
00190
00191 # ifndef WINVER
00192 # ifdef _WIN32_WINNT
00193 # define WINVER _WIN32_WINNT
00194 # else
00195 # define WINVER 0x0600
00196 # endif
00197 # endif
00198 # include <limits.h>
00199 # include <windows.h>
00200 # include <direct.h>
00201 # define mkdir(x,y) _mkdir(x)
00202 # define chmod _chmod
00203 # if defined(_DEBUG)
00204 # include <crtdbg.h>
00205 # endif
00206
00207
00208 # ifndef int16_t
00209 # define int16_t __int16
00210 # endif
00211 # ifndef uint16_t
00212 # define uint16_t unsigned __int16
00213 # endif
00214 # ifndef int32_t
00215 # define int32_t __int32
00216 # endif
00217 # ifndef uint32_t
00218 # define uint32_t unsigned __int32
00219 # endif
00220 # ifndef int64_t
00221 # define int64_t __int64
00222 # endif
00223 # ifndef uint64_t
00224 # define uint64_t unsigned __int64
00225 # endif
00226
00227 #elif defined(__APPLE__)
00228 # include <stdint.h>
00229 # include <sys/syslimits.h>
00230
00231 #else
00232 # include <stdint.h>
00233 # include <syslimits.h>
00234
00235 #endif
00236
00237
00238
00239
00240
00241
00242 #if !(defined(HAVE_STDINT_H) || defined(unix) || defined(_WIN32) || defined(__APPLE__) || defined(__x86_64__) || defined(_STDINT_H))
00243 # ifndef INT16_MAX
00244 # define int16_t short int
00245 # define INT16_MAX (32767)
00246 # endif
00247 # ifndef UINT16_MAX
00248 # define uint16_t unsigned short int
00249 # define UINT16_MAX (65535)
00250 # endif
00251 # ifndef INT32_MAX
00252 # define int32_t int
00253 # define INT32_MAX (2147483647)
00254 # endif
00255 # ifndef UINT32_MAX
00256 # define uint32_t unsigned int
00257 # define UINT32_MAX (4294967295UL)
00258 # endif
00259 # ifndef INT64_MAX
00260 # define int64_t long long int
00261 # define INT64_MAX (9223372036854775807LL)
00262 # endif
00263 # ifndef UINT64_MAX
00264 # define uint64_t unsigned long long int
00265 # define UINT64_MAX (18446744073709551615ULL)
00266 # endif
00267 #endif
00268
00269 #ifndef PATH_MAX
00270 # define PATH_MAX 512
00271 #endif
00272
00273
00274
00275
00276 #if defined(_WIN32) && defined(_MSC_VER)
00277 # define FASTBIT_DIRSEP '\\'
00278 #else
00279 # define FASTBIT_DIRSEP '/'
00280 #endif
00281 #if defined(_WIN32) && (defined(_MSC_VER) || defined(__MINGW32__))
00282 # if defined(_USRDLL) || defined(CXX_USE_DLL)
00283 # if defined(DLL_EXPORT)
00284 # define FASTBIT_CXX_DLLSPEC __declspec(dllexport)
00285 # else
00286 # define FASTBIT_CXX_DLLSPEC __declspec(dllimport)
00287 # endif
00288 # else
00289 # define FASTBIT_CXX_DLLSPEC
00290 # endif
00291 #else
00292 # define FASTBIT_CXX_DLLSPEC
00293 #endif
00294
00295
00296
00297
00298
00299
00300
00301
00302 #if defined(__APPLE__) && !defined(PTHREAD_RWLOCK_INITIALIZER)
00303 #define PTHREAD_RWLOCK_INITIALIZER
00304 #endif
00305
00306 #ifndef PTHREAD_RWLOCK_INITIALIZER
00307 #define IBIS_REPLACEMENT_RWLOCK
00308 #define THREAD_RWLOCK_INITIALIZER \
00309 {PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, \
00310 PTHREAD_COND_INITIALIZER, 0, 0}
00311 typedef struct _rwlock {
00312 pthread_mutex_t lock;
00313 pthread_cond_t readers;
00314 pthread_cond_t writers;
00315 int state;
00316 int waiters;
00317 } pthread_rwlock_t;
00318 int pthread_rwlock_init(pthread_rwlock_t *rwlock, void*);
00319 int pthread_rwlock_destroy(pthread_rwlock_t *rwlock);
00320 int pthread_rwlock_rdlock(pthread_rwlock_t *rwlock);
00321 int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock);
00322 int pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock);
00323 int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock);
00324 int pthread_rwlock_unlock(pthread_rwlock_t *rwlock);
00325 #endif
00326
00327
00328
00329
00330 #ifdef _WIN32
00331 # if _MSC_VER >= 1500
00332 # define strnicmp _strnicmp
00333 # define stricmp _stricmp
00334 # endif
00335 #else
00336 # include <strings.h>
00337 # define MessageBox(x1,x2,x3,x4); {} // fake message box
00338 # define strnicmp strncasecmp
00339 # define stricmp strcasecmp
00340 #endif
00341
00342
00343
00344
00345
00346
00347 namespace ibis {
00350 class part;
00351 class query;
00352 class qExpr;
00353
00354
00355 template<class T> class array_t;
00357 typedef FASTBIT_CXX_DLLSPEC std::vector< part* > partList;
00358
00360 union FASTBIT_CXX_DLLSPEC rid_t {
00361 uint64_t value;
00362
00363 struct name {
00364 uint32_t run;
00365 uint32_t event;
00366 } num;
00367
00368 bool operator<(const rid_t& r) const {
00369 return((num.run < r.num.run) |
00370 (num.run == r.num.run && num.event < r.num.event));}
00371 bool operator>(const rid_t& r) const {
00372 return((num.run > r.num.run) |
00373 (num.run == r.num.run && num.event > r.num.event));}
00374 bool operator<=(const rid_t& r) const {
00375 return((num.run < r.num.run) |
00376 (num.run == r.num.run && num.event <= r.num.event));}
00377 bool operator>=(const rid_t& r) const {
00378 return((num.run > r.num.run) |
00379 (num.run == r.num.run && num.event >= r.num.event));}
00380 bool operator==(const rid_t& r) const {return(value == r.value);}
00381 bool operator!=(const rid_t& r) const {return(value != r.value);}
00382 };
00383
00386 struct lessi :
00387 public std::binary_function< const char*, const char*, bool > {
00388 bool operator()(const char* x, const char* y) const {
00389 return (x && y ? stricmp(x, y) < 0 : false);
00390 }
00391 };
00392
00395 extern FASTBIT_CXX_DLLSPEC int gVerbose;
00396 }
00397 #endif // ifndef IBIS_CONST_H