~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/global.h

  • Committer: Monty Taylor
  • Date: 2008-08-04 19:37:18 UTC
  • mto: (261.2.2 codestyle)
  • mto: This revision was merged to the branch mainline in revision 262.
  • Revision ID: monty@inaugust.com-20080804193718-f0rz13uli4429ozb
Changed gettext_noop() to N_()

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems
5
 
 *
6
 
 *  This program is free software; you can redistribute it and/or modify
7
 
 *  it under the terms of the GNU General Public License as published by
8
 
 *  the Free Software Foundation; version 2 of the License.
9
 
 *
10
 
 *  This program is distributed in the hope that it will be useful,
11
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 *  GNU General Public License for more details.
14
 
 *
15
 
 *  You should have received a copy of the GNU General Public License
16
 
 *  along with this program; if not, write to the Free Software
17
 
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 
 */
 
1
/* Copyright (C) 2000-2003 MySQL AB
 
2
 
 
3
   This program is free software; you can redistribute it and/or modify
 
4
   it under the terms of the GNU General Public License as published by
 
5
   the Free Software Foundation; version 2 of the License.
 
6
 
 
7
   This program is distributed in the hope that it will be useful,
 
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
   GNU General Public License for more details.
 
11
 
 
12
   You should have received a copy of the GNU General Public License
 
13
   along with this program; if not, write to the Free Software
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
19
15
 
20
16
/* This is the include file that should be included 'first' in every C file. */
21
17
 
22
 
#ifndef DRIZZLE_SERVER_GLOBAL_H
23
 
#define DRIZZLE_SERVER_GLOBAL_H
 
18
#ifndef _global_h
 
19
#define _global_h
 
20
 
 
21
#define HAVE_REPLICATION
 
22
#define HAVE_EXTERNAL_CLIENT
 
23
 
 
24
/*
 
25
  InnoDB depends on some MySQL internals which other plugins should not
 
26
  need.  This is because of InnoDB's foreign key support, "safe" binlog
 
27
  truncation, and other similar legacy features.
 
28
 
 
29
  We define accessors for these internals unconditionally, but do not
 
30
  expose them in mysql/plugin.h.  They are declared in ha_innodb.h for
 
31
  InnoDB's use.
 
32
*/
 
33
#define INNODB_COMPATIBILITY_HOOKS
 
34
 
 
35
/* to make command line shorter we'll define USE_PRAGMA_INTERFACE here */
 
36
#ifdef USE_PRAGMA_IMPLEMENTATION
 
37
#define USE_PRAGMA_INTERFACE
 
38
#endif
24
39
 
25
40
#if defined(i386) && !defined(__i386__)
26
41
#define __i386__
27
42
#endif
28
43
 
29
 
#include <config.h>
30
 
 
31
 
#if defined(__cplusplus)
32
 
 
33
 
# if defined(__GNUC) && defined(__EXCEPTIONS)
34
 
#  error "Please add -fno-exceptions to CXXFLAGS and reconfigure/recompile"
 
44
/* Macros to make switching between C and C++ mode easier */
 
45
#ifdef __cplusplus
 
46
#define C_MODE_START    extern "C" {
 
47
#define C_MODE_END      }
 
48
#else
 
49
#define C_MODE_START
 
50
#define C_MODE_END
 
51
#endif
 
52
 
 
53
#include "config.h"
 
54
#if defined(__cplusplus) && defined(inline)
 
55
#undef inline                           /* fix configure problem */
 
56
#endif
 
57
 
 
58
/* Make it easier to add conditionl code for windows */
 
59
#define IF_WIN(A,B) (B)
 
60
 
 
61
/*
 
62
  The macros below are borrowed from include/linux/compiler.h in the
 
63
  Linux kernel. Use them to indicate the likelyhood of the truthfulness
 
64
  of a condition. This serves two purposes - newer versions of gcc will be
 
65
  able to optimize for branch predication, which could yield siginficant
 
66
  performance gains in frequently executed sections of the code, and the
 
67
  other reason to use them is for documentation
 
68
*/
 
69
 
 
70
#if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
 
71
#define __builtin_expect(x, expected_value) (x)
 
72
#endif
 
73
 
 
74
#define likely(x)       __builtin_expect((x),1)
 
75
#define unlikely(x)     __builtin_expect((x),0)
 
76
 
 
77
 
 
78
/*
 
79
  The macros below are useful in optimising places where it has been
 
80
  discovered that cache misses stall the process and where a prefetch
 
81
  of the cache line can improve matters. This is available in GCC 3.1.1
 
82
  and later versions.
 
83
  PREFETCH_READ says that addr is going to be used for reading and that
 
84
  it is to be kept in caches if possible for a while
 
85
  PREFETCH_WRITE also says that the item to be cached is likely to be
 
86
  updated.
 
87
  The *LOCALITY scripts are also available for experimentation purposes
 
88
  mostly and should only be used if they are verified to improve matters.
 
89
  For more input see GCC manual (available in GCC 3.1.1 and later)
 
90
*/
 
91
 
 
92
#if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR > 10)
 
93
#define PREFETCH_READ(addr) __builtin_prefetch(addr, 0, 3)
 
94
#define PREFETCH_WRITE(addr) \
 
95
  __builtin_prefetch(addr, 1, 3)
 
96
#define PREFETCH_READ_LOCALITY(addr, locality) \
 
97
  __builtin_prefetch(addr, 0, locality)
 
98
#define PREFETCH_WRITE_LOCALITY(addr, locality) \
 
99
  __builtin_prefetch(addr, 1, locality)
 
100
#else
 
101
#define PREFETCH_READ(addr)
 
102
#define PREFETCH_READ_LOCALITY(addr, locality)
 
103
#define PREFETCH_WRITE(addr)
 
104
#define PREFETCH_WRITE_LOCALITY(addr, locality)
 
105
#endif
 
106
 
 
107
/*
 
108
  now let's figure out if inline functions are supported
 
109
  autoconf defines 'inline' to be empty, if not
 
110
*/
 
111
#if defined(inline)
 
112
#define HAVE_INLINE
 
113
#endif
 
114
/* helper macro for "instantiating" inline functions */
 
115
#define STATIC_INLINE static inline
 
116
 
 
117
/*
 
118
  The following macros are used to control inlining a bit more than
 
119
  usual. These macros are used to ensure that inlining always or
 
120
  never occurs (independent of compilation mode).
 
121
  For more input see GCC manual (available in GCC 3.1.1 and later)
 
122
*/
 
123
 
 
124
#if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR > 10)
 
125
#define ALWAYS_INLINE __attribute__ ((always_inline))
 
126
#define NEVER_INLINE __attribute__ ((noinline))
 
127
#else
 
128
#define ALWAYS_INLINE
 
129
#define NEVER_INLINE
 
130
#endif
 
131
 
 
132
/*
 
133
 *   Disable __attribute__ for non GNU compilers, since we're using them
 
134
 *     only to either generate or suppress warnings.
 
135
 *     */
 
136
#ifndef __attribute__
 
137
# if !defined(__GNUC__)
 
138
#  define __attribute__(A)
35
139
# endif
36
 
 
37
 
