~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to include/my_global.h

Fixed sql_builtin.cc.in... stupid generated files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 */
 
15
 
 
16
/* This is the include file that should be included 'first' in every C file. */
 
17
 
 
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
 
39
 
 
40
#if defined(i386) && !defined(__i386__)
 
41
#define __i386__
 
42
#endif
 
43
 
 
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
 
 
139
 
 
140
/*
 
141
  Temporary solution to solve bug#7156. Include "sys/types.h" before
 
142
  the thread headers, else the function madvise() will not be defined
 
143
*/
 
144
#if defined(HAVE_SYS_TYPES_H) && ( defined(sun) || defined(__sun) )
 
145
#include <sys/types.h>
 
146
#endif
 
147
 
 
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
#if defined(HAVE_STDINT_H)
 
218
/* Need to include this _before_ stdlib, so that all defines are right */
 
219
/* We are mixing C and C++, so we wan the C limit macros in the C++ too */
 
220
/* Enable some extra C99 extensions */
 
221
#define __STDC_LIMIT_MACROS
 
222
#define __STDC_FORMAT_MACROS
 
223
#include <inttypes.h>
 
224
#include <stdint.h>
 
225
#endif
 
226
 
 
227
#ifndef stdin
 
228
#include <stdio.h>
 
229
#endif
 
230
#ifdef HAVE_STDLIB_H
 
231
#include <stdlib.h>
 
232
#endif
 
233
#ifdef HAVE_STDDEF_H
 
234
#include <stddef.h>
 
235
#endif
 
236
 
 
237
#include <math.h>
 
238
#ifdef HAVE_LIMITS_H
 
239
#include <limits.h>
 
240
#endif
 
241
 
 
242
#ifdef HAVE_SYS_TYPES_H
 
243
#include <sys/types.h>
 
244
#endif
 
245
#ifdef HAVE_FCNTL_H
 
246
#include <fcntl.h>
 
247
#endif
 
248
#ifdef HAVE_SYS_TIMEB_H
 
249
#include <sys/timeb.h>                          /* Avoid warnings on SCO */
 
250
#endif
 
251
#if TIME_WITH_SYS_TIME
 
252
# include <sys/time.h>
 
253
# include <time.h>
 
254
#else
 
255
# if HAVE_SYS_TIME_H
 
256
#  include <sys/time.h>
 
257
# else
 
258
#  include <time.h>
 
259
# endif
 
260
#endif /* TIME_WITH_SYS_TIME */
 
261
#ifdef HAVE_UNISTD_H
 
262
#include <unistd.h>
 
263
#endif
 
264
#if defined(__cplusplus) && defined(NO_CPLUSPLUS_ALLOCA)
 
265
#undef HAVE_ALLOCA
 
266
#undef HAVE_ALLOCA_H
 
267
#endif
 
268
#ifdef HAVE_ALLOCA_H
 
269
#include <alloca.h>
 
270
#endif
 
271
 
 
272
#include <errno.h>                              /* Recommended by debian */
 
273
 
 
274
#if defined(HAVE_STDBOOL_H)
 
275
#include <stdbool.h>
 
276
#endif
 
277
 
 
278
 
 
279
/*
 
280
  A lot of our programs uses asserts, so better to always include it
 
281
*/
 
282
#include <assert.h>
 
283
 
 
284
/* an assert that works at compile-time. only for constant expression */
 
285
#ifndef __GNUC__
 
286
#define compile_time_assert(X)  do { } while(0)
 
287
#else
 
288
#define compile_time_assert(X)                                  \
 
289
  do                                                            \
 
290
  {                                                             \
 
291
    char compile_time_assert[(X) ? 1 : -1]                      \
 
292
                             __attribute__ ((unused));          \
 
293
  } while(0)
 
294
#endif
 
295
 
 
296
/* Declare madvise where it is not declared for C++, like Solaris */
 
297
#if HAVE_MADVISE && !defined(HAVE_DECL_MADVISE) && defined(__cplusplus)
 
298
extern "C" int madvise(void *addr, size_t len, int behav);
 
299
#endif
 
300
 
 
301
/* We can not live without the following defines */
 
302
 
 
303
#define USE_MYFUNC 1            /* Must use syscall indirection */
 
304
#define MASTER 1                /* Compile without unireg */
 
305
#define ENGLISH 1               /* Messages in English */
 
306
#define POSIX_MISTAKE 1         /* regexp: Fix stupid spec error */
 
307
/* Do not define for ultra sparcs */
 
308
#define USE_BMOVE512 1          /* Use this unless system bmove is faster */
 
309
 
 
310
#define QUOTE_ARG(x)            #x      /* Quote argument (before cpp) */
 
311
#define STRINGIFY_ARG(x) QUOTE_ARG(x)   /* Quote argument, after cpp */
 
312
/* Does the system remember a signal handler after a signal ? */
 
313
#ifndef HAVE_BSD_SIGNALS
 
314
#define DONT_REMEMBER_SIGNAL
 
315
#endif
 
316
 
 
317
/* Define void to stop lint from generating "null effekt" comments */
 
318
#ifndef DONT_DEFINE_VOID
 
319
#ifdef _lint
 
320
int     __void__;
 
321
#define VOID(X)         (__void__ = (int) (X))
 
322
#else
 
323
#undef VOID
 
324
#define VOID(X)         (X)
 
325
#endif
 
326
#endif /* DONT_DEFINE_VOID */
 
327
 
 
328
#if !defined(HAVE_UINT)
 
