~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to include/my_global.h

Removed dead variable, sorted authors file.

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"
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
 
/*
54
 
  A lot of our programs uses asserts, so better to always include it
55
 
*/
56
 
# include <assert.h>
57
 
# include <stdbool.h>
58
 
 
59
 
#endif // __cplusplus
60
 
 
61
 
/*
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>
70
 
# endif
71
 
#endif */ /* TIME_WITH_SYS_TIME */
 
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
/* Fix problem with S_ISLNK() on Linux */
 
134
#if defined(TARGET_OS_LINUX) || defined(__GLIBC__)
 
135
#undef  _GNU_SOURCE
 
136
#define _GNU_SOURCE 1
 
137
#endif
 
138
 
72
139
 
73
140
/*
74
141
  Temporary solution to solve bug#7156. Include "sys/types.h" before
78
145
#include <sys/types.h>
79
146
#endif
80
147
 
81
 
 
82
 
#include <pthread.h>    /* AIX must have this included first */
83
 
 
84
 
#define _REENTRANT  1  /* Threads requires reentrant code */
85
 
 
 
148
#ifdef HAVE_THREADS_WITHOUT_SOCKETS
 
149
/* MIT pthreads does not work with unix sockets */
 
150
#undef HAVE_SYS_UN_H
 
151
#endif
 
152
 
 
153
#define __EXTENSIONS__ 1        /* We want some extension */
 
154
#ifndef __STDC_EXT__
 
155
#define __STDC_EXT__ 1          /* To get large file support on hpux */
 
156
#endif
 
157
 
 
158
/*
 
159
  Solaris 9 include file <sys/feature_tests.h> refers to X/Open document
 
160
 
 
161
    System Interfaces and Headers, Issue 5
 
162
 
 
163
  saying we should define _XOPEN_SOURCE=500 to get POSIX.1c prototypes,
 
164
  but apparently other systems (namely FreeBSD) don't agree.
 
165
 
 
166
  On a newer Solaris 10, the above file recognizes also _XOPEN_SOURCE=600.
 
167
  Furthermore, it tests that if a program requires older standard
 
168
  (_XOPEN_SOURCE<600 or _POSIX_C_SOURCE<200112L) it cannot be
 
169
  run on a new compiler (that defines _STDC_C99) and issues an #error.
 
170
  It's also an #error if a program requires new standard (_XOPEN_SOURCE=600
 
171
  or _POSIX_C_SOURCE=200112L) and a compiler does not define _STDC_C99.
 
172
 
 
173
  To add more to this mess, Sun Studio C compiler defines _STDC_C99 while
 
174
  C++ compiler does not!
 
175
 
 
176
  So, in a desperate attempt to get correct prototypes for both
 
177
  C and C++ code, we define either _XOPEN_SOURCE=600 or _XOPEN_SOURCE=500
 
178
  depending on the compiler's announced C standard support.
 
179
 
 
180
  Cleaner solutions are welcome.
 
181
*/
 
182
#ifdef __sun
 
183
#if __STDC_VERSION__ - 0 >= 199901L
 
184
#define _XOPEN_SOURCE 600
 
185
#else
 
186
#define _XOPEN_SOURCE 500
 
187
#endif
 
188
#endif
 
189
 
 
190
#ifndef _POSIX_PTHREAD_SEMANTICS
 
191
#define _POSIX_PTHREAD_SEMANTICS /* We want posix threads */
 
192
#endif
 
193
 
 
194
#define _REENTRANT      1       /* Some thread libraries require this */
 
195
 
 
196
#if !defined(_THREAD_SAFE) && !defined(_AIX)
 
197
#define _THREAD_SAFE            /* Required for OSF1 */
 
198
#endif
 
199
 
 
200
#include <pthread.h>            /* AIX must have this included first */
 
201
 
 
202
#define _REENTRANT      1       /* Threads requires reentrant code */
 
203
 
 
204
/* Go around some bugs in different OS and compilers */
 
205
 
 
206
#if defined(HAVE_BROKEN_INLINE) && !defined(__cplusplus)
 
207
#undef inline
 
208
#define inline
 
209
#endif
 
210
 
 
211
/* gcc/egcs issues */
 
212
 
 
213
#if defined(__GNUC) && defined(__EXCEPTIONS)
 
214
#error "Please add -fno-exceptions to CXXFLAGS and reconfigure/recompile"
 
215
#endif
 
216
 
 
217
#ifndef stdin
 
218
#include <stdio.h>
 
219
#endif
 
220
#ifdef HAVE_STDLIB_H
 
221
#include <stdlib.h>
 
222
#endif
 
223
#ifdef HAVE_STDDEF_H
 
224
#include <stddef.h>
 
225
#endif
 
226
 
 
227
#include <math.h>
86
228
#ifdef HAVE_LIMITS_H
87
229
#include <limits.h>
88
230
#endif
93
235
#ifdef HAVE_FCNTL_H
94
236
#include <fcntl.h>
95
237
#endif
96
 
 
 
238
#ifdef HAVE_SYS_TIMEB_H
 
239
#include <sys/timeb.h>                          /* Avoid warnings on SCO */
 
240
#endif
 
241
#if TIME_WITH_SYS_TIME
 
242
# include <sys/time.h>
 
243
# include <time.h>
 
244
#else
 
245
# if HAVE_SYS_TIME_H
 
246
#  include <sys/time.h>
 
247
# else
 
248
#  include <time.h>
 
249
# endif
 
250
#endif /* TIME_WITH_SYS_TIME */
97
251
#ifdef HAVE_UNISTD_H
98
252
#include <unistd.h>
99
253
#endif
105
259
#include <alloca.h>
106
260
#endif
107
261
 
108
 
 
109
 
 
110
 
#ifdef HAVE_SYS_STAT_H
111
 
# include <sys/stat.h>
112
 
#endif
 
262
#include <errno.h>                              /* Recommended by debian */
 
263
/* We need the following to go around a problem with openssl on solaris */
 
264
#if defined(HAVE_CRYPT_H)
 
265
#include <crypt.h>
 
266
#endif
 
267
 
 
268
#if defined(HAVE_STDINT_H)
 
269
/* We are mixing C and C++, so we wan the C limit macros in the C++ too */
 
270
/* Enable some extra C99 extensions */
 
271
#define __STDC_LIMIT_MACROS
 
272
#define __STDC_FORMAT_MACROS
 
273
#include <inttypes.h>
 
274
#include <stdint.h>
 
275
#endif
 
276
 
 
277
#if defined(HAVE_STDBOOL_H)
 