# include CSTDINT_H
38
 
# include CINTTYPES_H
39
 
# include <cstdio>
40
 
# include <cstdlib>
41
 
# include <cstddef>
42
 
# include <cassert>
43
 
# include <cerrno>
44
 
#else
45
 
# include <stdint.h>
46
 
# include <inttypes.h>
47
 
# include <stdio.h>
48
 
# include <stdlib.h>
49
 
# include <stddef.h>
50
 
# include <math.h>
51
 
# include <errno.h>        /* Recommended by debian */
52
 
/*
53
 
  A lot of our programs uses asserts, so better to always include it
54
 
*/
55
 
# include <assert.h>
56
 
# include <stdbool.h>
57
 
 
58
 
#endif // __cplusplus
 
140
#endif
 
141
 
 
142
 
 
143
/* Fix problem with S_ISLNK() on Linux */
 
144
#if defined(TARGET_OS_LINUX) || defined(__GLIBC__)
 
145
#undef  _GNU_SOURCE
 
146
#define _GNU_SOURCE 1
 
147
#endif
 
148
 
59
149
 
60
150
/*
61
151
  Temporary solution to solve bug#7156. Include "sys/types.h" before
65
155
#include <sys/types.h>
66
156
#endif
67
157
 
68
 
 
69
 
#include <pthread.h>    /* AIX must have this included first */
70
 
 
71
 
#define _REENTRANT  1  /* Threads requires reentrant code */
72
 
 
 
158
#ifdef HAVE_THREADS_WITHOUT_SOCKETS
 
159
/* MIT pthreads does not work with unix sockets */
 
160
#undef HAVE_SYS_UN_H
 
161
#endif
 
162
 
 
163
#define __EXTENSIONS__ 1        /* We want some extension */
 
164
#ifndef __STDC_EXT__
 
165
#define __STDC_EXT__ 1          /* To get large file support on hpux */
 
166
#endif
 
167
 
 
168
/*
 
169
  Solaris 9 include file <sys/feature_tests.h> refers to X/Open document
 
170
 
 
171
    System Interfaces and Headers, Issue 5
 
172
 
 
173
  saying we should define _XOPEN_SOURCE=500 to get POSIX.1c prototypes,
 
174
  but apparently other systems (namely FreeBSD) don't agree.
 
175
 
 
176
  On a newer Solaris 10, the above file recognizes also _XOPEN_SOURCE=600.
 
177
  Furthermore, it tests that if a program requires older standard
 
178
  (_XOPEN_SOURCE<600 or _POSIX_C_SOURCE<200112L) it cannot be
 
179
  run on a new compiler (that defines _STDC_C99) and issues an #error.
 
180
  It's also an #error if a program requires new standard (_XOPEN_SOURCE=600
 
181
  or _POSIX_C_SOURCE=200112L) and a compiler does not define _STDC_C99.
 
182
 
 
183
  To add more to this mess, Sun Studio C compiler defines _STDC_C99 while
 
184
  C++ compiler does not!
 
185
 
 
186
  So, in a desperate attempt to get correct prototypes for both
 
187
  C and C++ code, we define either _XOPEN_SOURCE=600 or _XOPEN_SOURCE=500
 
188
  depending on the compiler's announced C standard support.
 
189
 
 
190
  Cleaner solutions are welcome.
 
191
*/
 
192
#ifdef __sun
 
193
#if __STDC_VERSION__ - 0 >= 199901L
 
194
#define _XOPEN_SOURCE 600
 
195
#else
 
196
#define _XOPEN_SOURCE 500
 
197
#endif
 
198
#endif
 
199
 
 
200
#ifndef _POSIX_PTHREAD_SEMANTICS
 
201
#define _POSIX_PTHREAD_SEMANTICS /* We want posix threads */
 
202
#endif
 
203
 
 
204
#define _REENTRANT      1       /* Some thread libraries require this */
 
205
 
 
206
#if !defined(_THREAD_SAFE) && !defined(_AIX)
 
207
#define _THREAD_SAFE            /* Required for OSF1 */
 
208
#endif
 
209
 
 
210
#include <pthread.h>            /* AIX must have this included first */
 
211
 
 
212
#define _REENTRANT      1       /* Threads requires reentrant code */
 
213
 
 
214
/* Go around some bugs in different OS and compilers */
 
215
 
 
216
#if defined(HAVE_BROKEN_INLINE) && !defined(__cplusplus)
 
217
#undef inline
 
218
#define inline
 
219
#endif
 
220
 
 
221
/* gcc/egcs issues */
 
222
 
 
223
#if defined(__GNUC) && defined(__EXCEPTIONS)
 
224
#error "Please add -fno-exceptions to CXXFLAGS and reconfigure/recompile"
 
225
#endif
 
226
 
 
227
#if defined(HAVE_STDINT_H)
 
228
/* Need to include this _before_ stdlib, so that all defines are right */
 
229
/* We are mixing C and C++, so we wan the C limit macros in the C++ too */
 
230
/* Enable some extra C99 extensions */
 
231
#define __STDC_LIMIT_MACROS
 
232
#define __STDC_FORMAT_MACROS
 
233
#include <inttypes.h>
 
234
#include <stdint.h>
 
235
#endif
 
236
 
 
237
#ifndef stdin
 
238
#include <stdio.h>
 
239
#endif
 
240
#ifdef HAVE_STDLIB_H
 
241
#include <stdlib.h>
 
242
#endif
 
243
#ifdef HAVE_STDDEF_H
 
244
#include <stddef.h>
 
245
#endif
 
246
 
 
247
#include <math.h>
73
248
#ifdef HAVE_LIMITS_H
74
249
#include <limits.h>
75
250
#endif
80
255
#ifdef HAVE_FCNTL_H
81
256
#include <fcntl.h>
82
257
#endif
83
 
 
 
258
#ifdef HAVE_SYS_TIMEB_H
 
259
#include <sys/timeb.h>                          /* Avoid warnings on SCO */
 
260
#endif
 
261
#if TIME_WITH_SYS_TIME
 
262
# include <sys/time.h>
 
263
# include <time.h>
 
264
#else
 
265
# if HAVE_SYS_TIME_H
 
266
#  include <sys/time.h>
 
267
# else
 
268
#  include <time.h>
 
269
# endif
 
270
#endif /* TIME_WITH_SYS_TIME */
84
271
#ifdef HAVE_UNISTD_H
85
272
#include <unistd.h>
86
273
#endif
92
279
#include <alloca.h>
93
280
#endif
94
281
 
 
282
#include <errno.h>                              /* Recommended by debian */
95
283
 
 
284
#if defined(HAVE_STDBOOL_H)
 
285
#include <stdbool.h>
 
286
#endif
96
287
 
97
288
#ifdef HAVE_SYS_STAT_H
98
289
# include <sys/stat.h>
99
290
#endif
100
291
 
 
292
/*
 
293
  A lot of our programs uses asserts, so better to always include it
 
294
*/
 
295
#include <assert.h>
 
296
 
 
297
/* an assert that works at compile-time. only for constant expression */
 
298
#ifndef __GNUC__
 