329
#undef HAVE_UINT
 
330
#define HAVE_UINT
 
331
typedef unsigned int uint;
 
332
typedef unsigned short ushort;
 
333
#endif
 
334
 
 
335
#define CMP_NUM(a,b)    (((a) < (b)) ? -1 : ((a) == (b)) ? 0 : 1)
 
336
#define sgn(a)          (((a) < 0) ? -1 : ((a) > 0) ? 1 : 0)
 
337
#define swap_variables(t, a, b) { register t dummy; dummy= a; a= b; b= dummy; }
 
338
#define test(a)         ((a) ? 1 : 0)
 
339
#define set_if_bigger(a,b)  do { if ((a) < (b)) (a)=(b); } while(0)
 
340
#define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0)
 
341
#define test_all_bits(a,b) (((a) & (b)) == (b))
 
342
#define set_bits(type, bit_count) (sizeof(type)*8 <= (bit_count) ? ~(type) 0 : ((((type) 1) << (bit_count)) - (type) 1))
 
343
#define array_elements(A) ((uint32_t) (sizeof(A)/sizeof(A[0])))
 
344
#ifndef HAVE_RINT
 
345
#define rint(A) floor((A)+(((A) < 0)? -0.5 : 0.5))
 
346
#endif
 
347
 
 
348
#if defined(__GNUC__)
 
349
#define function_volatile       volatile
 
350
#define my_reinterpret_cast(A) reinterpret_cast<A>
 
351
#define my_const_cast(A) const_cast<A>
 
352
# ifndef GCC_VERSION
 
353
#  define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
 
354
# endif
 
355
#elif !defined(my_reinterpret_cast)
 
356
#define my_reinterpret_cast(A) (A)
 
357
#define my_const_cast(A) (A)
 
358
#endif
 
359
 
 
360
#include <my_attribute.h>
 
361
 
 
362
/* From old s-system.h */
 
363
 
 
364
/*
 
365
  Support macros for non ansi & other old compilers. Since such
 
366
  things are no longer supported we do nothing. We keep then since
 
367
  some of our code may still be needed to upgrade old customers.
 
368
*/
 
369
#define _VARARGS(X) X
 
370
#define _STATIC_VARARGS(X) X
 
371
#define _PC(X)  X
 
372
 
 
373
#define MIN_ARRAY_SIZE  0       /* Zero or One. Gcc allows zero*/
 
374
#define ASCII_BITS_USED 8       /* Bit char used */
 
375
 
 
376
/* Some types that is different between systems */
 
377
 
 
378
typedef int     File;           /* File descriptor */
 
379
#ifndef Socket_defined
 
380
typedef int     my_socket;      /* File descriptor for sockets */
 
381
#define INVALID_SOCKET -1
 
382
#endif
 
383
/* Type for fuctions that handles signals */
 
384
#define sig_handler RETSIGTYPE
 
385
C_MODE_START
 
386
typedef void    (*sig_return)(void);/* Returns type from signal */
 
387
typedef int     (*qsort_cmp)(const void *,const void *);
 
388
typedef int     (*qsort_cmp2)(void*, const void *,const void *);
 
389
C_MODE_END
 
390
#define qsort_t RETQSORTTYPE    /* Broken GCC cant handle typedef !!!! */
 
391
#ifdef HAVE_SYS_SOCKET_H
 
392
#include <sys/socket.h>
 
393
#endif
 
394
typedef SOCKET_SIZE_TYPE size_socket;
 
395
 
 
396
#ifndef SOCKOPT_OPTLEN_TYPE
 
397
#define SOCKOPT_OPTLEN_TYPE size_socket
 
398
#endif
 
399
 
 
400
/* file create flags */
 
401
 
 
402
#ifndef O_SHARE                 /* Probably not windows */
 
403
#define O_SHARE         0       /* Flag to my_open for shared files */
 
404
#endif /* O_SHARE */
 
405
 
 
406
#ifndef O_BINARY
 
407
#define O_BINARY        0       /* Flag to my_open for binary files */
 
408
#endif
 
409
 
 
410
#ifndef FILE_BINARY
 
411
#define FILE_BINARY     O_BINARY /* Flag to my_fopen for binary streams */
 
412
#endif
 
413
 
 
414
#define F_TO_EOF        0L      /* Param to lockf() to lock rest of file */
 
415
 
 
416
#ifndef O_TEMPORARY
 
417
#define O_TEMPORARY     0
 
418
#endif
 
419
#ifndef O_SHORT_LIVED
 
420
#define O_SHORT_LIVED   0
 
421
#endif
 
422
#ifndef O_NOFOLLOW
 
423
#define O_NOFOLLOW      0
 
424
#endif
 
425
 
 
426
/* #define USE_RECORD_LOCK      */
 
427
 
 
428
        /* Unsigned types supported by the compiler */
 
429
#define UNSINT8                 /* unsigned int8_t (char) */
 
430
#define UNSINT16                /* unsigned int16_t */
 
431
#define UNSINT32                /* unsigned int32_t */
 
432
 
 
433
        /* General constants */
 
434
#define SC_MAXWIDTH     256     /* Max width of screen (for error messages) */
 
435
#define FN_LEN          256     /* Max file name len */
 
436
#define FN_HEADLEN      253     /* Max length of filepart of file name */
 
437
#define FN_EXTLEN       20      /* Max length of extension (part of FN_LEN) */
 
438
#define FN_REFLEN       512     /* Max length of full path-name */
 
439
#define FN_EXTCHAR      '.'
 