278
#include <stdbool.h>
 
279
#endif
 
280
 
 
281
 
 
282
/*
 
283
  A lot of our programs uses asserts, so better to always include it
 
284
  This also fixes a problem when people uses DBUG_ASSERT without including
 
285
  assert.h
 
286
*/
 
287
#include <assert.h>
 
288
 
 
289
/* an assert that works at compile-time. only for constant expression */
 
290
#ifndef __GNUC__
 
291
#define compile_time_assert(X)  do { } while(0)
 
292
#else
 
293
#define compile_time_assert(X)                                  \
 
294
  do                                                            \
 
295
  {                                                             \
 
296
    char compile_time_assert[(X) ? 1 : -1]                      \
 
297
                             __attribute__ ((unused));          \
 
298
  } while(0)
 
299
#endif
 
300
 
 
301
/* Declare madvise where it is not declared for C++, like Solaris */
 
302
#if HAVE_MADVISE && !defined(HAVE_DECL_MADVISE) && defined(__cplusplus)
 
303
extern "C" int madvise(void *addr, size_t len, int behav);
 
304
#endif
 
305
 
 
306
/* We can not live without the following defines */
 
307
 
 
308
#define USE_MYFUNC 1            /* Must use syscall indirection */
 
309
#define MASTER 1                /* Compile without unireg */
 
310
#define ENGLISH 1               /* Messages in English */
 
311
#define POSIX_MISTAKE 1         /* regexp: Fix stupid spec error */
 
312
/* Do not define for ultra sparcs */
 
313
#define USE_BMOVE512 1          /* Use this unless system bmove is faster */
 
314
 
 
315
#define QUOTE_ARG(x)            #x      /* Quote argument (before cpp) */
 
316
#define STRINGIFY_ARG(x) QUOTE_ARG(x)   /* Quote argument, after cpp */
 
317
/* Does the system remember a signal handler after a signal ? */
 
318
#ifndef HAVE_BSD_SIGNALS
 
319
#define DONT_REMEMBER_SIGNAL
 
320
#endif
 
321
 
 
322
/* Define void to stop lint from generating "null effekt" comments */
 
323
#ifndef DONT_DEFINE_VOID
 
324
#ifdef _lint
 
325
int     __void__;
 
326
#define VOID(X)         (__void__ = (int) (X))
 
327
#else
 
328
#undef VOID
 
329
#define VOID(X)         (X)
 
330
#endif
 
331
#endif /* DONT_DEFINE_VOID */
113
332
 
114
333
#if !defined(HAVE_UINT)
115
334
#undef HAVE_UINT
116
335
#define HAVE_UINT
117
336
typedef unsigned int uint;
 
337
typedef unsigned short ushort;
118
338
#endif
119
339
 
120
 
/* Declared in int2str() */
121
 
extern char _dig_vec_upper[];
122
 
extern char _dig_vec_lower[];
123
 
 
 
340
#define CMP_NUM(a,b)    (((a) < (b)) ? -1 : ((a) == (b)) ? 0 : 1)
 
341
#define sgn(a)          (((a) < 0) ? -1 : ((a) > 0) ? 1 : 0)
 
342
#define swap_variables(t, a, b) { register t dummy; dummy= a; a= b; b= dummy; }
 
343
#define test(a)         ((a) ? 1 : 0)
124
344
#define set_if_bigger(a,b)  do { if ((a) < (b)) (a)=(b); } while(0)
125
 
 
126
345
#define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0)
127
 
#define array_elements(A) ((size_t) (sizeof(A)/sizeof(A[0])))
 
346
#define test_all_bits(a,b) (((a) & (b)) == (b))
 
347
#define set_bits(type, bit_count) (sizeof(type)*8 <= (bit_count) ? ~(type) 0 : ((((type) 1) << (bit_count)) - (type) 1))
 
348
#define array_elements(A) ((uint32_t) (sizeof(A)/sizeof(A[0])))
 
349
#ifndef HAVE_RINT
 
350
#define rint(A) floor((A)+(((A) < 0)? -0.5 : 0.5))
 
351
#endif
 
352
 
 
353
#if defined(__GNUC__)
 
354
#define function_volatile       volatile
 
355
#define my_reinterpret_cast(A) reinterpret_cast<A>
 
356
#define my_const_cast(A) const_cast<A>
 
357
# ifndef GCC_VERSION
 
358
#  define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
 
359
# endif
 
360
#elif !defined(my_reinterpret_cast)
 
361
#define my_reinterpret_cast(A) (A)
 
362
#define my_const_cast(A) (A)
 
363
#endif
 
364
 
 
365
#include <my_attribute.h>
 
366
 
 
367
/* From old s-system.h */
 
368
 
 
369
/*
 
370
  Support macros for non ansi & other old compilers. Since such
 
371
  things are no longer supported we do nothing. We keep then since
 
372
  some of our code may still be needed to upgrade old customers.
 
373
*/
 
374
#define _VARARGS(X) X
 
375
#define _STATIC_VARARGS(X) X
 
376
#define _PC(X)  X
 
377
 
 
378
/* The DBUG_ON flag always takes precedence over default DBUG_OFF */
 
379
#if defined(DBUG_ON) && defined(DBUG_OFF)
 
380
#undef DBUG_OFF
 
381
#endif
 
382
 
 
383
/* We might be forced to turn debug off, if not turned off already */
 
384
#if (defined(FORCE_DBUG_OFF) || defined(_lint)) && !defined(DBUG_OFF)
 
385
#  define DBUG_OFF
 
386
#  ifdef DBUG_ON
 
387
#    undef DBUG_ON
 
388
#  endif
 
389
#endif
 
390
 
 
391
#include <my_dbug.h>
 
392
 
 
393
#define MIN_ARRAY_SIZE  0       /* Zero or One. Gcc allows zero*/
 
394
#define ASCII_BITS_USED 8       /* Bit char used */
128
395
 
129
396
/* Some types that is different between systems */
130
397
 
131
 
typedef int  File;    /* File descriptor */
132
 
 
 
398
typedef int     File;           /* File descriptor */
 
399
#ifndef Socket_defined
 
400
typedef int     my_socket;      /* File descriptor for sockets */
 
401
#define INVALID_SOCKET -1
 
402
#endif
 
403
/* Type for fuctions that handles signals */
 
404
#define sig_handler RETSIGTYPE
 
405
C_MODE_START
 
406
typedef void    (*sig_return)(void);/* Returns type from signal */
 
407
typedef int     (*qsort_cmp)(const void *,const void *);
 