299
#define compile_time_assert(X)  do { } while(0)
 
300
#else
 
301
#define compile_time_assert(X)                                  \
 
302
  do                                                            \
 
303
  {                                                             \
 
304
    char compile_time_assert[(X) ? 1 : -1]                      \
 
305
                             __attribute__ ((unused));          \
 
306
  } while(0)
 
307
#endif
 
308
 
 
309
/* Declare madvise where it is not declared for C++, like Solaris */
 
310
#if HAVE_MADVISE && !defined(HAVE_DECL_MADVISE) && defined(__cplusplus)
 
311
extern "C" int madvise(void *addr, size_t len, int behav);
 
312
#endif
 
313
 
 
314
/* We can not live without the following defines */
 
315
 
 
316
#define USE_MYFUNC 1            /* Must use syscall indirection */
 
317
#define MASTER 1                /* Compile without unireg */
 
318
#define ENGLISH 1               /* Messages in English */
 
319
#define POSIX_MISTAKE 1         /* regexp: Fix stupid spec error */
 
320
/* Do not define for ultra sparcs */
 
321
#define USE_BMOVE512 1          /* Use this unless system bmove is faster */
 
322
 
 
323
#define QUOTE_ARG(x)            #x      /* Quote argument (before cpp) */
 
324
#define STRINGIFY_ARG(x) QUOTE_ARG(x)   /* Quote argument, after cpp */
 
325
/* Does the system remember a signal handler after a signal ? */
 
326
#ifndef HAVE_BSD_SIGNALS
 
327
#define DONT_REMEMBER_SIGNAL
 
328
#endif
 
329
 
 
330
/* Define void to stop lint from generating "null effekt" comments */
 
331
#ifndef DONT_DEFINE_VOID
 
332
#ifdef _lint
 
333
int     __void__;
 
334
#define VOID(X)         (__void__ = (int) (X))
 
335
#else
 
336
#undef VOID
 
337
#define VOID(X)         (X)
 
338
#endif
 
339
#endif /* DONT_DEFINE_VOID */
 
340
 
101
341
#if !defined(HAVE_UINT)
102
342
#undef HAVE_UINT
103
343
#define HAVE_UINT
104
344
typedef unsigned int uint;
 
345
typedef unsigned short ushort;
105
346
#endif
106
347
 
107
 
/* Declared in int2str() */
108
 
extern char _dig_vec_upper[];
109
 
extern char _dig_vec_lower[];
110
 
 
 
348
#define CMP_NUM(a,b)    (((a) < (b)) ? -1 : ((a) == (b)) ? 0 : 1)
 
349
#define sgn(a)          (((a) < 0) ? -1 : ((a) > 0) ? 1 : 0)
 
350
#define swap_variables(t, a, b) { register t dummy; dummy= a; a= b; b= dummy; }
 
351
#define test(a)         ((a) ? 1 : 0)
111
352
#define set_if_bigger(a,b)  do { if ((a) < (b)) (a)=(b); } while(0)
112
 
 
113
353
#define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0)
114
 
#define array_elements(A) ((size_t) (sizeof(A)/sizeof(A[0])))
 
354
#define test_all_bits(a,b) (((a) & (b)) == (b))
 
355
#define set_bits(type, bit_count) (sizeof(type)*8 <= (bit_count) ? ~(type) 0 : ((((type) 1) << (bit_count)) - (type) 1))
 
356
#define array_elements(A) ((uint32_t) (sizeof(A)/sizeof(A[0])))
 
357
#ifndef HAVE_RINT
 
358
#define rint(A) floor((A)+(((A) < 0)? -0.5 : 0.5))
 
359
#endif
 
360
 
 
361
#if defined(__GNUC__)
 
362
#define function_volatile       volatile
 
363
#define my_reinterpret_cast(A) reinterpret_cast<A>
 
364
#define my_const_cast(A) const_cast<A>
 
365
# ifndef GCC_VERSION
 
366
#  define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
 
367
# endif
 
368
#elif !defined(my_reinterpret_cast)
 
369
#define my_reinterpret_cast(A) (A)
 
370
#define my_const_cast(A) (A)
 
371
#endif
 
372
 
 
373
/* From old s-system.h */
 
374
 
 
375
/*
 
376
  Support macros for non ansi & other old compilers. Since such
 
377
  things are no longer supported we do nothing. We keep then since
 
378
  some of our code may still be needed to upgrade old customers.
 
379
*/
 
380
#define _VARARGS(X) X
 
381
#define _STATIC_VARARGS(X) X
 
382
#define _PC(X)  X
 
383
 
 
384
#define MIN_ARRAY_SIZE  0       /* Zero or One. Gcc allows zero*/
 
385
#define ASCII_BITS_USED 8       /* Bit char used */
115
386
 
116
387
/* Some types that is different between systems */
117
388
 
118
 
typedef int  File;    /* File descriptor */
119
 
 
 
389
typedef int     File;           /* File descriptor */
 
390
#ifndef Socket_defined
 
391
typedef int     my_socket;      /* File descriptor for sockets */
 
392
#define INVALID_SOCKET -1
 
393
#endif
 
394
/* Type for fuctions that handles signals */
 
395
#define sig_handler RETSIGTYPE
 
396
C_MODE_START
 
397
typedef void    (*sig_return)(void);/* Returns type from signal */
 
398
typedef int     (*qsort_cmp)(const void *,const void *);
 
399
typedef int     (*qsort_cmp2)(void*, const void *,const void *);
 
400
C_MODE_END
 
401
#define qsort_t RETQSORTTYPE    /* Broken GCC cant handle typedef !!!! */
120
402
#ifdef HAVE_SYS_SOCKET_H
121
403
#include <sys/socket.h>
122
404
#endif
123
 
 
 
405
typedef SOCKET_SIZE_TYPE size_socket;
 
406
 
 
407
#ifndef SOCKOPT_OPTLEN_TYPE
 
408
#define SOCKOPT_OPTLEN_TYPE size_socket
 
409
#endif
 
410
 
 
411
/* file create flags */
 
412
 
 
413
#ifndef O_SHARE                 /* Probably not windows */
 
414
#define O_SHARE         0       /* Flag to my_open for shared files */
 
415
#endif /* O_SHARE */
 
416
 
 
417
#ifndef O_BINARY
 
418
#define O_BINARY        0       /* Flag to my_open for binary files */
 
419
#endif
 
420
 
 
421
#ifndef FILE_BINARY
 
422
#define FILE_BINARY     O_BINARY /* Flag to my_fopen for binary streams */
 
423
#endif
 
424
 
 
425
#define F_TO_EOF        0L      /* Param to lockf() to lock rest of file */
 
426
 
 
427
#ifndef O_TEMPORARY
 
428
#define O_TEMPORARY     0
 
429
#endif
 
430
#ifndef O_SHORT_LIVED
 
431
#define O_SHORT_LIVED   0
 
432
#endif
 
433
#ifndef O_NOFOLLOW
 
434
#define O_NOFOLLOW      0
 
435
#endif
 
436
 
 
437
/* #define USE_RECORD_LOCK      */
 
