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