~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/global.h

  • Committer: Monty Taylor
  • Date: 2008-10-02 18:09:31 UTC
  • Revision ID: monty@inaugust.com-20081002180931-t9oosmm6uvps27k0
RemovedĀ getpassĀ references.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
#ifndef DRIZZLE_SERVER_GLOBAL_H
23
23
#define DRIZZLE_SERVER_GLOBAL_H
24
24
 
 
25
#define HAVE_REPLICATION
 
26
 
 
27
/*
 
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.
 
31
 
 
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
 
34
  InnoDB's use.
 
35
*/
 
36
#define INNODB_COMPATIBILITY_HOOKS
 
37
 
 
38
/* to make command line shorter we'll define USE_PRAGMA_INTERFACE here */
 
39
#ifdef USE_PRAGMA_IMPLEMENTATION
 
40
#define USE_PRAGMA_INTERFACE
 
41
#endif
 
42
 
25
43
#if defined(i386) && !defined(__i386__)
26
44
#define __i386__
27
45
#endif
28
46
 
29
47
#include "config.h"
30
48
 
31
 
#if defined(__cplusplus)
32
 
 
33
 
# if defined(__GNUC) && defined(__EXCEPTIONS)
34
 
#  error "Please add -fno-exceptions to CXXFLAGS and reconfigure/recompile"
35
 
# endif
36
 
 
37
 
# include CSTDINT_H
38
 
# include CINTTYPES_H
39
 
# include CMATH_H
40
 
# include <cstdio>
41
 
# include <cstdlib>
42
 
# include <cstddef>
43
 
# include <cassert>
44
 
# include <cerrno>
45
 
#else
46
 
# include <stdint.h>
47
 
# include <inttypes.h>
48
 
# include <stdio.h>
49
 
# include <stdlib.h>
50
 
# include <stddef.h>
51
 
# include <math.h>
52
 
# include <errno.h>        /* Recommended by debian */
53
49
/*
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
55
56
*/
56
 
# include <assert.h>
57
 
# include <stdbool.h>
58
 
 
59
 
#endif // __cplusplus
 
57
 
 
58
#if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
 
59
#define __builtin_expect(x, expected_value) (x)
 
60
#endif
 
61
 
 
62
#define likely(x)  __builtin_expect((x),1)
 
63
#define unlikely(x)  __builtin_expect((x),0)
60
64
 
61
65
/*
62
 
#if TIME_WITH_SYS_TIME
63
 
# include <sys/time.h>
64
 
# include <time.h>
65
 
#else
66
 
# if HAVE_SYS_TIME_H
67
 
#  include <sys/time.h>
68
 
# else
69
 
#  include <time.h>
 
66
 *   Disable __attribute__ for non GNU compilers, since we're using them
 
67
 *     only to either generate or suppress warnings.
 
68
 *     */
 
69
#ifndef __attribute__
 
70
# if !defined(__GNUC__)
 
71
#  define __attribute__(A)
70
72
# endif
71
 
#endif */ /* TIME_WITH_SYS_TIME */
 
73
#endif
 
74
 
 
75
 
 
76
/* Fix problem with S_ISLNK() on Linux */
 
77
#if defined(TARGET_OS_LINUX) || defined(__GLIBC__)
 
78
#undef  _GNU_SOURCE
 
79
#define _GNU_SOURCE 1
 
80
#endif
 
81
 
72
82
 
73
83
/*
74
84
  Temporary solution to solve bug#7156. Include "sys/types.h" before
78
88
#include <sys/types.h>
79
89
#endif
80
90
 
 
91
#if defined(HAVE_STDINT_H)
 
92
#include <stdint.h>
 
93
#else
 
94
#error "You must have stdint!"
 
95
#endif
 
96
 
 
97
#if defined(HAVE_INTTYPES_H)
 
98
#include <inttypes.h>
 
99
#else
 
100
#error "You must have inttypes!"
 
101
#endif
 
102
 
 
103
 
 
104
/*
 
105
  Solaris 9 include file <sys/feature_tests.h> refers to X/Open document
 
106
 
 
107
  System Interfaces and Headers, Issue 5
 
108
 
 
109
  saying we should define _XOPEN_SOURCE=500 to get POSIX.1c prototypes,
 
110
  but apparently other systems (namely FreeBSD) don't agree.
 
111
 
 
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.
 
118
 
 
119
  To add more to this mess, Sun Studio C compiler defines _STDC_C99 while
 
120
  C++ compiler does not!
 
121
 
 
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.
 
125
 
 
126
  Cleaner solutions are welcome.
 
127
*/
 