438
 
 
439
        /* Unsigned types supported by the compiler */
 
440
#define UNSINT8                 /* unsigned int8_t (char) */
 
441
#define UNSINT16                /* unsigned int16_t */
 
442
#define UNSINT32                /* unsigned int32_t */
 
443
 
 
444
        /* General constants */
 
445
#define SC_MAXWIDTH     256     /* Max width of screen (for error messages) */
 
446
#define FN_LEN          256     /* Max file name len */
 
447
#define FN_HEADLEN      253     /* Max length of filepart of file name */
 
448
#define FN_EXTLEN       20      /* Max length of extension (part of FN_LEN) */
 
449
#define FN_REFLEN       512     /* Max length of full path-name */
 
450
#define FN_EXTCHAR      '.'
 
451
#define FN_HOMELIB      '~'     /* ~/ is used as abbrev for home dir */
 
452
#define FN_CURLIB       '.'     /* ./ is used as abbrev for current dir */
 
453
#define FN_PARENTDIR    ".."    /* Parent directory; Must be a string */
124
454
 
125
455
#ifndef FN_LIBCHAR
126
 
#define FN_LIBCHAR  '/'
127
 
#define FN_ROOTDIR  "/"
 
456
#define FN_LIBCHAR      '/'
 
457
#define FN_ROOTDIR      "/"
128
458
#endif
129
 
#define MY_NFILE  64  /* This is only used to save filenames */
 
459
#define MY_NFILE        64      /* This is only used to save filenames */
130
460
#ifndef OS_FILE_LIMIT
131
 
#define OS_FILE_LIMIT  65535
 
461
#define OS_FILE_LIMIT   65535
132
462
#endif
133
463
 
 
464
/* #define EXT_IN_LIBNAME     */
 
465
/* #define FN_NO_CASE_SENCE   */
 
466
/* #define FN_UPPER_CASE TRUE */
 
467
 
 
468
/*
 
469
  Io buffer size; Must be a power of 2 and a multiple of 512. May be
 
470
  smaller what the disk page size. This influences the speed of the
 
471
  isam btree library. eg to big to slow.
 
472
*/
 
473
#define IO_SIZE                 4096
134
474
/*
135
475
  How much overhead does malloc have. The code often allocates
136
476
  something like 1024-MALLOC_OVERHEAD bytes
137
477
*/
138
478
#define MALLOC_OVERHEAD 8
139
479
 
140
 
/* get memory in huncs */
141
 
#define ONCE_ALLOC_INIT    (uint) (4096-MALLOC_OVERHEAD)
142
 
/* Typical record cash */
143
 
#define RECORD_CACHE_SIZE  (uint) (64*1024-MALLOC_OVERHEAD)
144
 
/* Typical key cash */
145
 
#define KEY_CACHE_SIZE    (uint) (8*1024*1024-MALLOC_OVERHEAD)
146
 
/* Default size of a key cache block  */
147
 
#define KEY_CACHE_BLOCK_SIZE  (uint) 1024
148
 
 
149
 
 
150
 
/* Some things that this system doesn't have */
 
480
        /* get memory in huncs */
 
481
#define ONCE_ALLOC_INIT         (uint) (4096-MALLOC_OVERHEAD)
 
482
        /* Typical record cash */
 
483
#define RECORD_CACHE_SIZE       (uint) (64*1024-MALLOC_OVERHEAD)
 
484
        /* Typical key cash */
 
485
#define KEY_CACHE_SIZE          (uint) (8*1024*1024-MALLOC_OVERHEAD)
 
486
        /* Default size of a key cache block  */
 
487
#define KEY_CACHE_BLOCK_SIZE    (uint) 1024
 
488
 
 
489
 
 
490
        /* Some things that this system doesn't have */
151
491
 
152
492
/* Some defines of functions for portability */
153
493
 
154
 
#undef remove    /* Crashes MySQL on SCO 5.0.0 */
 
494
#undef remove           /* Crashes MySQL on SCO 5.0.0 */
 
495
#define closesocket(A)  close(A)
155
496
#ifndef uint64_t2double
156
497
#define uint64_t2double(A) ((double) (uint64_t) (A))
157
498
#define my_off_t2double(A)  ((double) (my_off_t) (A))
161
502
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
162
503
#endif
163
504
#define ulong_to_double(X) ((double) (ulong) (X))
 
505
#define SET_STACK_SIZE(X)       /* Not needed on real machines */
164
506
 
165
507
#ifndef STACK_DIRECTION
166
508
#error "please add -DSTACK_DIRECTION=1 or -1 to your CPPFLAGS"
183
525
 
184
526
/* From limits.h instead */
185
527
#ifndef DBL_MIN
186
 
#define DBL_MIN    4.94065645841246544e-324
 
528
#define DBL_MIN         4.94065645841246544e-324
187
529
#endif
188
530
#ifndef DBL_MAX
189
 
#define DBL_MAX    1.79769313486231470e+308
 
531
#define DBL_MAX         1.79769313486231470e+308
190
532
#endif
191
533
#ifndef SIZE_T_MAX
192
534
#define SIZE_T_MAX ~((size_t) 0)
193
535
#endif
194
536
 
 
537
#ifndef isfinite
 
538
#ifdef HAVE_FINITE
 
539
#define isfinite(x) finite(x)
 
540
#else
 
541
#define finite(x) (1.0 / fabs(x) > 0.0)
 
542
#endif /* HAVE_FINITE */
 
543
#endif /* isfinite */
 
544
 
 
545
#ifndef HAVE_ISNAN
 
546
#define isnan(x) ((x) != (x))
 
547
#endif
 
548
 
 
549
#ifdef HAVE_ISINF
 
550
/* isinf() can be used in both C and C++ code */
 
551
#define my_isinf(X) isinf(X)
 
552
#else
 
553
#define my_isinf(X) (!isfinite(X) && !isnan(X))
 
554
#endif
195
555
 
196
556
/* Define missing math constants. */
197
557
#ifndef M_PI
208
568
  Max size that must be added to a so that we know Size to make
209
569
  adressable obj.
210
570
*/
211
 
typedef ptrdiff_t my_ptrdiff_t;
 
571
#if SIZEOF_CHARP == 4
 
572
typedef int32_t         my_ptrdiff_t;
 
573
#else
 
574
typedef int64_t         my_ptrdiff_t;
 
575
#endif
212
576
 
213
 
#define MY_ALIGN(A,L)  (((A) + (L) - 1) & ~((L) - 1))
214
 
#define ALIGN_SIZE(A)  MY_ALIGN((A),sizeof(double))
 
577
#define MY_ALIGN(A,L)   (((A) + (L) - 1) & ~((L) - 1))
 
578
#define ALIGN_SIZE(A)   MY_ALIGN((A),sizeof(double))
215
579
/* Size to make adressable obj. */
216
580
#define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A),sizeof(t)))
217
 
/* Offset of field f in structure t */
218
 
#define OFFSET(t, f)  ((size_t)(char *)&((t *)0)->f)
219
 
#define ADD_TO_PTR(ptr,size,type) (type) ((unsigned char*) (ptr)+size)
220
 