408
typedef int     (*qsort_cmp2)(void*, const void *,const void *);
 
409
C_MODE_END
 
410
#define qsort_t RETQSORTTYPE    /* Broken GCC cant handle typedef !!!! */
133
411
#ifdef HAVE_SYS_SOCKET_H
134
412
#include <sys/socket.h>
135
413
#endif
136
 
 
 
414
typedef SOCKET_SIZE_TYPE size_socket;
 
415
 
 
416
#ifndef SOCKOPT_OPTLEN_TYPE
 
417
#define SOCKOPT_OPTLEN_TYPE size_socket
 
418
#endif
 
419
 
 
420
/* file create flags */
 
421
 
 
422
#ifndef O_SHARE                 /* Probably not windows */
 
423
#define O_SHARE         0       /* Flag to my_open for shared files */
 
424
#endif /* O_SHARE */
 
425
 
 
426
#ifndef O_BINARY
 
427
#define O_BINARY        0       /* Flag to my_open for binary files */
 
428
#endif
 
429
 
 
430
#ifndef FILE_BINARY
 
431
#define FILE_BINARY     O_BINARY /* Flag to my_fopen for binary streams */
 
432
#endif
 
433
 
 
434
#define F_TO_EOF        0L      /* Param to lockf() to lock rest of file */
 
435
 
 
436
#ifndef O_TEMPORARY
 
437
#define O_TEMPORARY     0
 
438
#endif
 
439
#ifndef O_SHORT_LIVED
 
440
#define O_SHORT_LIVED   0
 
441
#endif
 
442
#ifndef O_NOFOLLOW
 
443
#define O_NOFOLLOW      0
 
444
#endif
 
445
 
 
446
/* #define USE_RECORD_LOCK      */
 
447
 
 
448
        /* Unsigned types supported by the compiler */
 
449
#define UNSINT8                 /* unsigned int8 (char) */
 
450
#define UNSINT16                /* unsigned int16 */
 
451
#define UNSINT32                /* unsigned int32 */
 
452
 
 
453
        /* General constants */
 
454
#define SC_MAXWIDTH     256     /* Max width of screen (for error messages) */
 
455
#define FN_LEN          256     /* Max file name len */
 
456
#define FN_HEADLEN      253     /* Max length of filepart of file name */
 
457
#define FN_EXTLEN       20      /* Max length of extension (part of FN_LEN) */
 
458
#define FN_REFLEN       512     /* Max length of full path-name */
 
459
#define FN_EXTCHAR      '.'
 
460
#define FN_HOMELIB      '~'     /* ~/ is used as abbrev for home dir */
 
461
#define FN_CURLIB       '.'     /* ./ is used as abbrev for current dir */
 
462
#define FN_PARENTDIR    ".."    /* Parent directory; Must be a string */
137
463
 
138
464
#ifndef FN_LIBCHAR
139
 
#define FN_LIBCHAR  '/'
140
 
#define FN_ROOTDIR  "/"
 
465
#define FN_LIBCHAR      '/'
 
466
#define FN_ROOTDIR      "/"
141
467
#endif
142
 
#define MY_NFILE  64  /* This is only used to save filenames */
 
468
#define MY_NFILE        64      /* This is only used to save filenames */
143
469
#ifndef OS_FILE_LIMIT
144
 
#define OS_FILE_LIMIT  65535
 
470
#define OS_FILE_LIMIT   65535
145
471
#endif
146
472
 
 
473
/* #define EXT_IN_LIBNAME     */
 
474
/* #define FN_NO_CASE_SENCE   */
 
475
/* #define FN_UPPER_CASE TRUE */
 
476
 
 
477
/*
 
478
  Io buffer size; Must be a power of 2 and a multiple of 512. May be
 
479
  smaller what the disk page size. This influences the speed of the
 
480
  isam btree library. eg to big to slow.
 
481
*/
 
482
#define IO_SIZE                 4096
147
483
/*
148
484
  How much overhead does malloc have. The code often allocates
149
485
  something like 1024-MALLOC_OVERHEAD bytes
150
486
*/
151
487
#define MALLOC_OVERHEAD 8
152
488
 
153
 
/* get memory in huncs */
154
 
#define ONCE_ALLOC_INIT    (uint) (4096-MALLOC_OVERHEAD)
155
 
/* Typical record cash */
156
 
#define RECORD_CACHE_SIZE  (uint) (64*1024-MALLOC_OVERHEAD)
157
 
/* Typical key cash */
158
 
#define KEY_CACHE_SIZE    (uint) (8*1024*1024-MALLOC_OVERHEAD)
159
 
/* Default size of a key cache block  */
160
 
#define KEY_CACHE_BLOCK_SIZE  (uint) 1024
161
 
 
162
 
 
163
 
/* Some things that this system doesn't have */
 
489
        /* get memory in huncs */
 
490
#define ONCE_ALLOC_INIT         (uint) (4096-MALLOC_OVERHEAD)
 
491
        /* Typical record cash */
 
492
#define RECORD_CACHE_SIZE       (uint) (64*1024-MALLOC_OVERHEAD)
 
493
        /* Typical key cash */
 
494
#define KEY_CACHE_SIZE          (uint) (8*1024*1024-MALLOC_OVERHEAD)
 
495
        /* Default size of a key cache block  */
 
496
#define KEY_CACHE_BLOCK_SIZE    (uint) 1024
 
497
 
 
498
 
 
499
        /* Some things that this system doesn't have */
164
500
 
165
501
/* Some defines of functions for portability */
166
502
 
167
 
#undef remove    /* Crashes MySQL on SCO 5.0.0 */
 
503
#undef remove           /* Crashes MySQL on SCO 5.0.0 */
 
504
#define closesocket(A)  close(A)
168
505
#ifndef uint64_t2double
169
506
#define uint64_t2double(A) ((double) (uint64_t) (A))
170
507
#define my_off_t2double(A)  ((double) (my_off_t) (A))
174
511
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
175
512
#endif
176
513
#define ulong_to_double(X) ((double) (ulong) (X))
 
514
#define SET_STACK_SIZE(X)       /* Not needed on real machines */
177
515
 
178
516
#ifndef STACK_DIRECTION
179
517
#error "please add -DSTACK_DIRECTION=1 or -1 to your CPPFLAGS"
196
534
 
197
535
/* From limits.h instead */
198
536
#ifndef DBL_MIN
199
 
#define DBL_MIN    4.94065645841246544e-324
 
537
#define DBL_MIN         4.94065645841246544e-324
200
538
#endif
201
539
#ifndef DBL_MAX
202
 