440
#define FN_HOMELIB      '~'     /* ~/ is used as abbrev for home dir */
 
441
#define FN_CURLIB       '.'     /* ./ is used as abbrev for current dir */
 
442
#define FN_PARENTDIR    ".."    /* Parent directory; Must be a string */
 
443
 
 
444
#ifndef FN_LIBCHAR
 
445
#define FN_LIBCHAR      '/'
 
446
#define FN_ROOTDIR      "/"
 
447
#endif
 
448
#define MY_NFILE        64      /* This is only used to save filenames */
 
449
#ifndef OS_FILE_LIMIT
 
450
#define OS_FILE_LIMIT   65535
 
451
#endif
 
452
 
 
453
/* #define EXT_IN_LIBNAME     */
 
454
/* #define FN_NO_CASE_SENCE   */
 
455
/* #define FN_UPPER_CASE TRUE */
 
456
 
 
457
/*
 
458
  Io buffer size; Must be a power of 2 and a multiple of 512. May be
 
459
  smaller what the disk page size. This influences the speed of the
 
460
  isam btree library. eg to big to slow.
 
461
*/
 
462
#define IO_SIZE                 4096
 
463
/*
 
464
  How much overhead does malloc have. The code often allocates
 
465
  something like 1024-MALLOC_OVERHEAD bytes
 
466
*/
 
467
#define MALLOC_OVERHEAD 8
 
468
 
 
469
        /* get memory in huncs */
 
470
#define ONCE_ALLOC_INIT         (uint) (4096-MALLOC_OVERHEAD)
 
471
        /* Typical record cash */
 
472
#define RECORD_CACHE_SIZE       (uint) (64*1024-MALLOC_OVERHEAD)
 
473
        /* Typical key cash */
 
474
#define KEY_CACHE_SIZE          (uint) (8*1024*1024-MALLOC_OVERHEAD)
 
475
        /* Default size of a key cache block  */
 
476
#define KEY_CACHE_BLOCK_SIZE    (uint) 1024
 
477
 
 
478
 
 
479
        /* Some things that this system doesn't have */
 
480
 
 
481
/* Some defines of functions for portability */
 
482
 
 
483
#undef remove           /* Crashes MySQL on SCO 5.0.0 */
 
484
#define closesocket(A)  close(A)
 
485
#ifndef uint64_t2double
 
486
#define uint64_t2double(A) ((double) (uint64_t) (A))
 
487
#define my_off_t2double(A)  ((double) (my_off_t) (A))
 
488
#endif
 
489
 
 
490
#ifndef offsetof
 
491
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
 
492
#endif
 
493
#define ulong_to_double(X) ((double) (ulong) (X))
 
494
#define SET_STACK_SIZE(X)       /* Not needed on real machines */
 
495
 
 
496
#ifndef STACK_DIRECTION
 
497
#error "please add -DSTACK_DIRECTION=1 or -1 to your CPPFLAGS"
 
498
#endif
 
499
 
 
500
#if !defined(HAVE_STRTOK_R)
 
501
#define strtok_r(A,B,C) strtok((A),(B))
 
502
#endif
 
503
 
 
504
#ifdef HAVE_FLOAT_H
 
505
#include <float.h>
 
506
#else
 
507
#if !defined(FLT_MIN)
 
508
#define FLT_MIN         ((float)1.40129846432481707e-45)
 
509
#endif
 
510
#if !defined(FLT_MAX)
 
511
#define FLT_MAX         ((float)3.40282346638528860e+38)
 
512
#endif
 
513
#endif
 
514
 
 
515
/* From limits.h instead */
 
516
#ifndef DBL_MIN
 
517
#define DBL_MIN         4.94065645841246544e-324
 
518
#endif
 
519
#ifndef DBL_MAX
 
520
#define DBL_MAX         1.79769313486231470e+308
 
521
#endif
 
522
#ifndef SIZE_T_MAX
 
523
#define SIZE_T_MAX ~((size_t) 0)
 
524
#endif
 
525
 
 
526
#ifndef isfinite
 
527
#ifdef HAVE_FINITE
 
528
#define isfinite(x) finite(x)
 
529
#else
 
530
#define finite(x) (1.0 / fabs(x) > 0.0)
 
531
#endif /* HAVE_FINITE */
 
532
#endif /* isfinite */
 
533
 
 
534
#ifndef HAVE_ISNAN
 
535
#define isnan(x) ((x) != (x))
 
536
#endif
 
537
 
 
538
#ifdef HAVE_ISINF
 
539
/* isinf() can be used in both C and C++ code */
 
540
#define my_isinf(X) isinf(X)
 
541
#else
 
542
#define my_isinf(X) (!isfinite(X) && !isnan(X))
 
543
#endif
 
544
 
 
545
/* Define missing math constants. */
 
546
#ifndef M_PI
 
547
#define M_PI 3.14159265358979323846
 
548
#endif
 
549
#ifndef M_E
 
550
#define M_E 2.7182818284590452354
 
551
#endif
 
552
#ifndef M_LN2
 
553
#define M_LN2 0.69314718055994530942
 
554
#endif
 
555
 
 
556
/*
 
557
  Max size that must be added to a so that we know Size to make
 
558
  adressable obj.
 
559
*/
 
560
#if SIZEOF_CHARP == 4
 
561
typedef int32_t         my_ptrdiff_t;
 
562
#else
 
563
typedef int64_t         my_ptrdiff_t;
 
564
#endif
 