#define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((unsigned char*) (A) - (unsigned char*) (B))
 
581
                         /* Offset of field f in structure t */
 
582
#define OFFSET(t, f)    ((size_t)(char *)&((t *)0)->f)
 
583
#define ADD_TO_PTR(ptr,size,type) (type) ((uchar*) (ptr)+size)
 
584
#define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((uchar*) (A) - (uchar*) (B))
221
585
 
222
586
#define MY_DIV_UP(A, B) (((A) + (B) - 1) / (B))
223
587
#define MY_ALIGNED_BYTE_ARRAY(N, S, T) T N[MY_DIV_UP(S, sizeof(T))]
224
588
 
 
589
/*
 
590
  Custom version of standard offsetof() macro which can be used to get
 
591
  offsets of members in class for non-POD types (according to the current
 
592
  version of C++ standard offsetof() macro can't be used in such cases and
 
593
  attempt to do so causes warnings to be emitted, OTOH in many cases it is
 
594
  still OK to assume that all instances of the class has the same offsets
 
595
  for the same members).
 
596
 
 
597
  This is temporary solution which should be removed once File_parser class
 
598
  and related routines are refactored.
 
599
*/
 
600
 
 
601
#define my_offsetof(TYPE, MEMBER) \
 
602
        ((size_t)((char *)&(((TYPE *)0x10)->MEMBER) - (char*)0x10))
 
603
 
 
604
#define NullS           (char *) 0
 
605
 
 
606
#define STDCALL
 
607
 
225
608
/* Typdefs for easyier portability */
226
609
 
 
610
#ifndef HAVE_UCHAR
 
611
typedef unsigned char   uchar;  /* Short for unsigned char */
 
612
#endif
 
613
 
227
614
#if !defined(HAVE_ULONG) && !defined(__USE_MISC)
228
 
typedef unsigned long ulong;      /* Short for unsigned long */
 
615
typedef unsigned long ulong;              /* Short for unsigned long */
229
616
#endif
230
617
 
 
618
#define MY_ERRPTR ((void*)(intptr)1)
 
619
 
 
620
#if SIZEOF_OFF_T > 4 
231
621
typedef uint64_t my_off_t;
232
 
 
233
 
#define MY_FILEPOS_ERROR  (UINT64_MAX)
234
 
 
 
622
#else
 
623
typedef unsigned long my_off_t;
 
624
#endif 
 
625
#define MY_FILEPOS_ERROR        (~(my_off_t) 0)
 
626
 
 
627
typedef off_t os_off_t;
 
628
 
 
629
#define socket_errno    errno
 
630
#define closesocket(A)  close(A)
 
631
#define SOCKET_EINTR    EINTR
 
632
#define SOCKET_EAGAIN   EAGAIN
 
633
#define SOCKET_ETIMEDOUT SOCKET_EINTR
 
634
#define SOCKET_EWOULDBLOCK EWOULDBLOCK
 
635
#define SOCKET_EADDRINUSE EADDRINUSE
 
636
#define SOCKET_ENFILE   ENFILE
 
637
#define SOCKET_EMFILE   EMFILE
 
638
 
 
639
typedef uint8_t         int7;   /* Most effective integer 0 <= x <= 127 */
 
640
typedef short           int15;  /* Most effective integer 0 <= x <= 32767 */
 
641
typedef int             myf;    /* Type of MyFlags in my_funcs */
 
642
typedef char            my_bool; /* Small bool */
 
643
#if !defined(bool) && (!defined(HAVE_BOOL) || !defined(__cplusplus))
 
644
typedef char            bool;   /* Ordinary boolean values 0 1 */
 
645
#endif
 
646
        /* Macros for converting *constants* to the right type */
 
647
#define INT8(v)         (int8_t) (v)
 
648
#define INT16(v)        (int16_t) (v)
 
649
#define INT32(v)        (int32_t) (v)
 
650
#define MYF(v)          (myf) (v)
235
651
 
236
652
/* Defines for time function */
237
 
#define SCALE_SEC  100
238
 
#define SCALE_USEC  10000
239
 
#define MY_HOW_OFTEN_TO_ALARM  2  /* How often we want info on screen */
240
 
#define MY_HOW_OFTEN_TO_WRITE  1000  /* How often we want info on screen */
241
 
 
 
653
#define SCALE_SEC       100
 
654
#define SCALE_USEC      10000
 
655
#define MY_HOW_OFTEN_TO_ALARM   2       /* How often we want info on screen */
 
656
#define MY_HOW_OFTEN_TO_WRITE   1000    /* How often we want info on screen */
 
657
 
 
658
 
 
659
 
 
660
/*
 
661
  Define-funktions for reading and storing in machine independent format
 
662
  (low byte first)
 
663
*/
 
664
 
 
665
/* Optimized store functions for Intel x86 */
 
666
#if defined(__i386__)
 
667
#define sint2korr(A)    (*((int16_t *) (A)))
 
668
#define sint3korr(A)    ((int32_t) ((((uchar) (A)[2]) & 128) ? \
 
669
                                  (((uint32_t) 255L << 24) | \
 
670
                                   (((uint32_t) (uchar) (A)[2]) << 16) |\
 
671
                                   (((uint32_t) (uchar) (A)[1]) << 8) | \
 
672
                                   ((uint32_t) (uchar) (A)[0])) : \
 
673
                                  (((uint32_t) (uchar) (A)[2]) << 16) |\
 
674
                                  (((uint32_t) (uchar) (A)[1]) << 8) | \
 
675
                                  ((uint32_t) (uchar) (A)[0])))
 
676
#define sint4korr(A)    (*((long *) (A)))
 
677
#define uint2korr(A)    (*((uint16_t *) (A)))
 
678
#if defined(HAVE_purify)
 
679
#define uint3korr(A)    (uint32_t) (((uint32_t) ((uchar) (A)[0])) +\
 
680
                                  (((uint32_t) ((uchar) (A)[1])) << 8) +\
 
681
                                  (((uint32_t) ((uchar) (A)[2])) << 16))
 
682
#else
 
683
/*
 
684
   ATTENTION !
 
685
   
 
686
    Please, note, uint3korr reads 4 bytes (not 3) !
 
687
    It means, that you have to provide enough allocated space !
 
688
*/
 
689
#define uint3korr(A)    (long) (*((unsigned int *) (A)) & 0xFFFFFF)
 
690
#endif /* HAVE_purify */
 
691
#define uint4korr(A)    (*((uint32_t *) (A)))
 
692
#define uint5korr(A)    ((uint64_t)(((uint32_t) ((uchar) (A)[0])) +\
 
693
                                    (((uint32_t) ((uchar) (A)[1])) << 8) +\
 
694
                                    (((uint32_t) ((uchar) (A)[2])) << 16) +\
 
695
                                    (((uint32_t) ((uchar) (A)[3])) << 24)) +\
 
696
                                    (((uint64_t) ((uchar) (A)[4])) << 32))
 
697
#define uint6korr(A)    ((uint64_t)(((uint32_t)    ((uchar) (A)[0]))          + \
 
698
                                     (((uint32_t)    ((uchar) (A)[1])) << 8)   + \
 
