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 HAVE_CONFIG_H
00072 # include "config.h"
00073 # if HAVE_STRING_H
00074 # if !STDC_HEADERS && HAVE_MEMORY_H
00075 # include <memory.h>
00076 # endif
00077 # include <string.h>
00078 # endif
00079 # if HAVE_SYS_TYPES_H
00080 # include <sys/types.h>
00081 # endif
00082 # if 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 # include <string.h>
00093 # endif
00094 #endif
00095 #include <functional>
00096
00097
00098 #define TIME_BUF_LEN 32
00099 #define MAX_LINE 2048
00100
00101
00102
00103
00104
00105 #if defined(__SUNPRO_CC)
00106 # if defined(_REENTRANT)
00107 # ifdef errno
00108 # undef errno
00109 # endif
00110 # define errno (*(::___errno()))
00111 # endif // defined(_REENTRANT)
00112
00113
00114
00115
00116
00117
00118
00119 #endif
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 <iostream>
00142 #endif
00143
00144
00145 #else
00146 # include <iostream>
00147 #endif
00148
00149
00150
00151 #if defined(_CRAY) | defined(__KCC)
00152 # define __LIM_H_PARAM_
00153 # include <sys/param.h>
00154
00155 #elif defined(sun)
00156 # include <limits.h>
00157 # include <inttypes.h>
00158
00159
00160 # ifndef PTHREAD_RWLOCK_INITIALIZER
00161 # include <synch.h>
00162 # define pthread_rwlock_t rwlock_t
00163 # define pthread_rwlock_init(lk, attr) rwlock_init(lk, attr, 0)
00164 # define pthread_rwlock_destroy rwlock_destroy
00165 # define pthread_rwlock_rdlock rw_rdlock
00166 # define pthread_rwlock_wrlock rw_wrlock
00167 # define pthread_rwlock_tryrdlock rw_tryrdlock
00168 # define pthread_rwlock_trywrlock rw_trywrlock
00169 # define pthread_rwlock_unlock rw_unlock
00170 # define PTHREAD_RWLOCK_INITIALIZER DEFAULTRWLOCK;
00171 # endif
00172
00173 #elif defined(unix) || defined(__HOS_AIX__)
00174 # include <stdint.h>
00175 # include <limits.h>
00176 # ifdef __CYGWIN__ // cygwin port of gcc compiler
00177
00178 # include <cygwin/types.h>
00179 # endif
00180
00181 #elif defined(_WIN32)
00182 # include <limits.h>
00183 # include <windows.h>
00184 # include <direct.h>
00185 # define mkdir(x,y) _mkdir(x)
00186 # define chmod _chmod
00187 # if defined(_DEBUG)
00188 # include <crtdbg.h>
00189 # endif
00190
00191
00192 # ifndef int16_t
00193 # define int16_t __int16
00194 # endif
00195 # ifndef uint16_t
00196 # define uint16_t unsigned __int16
00197 # endif
00198 # ifndef int32_t
00199 # define int32_t __int32
00200 # endif
00201 # ifndef uint32_t
00202 # define uint32_t unsigned __int32
00203 # endif
00204 # ifndef int64_t
00205 # define int64_t __int64
00206 # endif
00207 # ifndef uint64_t
00208 # define uint64_t unsigned __int64
00209 # endif
00210
00211 #elif defined(__APPLE__)
00212 # include <stdint.h>
00213 # include <sys/syslimits.h>
00214
00215 #else
00216 # include <stdint.h>
00217 # include <syslimits.h>
00218
00219 #endif
00220
00221
00222 #if HAVE_STDINT_H+0 == 0 && !defined(_WIN32) && !defined(INT64_MIN) && !(defined __x86_64__)
00223 # ifndef int16_t
00224 # define int16_t short int
00225 # endif
00226 # ifndef uint16_t
00227 # define uint16_t unsigned short int
00228 # endif
00229 # ifndef int32_t
00230 # define int32_t int
00231 # endif
00232 # ifndef uint32_t
00233 # define uint32_t unsigned int
00234 # endif
00235 # ifndef int64_t
00236 # define int64_t long long int
00237 # endif
00238 # ifndef uint64_t
00239 # define uint64_t unsigned long long int
00240 # endif
00241 #endif
00242
00243 #ifndef PATH_MAX
00244 # define PATH_MAX 512
00245 #endif
00246
00247
00248
00249
00250 #if defined(_WIN32) && defined(_MSC_VER)
00251 # define DIRSEP '\\'
00252 #else
00253 # define DIRSEP '/'
00254 #endif
00255 #if defined(_WIN32) && (defined(_MSC_VER) || defined(__MINGW32__))
00256 # if defined(CXX_USE_DLL) && defined(DLL_EXPORTS)
00257 # define FASTBIT_CXX_DLLSPEC __declspec(dllexport)
00258 # elif defined(CXX_USE_DLL)
00259 # define FASTBIT_CXX_DLLSPEC __declspec(dllimport)
00260 # else
00261 # define FASTBIT_CXX_DLLSPEC
00262 # endif
00263 #else
00264 # define FASTBIT_CXX_DLLSPEC
00265 #endif
00266
00267
00268
00269
00270
00271
00272
00273
00274 #if defined(__APPLE__) && !defined(PTHREAD_RWLOCK_INITIALIZER)
00275 #define PTHREAD_RWLOCK_INITIALIZER
00276 #endif
00277
00278 #ifndef PTHREAD_RWLOCK_INITIALIZER
00279 #define IBIS_REPLACEMENT_RWLOCK
00280 #define THREAD_RWLOCK_INITIALIZER \
00281 {PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, \
00282 PTHREAD_COND_INITIALIZER, 0, 0}
00283 typedef struct _rwlock {
00284 pthread_mutex_t lock;
00285 pthread_cond_t readers;
00286 pthread_cond_t writers;
00287 int state;
00288 int waiters;
00289 } pthread_rwlock_t;
00290 int pthread_rwlock_init(pthread_rwlock_t *rwlock, void*);
00291 int pthread_rwlock_destroy(pthread_rwlock_t *rwlock);
00292 int pthread_rwlock_rdlock(pthread_rwlock_t *rwlock);
00293 int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock);
00294 int pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock);
00295 int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock);
00296 int pthread_rwlock_unlock(pthread_rwlock_t *rwlock);
00297 #endif
00298
00299
00300
00301
00302 #ifndef _WIN32
00303 # include <strings.h>
00304 # define MessageBox(x1,x2,x3,x4); {} // fake message box
00305 # define strnicmp strncasecmp
00306 # define stricmp strcasecmp
00307 #endif
00308
00309
00310
00311
00312
00313
00314 namespace ibis {
00315 class bitvector;
00316 class part;
00317 class query;
00318 class resource;
00319
00321 union FASTBIT_CXX_DLLSPEC rid_t {
00322 uint64_t value;
00323
00324 struct name {
00325 uint32_t run;
00326 uint32_t event;
00327 } num;
00328
00329 bool operator<(const rid_t& r) const {
00330 return((num.run < r.num.run) |
00331 (num.run == r.num.run && num.event < r.num.event));}
00332 bool operator>(const rid_t& r) const {
00333 return((num.run > r.num.run) |
00334 (num.run == r.num.run && num.event > r.num.event));}
00335 bool operator<=(const rid_t& r) const {
00336 return((num.run < r.num.run) |
00337 (num.run == r.num.run && num.event <= r.num.event));}
00338 bool operator>=(const rid_t& r) const {
00339 return((num.run > r.num.run) |
00340 (num.run == r.num.run && num.event >= r.num.event));}
00341 bool operator==(const rid_t& r) const {return(value == r.value);}
00342 bool operator!=(const rid_t& r) const {return(value != r.value);}
00343 };
00344
00347 struct lessi :
00348 public std::binary_function< const char*, const char*, bool > {
00349 bool operator()(const char* x, const char* y) const {
00350 return (x && y ? stricmp(x, y) < 0 : false);
00351 }
00352 };
00353
00356 extern FASTBIT_CXX_DLLSPEC int gVerbose;
00357 }
00358
00359
00360 template<class T> class array_t;
00361 #endif // ifndef IBIS_CONST_H