22
22
#ifndef DRIZZLE_SERVER_GLOBAL_H
23
23
#define DRIZZLE_SERVER_GLOBAL_H
25
#define HAVE_REPLICATION
28
InnoDB depends on some MySQL internals which other plugins should not
29
need. This is because of InnoDB's foreign key support, "safe" binlog
30
truncation, and other similar legacy features.
32
We define accessors for these internals unconditionally, but do not
33
expose them in mysql/plugin.h. They are declared in ha_innodb.h for
36
#define INNODB_COMPATIBILITY_HOOKS
38
/* to make command line shorter we'll define USE_PRAGMA_INTERFACE here */
39
#ifdef USE_PRAGMA_IMPLEMENTATION
40
#define USE_PRAGMA_INTERFACE
25
43
#if defined(i386) && !defined(__i386__)
29
47
#include "config.h"
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
50
The macros below are borrowed from include/linux/compiler.h in the
51
Linux kernel. Use them to indicate the likelyhood of the truthfulness
52
of a condition. This serves two purposes - newer versions of gcc will be
53
able to optimize for branch predication, which could yield siginficant
54
performance gains in frequently executed sections of the code, and the
55
other reason to use them is for documentation
58
#if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
59
#define __builtin_expect(x, expected_value) (x)
62
#define likely(x) __builtin_expect((x),1)
63
#define unlikely(x) __builtin_expect((x),0)
62
#if TIME_WITH_SYS_TIME
63
# include <sys/time.h>
67
# include <sys/time.h>
66
* Disable __attribute__ for non GNU compilers, since we're using them
67
* only to either generate or suppress warnings.
70
# if !defined(__GNUC__)
71
# define __attribute__(A)
71
#endif */ /* TIME_WITH_SYS_TIME */
76
/* Fix problem with S_ISLNK() on Linux */
77
#if defined(TARGET_OS_LINUX) || defined(__GLIBC__)
74
84
Temporary solution to solve bug#7156. Include "sys/types.h" before
78
88
#include <sys/types.h>
91
#if defined(HAVE_STDINT_H)
94
#error "You must have stdint!"
97
#if defined(HAVE_INTTYPES_H)
100
#error "You must have inttypes!"
105
Solaris 9 include file <sys/feature_tests.h> refers to X/Open document
107
System Interfaces and Headers, Issue 5
109
saying we should define _XOPEN_SOURCE=500 to get POSIX.1c prototypes,
110
but apparently other systems (namely FreeBSD) don't agree.
112
On a newer Solaris 10, the above file recognizes also _XOPEN_SOURCE=600.
113
Furthermore, it tests that if a program requires older standard
114
(_XOPEN_SOURCE<600 or _POSIX_C_SOURCE<200112L) it cannot be
115
run on a new compiler (that defines _STDC_C99) and issues an #error.
116
It's also an #error if a program requires new standard (_XOPEN_SOURCE=600
117
or _POSIX_C_SOURCE=200112L) and a compiler does not define _STDC_C99.
119
To add more to this mess, Sun Studio C compiler defines _STDC_C99 while
120
C++ compiler does not!
122
So, in a desperate attempt to get correct prototypes for both
123
C and C++ code, we define either _XOPEN_SOURCE=600 or _XOPEN_SOURCE=500
124
depending on the compiler's announced C standard support.
126
Cleaner solutions are welcome.
128
#if defined(__sun) && !defined(__cplusplus)
129
#if __STDC_VERSION__ - 0 >= 199901L
130
#define _XOPEN_SOURCE 600
132
#define _XOPEN_SOURCE 500
136
#ifndef _POSIX_PTHREAD_SEMANTICS
137
#define _POSIX_PTHREAD_SEMANTICS /* We want posix threads */
140
#define _REENTRANT 1 /* Some thread libraries require this */
82
142
#include <pthread.h> /* AIX must have this included first */
84
144
#define _REENTRANT 1 /* Threads requires reentrant code */
147
/* gcc/egcs issues */
149
#if defined(__GNUC) && defined(__EXCEPTIONS)
150
#error "Please add -fno-exceptions to CXXFLAGS and reconfigure/recompile"
86
164
#ifdef HAVE_LIMITS_H
87
165
#include <limits.h>
105
195
#include <alloca.h>
198
#include <errno.h> /* Recommended by debian */
200
#if defined(HAVE_STDBOOL_H)
110
204
#ifdef HAVE_SYS_STAT_H
111
205
# include <sys/stat.h>
209
A lot of our programs uses asserts, so better to always include it
213
/* an assert that works at compile-time. only for constant expression */
215
#define compile_time_assert(X) do { } while(0)
217
#define compile_time_assert(X) \
220
char compile_time_assert[(X) ? 1 : -1] \
221
__attribute__ ((unused)); \
225
/* Declare madvise where it is not declared for C++, like Solaris */
226
#if defined(HAVE_MADVISE) && !defined(HAVE_DECL_MADVISE) && defined(__cplusplus)
227
extern "C" int madvise(void *addr, size_t len, int behav);
230
/* We can not live without the following defines */
232
#define MASTER 1 /* Compile without unireg */
234
#define QUOTE_ARG(x) #x /* Quote argument (before cpp) */
235
#define STRINGIFY_ARG(x) QUOTE_ARG(x) /* Quote argument, after cpp */
236
/* Does the system remember a signal handler after a signal ? */
237
#ifndef HAVE_BSD_SIGNALS
238
#define DONT_REMEMBER_SIGNAL
114
241
#if !defined(HAVE_UINT)
116
243
#define HAVE_UINT
117
244
typedef unsigned int uint;
245
typedef unsigned short ushort;
120
248
/* Declared in int2str() */
121
249
extern char _dig_vec_upper[];
122
250
extern char _dig_vec_lower[];
252
#define test(a) ((a) ? 1 : 0)
124
253
#define set_if_bigger(a,b) do { if ((a) < (b)) (a)=(b); } while(0)
126
254
#define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0)
255
#define test_all_bits(a,b) (((a) & (b)) == (b))
127
256
#define set_bits(type, bit_count) (sizeof(type)*8 <= (bit_count) ? ~(type) 0 : ((((type) 1) << (bit_count)) - (type) 1))
128
#define array_elements(A) ((size_t) (sizeof(A)/sizeof(A[0])))
257
#define array_elements(A) ((uint32_t) (sizeof(A)/sizeof(A[0])))
259
#define rint(A) floor((A)+(((A) < 0)? -0.5 : 0.5))
262
#if defined(__GNUC__)
263
#define function_volatile volatile
264
#define my_reinterpret_cast(A) reinterpret_cast<A>
265
#define my_const_cast(A) const_cast<A>
267
# define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
269
#elif !defined(my_reinterpret_cast)
270
#define my_reinterpret_cast(A) (A)
271
#define my_const_cast(A) (A)
130
274
/* Some types that is different between systems */
132
276
typedef int File; /* File descriptor */
277
/* Type for fuctions that handles signals */
278
/* RETSIGTYPE is defined by autoconf */
279
#define sig_handler RETSIGTYPE
285
typedef void (*sig_return)(void);/* Returns type from signal */
286
typedef int (*qsort_cmp)(const void *,const void *);
287
typedef int (*qsort_cmp2)(void*, const void *,const void *);
134
293
#ifdef HAVE_SYS_SOCKET_H
135
294
#include <sys/socket.h>
296
typedef SOCKET_SIZE_TYPE size_socket;
298
#ifndef SOCKOPT_OPTLEN_TYPE
299
#define SOCKOPT_OPTLEN_TYPE size_socket
138
302
/* file create flags */
233
402
#define SIZE_T_MAX ~((size_t) 0)
407
#define isfinite(x) finite(x)
409
#define finite(x) (1.0 / fabs(x) > 0.0)
410
#endif /* HAVE_FINITE */
411
#endif /* isfinite */
414
#define isnan(x) ((x) != (x))
418
/* isinf() can be used in both C and C++ code */
419
#define my_isinf(X) isinf(X)
421
#define my_isinf(X) (!isfinite(X) && !isnan(X))
237
424
/* Define missing math constants. */
257
448
#define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A),sizeof(t)))
258
449
/* Offset of field f in structure t */
259
450
#define OFFSET(t, f) ((size_t)(char *)&((t *)0)->f)
260
#define ADD_TO_PTR(ptr,size,type) (type) ((unsigned char*) (ptr)+size)
261
#define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((unsigned char*) (A) - (unsigned char*) (B))
451
#define ADD_TO_PTR(ptr,size,type) (type) ((uchar*) (ptr)+size)
452
#define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((uchar*) (A) - (uchar*) (B))
263
454
#define MY_DIV_UP(A, B) (((A) + (B) - 1) / (B))
264
455
#define MY_ALIGNED_BYTE_ARRAY(N, S, T) T N[MY_DIV_UP(S, sizeof(T))]
458
Custom version of standard offsetof() macro which can be used to get
459
offsets of members in class for non-POD types (according to the current
460
version of C++ standard offsetof() macro can't be used in such cases and
461
attempt to do so causes warnings to be emitted, OTOH in many cases it is
462
still OK to assume that all instances of the class has the same offsets
463
for the same members).
465
This is temporary solution which should be removed once File_parser class
466
and related routines are refactored.
469
#define my_offsetof(TYPE, MEMBER) \
470
((size_t)((char *)&(((TYPE *)0x10)->MEMBER) - (char*)0x10))
472
#define NullS (char *) 0
266
474
/* Typdefs for easyier portability */
477
typedef unsigned char uchar; /* Short for unsigned char */
268
480
#if !defined(HAVE_ULONG) && !defined(__USE_MISC)
269
481
typedef unsigned long ulong; /* Short for unsigned long */
272
485
typedef uint64_t my_off_t;
274
#define MY_FILEPOS_ERROR (UINT64_MAX)
487
typedef unsigned long my_off_t;
489
#define MY_FILEPOS_ERROR (~(my_off_t) 0)
491
typedef off_t os_off_t;
493
#define socket_errno errno
494
#define SOCKET_EINTR EINTR
495
#define SOCKET_EAGAIN EAGAIN
496
#define SOCKET_ETIMEDOUT SOCKET_EINTR
497
#define SOCKET_EWOULDBLOCK EWOULDBLOCK
498
#define SOCKET_EADDRINUSE EADDRINUSE
499
#define SOCKET_ENFILE ENFILE
500
#define SOCKET_EMFILE EMFILE
502
typedef uint8_t int7; /* Most effective integer 0 <= x <= 127 */
503
typedef short int15; /* Most effective integer 0 <= x <= 32767 */
276
504
typedef int myf; /* Type of MyFlags in my_funcs */
505
#if !defined(bool) && (!defined(HAVE_BOOL) || !defined(__cplusplus))
506
typedef char bool; /* Ordinary boolean values 0 1 */
277
508
#define MYF(v) (myf) (v)
279
510
/* Defines for time function */