8 // #define MULTITHREAD_SUPPORT // Try to parallelize things using OpenMP.
9 // #define MASSIVE_DATA_RLCSA // usint and sint become 64-bit in a 64-bit environment.
16 #ifdef MASSIVE_DATA_RLCSA
17 typedef unsigned long usint;
18 typedef signed long sint;
20 typedef unsigned int usint;
21 typedef signed int sint;
25 typedef unsigned int uint;
29 typedef unsigned char uchar;
32 typedef std::pair<usint, usint> pair_type;
35 inline usint length(usint n)
38 while(n > 0) { b++; n >>= 1; }
42 inline bool isEmpty(const pair_type& data)
44 return (data.first > data.second);
47 inline usint length(const pair_type& data)
49 return data.second + 1 - data.first;
52 inline usint nextMultipleOf(usint multiplier, usint value)
54 return multiplier * ((value / multiplier) + 1);
58 const usint CHARS = ((usint)1 << CHAR_BIT);
59 const usint MEGABYTE = 1048576;
60 const usint MILLION = 1000000;
61 const usint WORD_BITS = CHAR_BIT * sizeof(usint);
62 const usint WORD_MAX = ~((usint)0);
64 const pair_type EMPTY_PAIR = pair_type(1, 0);
67 // Previous GET was broken when BITS == WORD_BITS
68 // Current version works for usints and less
69 //#define GET(FIELD, BITS) ((FIELD) & ((1 << (BITS)) - 1))
70 #define GET(FIELD, BITS) ((FIELD) & (WORD_MAX >> (WORD_BITS - (BITS))))
71 #define LOWER(FIELD, N) ((FIELD) >> (N))
72 #define HIGHER(FIELD, N) ((FIELD) << (N))
74 #define BITS_TO_BYTES(BITS) (((BITS) + CHAR_BIT - 1) / CHAR_BIT)
75 #define BYTES_TO_WORDS(BYTES) (((BYTES) + sizeof(usint) - 1) / sizeof(usint))
76 #define BITS_TO_WORDS(BITS) (((BITS) + WORD_BITS - 1) / WORD_BITS)