565
 
 
566
#define MY_ALIGN(A,L)   (((A) + (L) - 1) & ~((L) - 1))
 
567
#define ALIGN_SIZE(A)   MY_ALIGN((A),sizeof(double))
 
568
/* Size to make adressable obj. */
 
569
#define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A),sizeof(t)))
 
570
                         /* Offset of field f in structure t */
 
571
#define OFFSET(t, f)    ((size_t)(char *)&((t *)0)->f)
 
572
#define ADD_TO_PTR(ptr,size,type) (type) ((uchar*) (ptr)+size)
 
573
#define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((uchar*) (A) - (uchar*) (B))
 
574
 
 
575
#define MY_DIV_UP(A, B) (((A) + (B) - 1) / (B))
 
576
#define MY_ALIGNED_BYTE_ARRAY(N, S, T) T N[MY_DIV_UP(S, sizeof(T))]
 
577
 
 
578
/*
 
579
  Custom version of standard offsetof() macro which can be used to get
 
580
  offsets of members in class for non-POD types (according to the current
 
581
  version of C++ standard offsetof() macro can't be used in such cases and
 
582
  attempt to do so causes warnings to be emitted, OTOH in many cases it is
 
583
  still OK to assume that all instances of the class has the same offsets
 
584
  for the same members).
 
585
 
 
586
  This is temporary solution which should be removed once File_parser class
 
587
  and related routines are refactored.
 
588
*/
 
589
 
 
590
#define my_offsetof(TYPE, MEMBER) \
 
591
        ((size_t)((char *)&(((TYPE *)0x10)->MEMBER) - (char*)0x10))
 
592
 
 
593
#define NullS           (char *) 0
 
594
 
 
595
#define STDCALL
 
596
 
 
597
/* Typdefs for easyier portability */
 
598
 
 
599
#ifndef HAVE_UCHAR
 
600
typedef unsigned char   uchar;  /* Short for unsigned char */
 
601
#endif
 
602
 
 
603
#if !defined(HAVE_ULONG) && !defined(__USE_MISC)
 
604
typedef unsigned long ulong;              /* Short for unsigned long */
 
605
#endif
 
606
 
 
607
#define MY_ERRPTR ((void*)(intptr)1)
 
608
 
 
609
#if SIZEOF_OFF_T > 4 
 
610
typedef uint64_t my_off_t;
 
611
#else
 
612
typedef unsigned long my_off_t;
 
613
#endif 
 
614
#define MY_FILEPOS_ERROR        (~(my_off_t) 0)
 
615
 
 
616
typedef off_t os_off_t;
 
617
 
 
618
#define socket_errno    errno
 
619
#define closesocket(A)  close(A)
 
620
#define SOCKET_EINTR    EINTR
 
621
#define SOCKET_EAGAIN   EAGAIN
 
622
#define SOCKET_ETIMEDOUT SOCKET_EINTR
 
623
#define SOCKET_EWOULDBLOCK EWOULDBLOCK
 
624
#define SOCKET_EADDRINUSE EADDRINUSE
 
625
#define SOCKET_ENFILE   ENFILE
 
626
#define SOCKET_EMFILE   EMFILE
 
627
 
 
628
typedef uint8_t         int7;   /* Most effective integer 0 <= x <= 127 */
 
629
typedef short           int15;  /* Most effective integer 0 <= x <= 32767 */
 
630
typedef int             myf;    /* Type of MyFlags in my_funcs */
 
631
typedef char            my_bool; /* Small bool */
 
632
#if !defined(bool) && (!defined(HAVE_BOOL) || !defined(__cplusplus))
 
633
typedef char            bool;   /* Ordinary boolean values 0 1 */
 
634
#endif
 
635
        /* Macros for converting *constants* to the right type */
 
636
#define INT8(v)         (int8_t) (v)
 
637
#define INT16(v)        (int16_t) (v)
 
638
#define INT32(v)        (int32_t) (v)
 
639
#define MYF(v)          (myf) (v)
 
640
 
 
641
/* Defines for time function */
 
642
#define SCALE_SEC       100
 
643
#define SCALE_USEC      10000
 
644
#define MY_HOW_OFTEN_TO_ALARM   2       /* How often we want info on screen */
 
645
#define MY_HOW_OFTEN_TO_WRITE   1000    /* How often we want info on screen */
 
646
 
 
647
 
 
648
 
 
649
/*
 
650
  Define-funktions for reading and storing in machine independent format
 
651
  (low byte first)
 
652
*/
 
653
 
 
654
/* Optimized store functions for Intel x86 */
 
655
#if defined(__i386__)
 
656
#define sint2korr(A)    (*((int16_t *) (A)))
 
657
#define sint3korr(A)    ((int32_t) ((((uchar) (A)[2]) & 128) ? \
 
658
                                  (((uint32_t) 255L << 24) | \
 
659
                                   (((uint32_t) (uchar) (A)[2]) << 16) |\
 
660
                                   (((uint32_t) (uchar) (A)[1]) << 8) | \
 
661
                                   ((uint32_t) (uchar) (A)[0])) : \
 
662
                                  (((uint32_t) (uchar) (A)[2]) << 16) |\
 
663
                                  (((uint32_t) (uchar) (A)[1]) << 8) | \
 
664
                                  ((uint32_t) (uchar) (A)[0])))
 
665
#define sint4korr(A)    (*((long *) (A)))
 
666
#define uint2korr(A)    (*((uint16_t *) (A)))
 
667
#if defined(HAVE_purify)
 