#define DBL_MAX    1.79769313486231470e+308
 
540
#define DBL_MAX         1.79769313486231470e+308
203
541
#endif
204
542
#ifndef SIZE_T_MAX
205
543
#define SIZE_T_MAX ~((size_t) 0)
206
544
#endif
207
545
 
 
546
#ifndef isfinite
 
547
#ifdef HAVE_FINITE
 
548
#define isfinite(x) finite(x)
 
549
#else
 
550
#define finite(x) (1.0 / fabs(x) > 0.0)
 
551
#endif /* HAVE_FINITE */
 
552
#endif /* isfinite */
 
553
 
 
554
#ifndef HAVE_ISNAN
 
555
#define isnan(x) ((x) != (x))
 
556
#endif
 
557
 
 
558
#ifdef HAVE_ISINF
 
559
/* isinf() can be used in both C and C++ code */
 
560
#define my_isinf(X) isinf(X)
 
561
#else
 
562
#define my_isinf(X) (!isfinite(X) && !isnan(X))
 
563
#endif
208
564
 
209
565
/* Define missing math constants. */
210
566
#ifndef M_PI
221
577
  Max size that must be added to a so that we know Size to make
222
578
  adressable obj.
223
579
*/
224
 
typedef ptrdiff_t my_ptrdiff_t;
 
580
#if SIZEOF_CHARP == 4
 
581
typedef int32_t         my_ptrdiff_t;
 
582
#else
 
583
typedef int64_t         my_ptrdiff_t;
 
584
#endif
225
585
 
226
 
#define MY_ALIGN(A,L)  (((A) + (L) - 1) & ~((L) - 1))
227
 
#define ALIGN_SIZE(A)  MY_ALIGN((A),sizeof(double))
 
586
#define MY_ALIGN(A,L)   (((A) + (L) - 1) & ~((L) - 1))
 
587
#define ALIGN_SIZE(A)   MY_ALIGN((A),sizeof(double))
228
588
/* Size to make adressable obj. */
229
589
#define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A),sizeof(t)))
230
 
/* Offset of field f in structure t */
231
 
#define OFFSET(t, f)  ((size_t)(char *)&((t *)0)->f)
232
 
#define ADD_TO_PTR(ptr,size,type) (type) ((unsigned char*) (ptr)+size)
233
 
#define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((unsigned char*) (A) - (unsigned char*) (B))
 
590
                         /* Offset of field f in structure t */
 
591
#define OFFSET(t, f)    ((size_t)(char *)&((t *)0)->f)
 
592
#define ADD_TO_PTR(ptr,size,type) (type) ((uchar*) (ptr)+size)
 
593
#define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((uchar*) (A) - (uchar*) (B))
234
594
 
235
595
#define MY_DIV_UP(A, B) (((A) + (B) - 1) / (B))
236
596
#define MY_ALIGNED_BYTE_ARRAY(N, S, T) T N[MY_DIV_UP(S, sizeof(T))]
237
597
 
 
598
/*
 
599
  Custom version of standard offsetof() macro which can be used to get
 
600
  offsets of members in class for non-POD types (according to the current
 
601
  version of C++ standard offsetof() macro can't be used in such cases and
 
602
  attempt to do so causes warnings to be emitted, OTOH in many cases it is
 
603
  still OK to assume that all instances of the class has the same offsets
 
604
  for the same members).
 
605
 
 
606
  This is temporary solution which should be removed once File_parser class
 
607
  and related routines are refactored.
 
608
*/
 
609
 
 
610
#define my_offsetof(TYPE, MEMBER) \
 
611
        ((size_t)((char *)&(((TYPE *)0x10)->MEMBER) - (char*)0x10))
 
612
 
 
613
#define NullS           (char *) 0
 
614
 
 
615
#define STDCALL
 
616
 
238
617
/* Typdefs for easyier portability */
239
618
 
 
619
#ifndef HAVE_UCHAR
 
620
typedef unsigned char   uchar;  /* Short for unsigned char */
 
621
#endif
 
622
 
 
623
#ifndef HAVE_INT8
 
624
typedef signed char int8;       /* Signed integer >= 8  bits */
 
625
#endif
 
626
#ifndef HAVE_UINT8
 
627
typedef unsigned char uint8;    /* Unsigned integer >= 8  bits */
 
628
#endif
 
629
#ifndef HAVE_INT16
 
630
typedef short int16;
 
631
#endif
 
632
#ifndef HAVE_UINT16
 
633
typedef unsigned short uint16;
 
634
#endif
 
635
#if SIZEOF_INT == 4
 
636
#ifndef HAVE_INT32
 
637
typedef int int32;
 
638
#endif
 
639
#ifndef HAVE_UINT32
 
640
typedef unsigned int uint32;
 
641
#endif
 
642
#elif SIZEOF_LONG == 4
 
643
#ifndef HAVE_INT32
 
644
typedef long int32;
 
645
#endif
 
646
#ifndef HAVE_UINT32
 
647
typedef unsigned long uint32;
 
648
#endif
 
649
#else
 
650
#error Neither int or long is of 4 bytes width
 
651
#endif
 
652
 
240
653
#if !defined(HAVE_ULONG) && !defined(__USE_MISC)
241
 
typedef unsigned long ulong;      /* Short for unsigned long */
242
 
#endif
243
 
 
 
654
typedef uint32_t        ulong;            /* Short for unsigned long */
 
655
#endif
 
656
#ifndef int64_t_defined
 
657
/* 
 
658
  Using [unsigned] long long is preferable as [u]int64_t because we use 
 
659
  [unsigned] long long unconditionally in many places, 
 
660
  for example in constants with [U]LL suffix.
 
661
*/
 
662
typedef int64_t int64_t;
 
663
#endif
 
664
 
 
665
#define MY_ERRPTR ((void*)(intptr)1)
 
666
 
 
667
#if SIZEOF_OFF_T > 4 
244
668
typedef uint64_t my_off_t;
245
 
 
246
 
#define MY_FILEPOS_ERROR  (UINT64_MAX)
247
 
 
248
 
typedef int    myf;  /* Type of MyFlags in my_funcs */
 
669
#else
 
670
typedef unsigned long my_off_t;
 
671
#endif 
 
672
#define MY_FILEPOS_ERROR        (~(my_off_t) 0)
 
673
 
 
674
typedef off_t os_off_t;
 
675
 
 
676
#define socket_errno    errno
 
677
#define closesocket(A)  close(A)
 
678
#define SOCKET_EINTR    EINTR
 
679
#define SOCKET_EAGAIN   EAGAIN
 
