29
#if defined(__sun) && defined(_FILE_OFFSET_BITS)
30
#undef _FILE_OFFSET_BITS
35
#if defined(__cplusplus)
45
# if defined(HAVE_MEMORY)
48
# if defined(HAVE_TR1_MEMORY)
49
# include <tr1/memory>
51
# if defined(HAVE_BOOST_SHARED_PTR_HPP)
52
# include <boost/shared_ptr.hpp>
56
# include <inttypes.h>
60
# include <errno.h> /* Recommended by debian */
62
A lot of our programs uses asserts, so better to always include it
75
#if TIME_WITH_SYS_TIME
76
# include <sys/time.h>
80
# include <sys/time.h>
87
#if defined(__cplusplus)
88
# if !defined(SHARED_PTR_NAMESPACE)
89
# error SHARED_PTR_NAMESPACE not defined, configure error!
91
# if defined(SHARED_PTR_NAMESPACE)
92
//We aren't using this yet - don't actually put in code yet.
93
//using SHARED_PTR_NAMESPACE::shared_ptr;
95
#endif /* defined(SHARED_PTR_NAMESPACE) */
32
98
Temporary solution to solve bug#7156. Include "sys/types.h" before
36
102
#include <sys/types.h>
39
#if defined(HAVE_STDINT_H)
42
#error "You must have stdint!"
45
#if defined(HAVE_INTTYPES_H)
48
#error "You must have inttypes!"
51
106
#include <pthread.h> /* AIX must have this included first */
53
108
#define _REENTRANT 1 /* Threads requires reentrant code */
58
#if defined(__GNUC) && defined(__EXCEPTIONS)
59
#error "Please add -fno-exceptions to CXXFLAGS and reconfigure/recompile"
73
110
#ifdef HAVE_LIMITS_H
74
111
#include <limits.h>
80
117
#ifdef HAVE_FCNTL_H
81
118
#include <fcntl.h>
83
#ifdef HAVE_SYS_TIMEB_H
84
#include <sys/timeb.h> /* Avoid warnings on SCO */
86
#if TIME_WITH_SYS_TIME
87
# include <sys/time.h>
91
# include <sys/time.h>
95
#endif /* TIME_WITH_SYS_TIME */
96
121
#ifdef HAVE_UNISTD_H
97
122
#include <unistd.h>
99
#if defined(__cplusplus) && defined(NO_CPLUSPLUS_ALLOCA)
107
#include <errno.h> /* Recommended by debian */
109
#if defined(HAVE_STDBOOL_H)
113
126
#ifdef HAVE_SYS_STAT_H
114
127
# include <sys/stat.h>
118
A lot of our programs uses asserts, so better to always include it
122
#if !defined(HAVE_UINT)
125
typedef unsigned int uint;
126
typedef unsigned short ushort;
129
130
/* Declared in int2str() */
130
131
extern char _dig_vec_upper[];
131
132
extern char _dig_vec_lower[];
133
#if defined(__cplusplus)
135
inline bool test(const T a)
137
return a ? true : false;
139
template <class T, class U>
140
inline bool test_all_bits(const T a, const U b)
142
return ((a & b) == b);
145
#define test(a) ((a) ? 1 : 0)
146
#define test_all_bits(a,b) (((a) & (b)) == (b))
135
template <class T> void set_if_bigger(T &a, const T &b)
141
template <class T> void set_if_smaller(T &a, const T &b)
148
#define set_if_bigger(a,b) do { \
149
const typeof(a) _a = (a); \
150
const typeof(b) _b = (b); \
151
(void) (&_a == &_b); \
152
if ((a) < (b)) (a)=(b); \
154
#define set_if_smaller(a,b) do { \
155
const typeof(a) _a = (a); \
156
const typeof(b) _b = (b); \
157
(void) (&_a == &_b); \
158
if ((a) > (b)) (a)=(b); \
149
162
#define set_if_bigger(a,b) do { if ((a) < (b)) (a)=(b); } while(0)
151
163
#define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0)
152
#define set_bits(type, bit_count) (sizeof(type)*8 <= (bit_count) ? ~(type) 0 : ((((type) 1) << (bit_count)) - (type) 1))
153
167
#define array_elements(A) ((size_t) (sizeof(A)/sizeof(A[0])))
155
169
/* Some types that is different between systems */
160
174
#include <sys/socket.h>
163
/* file create flags */
165
#ifndef O_SHARE /* Probably not windows */
166
#define O_SHARE 0 /* Flag to my_open for shared files */
170
#define O_BINARY 0 /* Flag to my_open for binary files */
174
#define FILE_BINARY O_BINARY /* Flag to my_fopen for binary streams */
177
#define F_TO_EOF 0L /* Param to lockf() to lock rest of file */
180
#define O_TEMPORARY 0
182
#ifndef O_SHORT_LIVED
183
#define O_SHORT_LIVED 0
191
178
#ifndef FN_LIBCHAR
192
179
#define FN_LIBCHAR '/'
204
191
#define MALLOC_OVERHEAD 8
206
193
/* get memory in huncs */
207
#define ONCE_ALLOC_INIT (uint) (4096-MALLOC_OVERHEAD)
194
static const uint32_t ONCE_ALLOC_INIT= 4096;
208
195
/* Typical record cash */
209
#define RECORD_CACHE_SIZE (uint) (64*1024-MALLOC_OVERHEAD)
196
static const uint32_t RECORD_CACHE_SIZE= 64*1024;
210
197
/* Typical key cash */
211
#define KEY_CACHE_SIZE (uint) (8*1024*1024-MALLOC_OVERHEAD)
198
static const uint32_t KEY_CACHE_SIZE= 8*1024*1024;
212
200
/* Default size of a key cache block */
213
#define KEY_CACHE_BLOCK_SIZE (uint) 1024
201
static const uint32_t KEY_CACHE_BLOCK_SIZE= 1024;
216
204
/* Some things that this system doesn't have */
232
220
#error "please add -DSTACK_DIRECTION=1 or -1 to your CPPFLAGS"
235
#if !defined(HAVE_STRTOK_R)
236
#define strtok_r(A,B,C) strtok((A),(B))
239
223
#ifdef HAVE_FLOAT_H
240
224
#include <float.h>
274
258
Max size that must be added to a so that we know Size to make
277
#if SIZEOF_CHARP == 4
278
typedef int32_t my_ptrdiff_t;
280
typedef int64_t my_ptrdiff_t;
261
typedef ptrdiff_t my_ptrdiff_t;
283
263
#define MY_ALIGN(A,L) (((A) + (L) - 1) & ~((L) - 1))
284
264
#define ALIGN_SIZE(A) MY_ALIGN((A),sizeof(double))
298
278
typedef unsigned long ulong; /* Short for unsigned long */
302
281
typedef uint64_t my_off_t;
304
typedef unsigned long my_off_t;
283
#if defined(SIZEOF_OFF_T)
284
# if (SIZEOF_OFF_T == 8)
285
# define OFF_T_MAX (INT64_MAX)
287
# define OFF_T_MAX (INT32_MAX)
306
#define MY_FILEPOS_ERROR (~(my_off_t) 0)
308
typedef off_t os_off_t;
310
typedef int myf; /* Type of MyFlags in my_funcs */
311
#define MYF(v) (myf) (v)
291
#define MY_FILEPOS_ERROR -1
313
293
/* Defines for time function */
314
294
#define SCALE_SEC 100
317
297
#define MY_HOW_OFTEN_TO_WRITE 1000 /* How often we want info on screen */
320
#if defined(HAVE_CHARSET_utf8mb3) || defined(HAVE_CHARSET_utf8mb4)
321
#define DRIZZLE_UNIVERSAL_CLIENT_CHARSET "utf8"
323
#define DRIZZLE_UNIVERSAL_CLIENT_CHARSET DRIZZLE_DEFAULT_CHARSET_NAME
326
300
#include <dlfcn.h>
328
302
/* FreeBSD 2.2.2 does not define RTLD_NOW) */
330
304
#define RTLD_NOW 1
333
#define cmax(a, b) ((a) > (b) ? (a) : (b))
334
#define cmin(a, b) ((a) < (b) ? (a) : (b))
307
#define DRIZZLE_SERVER
336
309
/* Length of decimal number represented by INT32. */
337
310
#define MY_INT32_NUM_DECIMAL_DIGITS 11
340
313
#define MY_INT64_NUM_DECIMAL_DIGITS 21
316
Io buffer size; Must be a power of 2 and
317
a multiple of 512. May be
318
smaller what the disk page size. This influences the speed of the
319
isam btree library. eg to big to slow.
322
/* Max file name len */
324
/* Max length of extension (part of FN_LEN) */
326
/* Max length of full path-name */
327
#define FN_REFLEN 512
328
/* File extension character */
329
#define FN_EXTCHAR '.'
330
/* ~ is used as abbrev for home dir */
331
#define FN_HOMELIB '~'
332
/* ./ is used as abbrev for current dir */
333
#define FN_CURLIB '.'
334
/* Parent directory; Must be a string */
335
#define FN_PARENTDIR ".."
337
/* Quote argument (before cpp) */
339
# define QUOTE_ARG(x) #x
341
/* Quote argument, (after cpp) */
342
#ifndef STRINGIFY_ARG
343
# define STRINGIFY_ARG(x) QUOTE_ARG(x)
347
* The macros below are borrowed from include/linux/compiler.h in the
348
* Linux kernel. Use them to indicate the likelyhood of the truthfulness
349
* of a condition. This serves two purposes - newer versions of gcc will be
350
* able to optimize for branch predication, which could yield siginficant
351
* performance gains in frequently executed sections of the code, and the
352
* other reason to use them is for documentation
354
#if !defined(__GNUC__)
355
#define __builtin_expect(x, expected_value) (x)
358
#define likely(x) __builtin_expect((x),1)
359
#define unlikely(x) __builtin_expect((x),0)
343
363
Only Linux is known to need an explicit sync of the directory to make sure a
344
364
file creation/deletion/renaming in(from,to) this directory durable.
347
367
#define NEED_EXPLICIT_SYNC_DIR 1
350
#include <libdrizzle/gettext.h>
370
/* We need to turn off _DTRACE_VERSION if we're not going to use dtrace */
371
#if !defined(HAVE_DTRACE)
372
# undef _DTRACE_VERSION
373
# define _DTRACE_VERSION 0
352
376
#endif /* DRIZZLE_SERVER_GLOBAL_H */