699
                                     (((uint32_t)    ((uchar) (A)[2])) << 16)  + \
 
700
                                     (((uint32_t)    ((uchar) (A)[3])) << 24)) + \
 
701
                         (((uint64_t) ((uchar) (A)[4])) << 32) +       \
 
702
                         (((uint64_t) ((uchar) (A)[5])) << 40))
 
703
#define uint8korr(A)    (*((uint64_t *) (A)))
 
704
#define sint8korr(A)    (*((int64_t *) (A)))
 
705
#define int2store(T,A)  *((uint16_t*) (T))= (uint16_t) (A)
 
706
#define int3store(T,A)  do { *(T)=  (uchar) ((A));\
 
707
                            *(T+1)=(uchar) (((uint) (A) >> 8));\
 
708
                            *(T+2)=(uchar) (((A) >> 16)); } while (0)
 
709
#define int4store(T,A)  *((long *) (T))= (long) (A)
 
710
#define int5store(T,A)  do { *(T)= (uchar)((A));\
 
711
                             *((T)+1)=(uchar) (((A) >> 8));\
 
712
                             *((T)+2)=(uchar) (((A) >> 16));\
 
713
                             *((T)+3)=(uchar) (((A) >> 24)); \
 
714
                             *((T)+4)=(uchar) (((A) >> 32)); } while(0)
 
715
#define int6store(T,A)  do { *(T)=    (uchar)((A));          \
 
716
                             *((T)+1)=(uchar) (((A) >> 8));  \
 
717
                             *((T)+2)=(uchar) (((A) >> 16)); \
 
718
                             *((T)+3)=(uchar) (((A) >> 24)); \
 
719
                             *((T)+4)=(uchar) (((A) >> 32)); \
 
720
                             *((T)+5)=(uchar) (((A) >> 40)); } while(0)
 
721
#define int8store(T,A)  *((uint64_t *) (T))= (uint64_t) (A)
 
722
 
 
723
typedef union {
 
724
  double v;
 
725
  long m[2];
 
726
} doubleget_union;
 
727
#define doubleget(V,M)  \
 
728
do { doubleget_union _tmp; \
 
729
     _tmp.m[0] = *((long*)(M)); \
 
730
     _tmp.m[1] = *(((long*) (M))+1); \
 
731
     (V) = _tmp.v; } while(0)
 
732
#define doublestore(T,V) do { *((long *) T) = ((doubleget_union *)&V)->m[0]; \
 
733
                             *(((long *) T)+1) = ((doubleget_union *)&V)->m[1]; \
 
734
                         } while (0)
 
735
#define float4get(V,M)   do { *((float *) &(V)) = *((float*) (M)); } while(0)
 
736
#define float8get(V,M)   doubleget((V),(M))
 
737
#define float4store(V,M) memcpy((uchar*) V,(uchar*) (&M),sizeof(float))
 
738
#define floatstore(T,V)  memcpy((uchar*)(T), (uchar*)(&V),sizeof(float))
 
739
#define floatget(V,M)    memcpy((uchar*) &V,(uchar*) (M),sizeof(float))
 
740
#define float8store(V,M) doublestore((V),(M))
 
741
#else
 
742
 
 
743
/*
 
744
  We're here if it's not a IA-32 architecture (Win32 and UNIX IA-32 defines
 
745
  were done before)
 
746
*/
 
747
#define sint2korr(A)    (int16_t) (((int16_t) ((uchar) (A)[0])) +\
 
748
                                 ((int16_t) ((int16_t) (A)[1]) << 8))
 
749
#define sint3korr(A)    ((int32_t) ((((uchar) (A)[2]) & 128) ? \
 
750
                                  (((uint32_t) 255L << 24) | \
 
751
                                   (((uint32_t) (uchar) (A)[2]) << 16) |\
 
752
                                   (((uint32_t) (uchar) (A)[1]) << 8) | \
 
753
                                   ((uint32_t) (uchar) (A)[0])) : \
 
754
                                  (((uint32_t) (uchar) (A)[2]) << 16) |\
 
755
                                  (((uint32_t) (uchar) (A)[1]) << 8) | \
 
756
                                  ((uint32_t) (uchar) (A)[0])))
 
757
#define sint4korr(A)    (int32_t) (((int32_t) ((uchar) (A)[0])) +\
 
758
                                (((int32_t) ((uchar) (A)[1]) << 8)) +\
 
759
                                (((int32_t) ((uchar) (A)[2]) << 16)) +\
 
760
                                (((int32_t) ((int16_t) (A)[3]) << 24)))
 
761
#define sint8korr(A)    (int64_t) uint8korr(A)
 
762
#define uint2korr(A)    (uint16_t) (((uint16_t) ((uchar) (A)[0])) +\
 
763
                                  ((uint16_t) ((uchar) (A)[1]) << 8))
 
764
#define uint3korr(A)    (uint32_t) (((uint32_t) ((uchar) (A)[0])) +\
 
765
                                  (((uint32_t) ((uchar) (A)[1])) << 8) +\
 
766
                                  (((uint32_t) ((uchar) (A)[2])) << 16))
 
767
#define uint4korr(A)    (uint32_t) (((uint32_t) ((uchar) (A)[0])) +\
 
768
                                  (((uint32_t) ((uchar) (A)[1])) << 8) +\
 
769
                                  (((uint32_t) ((uchar) (A)[2])) << 16) +\
 
770
                                  (((uint32_t) ((uchar) (A)[3])) << 24))
 
771
#define uint5korr(A)    ((uint64_t)(((uint32_t) ((uchar) (A)[0])) +\
 
772
                                    (((uint32_t) ((uchar) (A)[1])) << 8) +\
 
773
                                    (((uint32_t) ((uchar) (A)[2])) << 16) +\
 
774
                                    (((uint32_t) ((uchar) (A)[3])) << 24)) +\
 
775
                                    (((uint64_t) ((uchar) (A)[4])) << 32))
 
776
#define uint6korr(A)    ((uint64_t)(((uint32_t)    ((uchar) (A)[0]))          + \
 
777
                                     (((uint32_t)    ((uchar) (A)[1])) << 8)   + \
 
778
                                     (((uint32_t)    ((uchar) (A)[2])) << 16)  + \
 
779
                                     (((uint32_t)    ((uchar) (A)[3])) << 24)) + \
 
780
                         (((uint64_t) ((uchar) (A)[4])) << 32) +       \
 
781
                         (((uint64_t) ((uchar) (A)[5])) << 40))
 
782
#define uint8korr(A)    ((uint64_t)(((uint32_t) ((uchar) (A)[0])) +\
 
783
                                    (((uint32_t) ((uchar) (A)[1])) << 8) +\
 
784
                                    (((uint32_t) ((uchar) (A)[2])) << 16) +\
 
785
                                    (((uint32_t) ((uchar) (A)[3])) << 24)) +\
 
786
                        (((uint64_t) (((uint32_t) ((uchar) (A)[4])) +\
 
787
                                    (((uint32_t) ((uchar) (A)[5])) << 8) +\
 
788
                                    (((uint32_t) ((uchar) (A)[6])) << 16) +\
 
789
                                    (((uint32_t) ((uchar) (A)[7])) << 24))) <<\
 
790
                                    32))
 