128
#if defined(__sun) && !defined(__cplusplus)
 
129
#if __STDC_VERSION__ - 0 >= 199901L
 
130
#define _XOPEN_SOURCE 600
 
131
#else
 
132
#define _XOPEN_SOURCE 500
 
133
#endif
 
134
#endif
 
135
 
 
136
#ifndef _POSIX_PTHREAD_SEMANTICS
 
137
#define _POSIX_PTHREAD_SEMANTICS /* We want posix threads */
 
138
#endif
 
139
 
 
140
#define _REENTRANT  1  /* Some thread libraries require this */
81
141
 
82
142
#include <pthread.h>    /* AIX must have this included first */
83
143
 
84
144
#define _REENTRANT  1  /* Threads requires reentrant code */
85
145
 
 
146
 
 
147
/* gcc/egcs issues */
 
148
 
 
149
#if defined(__GNUC) && defined(__EXCEPTIONS)
 
150
#error "Please add -fno-exceptions to CXXFLAGS and reconfigure/recompile"
 
151
#endif
 
152
 
 
153
#ifndef stdin
 
154
#include <stdio.h>
 
155
#endif
 
156
#ifdef HAVE_STDLIB_H
 
157
#include <stdlib.h>
 
158
#endif
 
159
#ifdef HAVE_STDDEF_H
 
160
#include <stddef.h>
 
161
#endif
 
162
 
 
163
#include <math.h>
86
164
#ifdef HAVE_LIMITS_H
87
165
#include <limits.h>
88
166
#endif
93
171
#ifdef HAVE_FCNTL_H
94
172
#include <fcntl.h>
95
173
#endif
96
 
 
 
174
#ifdef HAVE_SYS_TIMEB_H
 
175
#include <sys/timeb.h>        /* Avoid warnings on SCO */
 
176
#endif
 
177
#if TIME_WITH_SYS_TIME
 
178
# include <sys/time.h>
 
179
# include <time.h>
 
180
#else
 
181
# if HAVE_SYS_TIME_H
 
182
#  include <sys/time.h>
 
183
# else
 
184
#  include <time.h>
 
185
# endif
 
186
#endif /* TIME_WITH_SYS_TIME */
97
187
#ifdef HAVE_UNISTD_H
98
188
#include <unistd.h>
99
189
#endif
105
195
#include <alloca.h>
106
196
#endif
107
197
 
 
198
#include <errno.h>        /* Recommended by debian */
108
199
 
 
200
#if defined(HAVE_STDBOOL_H)
 
201
#include <stdbool.h>
 
202
#endif
109
203
 
110
204
#ifdef HAVE_SYS_STAT_H
111
205
# include <sys/stat.h>
112
206
#endif
113
207
 
 
208
/*
 
209
  A lot of our programs uses asserts, so better to always include it
 
210
*/
 
211
#include <assert.h>
 
212
 
 
213
/* an assert that works at compile-time. only for constant expression */
 
214
#ifndef __GNUC__
 
215
#define compile_time_assert(X)  do { } while(0)
 
216
#else
 
217
#define compile_time_assert(X)                                  \
 
218
  do                                                            \
 
219
  {                                                             \
 
220
    char compile_time_assert[(X) ? 1 : -1]                      \
 
221
      __attribute__ ((unused));                                 \
 
222
  } while(0)
 
223
#endif
 
224
 
 
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);
 
228
#endif
 
229
 
 
230
/* We can not live without the following defines */
 
231
 
 
232
#define MASTER 1    /* Compile without unireg */
 
233
 
 
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
 
239
#endif
 
240
 
114
241
#if !defined(HAVE_UINT)
115
242
#undef HAVE_UINT
116
243
#define HAVE_UINT
117
244
typedef unsigned int uint;
 
245
typedef unsigned short ushort;
118
246
#endif
119
247
 
120
248
/* Declared in int2str() */
121
249
extern char _dig_vec_upper[];
122
250
extern char _dig_vec_lower[];
123
251
 
 
252
#define test(a)    ((a) ? 1 : 0)
124
253
#define set_if_bigger(a,b)  do { if ((a) < (b)) (a)=(b); } while(0)
125
 
 
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])))
 
258
#ifndef HAVE_RINT
 
259
#define rint(A) floor((A)+(((A) < 0)? -0.5 : 0.5))
 
260
#endif
 
261
 
 
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>
 
266
# ifndef GCC_VERSION
 
267
#  define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
 
268
# endif
 
269
#elif !defined(my_reinterpret_cast)
 
270
#define my_reinterpret_cast(A) (A)
 
271
#define my_const_cast(A) (A)
 
272
#endif
129
273
 