668
#define uint3korr(A)    (uint32_t) (((uint32_t) ((uchar) (A)[0])) +\
 
669
                                  (((uint32_t) ((uchar) (A)[1])) << 8) +\
 
670
                                  (((uint32_t) ((uchar) (A)[2])) << 16))
 
671
#else
 
672
/*
 
673
   ATTENTION !
 
674
   
 
675
    Please, note, uint3korr reads 4 bytes (not 3) !
 
676
    It means, that you have to provide enough allocated space !
 
677
*/
 
678
#define uint3korr(A)    (long) (*((unsigned int *) (A)) & 0xFFFFFF)
 
679
#endif /* HAVE_purify */
 
680
#define uint4korr(A)    (*((uint32_t *) (A)))
 
681
#define uint5korr(A)    ((uint64_t)(((uint32_t) ((uchar) (A)[0])) +\
 
682
                                    (((uint32_t) ((uchar) (A)[1])) << 8) +\
 
683
                                    (((uint32_t) ((uchar) (A)[2])) << 16) +\
 
684
                                    (((uint32_t) ((uchar) (A)[3])) << 24)) +\
 
685
                                    (((uint64_t) ((uchar) (A)[4])) << 32))
 
686
#define uint6korr(A)    ((uint64_t)(((uint32_t)    ((uchar) (A)[0]))          + \
 
687
                                     (((uint32_t)    ((uchar) (A)[1])) << 8)   + \
 
688
                                     (((uint32_t)    ((uchar) (A)[2])) << 16)  + \
 
689
                                     (((uint32_t)    ((uchar) (A)[3])) << 24)) + \
 
690
                         (((uint64_t) ((uchar) (A)[4])) << 32) +       \
 
691
                         (((uint64_t) ((uchar) (A)[5])) << 40))
 
692
#define uint8korr(A)    (*((uint64_t *) (A)))
 
693
#define sint8korr(A)    (*((int64_t *) (A)))
 
694
#define int2store(T,A)  *((uint16_t*) (T))= (uint16_t) (A)
 
695
#define int3store(T,A)  do { *(T)=  (uchar) ((A));\
 
696
                            *(T+1)=(uchar) (((uint) (A) >> 8));\
 
697
                            *(T+2)=(uchar) (((A) >> 16)); } while (0)
 
698
#define int4store(T,A)  *((long *) (T))= (long) (A)
 
699
#define int5store(T,A)  do { *(T)= (uchar)((A));\
 
700
                             *((T)+1)=(uchar) (((A) >> 8));\
 
701
                             *((T)+2)=(uchar) (((A) >> 16));\
 
702
                             *((T)+3)=(uchar) (((A) >> 24)); \
 
703
                             *((T)+4)=(uchar) (((A) >> 32)); } while(0)
 
704
#define int6store(T,A)  do { *(T)=    (uchar)((A));          \
 
705
                             *((T)+1)=(uchar) (((A) >> 8));  \
 
706
                             *((T)+2)=(uchar) (((A) >> 16)); \
 
707
                             *((T)+3)=(uchar) (((A) >> 24)); \
 
708
                             *((T)+4)=(uchar) (((A) >> 32)); \
 
709
                             *((T)+5)=(uchar) (((A) >> 40)); } while(0)
 
710
#define int8store(T,A)  *((uint64_t *) (T))= (uint64_t) (A)
 
711
 
 
712
typedef union {
 
713
  double v;
 
714
  long m[2];
 
715
} doubleget_union;
 
716
#define doubleget(V,M)  \
 
717
do { doubleget_union _tmp; \
 
718
     _tmp.m[0] = *((long*)(M)); \
 
719
     _tmp.m[1] = *(((long*) (M))+1); \
 
720
     (V) = _tmp.v; } while(0)
 
721
#define doublestore(T,V) do { *((long *) T) = ((doubleget_union *)&V)->m[0]; \
 
722
                             *(((long *) T)+1) = ((doubleget_union *)&V)->m[1]; \
 
723
                         } while (0)
 
724
#define float4get(V,M)   do { *((float *) &(V)) = *((float*) (M)); } while(0)
 
725
#define float8get(V,M)   doubleget((V),(M))
 
726
#define float4store(V,M) memcpy((uchar*) V,(uchar*) (&M),sizeof(float))
 
727
#define floatstore(T,V)  memcpy((uchar*)(T), (uchar*)(&V),sizeof(float))
 
728
#define floatget(V,M)    memcpy((uchar*) &V,(uchar*) (M),sizeof(float))
 
729
#define float8store(V,M) doublestore((V),(M))
 
730
#else
 
731
 
 
732
/*
 
733
  We're here if it's not a IA-32 architecture (Win32 and UNIX IA-32 defines
 
734
  were done before)
 
735
*/
 
736
#define sint2korr(A)    (int16_t) (((int16_t) ((uchar) (A)[0])) +\
 
737
                                 ((int16_t) ((int16_t) (A)[1]) << 8))
 
738
#define sint3korr(A)    ((int32_t) ((((uchar) (A)[2]) & 128) ? \
 
739
                                  (((uint32_t) 255L << 24) | \
 
740
                                   (((uint32_t) (uchar) (A)[2]) << 16) |\
 
741
                                   (((uint32_t) (uchar) (A)[1]) << 8) | \
 
742
                                   ((uint32_t) (uchar) (A)[0])) : \
 
743
                                  (((uint32_t) (uchar) (A)[2]) << 16) |\
 
744
                                  (((uint32_t) (uchar) (A)[1]) << 8) | \
 
