~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/global.h

  • Committer: Monty Taylor
  • Date: 2008-10-04 22:16:00 UTC
  • Revision ID: monty@inaugust.com-20081004221600-6jep5u7msxfko7tw
Made a few macros into template functions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
147
147
extern char _dig_vec_upper[];
148
148
extern char _dig_vec_lower[];
149
149
 
 
150
#if defined(__cplusplus)
 
151
template <class T>
 
152
inline bool test(const T a)
 
153
{
 
154
  return a ? true : false;
 
155
}
 
156
template <class T, class U>
 
157
inline bool test_all_bits(const T a, const U b)
 
158
{
 
159
  return ((a & b) == b);
 
160
}
 
161
#else
150
162
#define test(a)    ((a) ? 1 : 0)
 
163
#define test_all_bits(a,b) (((a) & (b)) == (b))
 
164
#endif
 
165
 
151
166
#define set_if_bigger(a,b)  do { if ((a) < (b)) (a)=(b); } while(0)
 
167
 
152
168
#define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0)
153
 
#define test_all_bits(a,b) (((a) & (b)) == (b))
154
169
#define set_bits(type, bit_count) (sizeof(type)*8 <= (bit_count) ? ~(type) 0 : ((((type) 1) << (bit_count)) - (type) 1))
155
 
#define array_elements(A) ((uint32_t) (sizeof(A)/sizeof(A[0])))
 
170
#define array_elements(A) ((size_t) (sizeof(A)/sizeof(A[0])))
156
171
 
157
172
/* Some types that is different between systems */
158
173