680
#define SOCKET_ETIMEDOUT SOCKET_EINTR
 
681
#define SOCKET_EWOULDBLOCK EWOULDBLOCK
 
682
#define SOCKET_EADDRINUSE EADDRINUSE
 
683
#define SOCKET_ENFILE   ENFILE
 
684
#define SOCKET_EMFILE   EMFILE
 
685
 
 
686
typedef uint8           int7;   /* Most effective integer 0 <= x <= 127 */
 
687
typedef short           int15;  /* Most effective integer 0 <= x <= 32767 */
 
688
typedef int             myf;    /* Type of MyFlags in my_funcs */
 
689
typedef char            my_bool; /* Small bool */
 
690
#if !defined(bool) && (!defined(HAVE_BOOL) || !defined(__cplusplus))
 
691
typedef char            bool;   /* Ordinary boolean values 0 1 */
 
692
#endif
 
693
        /* Macros for converting *constants* to the right type */
 
694
#define INT8(v)         (int8) (v)
 
695
#define INT16(v)        (int16) (v)
 
696
#define INT32(v)        (int32) (v)
249
697
#define MYF(v)          (myf) (v)
250
698
 
 
699
/*
 
700
  Sometimes we want to make sure that the variable is not put into
 
701
  a register in debugging mode so we can see its value in the core
 
702
*/
 
703
 
 
704
#ifndef DBUG_OFF
 
705
#define dbug_volatile volatile
 
706
#else
 
707
#define dbug_volatile
 
708
#endif
 
709
 
251
710
/* Defines for time function */
252
 
#define SCALE_SEC  100
253
 
#define SCALE_USEC  10000
254
 
#define MY_HOW_OFTEN_TO_ALARM  2  /* How often we want info on screen */
255
 
#define MY_HOW_OFTEN_TO_WRITE  1000  /* How often we want info on screen */
256
 
 
 
711
#define SCALE_SEC       100
 
712
#define SCALE_USEC      10000
 
713
#define MY_HOW_OFTEN_TO_ALARM   2       /* How often we want info on screen */
 
714
#define MY_HOW_OFTEN_TO_WRITE   1000    /* How often we want info on screen */
 
715
 
 
716
 
 
717
 
 
718
/*
 
719
  Define-funktions for reading and storing in machine independent format
 
720
  (low byte first)
 
721
*/
 
722
 
 
723
/* Optimized store functions for Intel x86 */
 
724
#if defined(__i386__)
 
725
#define sint2korr(A)    (*((int16 *) (A)))
 
726
#define sint3korr(A)    ((int32) ((((uchar) (A)[2]) & 128) ? \
 
727
                                  (((uint32) 255L << 24) | \
 
728
                                   (((uint32) (uchar) (A)[2]) << 16) |\
 
729
                                   (((uint32) (uchar) (A)[1]) << 8) | \
 
730
                                   ((uint32) (uchar) (A)[0])) : \
 
731
                                  (((uint32) (uchar) (A)[2]) << 16) |\
 
732
                                  (((uint32) (uchar) (A)[1]) << 8) | \
 
733
                                  ((uint32) (uchar) (A)[0])))
 
734
#define sint4korr(A)    (*((long *) (A)))
 
735
#define uint2korr(A)    (*((uint16 *) (A)))
 
736
#if defined(HAVE_purify)
 
737
#define uint3korr(A)    (uint32) (((uint32) ((uchar) (A)[0])) +\
 
738
                                  (((uint32) ((uchar) (A)[1])) << 8) +\
 
739
                                  (((uint32) ((uchar) (A)[2])) << 16))
 
740
#else
 
741
/*
 
742
   ATTENTION !
 
743
   
 
744
    Please, note, uint3korr reads 4 bytes (not 3) !
 
745
    It means, that you have to provide enough allocated space !
 
746
*/
 
747
#define uint3korr(A)    (long) (*((unsigned int *) (A)) & 0xFFFFFF)
 
748
#endif /* HAVE_purify */
 
749
#define uint4korr(A)    (*((uint32 *) (A)))
 
750
#define uint5korr(A)    ((uint64_t)(((uint32) ((uchar) (A)[0])) +\
 
751
                                    (((uint32) ((uchar) (A)[1])) << 8) +\
 
752
                                    (((uint32) ((uchar) (A)[2])) << 16) +\
 
753
                                    (((uint32) ((uchar) (A)[3])) << 24)) +\
 
754
                                    (((uint64_t) ((uchar) (A)[4])) << 32))
 
755
#define uint6korr(A)    ((uint64_t)(((uint32)    ((uchar) (A)[0]))          + \
 
756
                                     (((uint32)    ((uchar) (A)[1])) << 8)   + \
 
757
                                     (((uint32)    ((uchar) (A)[2])) << 16)  + \
 
758
                                     (((uint32)    ((uchar) (A)[3])) << 24)) + \
 
759
                         (((uint64_t) ((uchar) (A)[4])) << 32) +       \
 
760
                         (((uint64_t) ((uchar) (A)[5])) << 40))
 
761
#define uint8korr(A)    (*((uint64_t *) (A)))
 
762
#define sint8korr(A)    (*((int64_t *) (A)))
 
763
#define int2store(T,A)  *((uint16*) (T))= (uint16) (A)
 
764
#define int3store(T,A)  do { *(T)=  (uchar) ((A));\
 
765
                            *(T+1)=(uchar) (((uint) (A) >> 8));\
 
766
                            *(T+2)=(uchar) (((A) >> 16)); } while (0)
 
767
#define int4store(T,A)  *((long *) (T))= (long) (A)
 
768
#define int5store(T,A)  do { *(T)= (uchar)((A));\
 
769
                             *((T)+1)=(uchar) (((A) >> 8));\
 
770
                             *((T)+2)=(uchar) (((A) >> 16));\
 
771
                             *((T)+3)=(uchar) (((A) >> 24)); \
 
772
                             *((T)+4)=(uchar) (((A) >> 32)); } while(0)
 
773
#define int6store(T,A)  do { *(T)=    (uchar)((A));          \
 
774
                             *((T)+1)=(uchar) (((A) >> 8));  \
 
775
                             *((T)+2)=(uchar) (((A) >> 16)); \
 
776
                             *((T)+3)=(uchar) (((A) >> 24)); \
 
777
                             *((T)+4)=(uchar) (((A) >> 32)); \
 
778
                             *((T)+5)=(uchar) (((A) >> 40)); } while(0)
 
779
#define int8store(T,A)  *((uint64_t *) (T))= (uint64_t) (A)
 