791
#define int2store(T,A)       do { uint def_temp= (uint) (A) ;\
 
792
                                  *((uchar*) (T))=  (uchar)(def_temp); \
 
793
                                   *((uchar*) (T)+1)=(uchar)((def_temp >> 8)); \
 
794
                             } while(0)
 
795
#define int3store(T,A)       do { /*lint -save -e734 */\
 
796
                                  *((uchar*)(T))=(uchar) ((A));\
 
797
                                  *((uchar*) (T)+1)=(uchar) (((A) >> 8));\
 
798
                                  *((uchar*)(T)+2)=(uchar) (((A) >> 16)); \
 
799
                                  /*lint -restore */} while(0)
 
800
#define int4store(T,A)       do { *((char *)(T))=(char) ((A));\
 
801
                                  *(((char *)(T))+1)=(char) (((A) >> 8));\
 
802
                                  *(((char *)(T))+2)=(char) (((A) >> 16));\
 
803
                                  *(((char *)(T))+3)=(char) (((A) >> 24)); } while(0)
 
804
#define int5store(T,A)       do { *((char *)(T))=     (char)((A));  \
 
805
                                  *(((char *)(T))+1)= (char)(((A) >> 8)); \
 
806
                                  *(((char *)(T))+2)= (char)(((A) >> 16)); \
 
807
                                  *(((char *)(T))+3)= (char)(((A) >> 24)); \
 
808
                                  *(((char *)(T))+4)= (char)(((A) >> 32)); \
 
809
                                } while(0)
 
810
#define int6store(T,A)       do { *((char *)(T))=     (char)((A)); \
 
811
                                  *(((char *)(T))+1)= (char)(((A) >> 8)); \
 
812
                                  *(((char *)(T))+2)= (char)(((A) >> 16)); \
 
813
                                  *(((char *)(T))+3)= (char)(((A) >> 24)); \
 
814
                                  *(((char *)(T))+4)= (char)(((A) >> 32)); \
 
815
                                  *(((char *)(T))+5)= (char)(((A) >> 40)); \
 
816
                                } while(0)
 
817
#define int8store(T,A)       do { uint def_temp= (uint) (A), def_temp2= (uint) ((A) >> 32); \
 
818
                                  int4store((T),def_temp); \
 
819
                                  int4store((T+4),def_temp2); } while(0)
 
820
#ifdef WORDS_BIGENDIAN
 
821
#define float4store(T,A) do { *(T)= ((uchar *) &A)[3];\
 
822
                              *((T)+1)=(char) ((uchar *) &A)[2];\
 
823
                              *((T)+2)=(char) ((uchar *) &A)[1];\
 
824
                              *((T)+3)=(char) ((uchar *) &A)[0]; } while(0)
 
825
 
 
826
#define float4get(V,M)   do { float def_temp;\
 
827
                              ((uchar*) &def_temp)[0]=(M)[3];\
 
828
                              ((uchar*) &def_temp)[1]=(M)[2];\
 
829
                              ((uchar*) &def_temp)[2]=(M)[1];\
 
830
                              ((uchar*) &def_temp)[3]=(M)[0];\
 
831
                              (V)=def_temp; } while(0)
 
832
#define float8store(T,V) do { *(T)= ((uchar *) &V)[7];\
 
833
                              *((T)+1)=(char) ((uchar *) &V)[6];\
 
834
                              *((T)+2)=(char) ((uchar *) &V)[5];\
 
835
                              *((T)+3)=(char) ((uchar *) &V)[4];\
 
836
                              *((T)+4)=(char) ((uchar *) &V)[3];\
 
837
                              *((T)+5)=(char) ((uchar *) &V)[2];\
 
838
                              *((T)+6)=(char) ((uchar *) &V)[1];\
 
839
                              *((T)+7)=(char) ((uchar *) &V)[0]; } while(0)
 
840
 
 
841
#define float8get(V,M)   do { double def_temp;\
 
842
                              ((uchar*) &def_temp)[0]=(M)[7];\
 
843
                              ((uchar*) &def_temp)[1]=(M)[6];\
 
844
                              ((uchar*) &def_temp)[2]=(M)[5];\
 
845
                              ((uchar*) &def_temp)[3]=(M)[4];\
 
846
                              ((uchar*) &def_temp)[4]=(M)[3];\
 
847
                              ((uchar*) &def_temp)[5]=(M)[2];\
 
848
                              ((uchar*) &def_temp)[6]=(M)[1];\
 
849
                              ((uchar*) &def_temp)[7]=(M)[0];\
 
850
                              (V) = def_temp; } while(0)
 
851
#else
 
852
#define float4get(V,M)   memcpy((uchar*) &V,(uchar*) (M),sizeof(float))
 
853
#define float4store(V,M) memcpy((uchar*) V,(uchar*) (&M),sizeof(float))
 
854
 
 
855
#if defined(__FLOAT_WORD_ORDER) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN)
 
856
#define doublestore(T,V) do { *(((char*)T)+0)=(char) ((uchar *) &V)[4];\
 
857
                              *(((char*)T)+1)=(char) ((uchar *) &V)[5];\
 
858
                              *(((char*)T)+2)=(char) ((uchar *) &V)[6];\
 
859
                              *(((char*)T)+3)=(char) ((uchar *) &V)[7];\
 
860
                              *(((char*)T)+4)=(char) ((uchar *) &V)[0];\
 
861
                              *(((char*)T)+5)=(char) ((uchar *) &V)[1];\
 
862
                              *(((char*)T)+6)=(char) ((uchar *) &V)[2];\
 
863
                              *(((char*)T)+7)=(char) ((uchar *) &V)[3]; }\
 
864
                         while(0)
 
865
#define doubleget(V,M)   do { double def_temp;\
 
866
                              ((uchar*) &def_temp)[0]=(M)[4];\
 
867
                              ((uchar*) &def_temp)[1]=(M)[5];\
 
868
                              ((uchar*) &def_temp)[2]=(M)[6];\
 
869
                              ((uchar*) &def_temp)[3]=(M)[7];\
 
870
                              ((uchar*) &def_temp)[4]=(M)[0];\
 
871
                              ((uchar*) &def_temp)[5]=(M)[1];\
 
872
                              ((uchar*) &def_temp)[6]=(M)[2];\
 
873
                              ((uchar*) &def_temp)[7]=(M)[3];\
 
874
                              (V) = def_temp; } while(0)
 
875
#endif /* __FLOAT_WORD_ORDER */
 
876
 
 
877
#define float8get(V,M)   doubleget((V),(M))
 
878
#define float8store(V,M) doublestore((V),(M))
 
879
#endif /* WORDS_BIGENDIAN */
 
880
 
 
881
#endif /* __i386__ */
 
882
 
 
883
/*
 
884
  Macro for reading 32-bit integer from network byte order (big-endian)
 
885
  from unaligned memory location.
 
886
*/
 
887
#define int4net(A)        (int32_t) (((uint32_t) ((uchar) (A)[3]))        |\
 