745
                                  ((uint32_t) (uchar) (A)[0])))
 
746
#define sint4korr(A)    (int32_t) (((int32_t) ((uchar) (A)[0])) +\
 
747
                                (((int32_t) ((uchar) (A)[1]) << 8)) +\
 
748
                                (((int32_t) ((uchar) (A)[2]) << 16)) +\
 
749
                                (((int32_t) ((int16_t) (A)[3]) << 24)))
 
750
#define sint8korr(A)    (int64_t) uint8korr(A)
 
751
#define uint2korr(A)    (uint16_t) (((uint16_t) ((uchar) (A)[0])) +\
 
752
                                  ((uint16_t) ((uchar) (A)[1]) << 8))
 
753
#define uint3korr(A)    (uint32_t) (((uint32_t) ((uchar) (A)[0])) +\
 
754
                                  (((uint32_t) ((uchar) (A)[1])) << 8) +\
 
755
                                  (((uint32_t) ((uchar) (A)[2])) << 16))
 
756
#define uint4korr(A)    (uint32_t) (((uint32_t) ((uchar) (A)[0])) +\
 
757
                                  (((uint32_t) ((uchar) (A)[1])) << 8) +\
 
758
                                  (((uint32_t) ((uchar) (A)[2])) << 16) +\
 
759
                                  (((uint32_t) ((uchar) (A)[3])) << 24))
 
760
#define uint5korr(A)    ((uint64_t)(((uint32_t) ((uchar) (A)[0])) +\
 
761
                                    (((uint32_t) ((uchar) (A)[1])) << 8) +\
 
762
                                    (((uint32_t) ((uchar) (A)[2])) << 16) +\
 
763
                                    (((uint32_t) ((uchar) (A)[3])) << 24)) +\
 
764
                                    (((uint64_t) ((uchar) (A)[4])) << 32))
 
765
#define uint6korr(A)    ((uint64_t)(((uint32_t)    ((uchar) (A)[0]))          + \
 
766
                                     (((uint32_t)    ((uchar) (A)[1])) << 8)   + \
 
767
                                     (((uint32_t)    ((uchar) (A)[2])) << 16)  + \
 
768
                                     (((uint32_t)    ((uchar) (A)[3])) << 24)) + \
 
769
                         (((uint64_t) ((uchar) (A)[4])) << 32) +       \
 
770
                         (((uint64_t) ((uchar) (A)[5])) << 40))
 
771
#define uint8korr(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) (((uint32_t) ((uchar) (A)[4])) +\
 
776
                                    (((uint32_t) ((uchar) (A)[5])) << 8) +\
 
777
                                    (((uint32_t) ((uchar) (A)[6])) << 16) +\
 
778
                                    (((uint32_t) ((uchar) (A)[7])) << 24))) <<\
 
779
                                    32))
 
780
#define int2store(T,A)       do { uint def_temp= (uint) (A) ;\
 
781
                                  *((uchar*) (T))=  (uchar)(def_temp); \
 
782
                                   *((uchar*) (T)+1)=(uchar)((def_temp >> 8)); \
 
783
                             } while(0)
 
784
#define int3store(T,A)       do { /*lint -save -e734 */\
 
785
                                  *((uchar*)(T))=(uchar) ((A));\
 
786
                                  *((uchar*) (T)+1)=(uchar) (((A) >> 8));\
 
787
                                  *((uchar*)(T)+2)=(uchar) (((A) >> 16)); \
 
788
                                  /*lint -restore */} while(0)
 
789
#define int4store(T,A)       do { *((char *)(T))=(char) ((A));\
 
790
                                  *(((char *)(T))+1)=(char) (((A) >> 8));\
 
791
                                  *(((char *)(T))+2)=(char) (((A) >> 16));\
 
792
                                  *(((char *)(T))+3)=(char) (((A) >> 24)); } while(0)
 
793
#define int5store(T,A)       do { *((char *)(T))=     (char)((A));  \
 
794
                                  *(((char *)(T))+1)= (char)(((A) >> 8)); \
 
795
                                  *(((char *)(T))+2)= (char)(((A) >> 16)); \
 
796
                                  *(((char *)(T))+3)= (char)(((A) >> 24)); \
 
797
                                  *(((char *)(T))+4)= (char)(((A) >> 32)); \
 
798
                                } while(0)
 
799
#define int6store(T,A)       do { *((char *)(T))=     (char)((A)); \
 
800
                                  *(((char *)(T))+1)= (char)(((A) >> 8)); \
 
801
                                  *(((char *)(T))+2)= (char)(((A) >> 16)); \
 
802
                                  *(((char *)(T))+3)= (char)(((A) >> 24)); \
 
803
                                  *(((char *)(T))+4)= (char)(((A) >> 32)); \
 
804
                                  *(((char *)(T))+5)= (char)(((A) >> 40)); \
 
805
                                } while(0)
 
806
#define int8store(T,A)       do { uint def_temp= (uint) (A), def_temp2= (uint) ((A) >> 32); \
 
807
                                  int4store((T),def_temp); \
 
808
                                  int4store((T+4),def_temp2); } while(0)
 
809
#ifdef WORDS_BIGENDIAN
 
810
#define float4store(T,A) do { *(T)= ((uchar *) &A)[3];\
 
811
                              *((T)+1)=(char) ((uchar *) &A)[2];\
 
812
                              *((T)+2)=(char) ((uchar *) &A)[1];\
 
813
                              *((T)+3)=(char) ((uchar *) &A)[0]; } while(0)
 