780
 
 
781
typedef union {
 
782
  double v;
 
783
  long m[2];
 
784
} doubleget_union;
 
785
#define doubleget(V,M)  \
 
786
do { doubleget_union _tmp; \
 
787
     _tmp.m[0] = *((long*)(M)); \
 
788
     _tmp.m[1] = *(((long*) (M))+1); \
 
789
     (V) = _tmp.v; } while(0)
 
790
#define doublestore(T,V) do { *((long *) T) = ((doubleget_union *)&V)->m[0]; \
 
791
                             *(((long *) T)+1) = ((doubleget_union *)&V)->m[1]; \
 
792
                         } while (0)
 
793
#define float4get(V,M)   do { *((float *) &(V)) = *((float*) (M)); } while(0)
 
794
#define float8get(V,M)   doubleget((V),(M))
 
795
#define float4store(V,M) memcpy((uchar*) V,(uchar*) (&M),sizeof(float))
 
796
#define floatstore(T,V)  memcpy((uchar*)(T), (uchar*)(&V),sizeof(float))
 
797
#define floatget(V,M)    memcpy((uchar*) &V,(uchar*) (M),sizeof(float))
 
798
#define float8store(V,M) doublestore((V),(M))
 
799
#else
 
800
 
 
801
/*
 
802
  We're here if it's not a IA-32 architecture (Win32 and UNIX IA-32 defines
 
803
  were done before)
 
804
*/
 
805
#define sint2korr(A)    (int16) (((int16) ((uchar) (A)[0])) +\
 
806
                                 ((int16) ((int16) (A)[1]) << 8))
 
807
#define sint3korr(A)    ((int32) ((((uchar) (A)[2]) & 128) ? \
 
808
                                  (((uint32) 255L << 24) | \
 
809
                                   (((uint32) (uchar) (A)[2]) << 16) |\
 
810
                                   (((uint32) (uchar) (A)[1]) << 8) | \
 
811
                                   ((uint32) (uchar) (A)[0])) : \
 
812
                                  (((uint32) (uchar) (A)[2]) << 16) |\
 
813
                                  (((uint32) (uchar) (A)[1]) << 8) | \
 
814
                                  ((uint32) (uchar) (A)[0])))
 
815
#define sint4korr(A)    (int32) (((int32) ((uchar) (A)[0])) +\
 
816
                                (((int32) ((uchar) (A)[1]) << 8)) +\
 
817
                                (((int32) ((uchar) (A)[2]) << 16)) +\
 
818
                                (((int32) ((int16) (A)[3]) << 24)))
 
819
#define sint8korr(A)    (int64_t) uint8korr(A)
 
820
#define uint2korr(A)    (uint16) (((uint16) ((uchar) (A)[0])) +\
 
821
                                  ((uint16) ((uchar) (A)[1]) << 8))
 
822
#define uint3korr(A)    (uint32) (((uint32) ((uchar) (A)[0])) +\
 
823
                                  (((uint32) ((uchar) (A)[1])) << 8) +\
 
824
                                  (((uint32) ((uchar) (A)[2])) << 16))
 
825
#define uint4korr(A)    (uint32) (((uint32) ((uchar) (A)[0])) +\
 
826
                                  (((uint32) ((uchar) (A)[1])) << 8) +\
 
827
                                  (((uint32) ((uchar) (A)[2])) << 16) +\
 
828
                                  (((uint32) ((uchar) (A)[3])) << 24))
 
829
#define uint5korr(A)    ((uint64_t)(((uint32) ((uchar) (A)[0])) +\
 
830
                                    (((uint32) ((uchar) (A)[1])) << 8) +\
 
831
                                    (((uint32) ((uchar) (A)[2])) << 16) +\
 
832
                                    (((uint32) ((uchar) (A)[3])) << 24)) +\
 
833
                                    (((uint64_t) ((uchar) (A)[4])) << 32))
 
834
#define uint6korr(A)    ((uint64_t)(((uint32)    ((uchar) (A)[0]))          + \
 
835
                                     (((uint32)    ((uchar) (A)[1])) << 8)   + \
 
836
                                     (((uint32)    ((uchar) (A)[2])) << 16)  + \
 
837
                                     (((uint32)    ((uchar) (A)[3])) << 24)) + \
 
838
                         (((uint64_t) ((uchar) (A)[4])) << 32) +       \
 
839
                         (((uint64_t) ((uchar) (A)[5])) << 40))
 
840
#define uint8korr(A)    ((uint64_t)(((uint32) ((uchar) (A)[0])) +\
 
841
                                    (((uint32) ((uchar) (A)[1])) << 8) +\
 
842
                                    (((uint32) ((uchar) (A)[2])) << 16) +\
 
843
                                    (((uint32) ((uchar) (A)[3])) << 24)) +\
 
844
                        (((uint64_t) (((uint32) ((uchar) (A)[4])) +\
 
845
                                    (((uint32) ((uchar) (A)[5])) << 8) +\
 
846
                                    (((uint32) ((uchar) (A)[6])) << 16) +\
 
847
                                    (((uint32) ((uchar) (A)[7])) << 24))) <<\
 
848
                                    32))
 
849
#define int2store(T,A)       do { uint def_temp= (uint) (A) ;\
 
850
                                  *((uchar*) (T))=  (uchar)(def_temp); \
 
851
                                   *((uchar*) (T)+1)=(uchar)((def_temp >> 8)); \
 
852
                             } while(0)
 
853
#define int3store(T,A)       do { /*lint -save -e734 */\
 
854
                                  *((uchar*)(T))=(uchar) ((A));\
 
855
                                  *((uchar*) (T)+1)=(uchar) (((A) >> 8));\
 
856
                                  *((uchar*)(T)+2)=(uchar) (((A) >> 16)); \
 
857
                                  /*lint -restore */} while(0)
 
858
#define int4store(T,A)       do { *((char *)(T))=(char) ((A));\
 
859
                                  *(((char *)(T))+1)=(char) (((A) >> 8));\
 
860
                                  *(((char *)(T))+2)=(char) (((A) >> 16));\
 
861
                                  *(((char *)(T))+3)=(char) (((A) >> 24)); } while(0)
 
862
#define int5store(T,A)       do { *((char *)(T))=     (char)((A));  \
 
863
                                  *(((char *)(T))+1)= (char)(((A) >> 8)); \
 
864
                                  *(((char *)(T))+2)= (char)(((A) >> 16)); \
 
865
                                  *(((char *)(T))+3)= (char)(((A) >> 24)); \
 
