31
#if defined(__cplusplus)
33
# if defined(__GNUC) && defined(__EXCEPTIONS)
34
# error "Please add -fno-exceptions to CXXFLAGS and reconfigure/recompile"
47
# include <inttypes.h>
52
# include <errno.h> /* Recommended by debian */
54
A lot of our programs uses asserts, so better to always include it
66
#if TIME_WITH_SYS_TIME
67
# include <sys/time.h>
71
# include <sys/time.h>
76
#ifndef HAVE_DECL_TIMEGM
77
#include <gnulib/time.h>
78
# if defined(__cplusplus)
81
time_t timegm (struct tm *__tm);
82
#endif /* HAVE_DECL_TIMEGM */
32
86
Temporary solution to solve bug#7156. Include "sys/types.h" before
36
90
#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
94
#include <pthread.h> /* AIX must have this included first */
53
96
#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
98
#ifdef HAVE_LIMITS_H
74
99
#include <limits.h>
80
105
#ifdef HAVE_FCNTL_H
81
106
#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
109
#ifdef HAVE_UNISTD_H
97
110
#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
114
#ifdef HAVE_SYS_STAT_H
114
115
# include <sys/stat.h>
118
A lot of our programs uses asserts, so better to always include it
122
118
#if !defined(HAVE_UINT)
124
120
#define HAVE_UINT
125
121
typedef unsigned int uint;
126
typedef unsigned short ushort;
129
124
/* Declared in int2str() */
130
125
extern char _dig_vec_upper[];
131
126
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))
149
128
#define set_if_bigger(a,b) do { if ((a) < (b)) (a)=(b); } while(0)
151
130
#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
131
#define array_elements(A) ((size_t) (sizeof(A)/sizeof(A[0])))
155
133
/* Some types that is different between systems */
160
138
#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
142
#ifndef FN_LIBCHAR
192
143
#define FN_LIBCHAR '/'
274
225
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;
228
typedef ptrdiff_t my_ptrdiff_t;
283
230
#define MY_ALIGN(A,L) (((A) + (L) - 1) & ~((L) - 1))
284
231
#define ALIGN_SIZE(A) MY_ALIGN((A),sizeof(double))
298
245
typedef unsigned long ulong; /* Short for unsigned long */
302
248
typedef uint64_t my_off_t;
304
typedef unsigned long my_off_t;
250
#if defined(SIZEOF_OFF_T)
251
# if (SIZEOF_OFF_T == 8)
252
# define OFF_T_MAX (INT64_MAX)
254
# 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)
258
#define MY_FILEPOS_ERROR -1
313
260
/* Defines for time function */
314
261
#define SCALE_SEC 100
333
280
#define cmax(a, b) ((a) > (b) ? (a) : (b))
334
281
#define cmin(a, b) ((a) < (b) ? (a) : (b))
283
#define DRIZZLE_SERVER
336
285
/* Length of decimal number represented by INT32. */
337
286
#define MY_INT32_NUM_DECIMAL_DIGITS 11
339
288
/* Length of decimal number represented by INT64. */
340
289
#define MY_INT64_NUM_DECIMAL_DIGITS 21
291
#define PROTOCOL_VERSION 10
293
Io buffer size; Must be a power of 2 and
294
a multiple of 512. May be
295
smaller what the disk page size. This influences the speed of the
296
isam btree library. eg to big to slow.
299
/* Max file name len */
301
/* Max length of extension (part of FN_LEN) */
303
/* Max length of full path-name */
304
#define FN_REFLEN 512
305
/* File extension character */
306
#define FN_EXTCHAR '.'
307
/* ~ is used as abbrev for home dir */
308
#define FN_HOMELIB '~'
309
/* ./ is used as abbrev for current dir */
310
#define FN_CURLIB '.'
311
/* Parent directory; Must be a string */
312
#define FN_PARENTDIR ".."
314
/* Quote argument (before cpp) */
316
# define QUOTE_ARG(x) #x
318
/* Quote argument, (after cpp) */
319
#ifndef STRINGIFY_ARG
320
# define STRINGIFY_ARG(x) QUOTE_ARG(x)
324
* The macros below are borrowed from include/linux/compiler.h in the
325
* Linux kernel. Use them to indicate the likelyhood of the truthfulness
326
* of a condition. This serves two purposes - newer versions of gcc will be
327
* able to optimize for branch predication, which could yield siginficant
328
* performance gains in frequently executed sections of the code, and the
329
* other reason to use them is for documentation
331
#if !defined(__GNUC__)
332
#define __builtin_expect(x, expected_value) (x)
335
#define likely(x) __builtin_expect((x),1)
336
#define unlikely(x) __builtin_expect((x),0)
343
340
Only Linux is known to need an explicit sync of the directory to make sure a
344
341
file creation/deletion/renaming in(from,to) this directory durable.
347
344
#define NEED_EXPLICIT_SYNC_DIR 1
350
#include <libdrizzle/gettext.h>
347
/* We need to turn off _DTRACE_VERSION if we're not going to use dtrace */
348
#if !defined(HAVE_DTRACE)
349
# undef _DTRACE_VERSION
350
# define _DTRACE_VERSION 0
352
353
#endif /* DRIZZLE_SERVER_GLOBAL_H */