814
 
 
815
#define float4get(V,M)   do { float def_temp;\
 
816
                              ((uchar*) &def_temp)[0]=(M)[3];\
 
817
                              ((uchar*) &def_temp)[1]=(M)[2];\
 
818
                              ((uchar*) &def_temp)[2]=(M)[1];\
 
819
                              ((uchar*) &def_temp)[3]=(M)[0];\
 
820
                              (V)=def_temp; } while(0)
 
821
#define float8store(T,V) do { *(T)= ((uchar *) &V)[7];\
 
822
                              *((T)+1)=(char) ((uchar *) &V)[6];\
 
823
                              *((T)+2)=(char) ((uchar *) &V)[5];\
 
824
                              *((T)+3)=(char) ((uchar *) &V)[4];\
 
825
                              *((T)+4)=(char) ((uchar *) &V)[3];\
 
826
                              *((T)+5)=(char) ((uchar *) &V)[2];\
 
827
                              *((T)+6)=(char) ((uchar *) &V)[1];\
 
828
                              *((T)+7)=(char) ((uchar *) &V)[0]; } while(0)
 
829
 
 
830
#define float8get(V,M)   do { double def_temp;\
 
831
                              ((uchar*) &def_temp)[0]=(M)[7];\
 
832
                              ((uchar*) &def_temp)[1]=(M)[6];\
 
833
                              ((uchar*) &def_temp)[2]=(M)[5];\
 
834
                              ((uchar*) &def_temp)[3]=(M)[4];\
 
835
                              ((uchar*) &def_temp)[4]=(M)[3];\
 
836
                              ((uchar*) &def_temp)[5]=(M)[2];\
 
837
                              ((uchar*) &def_temp)[6]=(M)[1];\
 
838
                              ((uchar*) &def_temp)[7]=(M)[0];\
 
839
                              (V) = def_temp; } while(0)
 
840
#else
 
841
#define float4get(V,M)   memcpy_fixed((uchar*) &V,(uchar*) (M),sizeof(float))
 
842
#define float4store(V,M) memcpy_fixed((uchar*) V,(uchar*) (&M),sizeof(float))
 
843
 
 
844
#if defined(__FLOAT_WORD_ORDER) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN)
 
845
#define doublestore(T,V) do { *(((char*)T)+0)=(char) ((uchar *) &V)[4];\
 
846
                              *(((char*)T)+1)=(char) ((uchar *) &V)[5];\
 
847
                              *(((char*)T)+2)=(char) ((uchar *) &V)[6];\
 
848
                              *(((char*)T)+3)=(char) ((uchar *) &V)[7];\
 
849
                              *(((char*)T)+4)=(char) ((uchar *) &V)[0];\
 
850
                              *(((char*)T)+5)=(char) ((uchar *) &V)[1];\
 
851
                              *(((char*)T)+6)=(char) ((uchar *) &V)[2];\
 
852
                              *(((char*)T)+7)=(char) ((uchar *) &V)[3]; }\
 
853
                         while(0)
 
854
#define doubleget(V,M)   do { double def_temp;\
 
855
                              ((uchar*) &def_temp)[0]=(M)[4];\
 
856
                              ((uchar*) &def_temp)[1]=(M)[5];\
 
857
                              ((uchar*) &def_temp)[2]=(M)[6];\
 
858
                              ((uchar*) &def_temp)[3]=(M)[7];\
 
859
                              ((uchar*) &def_temp)[4]=(M)[0];\
 
860
                              ((uchar*) &def_temp)[5]=(M)[1];\
 
861
                              ((uchar*) &def_temp)[6]=(M)[2];\
 
862
                              ((uchar*) &def_temp)[7]=(M)[3];\
 
863
                              (V) = def_temp; } while(0)
 
864
#endif /* __FLOAT_WORD_ORDER */
 
865
 
 
866
#define float8get(V,M)   doubleget((V),(M))
 
867
#define float8store(V,M) doublestore((V),(M))
 
868
#endif /* WORDS_BIGENDIAN */
 
869
 
 
870
#endif /* __i386__ */
 
871
 
 
872
/*
 
873
  Macro for reading 32-bit integer from network byte order (big-endian)
 
874
  from unaligned memory location.
 
875
*/
 
876
#define int4net(A)        (int32_t) (((uint32_t) ((uchar) (A)[3]))        |\
 
877
                                  (((uint32_t) ((uchar) (A)[2])) << 8)  |\
 
878
                                  (((uint32_t) ((uchar) (A)[1])) << 16) |\
 
879
                                  (((uint32_t) ((uchar) (A)[0])) << 24))
 
880
/*
 
881
  Define-funktions for reading and storing in machine format from/to
 
882
  short/long to/from some place in memory V should be a (not
 
883
  register) variable, M is a pointer to byte
 
884
*/
 
885
 
 
886
#ifdef WORDS_BIGENDIAN
 
887
 
 
888
#define ushortget(V,M)  do { V = (uint16_t) (((uint16_t) ((uchar) (M)[1]))+\
 
889
                                 ((uint16_t) ((uint16_t) (M)[0]) << 8)); } while(0)
 
890
#define shortget(V,M)   do { V = (short) (((short) ((uchar) (M)[1]))+\
 
891
                                 ((short) ((short) (M)[0]) << 8)); } while(0)
 
892
#define longget(V,M)    do { int32_t def_temp;\
 
893
                             ((uchar*) &def_temp)[0]=(M)[0];\
 
894
                             ((uchar*) &def_temp)[1]=(M)[1];\
 