866
                                  *(((char *)(T))+4)= (char)(((A) >> 32)); \
 
867
                                } while(0)
 
868
#define int6store(T,A)       do { *((char *)(T))=     (char)((A)); \
 
869
                                  *(((char *)(T))+1)= (char)(((A) >> 8)); \
 
870
                                  *(((char *)(T))+2)= (char)(((A) >> 16)); \
 
871
                                  *(((char *)(T))+3)= (char)(((A) >> 24)); \
 
872
                                  *(((char *)(T))+4)= (char)(((A) >> 32)); \
 
873
                                  *(((char *)(T))+5)= (char)(((A) >> 40)); \
 
874
                                } while(0)
 
875
#define int8store(T,A)       do { uint def_temp= (uint) (A), def_temp2= (uint) ((A) >> 32); \
 
876
                                  int4store((T),def_temp); \
 
877
                                  int4store((T+4),def_temp2); } while(0)
 
878
#ifdef WORDS_BIGENDIAN
 
879
#define float4store(T,A) do { *(T)= ((uchar *) &A)[3];\
 
880
                              *((T)+1)=(char) ((uchar *) &A)[2];\
 
881
                              *((T)+2)=(char) ((uchar *) &A)[1];\
 
882
                              *((T)+3)=(char) ((uchar *) &A)[0]; } while(0)
 
883
 
 
884
#define float4get(V,M)   do { float def_temp;\
 
885
                              ((uchar*) &def_temp)[0]=(M)[3];\
 
886
                              ((uchar*) &def_temp)[1]=(M)[2];\
 
887
                              ((uchar*) &def_temp)[2]=(M)[1];\
 
888
                              ((uchar*) &def_temp)[3]=(M)[0];\
 
889
                              (V)=def_temp; } while(0)
 
890
#define float8store(T,V) do { *(T)= ((uchar *) &V)[7];\
 
891
                              *((T)+1)=(char) ((uchar *) &V)[6];\
 
892
                              *((T)+2)=(char) ((uchar *) &V)[5];\
 
893
                              *((T)+3)=(char) ((uchar *) &V)[4];\
 
894
                              *((T)+4)=(char) ((uchar *) &V)[3];\
 
895
                              *((T)+5)=(char) ((uchar *) &V)[2];\
 
896
                              *((T)+6)=(char) ((uchar *) &V)[1];\
 
897
                              *((T)+7)=(char) ((uchar *) &V)[0]; } while(0)
 
898
 
 
899
#define float8get(V,M)   do { double def_temp;\
 
900
                              ((uchar*) &def_temp)[0]=(M)[7];\
 
901
                              ((uchar*) &def_temp)[1]=(M)[6];\
 
902
                              ((uchar*) &def_temp)[2]=(M)[5];\
 
903
                              ((uchar*) &def_temp)[3]=(M)[4];\
 
904
                              ((uchar*) &def_temp)[4]=(M)[3];\
 
905
                              ((uchar*) &def_temp)[5]=(M)[2];\
 
906
                              ((uchar*) &def_temp)[6]=(M)[1];\
 
907
                              ((uchar*) &def_temp)[7]=(M)[0];\
 
908
                              (V) = def_temp; } while(0)
 
909
#else
 
910
#define float4get(V,M)   memcpy_fixed((uchar*) &V,(uchar*) (M),sizeof(float))
 
911
#define float4store(V,M) memcpy_fixed((uchar*) V,(uchar*) (&M),sizeof(float))
 
912
 
 
913
#if defined(__FLOAT_WORD_ORDER) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN)
 
914
#define doublestore(T,V) do { *(((char*)T)+0)=(char) ((uchar *) &V)[4];\
 
915
                              *(((char*)T)+1)=(char) ((uchar *) &V)[5];\
 
916
                              *(((char*)T)+2)=(char) ((uchar *) &V)[6];\
 
917
                              *(((char*)T)+3)=(char) ((uchar *) &V)[7];\
 
918
                              *(((char*)T)+4)=(char) ((uchar *) &V)[0];\
 
919
                              *(((char*)T)+5)=(char) ((uchar *) &V)[1];\
 
920
                              *(((char*)T)+6)=(char) ((uchar *) &V)[2];\
 
921
                              *(((char*)T)+7)=(char) ((uchar *) &V)[3]; }\
 
922
                         while(0)
 
923
#define doubleget(V,M)   do { double def_temp;\
 
924
                              ((uchar*) &def_temp)[0]=(M)[4];\
 
925
                              ((uchar*) &def_temp)[1]=(M)[5];\
 
926
                              ((uchar*) &def_temp)[2]=(M)[6];\
 
927
                              ((uchar*) &def_temp)[3]=(M)[7];\
 
928
                              ((uchar*) &def_temp)[4]=(M)[0];\
 
929
                              ((uchar*) &def_temp)[5]=(M)[1];\
 
930
                              ((uchar*) &def_temp)[6]=(M)[2];\
 
931
                              ((uchar*) &def_temp)[7]=(M)[3];\
 
932
                              (V) = def_temp; } while(0)
 
933
#endif /* __FLOAT_WORD_ORDER */
 
934
 
 
935
#define float8get(V,M)   doubleget((V),(M))
 
936
#define float8store(V,M) doublestore((V),(M))
 
937
#endif /* WORDS_BIGENDIAN */
 
938
 
 
939
#endif /* __i386__ */
 
940
 
 
941
/*
 
942
  Macro for reading 32-bit integer from network byte order (big-endian)
 
943
  from unaligned memory location.
 
944
*/
 
945
#define int4net(A)        (int32) (((uint32) ((uchar) (A)[3]))        |\
 
946
                                  (((uint32) ((uchar) (A)[2])) << 8)  |\
 
947
                                  (((uint32) ((uchar) (A)[1])) << 16) |\
 
948
                                  (((uint32) ((uchar) (A)[0])) << 24))
 
949
/*
 
950
  Define-funktions for reading and storing in machine format from/to
 
951
  short/long to/from some place in memory V should be a (not
 
952
  register) variable, M is a pointer to byte
 
953
*/
 
954
 
 
955
#ifdef WORDS_BIGENDIAN
 
956
 
 
957
#define ushortget(V,M)  do { V = (uint16) (((uint16) ((uchar) (M)[1]))+\
 
958
                                 ((uint16) ((uint16) (M)[0]) << 8)); } while(0)
 
959
#define shortget(V,M)   do { V = (short) (((short) ((uchar) (M)[1]))+\
 
960
                                 ((short) ((short) (M)[0]) << 8)); } while(0)
 
961
#define longget(V,M)    do { int32 def_temp;\
 