130
274
/* Some types that is different between systems */
131
275
 
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
 
280
 
 
281
#ifdef __cplusplus
 
282
extern "C" {
 
283
#endif
 
284
 
 
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 *);
 
288
 
 
289
#ifdef __cplusplus
 
290
}
 
291
#endif
133
292
 
134
293
#ifdef HAVE_SYS_SOCKET_H
135
294
#include <sys/socket.h>
136
295
#endif
 
296
typedef SOCKET_SIZE_TYPE size_socket;
 
297
 
 
298
#ifndef SOCKOPT_OPTLEN_TYPE
 
299
#define SOCKOPT_OPTLEN_TYPE size_socket
 
300
#endif
137
301
 
138
302
/* file create flags */
139
303
 
172
336
#define OS_FILE_LIMIT  65535
173
337
#endif
174
338
 
 
339
/* #define EXT_IN_LIBNAME     */
 
340
/* #define FN_NO_CASE_SENCE   */
 
341
/* #define FN_UPPER_CASE TRUE */
 
342
 
175
343
/*
176
344
  How much overhead does malloc have. The code often allocates
177
345
  something like 1024-MALLOC_OVERHEAD bytes
202
370
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
203
371
#endif
204
372
#define ulong_to_double(X) ((double) (ulong) (X))
 
373
#define SET_STACK_SIZE(X)  /* Not needed on real machines */
205
374
 
206
375
#ifndef STACK_DIRECTION
207
376
#error "please add -DSTACK_DIRECTION=1 or -1 to your CPPFLAGS"
233
402
#define SIZE_T_MAX ~((size_t) 0)
234
403
#endif
235
404
 
 
405
#ifndef isfinite
 
406
#ifdef HAVE_FINITE
 
407
#define isfinite(x) finite(x)
 
408
#else
 
409
#define finite(x) (1.0 / fabs(x) > 0.0)
 
410
#endif /* HAVE_FINITE */
 
411
#endif /* isfinite */
 
412
 
 
413
#ifndef HAVE_ISNAN
 
414
#define isnan(x) ((x) != (x))
 
415
#endif
 
416
 
 
417
#ifdef HAVE_ISINF
 
418
/* isinf() can be used in both C and C++ code */
 
419
#define my_isinf(X) isinf(X)
 
420
#else
 
421
#define my_isinf(X) (!isfinite(X) && !isnan(X))
 
422
#endif
236
423
 
237
424
/* Define missing math constants. */
238
425
#ifndef M_PI
249
436
  Max size that must be added to a so that we know Size to make
250
437
  adressable obj.
251
438
*/
252
 
typedef ptrdiff_t my_ptrdiff_t;
 
439
#if SIZEOF_CHARP == 4
 
440
typedef int32_t    my_ptrdiff_t;
 
441
#else
 
442
typedef int64_t   my_ptrdiff_t;
 
443
#endif
253
444
 
254
445
#define MY_ALIGN(A,L)  (((A) + (L) - 1) & ~((L) - 1))
255
446
#define ALIGN_SIZE(A)  MY_ALIGN((A),sizeof(double))
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))
262
453
 
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))]
265
456
 
 
457
/*
 
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).
 
464
 
 
465
  This is temporary solution which should be removed once File_parser class
 
466
  and related routines are refactored.
 
467
*/
 
468
 
 
469
#define my_offsetof(TYPE, MEMBER)                                       \
 
470
  ((size_t)((char *)&(((TYPE *)0x10)->MEMBER) - (char*)0x10))
 
471
 
 
472
#define NullS    (char *) 0
 
473
 
266
474
/* Typdefs for easyier portability */
267
475
 
 
476
#ifndef HAVE_UCHAR
 
477
typedef unsigned char  uchar;  /* Short for unsigned char */
 
478
#endif
 
479
 
268
480
#if !defined(HAVE_ULONG) && !defined(__USE_MISC)
269
481
typedef unsigned long ulong;      /* Short for unsigned long */
270
482
#endif
271
483
 
 
484
#if SIZEOF_OFF_T > 4 
272
485
typedef uint64_t my_off_t;
273
 
 
274
 
#define MY_FILEPOS_ERROR  (UINT64_MAX)
275
 
 
 
486
#else
 
487
typedef unsigned long my_off_t;
 
488
#endif
 
489
#define MY_FILEPOS_ERROR  (~(my_off_t) 0)
 
490
 
 
491
typedef off_t os_off_t;
 
492
 
 
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
 
501
 
 
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 */
 
507
#endif
277
508
#define MYF(v)          (myf) (v)
278
509
 
279
510
/* Defines for time function */