895
                             ((uchar*) &def_temp)[2]=(M)[2];\
 
896
                             ((uchar*) &def_temp)[3]=(M)[3];\
 
897
                             (V)=def_temp; } while(0)
 
898
#define ulongget(V,M)   do { uint32_t def_temp;\
 
899
                            ((uchar*) &def_temp)[0]=(M)[0];\
 
900
                            ((uchar*) &def_temp)[1]=(M)[1];\
 
901
                            ((uchar*) &def_temp)[2]=(M)[2];\
 
902
                            ((uchar*) &def_temp)[3]=(M)[3];\
 
903
                            (V)=def_temp; } while(0)
 
904
#define shortstore(T,A) do { uint def_temp=(uint) (A) ;\
 
905
                             *(((char*)T)+1)=(char)(def_temp); \
 
906
                             *(((char*)T)+0)=(char)(def_temp >> 8); } while(0)
 
907
#define longstore(T,A)  do { *(((char*)T)+3)=((A));\
 
908
                             *(((char*)T)+2)=(((A) >> 8));\
 
909
                             *(((char*)T)+1)=(((A) >> 16));\
 
910
                             *(((char*)T)+0)=(((A) >> 24)); } while(0)
 
911
 
 
912
#define floatget(V,M)    memcpy_fixed((uchar*) &V,(uchar*) (M),sizeof(float))
 
913
#define floatstore(T,V)  memcpy_fixed((uchar*) (T),(uchar*)(&V),sizeof(float))
 
914
#define doubleget(V,M)   memcpy_fixed((uchar*) &V,(uchar*) (M),sizeof(double))
 
915
#define doublestore(T,V) memcpy_fixed((uchar*) (T),(uchar*) &V,sizeof(double))
 
916
#define int64_tget(V,M) memcpy_fixed((uchar*) &V,(uchar*) (M),sizeof(uint64_t))
 
917
#define int64_tstore(T,V) memcpy_fixed((uchar*) (T),(uchar*) &V,sizeof(uint64_t))
 
918
 
 
919
#else
 
920
 
 
921
#define ushortget(V,M)  do { V = uint2korr(M); } while(0)
 
922
#define shortget(V,M)   do { V = sint2korr(M); } while(0)
 
923
#define longget(V,M)    do { V = sint4korr(M); } while(0)
 
924
#define ulongget(V,M)   do { V = uint4korr(M); } while(0)
 
925
#define shortstore(T,V) int2store(T,V)
 
926
#define longstore(T,V)  int4store(T,V)
 
927
#ifndef floatstore
 
928
#define floatstore(T,V)  memcpy_fixed((uchar*) (T),(uchar*) (&V),sizeof(float))
 
929
#define floatget(V,M)    memcpy_fixed((uchar*) &V, (uchar*) (M), sizeof(float))
 
930
#endif
 
931
#ifndef doubleget
 
932
#define doubleget(V,M)   memcpy_fixed((uchar*) &V,(uchar*) (M),sizeof(double))
 
933
#define doublestore(T,V) memcpy_fixed((uchar*) (T),(uchar*) &V,sizeof(double))
 
934
#endif /* doubleget */
 
935
#define int64_tget(V,M) memcpy_fixed((uchar*) &V,(uchar*) (M),sizeof(uint64_t))
 
936
#define int64_tstore(T,V) memcpy_fixed((uchar*) (T),(uchar*) &V,sizeof(uint64_t))
 
937
 
 
938
#endif /* WORDS_BIGENDIAN */
 
939
 
 
940
/* my_sprintf  was here. RIP */
 
941
 
 
942
#if defined(HAVE_CHARSET_utf8mb3) || defined(HAVE_CHARSET_utf8mb4)
 
943
#define MYSQL_UNIVERSAL_CLIENT_CHARSET "utf8"
 
944
#else
 
945
#define MYSQL_UNIVERSAL_CLIENT_CHARSET MYSQL_DEFAULT_CHARSET_NAME
 
946
#endif
 
947
 
 
948
#include <dlfcn.h>
 
949
 
 
950
/* FreeBSD 2.2.2 does not define RTLD_NOW) */
 
951
#ifndef RTLD_NOW
 
952
#define RTLD_NOW 1
 
953
#endif
 
954
 
 
955
/*
 
956
 *  Include standard definitions of operator new and delete.
 
957
 */
 
958
#ifdef __cplusplus
 
959
#include <new>
 
960
#endif
 
961
 
 
962
/* Length of decimal number represented by INT32. */
 
963
#define MY_INT32_NUM_DECIMAL_DIGITS 11
 
964
 
 
965
/* Length of decimal number represented by INT64. */
 
966
#define MY_INT64_NUM_DECIMAL_DIGITS 21
 
967
 
 
968
#ifdef _cplusplus
 
969
#include <string>
 
970
#endif
 
971
 
 
972
/* Define some useful general macros (should be done after all headers). */
 
973
#if !defined(max)
 
974
#define max(a, b)       ((a) > (b) ? (a) : (b))
 
975
#define min(a, b)       ((a) < (b) ? (a) : (b))
 
976
#endif  
 
977
/*
 
978
  Only Linux is known to need an explicit sync of the directory to make sure a
 
979
  file creation/deletion/renaming in(from,to) this directory durable.
 
980
*/
 
981
#ifdef TARGET_OS_LINUX
 
982
#define NEED_EXPLICIT_SYNC_DIR 1
 
983
#endif
 
984
 
 
985
#endif /* my_global_h */