962
                             ((uchar*) &def_temp)[0]=(M)[0];\
 
963
                             ((uchar*) &def_temp)[1]=(M)[1];\
 
964
                             ((uchar*) &def_temp)[2]=(M)[2];\
 
965
                             ((uchar*) &def_temp)[3]=(M)[3];\
 
966
                             (V)=def_temp; } while(0)
 
967
#define ulongget(V,M)   do { uint32 def_temp;\
 
968
                            ((uchar*) &def_temp)[0]=(M)[0];\
 
969
                            ((uchar*) &def_temp)[1]=(M)[1];\
 
970
                            ((uchar*) &def_temp)[2]=(M)[2];\
 
971
                            ((uchar*) &def_temp)[3]=(M)[3];\
 
972
                            (V)=def_temp; } while(0)
 
973
#define shortstore(T,A) do { uint def_temp=(uint) (A) ;\
 
974
                             *(((char*)T)+1)=(char)(def_temp); \
 
975
                             *(((char*)T)+0)=(char)(def_temp >> 8); } while(0)
 
976
#define longstore(T,A)  do { *(((char*)T)+3)=((A));\
 
977
                             *(((char*)T)+2)=(((A) >> 8));\
 
978
                             *(((char*)T)+1)=(((A) >> 16));\
 
979
                             *(((char*)T)+0)=(((A) >> 24)); } while(0)
 
980
 
 
981
#define floatget(V,M)    memcpy_fixed((uchar*) &V,(uchar*) (M),sizeof(float))
 
982
#define floatstore(T,V)  memcpy_fixed((uchar*) (T),(uchar*)(&V),sizeof(float))
 
983
#define doubleget(V,M)   memcpy_fixed((uchar*) &V,(uchar*) (M),sizeof(double))
 
984
#define doublestore(T,V) memcpy_fixed((uchar*) (T),(uchar*) &V,sizeof(double))
 
985
#define int64_tget(V,M) memcpy_fixed((uchar*) &V,(uchar*) (M),sizeof(uint64_t))
 
986
#define int64_tstore(T,V) memcpy_fixed((uchar*) (T),(uchar*) &V,sizeof(uint64_t))
 
987
 
 
988
#else
 
989
 
 
990
#define ushortget(V,M)  do { V = uint2korr(M); } while(0)
 
991
#define shortget(V,M)   do { V = sint2korr(M); } while(0)
 
992
#define longget(V,M)    do { V = sint4korr(M); } while(0)
 
993
#define ulongget(V,M)   do { V = uint4korr(M); } while(0)
 
994
#define shortstore(T,V) int2store(T,V)
 
995
#define longstore(T,V)  int4store(T,V)
 
996
#ifndef floatstore
 
997
#define floatstore(T,V)  memcpy_fixed((uchar*) (T),(uchar*) (&V),sizeof(float))
 
998
#define floatget(V,M)    memcpy_fixed((uchar*) &V, (uchar*) (M), sizeof(float))
 
999
#endif
 
1000
#ifndef doubleget
 
1001
#define doubleget(V,M)   memcpy_fixed((uchar*) &V,(uchar*) (M),sizeof(double))
 
1002
#define doublestore(T,V) memcpy_fixed((uchar*) (T),(uchar*) &V,sizeof(double))
 
1003
#endif /* doubleget */
 
1004
#define int64_tget(V,M) memcpy_fixed((uchar*) &V,(uchar*) (M),sizeof(uint64_t))
 
1005
#define int64_tstore(T,V) memcpy_fixed((uchar*) (T),(uchar*) &V,sizeof(uint64_t))
 
1006
 
 
1007
#endif /* WORDS_BIGENDIAN */
 
1008
 
 
1009
/* my_sprintf  was here. RIP */
257
1010
 
258
1011
#if defined(HAVE_CHARSET_utf8mb3) || defined(HAVE_CHARSET_utf8mb4)
259
 
#define DRIZZLE_UNIVERSAL_CLIENT_CHARSET "utf8"
 
1012
#define MYSQL_UNIVERSAL_CLIENT_CHARSET "utf8"
260
1013
#else
261
 
#define DRIZZLE_UNIVERSAL_CLIENT_CHARSET DRIZZLE_DEFAULT_CHARSET_NAME
 
1014
#define MYSQL_UNIVERSAL_CLIENT_CHARSET MYSQL_DEFAULT_CHARSET_NAME
262
1015
#endif
263
1016
 
 
1017
#ifdef HAVE_DLOPEN
 
1018
#if defined(HAVE_DLFCN_H)
264
1019
#include <dlfcn.h>
 
1020
#endif
 
1021
#endif
265
1022
 
266
1023
/* FreeBSD 2.2.2 does not define RTLD_NOW) */
267
1024
#ifndef RTLD_NOW
268
1025
#define RTLD_NOW 1
269
1026
#endif
270
1027
 
271
 
#define cmax(a, b)       ((a) > (b) ? (a) : (b))
272
 
#define cmin(a, b)       ((a) < (b) ? (a) : (b))
 
1028
#ifndef HAVE_DLERROR
 
1029
#define dlerror() ""
 
1030
#endif
 
1031
 
 
1032
 
 
1033
/*
 
1034
 *  Include standard definitions of operator new and delete.
 
1035
 */
 
1036
#ifdef __cplusplus
 
1037
#include <new>
 
1038
#endif
273
1039
 
274
1040
/* Length of decimal number represented by INT32. */
275
1041
#define MY_INT32_NUM_DECIMAL_DIGITS 11
277
1043
/* Length of decimal number represented by INT64. */
278
1044
#define MY_INT64_NUM_DECIMAL_DIGITS 21
279
1045
 
 
1046
#ifdef _cplusplus
 
1047
#include <string>
 
1048
#endif
 
1049
 
 
1050
/* Define some useful general macros (should be done after all headers). */
 
1051
#if !defined(max)
 
1052
#define max(a, b)       ((a) > (b) ? (a) : (b))
 
1053
#define min(a, b)       ((a) < (b) ? (a) : (b))
 
1054
#endif  
280
1055
/*
281
1056
  Only Linux is known to need an explicit sync of the directory to make sure a
282
1057
  file creation/deletion/renaming in(from,to) this directory durable.
285
1060
#define NEED_EXPLICIT_SYNC_DIR 1
286
1061
#endif
287
1062
 
288
 
#include <libdrizzle/gettext.h>
289
 
 
290
 
#endif /* DRIZZLE_SERVER_GLOBAL_H */
 
1063
#endif /* my_global_h */