888
                                  (((uint32_t) ((uchar) (A)[2])) << 8)  |\
 
889
                                  (((uint32_t) ((uchar) (A)[1])) << 16) |\
 
890
                                  (((uint32_t) ((uchar) (A)[0])) << 24))
 
891
/*
 
892
  Define-funktions for reading and storing in machine format from/to
 
893
  short/long to/from some place in memory V should be a (not
 
894
  register) variable, M is a pointer to byte
 
895
*/
 
896
 
 
897
#ifdef WORDS_BIGENDIAN
 
898
 
 
899
#define ushortget(V,M)  do { V = (uint16_t) (((uint16_t) ((uchar) (M)[1]))+\
 
900
                                 ((uint16_t) ((uint16_t) (M)[0]) << 8)); } while(0)
 
901
#define shortget(V,M)   do { V = (short) (((short) ((uchar) (M)[1]))+\
 
902
                                 ((short) ((short) (M)[0]) << 8)); } while(0)
 
903
#define longget(V,M)    do { int32_t def_temp;\
 
904
                             ((uchar*) &def_temp)[0]=(M)[0];\
 
905
                             ((uchar*) &def_temp)[1]=(M)[1];\
 
906
                             ((uchar*) &def_temp)[2]=(M)[2];\
 
907
                             ((uchar*) &def_temp)[3]=(M)[3];\
 
908
                             (V)=def_temp; } while(0)
 
909
#define ulongget(V,M)   do { uint32_t def_temp;\
 
910
                            ((uchar*) &def_temp)[0]=(M)[0];\
 
911
                            ((uchar*) &def_temp)[1]=(M)[1];\
 
912
                            ((uchar*) &def_temp)[2]=(M)[2];\
 
913
                            ((uchar*) &def_temp)[3]=(M)[3];\
 
914
                            (V)=def_temp; } while(0)
 
915
#define shortstore(T,A) do { uint def_temp=(uint) (A) ;\
 
916
                             *(((char*)T)+1)=(char)(def_temp); \
 
917
                             *(((char*)T)+0)=(char)(def_temp >> 8); } while(0)
 
918
#define longstore(T,A)  do { *(((char*)T)+3)=((A));\
 
919
                             *(((char*)T)+2)=(((A) >> 8));\
 
920
                             *(((char*)T)+1)=(((A) >> 16));\
 
921
                             *(((char*)T)+0)=(((A) >> 24)); } while(0)
 
922
 
 
923
#define floatget(V,M)     memcpy((uchar*) &V,(uchar*) (M), sizeof(float))
 
924
#define floatstore(T,V)   memcpy((uchar*) (T),(uchar*)(&V), sizeof(float))
 
925
#define doubleget(V,M)    memcpy((uchar*) &V,(uchar*) (M), sizeof(double))
 
926
#define doublestore(T,V)  memcpy((uchar*) (T),(uchar*) &V, sizeof(double))
 
927
#define int64_tget(V,M)   memcpy((uchar*) &V,(uchar*) (M), sizeof(uint64_t))
 
928
#define int64_tstore(T,V) memcpy((uchar*) (T),(uchar*) &V, sizeof(uint64_t))
 
929
 
 
930
#else
 
931
 
 
932
#define ushortget(V,M)  do { V = uint2korr(M); } while(0)
 
933
#define shortget(V,M)   do { V = sint2korr(M); } while(0)
 
934
#define longget(V,M)    do { V = sint4korr(M); } while(0)
 
935
#define ulongget(V,M)   do { V = uint4korr(M); } while(0)
 
936
#define shortstore(T,V) int2store(T,V)
 
937
#define longstore(T,V)  int4store(T,V)
 
938
#ifndef floatstore
 
939
#define floatstore(T,V)   memcpy((uchar*) (T),(uchar*) (&V),sizeof(float))
 
940
#define floatget(V,M)     memcpy((uchar*) &V, (uchar*) (M), sizeof(float))
 
941
#endif
 
942
#ifndef doubleget
 
943
#define doubleget(V,M)    memcpy((uchar*) &V,(uchar*) (M),sizeof(double))
 
944
#define doublestore(T,V)  memcpy((uchar*) (T),(uchar*) &V,sizeof(double))
 
945
#endif /* doubleget */
 
946
#define int64_tget(V,M)   memcpy((uchar*) &V,(uchar*) (M),sizeof(uint64_t))
 
947
#define int64_tstore(T,V) memcpy((uchar*) (T),(uchar*) &V,sizeof(uint64_t))
 
948
 
 
949
#endif /* WORDS_BIGENDIAN */
 
950
 
 
951
/* my_sprintf  was here. RIP */
242
952
 
243
953
#if defined(HAVE_CHARSET_utf8mb3) || defined(HAVE_CHARSET_utf8mb4)
244
 
#define DRIZZLE_UNIVERSAL_CLIENT_CHARSET "utf8"
 
954
#define MYSQL_UNIVERSAL_CLIENT_CHARSET "utf8"
245
955
#else
246
 
#define DRIZZLE_UNIVERSAL_CLIENT_CHARSET DRIZZLE_DEFAULT_CHARSET_NAME
 
956
#define MYSQL_UNIVERSAL_CLIENT_CHARSET MYSQL_DEFAULT_CHARSET_NAME
247
957
#endif
248
958
 
249
959
#include <dlfcn.h>
253
963
#define RTLD_NOW 1
254
964
#endif
255
965
 
256
 
#define cmax(a, b)       ((a) > (b) ? (a) : (b))
257
 
#define cmin(a, b)       ((a) < (b) ? (a) : (b))
 
966
/*
 
967
 *  Include standard definitions of operator new and delete.
 
968
 */
 
969
#ifdef __cplusplus
 
970
#include <new>
 
971
#endif
258
972
 
259
973
/* Length of decimal number represented by INT32. */
260
974
#define MY_INT32_NUM_DECIMAL_DIGITS 11
262
976
/* Length of decimal number represented by INT64. */
263
977
#define MY_INT64_NUM_DECIMAL_DIGITS 21
264
978
 
 
979
#ifdef _cplusplus
 
980
#include <string>
 
981
#endif
 
982
 
 
983
/* Define some useful general macros (should be done after all headers). */
 
984
#if !defined(max)
 
985
#define max(a, b)       ((a) > (b) ? (a) : (b))
 
986
#define min(a, b)       ((a) < (b) ? (a) : (b))
 
987
#endif  
265
988
/*
266
989
  Only Linux is known to need an explicit sync of the directory to make sure a
267
990
  file creation/deletion/renaming in(from,to) this directory durable.
270
993
#define NEED_EXPLICIT_SYNC_DIR 1
271
994
#endif
272
995
 
273
 
/* We need to turn off _DTRACE_VERSION if we're not going to use dtrace */
274
 
#if !defined(HAVE_DTRACE)
275
 
# undef _DTRACE_VERSION
276
 
# define _DTRACE_VERSION 0
277
 
#endif
 
996
#include <libdrizzle/gettext.h>
278
997
 
279
 
#endif /* DRIZZLE_SERVER_GLOBAL_H */
 
998
#endif /* my_global_h */