root/trunk/dep/include/mysql/my_global.h @ 2

Revision 2, 42.6 kB (checked in by yumileroy, 17 years ago)

[svn] * Proper SVN structure

Original author: Neo2003
Date: 2008-10-02 16:23:55-05:00

Line 
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#ifndef EMBEDDED_LIBRARY
22#define HAVE_REPLICATION
23#define HAVE_EXTERNAL_CLIENT
24#endif
25
26#if defined( __EMX__) && !defined( MYSQL_SERVER)
27/* moved here to use below VOID macro redefinition */
28#define INCL_BASE
29#define INCL_NOPMAPI
30#include <os2.h>
31#endif /* __EMX__ */
32
33#ifdef __CYGWIN__
34/* We use a Unix API, so pretend it's not Windows */
35#undef WIN
36#undef WIN32
37#undef _WIN
38#undef _WIN32
39#undef _WIN64
40#undef __WIN__
41#undef __WIN32__
42#define HAVE_ERRNO_AS_DEFINE
43#endif /* __CYGWIN__ */
44
45#if defined(__QNXNTO__) && !defined(FD_SETSIZE)
46#define FD_SETSIZE 1024         /* Max number of file descriptor bits in
47                                   fd_set, used when calling 'select'
48                                   Must be defined before including
49                                   "sys/select.h" and "sys/time.h"
50                                 */
51#endif
52
53
54/* to make command line shorter we'll define USE_PRAGMA_INTERFACE here */
55#ifdef USE_PRAGMA_IMPLEMENTATION
56#define USE_PRAGMA_INTERFACE
57#endif
58
59#if defined(i386) && !defined(__i386__)
60#define __i386__
61#endif
62
63/* Macros to make switching between C and C++ mode easier */
64#ifdef __cplusplus
65#define C_MODE_START    extern "C" {
66#define C_MODE_END      }
67#else
68#define C_MODE_START
69#define C_MODE_END
70#endif
71
72#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32)
73#include <config-win.h>
74#elif defined(OS2)
75#include <config-os2.h>
76#elif defined(__NETWARE__)
77#include <my_config.h>
78#include <config-netware.h>
79#if defined(__cplusplus) && defined(inline)
80#undef inline                           /* fix configure problem */
81#endif
82#else
83#include <my_config.h>
84#if defined(__cplusplus) && defined(inline)
85#undef inline                           /* fix configure problem */
86#endif
87#endif /* _WIN32... */
88
89/* Make it easier to add conditionl code for windows */
90#ifdef __WIN__
91#define IF_WIN(A,B) (A)
92#else
93#define IF_WIN(A,B) (B)
94#endif
95
96
97/* Some defines to avoid ifdefs in the code */
98#ifndef NETWARE_YIELD
99#define NETWARE_YIELD
100#define NETWARE_SET_SCREEN_MODE(A)
101#endif
102
103/* Workaround for _LARGE_FILES and _LARGE_FILE_API incompatibility on AIX */
104#if defined(_AIX) && defined(_LARGE_FILE_API)
105#undef _LARGE_FILE_API
106#endif
107
108/*
109  The macros below are used to allow build of Universal/fat binaries of
110  MySQL and MySQL applications under darwin.
111*/
112#if defined(__APPLE__) && defined(__MACH__)
113#  undef SIZEOF_CHARP
114#  undef SIZEOF_SHORT
115#  undef SIZEOF_INT
116#  undef SIZEOF_LONG
117#  undef SIZEOF_LONG_LONG
118#  undef SIZEOF_OFF_T
119#  undef WORDS_BIGENDIAN
120#  define SIZEOF_SHORT 2
121#  define SIZEOF_INT 4
122#  define SIZEOF_LONG_LONG 8
123#  define SIZEOF_OFF_T 8
124#  if defined(__i386__) || defined(__ppc__)
125#    define SIZEOF_CHARP 4
126#    define SIZEOF_LONG 4
127#  elif defined(__x86_64__) || defined(__ppc64__)
128#    define SIZEOF_CHARP 8
129#    define SIZEOF_LONG 8
130#  else
131#    error Building FAT binary for an unknown architecture.
132#  endif
133#  if defined(__ppc__) || defined(__ppc64__)
134#    define WORDS_BIGENDIAN
135#  endif
136#endif /* defined(__APPLE__) && defined(__MACH__) */
137
138
139/*
140  The macros below are borrowed from include/linux/compiler.h in the
141  Linux kernel. Use them to indicate the likelyhood of the truthfulness
142  of a condition. This serves two purposes - newer versions of gcc will be
143  able to optimize for branch predication, which could yield siginficant
144  performance gains in frequently executed sections of the code, and the
145  other reason to use them is for documentation
146*/
147
148#if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
149#define __builtin_expect(x, expected_value) (x)
150#endif
151
152#define likely(x)       __builtin_expect((x),1)
153#define unlikely(x)     __builtin_expect((x),0)
154
155
156/* Fix problem with S_ISLNK() on Linux */
157#if defined(TARGET_OS_LINUX) || defined(__GLIBC__)
158#undef  _GNU_SOURCE
159#define _GNU_SOURCE 1
160#endif
161
162/*
163  Temporary solution to solve bug#7156. Include "sys/types.h" before
164  the thread headers, else the function madvise() will not be defined
165*/
166#if defined(HAVE_SYS_TYPES_H) && ( defined(sun) || defined(__sun) )
167#include <sys/types.h>
168#endif
169
170/* The client defines this to avoid all thread code */
171#if defined(UNDEF_THREADS_HACK)
172#undef THREAD
173#undef HAVE_mit_thread
174#undef HAVE_LINUXTHREADS
175#undef HAVE_NPTL
176#undef HAVE_UNIXWARE7_THREADS
177#endif
178
179#ifdef HAVE_THREADS_WITHOUT_SOCKETS
180/* MIT pthreads does not work with unix sockets */
181#undef HAVE_SYS_UN_H
182#endif
183
184#define __EXTENSIONS__ 1        /* We want some extension */
185#ifndef __STDC_EXT__
186#define __STDC_EXT__ 1          /* To get large file support on hpux */
187#endif
188
189/*
190  Solaris 9 include file <sys/feature_tests.h> refers to X/Open document
191
192    System Interfaces and Headers, Issue 5
193
194  saying we should define _XOPEN_SOURCE=500 to get POSIX.1c prototypes,
195  but apparently other systems (namely FreeBSD) don't agree.
196
197  On a newer Solaris 10, the above file recognizes also _XOPEN_SOURCE=600.
198  Furthermore, it tests that if a program requires older standard
199  (_XOPEN_SOURCE<600 or _POSIX_C_SOURCE<200112L) it cannot be
200  run on a new compiler (that defines _STDC_C99) and issues an #error.
201  It's also an #error if a program requires new standard (_XOPEN_SOURCE=600
202  or _POSIX_C_SOURCE=200112L) and a compiler does not define _STDC_C99.
203
204  To add more to this mess, Sun Studio C compiler defines _STDC_C99 while
205  C++ compiler does not!
206
207  So, in a desperate attempt to get correct prototypes for both
208  C and C++ code, we define either _XOPEN_SOURCE=600 or _XOPEN_SOURCE=500
209  depending on the compiler's announced C standard support.
210
211  Cleaner solutions are welcome.
212*/
213#ifdef __sun
214#if __STDC_VERSION__ - 0 >= 199901L
215#define _XOPEN_SOURCE 600
216#else
217#define _XOPEN_SOURCE 500
218#endif
219#endif
220
221#if defined(THREAD) && !defined(__WIN__) && !defined(OS2)
222#ifndef _POSIX_PTHREAD_SEMANTICS
223#define _POSIX_PTHREAD_SEMANTICS /* We want posix threads */
224#endif
225
226#if !defined(SCO)
227#define _REENTRANT      1       /* Some thread libraries require this */
228#endif
229#if !defined(_THREAD_SAFE) && !defined(_AIX)
230#define _THREAD_SAFE            /* Required for OSF1 */
231#endif
232#ifndef HAVE_mit_thread
233#ifdef HAVE_UNIXWARE7_THREADS
234#include <thread.h>
235#else
236#if defined(HPUX10) || defined(HPUX11)
237C_MODE_START                    /* HPUX needs this, signal.h bug */
238#include <pthread.h>
239C_MODE_END
240#else
241#include <pthread.h>            /* AIX must have this included first */
242#endif
243#endif /* HAVE_UNIXWARE7_THREADS */
244#endif /* HAVE_mit_thread */
245#if !defined(SCO) && !defined(_REENTRANT)
246#define _REENTRANT      1       /* Threads requires reentrant code */
247#endif
248#endif /* THREAD */
249
250/* Go around some bugs in different OS and compilers */
251#ifdef _AIX                     /* By soren@t.dk */
252#define _H_STRINGS
253#define _SYS_STREAM_H
254/* #define _AIX32_CURSES */     /* XXX: this breaks AIX 4.3.3 (others?). */
255#define ulonglong2double(A) my_ulonglong2double(A)
256#define my_off_t2double(A)  my_ulonglong2double(A)
257C_MODE_START
258double my_ulonglong2double(unsigned long long A);
259C_MODE_END
260#endif /* _AIX */
261
262#ifdef HAVE_BROKEN_SNPRINTF     /* HPUX 10.20 don't have this defined */
263#undef HAVE_SNPRINTF
264#endif
265#ifdef HAVE_BROKEN_PREAD
266/*
267  pread()/pwrite() are not 64 bit safe on HP-UX 11.0 without
268  installing the kernel patch PHKL_20349 or greater
269*/
270#undef HAVE_PREAD
271#undef HAVE_PWRITE
272#endif
273#if defined(HAVE_BROKEN_INLINE) && !defined(__cplusplus)
274#undef inline
275#define inline
276#endif
277
278#ifdef UNDEF_HAVE_GETHOSTBYNAME_R               /* For OSF4.x */
279#undef HAVE_GETHOSTBYNAME_R
280#endif
281#ifdef UNDEF_HAVE_INITGROUPS                    /* For AIX 4.3 */
282#undef HAVE_INITGROUPS
283#endif
284
285/* gcc/egcs issues */
286
287#if defined(__GNUC) && defined(__EXCEPTIONS)
288#error "Please add -fno-exceptions to CXXFLAGS and reconfigure/recompile"
289#endif
290
291
292/* Fix a bug in gcc 2.8.0 on IRIX 6.2 */
293#if SIZEOF_LONG == 4 && defined(__LONG_MAX__) && (__GNUC__ == 2 && __GNUC_MINOR__ == 8)
294#undef __LONG_MAX__             /* Is a longlong value in gcc 2.8.0 ??? */
295#define __LONG_MAX__ 2147483647
296#endif
297
298/* egcs 1.1.2 has a problem with memcpy on Alpha */
299#if defined(__GNUC__) && defined(__alpha__) && ! (__GNUC__ > 2 || (__GNUC__ == 2 &&  __GNUC_MINOR__ >= 95))
300#define BAD_MEMCPY
301#endif
302
303#if defined(_lint) && !defined(lint)
304#define lint
305#endif
306#if SIZEOF_LONG_LONG > 4 && !defined(_LONG_LONG)
307#define _LONG_LONG 1            /* For AIX string library */
308#endif
309
310#ifndef stdin
311#include <stdio.h>
312#endif
313#ifdef HAVE_STDLIB_H
314#include <stdlib.h>
315#endif
316#ifdef HAVE_STDDEF_H
317#include <stddef.h>
318#endif
319
320#include <math.h>
321#ifdef HAVE_LIMITS_H
322#include <limits.h>
323#endif
324#ifdef HAVE_FLOAT_H
325#include <float.h>
326#endif
327
328#ifdef HAVE_SYS_TYPES_H
329#include <sys/types.h>
330#endif
331#ifdef HAVE_FCNTL_H
332#include <fcntl.h>
333#endif
334#ifdef HAVE_SYS_TIMEB_H
335#include <sys/timeb.h>                          /* Avoid warnings on SCO */
336#endif
337#if TIME_WITH_SYS_TIME
338# include <sys/time.h>
339# include <time.h>
340#else
341# if HAVE_SYS_TIME_H
342#  include <sys/time.h>
343# else
344#  include <time.h>
345# endif
346#endif /* TIME_WITH_SYS_TIME */
347#ifdef HAVE_UNISTD_H
348#include <unistd.h>
349#endif
350#if defined(__cplusplus) && defined(NO_CPLUSPLUS_ALLOCA)
351#undef HAVE_ALLOCA
352#undef HAVE_ALLOCA_H
353#endif
354#ifdef HAVE_ALLOCA_H
355#include <alloca.h>
356#endif
357#ifdef HAVE_ATOMIC_ADD
358#define new my_arg_new
359#define need_to_restore_new 1
360C_MODE_START
361#include <asm/atomic.h>
362C_MODE_END
363#ifdef need_to_restore_new /* probably safer than #ifdef new */
364#undef new
365#undef need_to_restore_new
366#endif
367#endif
368#include <errno.h>                              /* Recommended by debian */
369/* We need the following to go around a problem with openssl on solaris */
370#if defined(HAVE_CRYPT_H)
371#include <crypt.h>
372#endif
373
374/*
375  A lot of our programs uses asserts, so better to always include it
376  This also fixes a problem when people uses DBUG_ASSERT without including
377  assert.h
378*/
379#include <assert.h>
380
381/* Go around some bugs in different OS and compilers */
382#if defined(_HPUX_SOURCE) && defined(HAVE_SYS_STREAM_H)
383#include <sys/stream.h>         /* HPUX 10.20 defines ulong here. UGLY !!! */
384#define HAVE_ULONG
385#endif
386#ifdef DONT_USE_FINITE          /* HPUX 11.x has is_finite() */
387#undef HAVE_FINITE
388#endif
389#if defined(HPUX10) && defined(_LARGEFILE64_SOURCE) && defined(THREAD)
390/* Fix bug in setrlimit */
391#undef setrlimit
392#define setrlimit cma_setrlimit64
393#endif
394/* Declare madvise where it is not declared for C++, like Solaris */
395#if HAVE_MADVISE && !HAVE_DECL_MADVISE && defined(__cplusplus)
396extern "C" int madvise(void *addr, size_t len, int behav);
397#endif
398
399#ifdef __QNXNTO__
400/* This has to be after include limits.h */
401#define HAVE_ERRNO_AS_DEFINE
402#define HAVE_FCNTL_LOCK
403#undef  HAVE_FINITE
404#undef  LONGLONG_MIN            /* These get wrongly defined in QNX 6.2 */
405#undef  LONGLONG_MAX            /* standard system library 'limits.h' */
406#ifdef __cplusplus
407#ifndef HAVE_RINT
408#define HAVE_RINT
409#endif                          /* rint() and isnan() functions are not */
410#define rint(a) std::rint(a)    /* visible in C++ scope due to an error */
411#define isnan(a) std::isnan(a)  /* in the usr/include/math.h on QNX     */
412#endif
413#endif
414
415/* We can not live without the following defines */
416
417#define USE_MYFUNC 1            /* Must use syscall indirection */
418#define MASTER 1                /* Compile without unireg */
419#define ENGLISH 1               /* Messages in English */
420#define POSIX_MISTAKE 1         /* regexp: Fix stupid spec error */
421#define USE_REGEX 1             /* We want the use the regex library */
422/* Do not define for ultra sparcs */
423#ifndef OS2
424#define USE_BMOVE512 1          /* Use this unless system bmove is faster */
425#endif
426
427#define QUOTE_ARG(x)            #x      /* Quote argument (before cpp) */
428#define STRINGIFY_ARG(x) QUOTE_ARG(x)   /* Quote argument, after cpp */
429
430/* Paranoid settings. Define I_AM_PARANOID if you are paranoid */
431#ifdef I_AM_PARANOID
432#define DONT_ALLOW_USER_CHANGE 1
433#define DONT_USE_MYSQL_PWD 1
434#endif
435
436/* Does the system remember a signal handler after a signal ? */
437#ifndef HAVE_BSD_SIGNALS
438#define DONT_REMEMBER_SIGNAL
439#endif
440
441/* Define void to stop lint from generating "null effekt" comments */
442#ifndef DONT_DEFINE_VOID
443#ifdef _lint
444int     __void__;
445#define VOID(X)         (__void__ = (int) (X))
446#else
447#undef VOID
448#define VOID(X)         (X)
449#endif
450#endif /* DONT_DEFINE_VOID */
451
452#if defined(_lint) || defined(FORCE_INIT_OF_VARS)
453#define LINT_INIT(var)  var=0                   /* No uninitialize-warning */
454#else
455#define LINT_INIT(var)
456#endif
457
458#if defined(_lint) || defined(FORCE_INIT_OF_VARS) || defined(HAVE_purify)
459#define PURIFY_OR_LINT_INIT(var) var=0
460#else
461#define PURIFY_OR_LINT_INIT(var)
462#endif
463
464/* Define some useful general macros */
465#if !defined(max)
466#define max(a, b)       ((a) > (b) ? (a) : (b))
467#define min(a, b)       ((a) < (b) ? (a) : (b))
468#endif
469
470#if defined(__EMX__) || !defined(HAVE_UINT)
471#undef HAVE_UINT
472#define HAVE_UINT
473typedef unsigned int uint;
474typedef unsigned short ushort;
475#endif
476
477#define CMP_NUM(a,b)    (((a) < (b)) ? -1 : ((a) == (b)) ? 0 : 1)
478#define sgn(a)          (((a) < 0) ? -1 : ((a) > 0) ? 1 : 0)
479#define swap_variables(t, a, b) { register t dummy; dummy= a; a= b; b= dummy; }
480#define test(a)         ((a) ? 1 : 0)
481#define set_if_bigger(a,b)  do { if ((a) < (b)) (a)=(b); } while(0)
482#define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0)
483#define test_all_bits(a,b) (((a) & (b)) == (b))
484#define set_bits(type, bit_count) (sizeof(type)*8 <= (bit_count) ? ~(type) 0 : ((((type) 1) << (bit_count)) - (type) 1))
485#define array_elements(A) ((uint) (sizeof(A)/sizeof(A[0])))
486#ifndef HAVE_RINT
487#define rint(A) floor((A)+(((A) < 0)? -0.5 : 0.5))
488#endif
489
490/* Define some general constants */
491#ifndef TRUE
492#define TRUE            (1)     /* Logical true */
493#define FALSE           (0)     /* Logical false */
494#endif
495
496#if defined(__GNUC__)
497#define function_volatile       volatile
498#define my_reinterpret_cast(A) reinterpret_cast<A>
499#define my_const_cast(A) const_cast<A>
500# ifndef GCC_VERSION
501#  define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
502# endif
503#elif !defined(my_reinterpret_cast)
504#define my_reinterpret_cast(A) (A)
505#define my_const_cast(A) (A)
506#endif
507
508#include <my_attribute.h>
509
510/*
511  Wen using the embedded library, users might run into link problems,
512  duplicate declaration of __cxa_pure_virtual, solved by declaring it a
513  weak symbol.
514*/
515#if defined(USE_MYSYS_NEW) && ! defined(DONT_DECLARE_CXA_PURE_VIRTUAL)
516C_MODE_START
517int __cxa_pure_virtual () __attribute__ ((weak));
518C_MODE_END
519#endif
520
521/* From old s-system.h */
522
523/*
524  Support macros for non ansi & other old compilers. Since such
525  things are no longer supported we do nothing. We keep then since
526  some of our code may still be needed to upgrade old customers.
527*/
528#define _VARARGS(X) X
529#define _STATIC_VARARGS(X) X
530#define _PC(X)  X
531
532#if defined(DBUG_ON) && defined(DBUG_OFF)
533#undef DBUG_OFF
534#endif
535
536#if defined(_lint) && !defined(DBUG_OFF)
537#define DBUG_OFF
538#endif
539
540#include <my_dbug.h>
541
542#define MIN_ARRAY_SIZE  0       /* Zero or One. Gcc allows zero*/
543#define ASCII_BITS_USED 8       /* Bit char used */
544#define NEAR_F                  /* No near function handling */
545
546/* Some types that is different between systems */
547
548typedef int     File;           /* File descriptor */
549#ifndef Socket_defined
550typedef int     my_socket;      /* File descriptor for sockets */
551#define INVALID_SOCKET -1
552#endif
553/* Type for fuctions that handles signals */
554#define sig_handler RETSIGTYPE
555C_MODE_START
556typedef void    (*sig_return)();/* Returns type from signal */
557C_MODE_END
558#if defined(__GNUC__) && !defined(_lint)
559typedef char    pchar;          /* Mixed prototypes can take char */
560typedef char    puchar;         /* Mixed prototypes can take char */
561typedef char    pbool;          /* Mixed prototypes can take char */
562typedef short   pshort;         /* Mixed prototypes can take short int */
563typedef float   pfloat;         /* Mixed prototypes can take float */
564#else
565typedef int     pchar;          /* Mixed prototypes can't take char */
566typedef uint    puchar;         /* Mixed prototypes can't take char */
567typedef int     pbool;          /* Mixed prototypes can't take char */
568typedef int     pshort;         /* Mixed prototypes can't take short int */
569typedef double  pfloat;         /* Mixed prototypes can't take float */
570#endif
571C_MODE_START
572typedef int     (*qsort_cmp)(const void *,const void *);
573typedef int     (*qsort_cmp2)(void*, const void *,const void *);
574C_MODE_END
575#ifdef HAVE_mit_thread
576#define qsort_t void
577#undef QSORT_TYPE_IS_VOID
578#define QSORT_TYPE_IS_VOID
579#else
580#define qsort_t RETQSORTTYPE    /* Broken GCC cant handle typedef !!!! */
581#endif
582#ifdef HAVE_mit_thread
583#define size_socket socklen_t   /* Type of last arg to accept */
584#else
585#ifdef HAVE_SYS_SOCKET_H
586#include <sys/socket.h>
587#endif
588typedef SOCKET_SIZE_TYPE size_socket;
589#endif
590
591#ifndef SOCKOPT_OPTLEN_TYPE
592#define SOCKOPT_OPTLEN_TYPE size_socket
593#endif
594
595/* file create flags */
596
597#ifndef O_SHARE                 /* Probably not windows */
598#define O_SHARE         0       /* Flag to my_open for shared files */
599#ifndef O_BINARY
600#define O_BINARY        0       /* Flag to my_open for binary files */
601#endif
602#ifndef FILE_BINARY
603#define FILE_BINARY     O_BINARY /* Flag to my_fopen for binary streams */
604#endif
605#ifdef HAVE_FCNTL
606#define HAVE_FCNTL_LOCK
607#define F_TO_EOF        0L      /* Param to lockf() to lock rest of file */
608#endif
609#endif /* O_SHARE */
610
611#ifndef O_TEMPORARY
612#define O_TEMPORARY     0
613#endif
614#ifndef O_SHORT_LIVED
615#define O_SHORT_LIVED   0
616#endif
617#ifndef O_NOFOLLOW
618#define O_NOFOLLOW      0
619#endif
620
621/* additional file share flags for win32 */
622#ifdef __WIN__
623#define _SH_DENYRWD     0x110    /* deny read/write mode & delete */
624#define _SH_DENYWRD     0x120    /* deny write mode & delete      */
625#define _SH_DENYRDD     0x130    /* deny read mode & delete       */
626#define _SH_DENYDEL     0x140    /* deny delete only              */
627#endif /* __WIN__ */
628
629
630/* #define USE_RECORD_LOCK      */
631
632        /* Unsigned types supported by the compiler */
633#define UNSINT8                 /* unsigned int8 (char) */
634#define UNSINT16                /* unsigned int16 */
635#define UNSINT32                /* unsigned int32 */
636
637        /* General constants */
638#define SC_MAXWIDTH     256     /* Max width of screen (for error messages) */
639#define FN_LEN          256     /* Max file name len */
640#define FN_HEADLEN      253     /* Max length of filepart of file name */
641#define FN_EXTLEN       20      /* Max length of extension (part of FN_LEN) */
642#define FN_REFLEN       512     /* Max length of full path-name */
643#define FN_EXTCHAR      '.'
644#define FN_HOMELIB      '~'     /* ~/ is used as abbrev for home dir */
645#define FN_CURLIB       '.'     /* ./ is used as abbrev for current dir */
646#define FN_PARENTDIR    ".."    /* Parent directory; Must be a string */
647
648#ifndef FN_LIBCHAR
649#ifdef __EMX__
650#define FN_LIBCHAR      '\\'
651#define FN_ROOTDIR      "\\"
652#else
653#define FN_LIBCHAR      '/'
654#define FN_ROOTDIR      "/"
655#endif
656#endif
657#define MY_NFILE        64      /* This is only used to save filenames */
658#ifndef OS_FILE_LIMIT
659#define OS_FILE_LIMIT   65535
660#endif
661
662/* #define EXT_IN_LIBNAME     */
663/* #define FN_NO_CASE_SENCE   */
664/* #define FN_UPPER_CASE TRUE */
665
666/*
667  Io buffer size; Must be a power of 2 and a multiple of 512. May be
668  smaller what the disk page size. This influences the speed of the
669  isam btree library. eg to big to slow.
670*/
671#define IO_SIZE                 4096
672/*
673  How much overhead does malloc have. The code often allocates
674  something like 1024-MALLOC_OVERHEAD bytes
675*/
676#ifdef SAFEMALLOC
677#define MALLOC_OVERHEAD (8+24+4)
678#else
679#define MALLOC_OVERHEAD 8
680#endif
681        /* get memory in huncs */
682#define ONCE_ALLOC_INIT         (uint) (4096-MALLOC_OVERHEAD)
683        /* Typical record cash */
684#define RECORD_CACHE_SIZE       (uint) (64*1024-MALLOC_OVERHEAD)
685        /* Typical key cash */
686#define KEY_CACHE_SIZE          (uint) (8*1024*1024-MALLOC_OVERHEAD)
687        /* Default size of a key cache block  */
688#define KEY_CACHE_BLOCK_SIZE    (uint) 1024
689
690
691        /* Some things that this system doesn't have */
692
693#define NO_HASH                 /* Not needed anymore */
694#ifdef __WIN__
695#define NO_DIR_LIBRARY          /* Not standar dir-library */
696#define USE_MY_STAT_STRUCT      /* For my_lib */
697#endif
698
699/* Some defines of functions for portability */
700
701#undef remove           /* Crashes MySQL on SCO 5.0.0 */
702#ifndef __WIN__
703#ifdef OS2
704#define closesocket(A)  soclose(A)
705#else
706#define closesocket(A)  close(A)
707#endif
708#ifndef ulonglong2double
709#define ulonglong2double(A) ((double) (ulonglong) (A))
710#define my_off_t2double(A)  ((double) (my_off_t) (A))
711#endif
712#endif
713
714#ifndef offsetof
715#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
716#endif
717#define ulong_to_double(X) ((double) (ulong) (X))
718#define SET_STACK_SIZE(X)       /* Not needed on real machines */
719
720#if !defined(HAVE_mit_thread) && !defined(HAVE_STRTOK_R)
721#define strtok_r(A,B,C) strtok((A),(B))
722#endif
723
724/* Remove some things that mit_thread break or doesn't support */
725#if defined(HAVE_mit_thread) && defined(THREAD)
726#undef HAVE_PREAD
727#undef HAVE_REALPATH
728#undef HAVE_MLOCK
729#undef HAVE_TEMPNAM                             /* Use ours */
730#undef HAVE_PTHREAD_SETPRIO
731#undef HAVE_FTRUNCATE
732#undef HAVE_READLINK
733#endif
734
735/* This is from the old m-machine.h file */
736
737#if SIZEOF_LONG_LONG > 4
738#define HAVE_LONG_LONG 1
739#endif
740
741/*
742  Some pre-ANSI-C99 systems like AIX 5.1 and Linux/GCC 2.95 define
743  ULONGLONG_MAX, LONGLONG_MIN, LONGLONG_MAX; we use them if they're defined.
744  Also on Windows we define these constants by hand in config-win.h.
745*/
746
747#if defined(HAVE_LONG_LONG) && !defined(LONGLONG_MIN)
748#define LONGLONG_MIN    ((long long) 0x8000000000000000LL)
749#define LONGLONG_MAX    ((long long) 0x7FFFFFFFFFFFFFFFLL)
750#endif
751
752#if defined(HAVE_LONG_LONG) && !defined(ULONGLONG_MAX)
753/* First check for ANSI C99 definition: */
754#ifdef ULLONG_MAX
755#define ULONGLONG_MAX  ULLONG_MAX
756#else
757#define ULONGLONG_MAX ((unsigned long long)(~0ULL))
758#endif
759#endif /* defined (HAVE_LONG_LONG) && !defined(ULONGLONG_MAX)*/
760
761#define INT_MIN32       (~0x7FFFFFFFL)
762#define INT_MAX32       0x7FFFFFFFL
763#define UINT_MAX32      0xFFFFFFFFL
764#define INT_MIN24       (~0x007FFFFF)
765#define INT_MAX24       0x007FFFFF
766#define UINT_MAX24      0x00FFFFFF
767#define INT_MIN16       (~0x7FFF)
768#define INT_MAX16       0x7FFF
769#define UINT_MAX16      0xFFFF
770#define INT_MIN8        (~0x7F)
771#define INT_MAX8        0x7F
772#define UINT_MAX8       0xFF
773
774/* From limits.h instead */
775#ifndef DBL_MIN
776#define DBL_MIN         4.94065645841246544e-324
777#define FLT_MIN         ((float)1.40129846432481707e-45)
778#endif
779#ifndef DBL_MAX
780#define DBL_MAX         1.79769313486231470e+308
781#define FLT_MAX         ((float)3.40282346638528860e+38)
782#endif
783
784#ifndef HAVE_FINITE
785#define finite(x) (1.0 / fabs(x) > 0.0)
786#endif
787
788#ifndef HAVE_ISNAN
789#define isnan(x) ((x) != (x))
790#endif
791
792#ifdef HAVE_ISINF
793/* isinf() can be used in both C and C++ code */
794#define my_isinf(X) isinf(X)
795#else
796#define my_isinf(X) (!finite(X) && !isnan(X))
797#endif
798
799/* Define missing math constants. */
800#ifndef M_PI
801#define M_PI 3.14159265358979323846
802#endif
803#ifndef M_E
804#define M_E 2.7182818284590452354
805#endif
806#ifndef M_LN2
807#define M_LN2 0.69314718055994530942
808#endif
809
810/*
811  Max size that must be added to a so that we know Size to make
812  adressable obj.
813*/
814#if SIZEOF_CHARP == 4
815typedef long            my_ptrdiff_t;
816#else
817typedef long long       my_ptrdiff_t;
818#endif
819
820#define MY_ALIGN(A,L)   (((A) + (L) - 1) & ~((L) - 1))
821#define ALIGN_SIZE(A)   MY_ALIGN((A),sizeof(double))
822/* Size to make adressable obj. */
823#define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A),sizeof(t)))
824                         /* Offset of field f in structure t */
825#define OFFSET(t, f)    ((size_t)(char *)&((t *)0)->f)
826#define ADD_TO_PTR(ptr,size,type) (type) ((byte*) (ptr)+size)
827#define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((byte*) (A) - (byte*) (B))
828
829/*
830  Custom version of standard offsetof() macro which can be used to get
831  offsets of members in class for non-POD types (according to the current
832  version of C++ standard offsetof() macro can't be used in such cases and
833  attempt to do so causes warnings to be emitted, OTOH in many cases it is
834  still OK to assume that all instances of the class has the same offsets
835  for the same members).
836
837  This is temporary solution which should be removed once File_parser class
838  and related routines are refactored.
839*/
840
841#define my_offsetof(TYPE, MEMBER) \
842        ((size_t)((char *)&(((TYPE *)0x10)->MEMBER) - (char*)0x10))
843
844#define NullS           (char *) 0
845/* Nowdays we do not support MessyDos */
846#ifndef NEAR
847#define NEAR                            /* Who needs segments ? */
848#define FAR                             /* On a good machine */
849#ifndef HUGE_PTR
850#define HUGE_PTR
851#endif
852#endif
853#if defined(__IBMC__) || defined(__IBMCPP__)
854/* This was  _System _Export but caused a lot of warnings on _AIX43 */
855#define STDCALL
856#elif !defined( STDCALL)
857#define STDCALL
858#endif
859
860/* Typdefs for easyier portability */
861
862#if defined(VOIDTYPE)
863typedef void    *gptr;          /* Generic pointer */
864#else
865typedef char    *gptr;          /* Generic pointer */
866#endif
867#ifndef HAVE_INT_8_16_32
868typedef signed char int8;       /* Signed integer >= 8  bits */
869typedef short   int16;          /* Signed integer >= 16 bits */
870#endif
871#ifndef HAVE_UCHAR
872typedef unsigned char   uchar;  /* Short for unsigned char */
873#endif
874typedef unsigned char   uint8;  /* Short for unsigned integer >= 8  bits */
875typedef unsigned short  uint16; /* Short for unsigned integer >= 16 bits */
876
877#if SIZEOF_INT == 4
878#ifndef HAVE_INT_8_16_32
879typedef int             int32;
880#endif
881typedef unsigned int    uint32; /* Short for unsigned integer >= 32 bits */
882#elif SIZEOF_LONG == 4
883#ifndef HAVE_INT_8_16_32
884typedef long            int32;
885#endif
886typedef unsigned long   uint32; /* Short for unsigned integer >= 32 bits */
887#else
888#error "Neither int or long is of 4 bytes width"
889#endif
890
891#if !defined(HAVE_ULONG) && !defined(TARGET_OS_LINUX) && !defined(__USE_MISC)
892typedef unsigned long   ulong;            /* Short for unsigned long */
893#endif
894#ifndef longlong_defined
895/*
896  Using [unsigned] long long is preferable as [u]longlong because we use
897  [unsigned] long long unconditionally in many places,
898  for example in constants with [U]LL suffix.
899*/
900#if defined(HAVE_LONG_LONG) && SIZEOF_LONG_LONG == 8
901typedef unsigned long long int ulonglong; /* ulong or unsigned long long */
902typedef long long int   longlong;
903#else
904typedef unsigned long   ulonglong;        /* ulong or unsigned long long */
905typedef long            longlong;
906#endif
907#endif
908
909#if defined(NO_CLIENT_LONG_LONG)
910typedef unsigned long my_ulonglong;
911#elif defined (__WIN__)
912typedef unsigned __int64 my_ulonglong;
913#else
914typedef unsigned long long my_ulonglong;
915#endif
916
917#ifdef USE_RAID
918/*
919  The following is done with a if to not get problems with pre-processors
920  with late define evaluation
921*/
922#if SIZEOF_OFF_T == 4
923#define SYSTEM_SIZEOF_OFF_T 4
924#else
925#define SYSTEM_SIZEOF_OFF_T 8
926#endif
927#undef  SIZEOF_OFF_T
928#define SIZEOF_OFF_T        8
929#else
930#define SYSTEM_SIZEOF_OFF_T SIZEOF_OFF_T
931#endif /* USE_RAID */
932
933#if SIZEOF_OFF_T > 4
934typedef ulonglong my_off_t;
935#else
936typedef unsigned long my_off_t;
937#endif
938#define MY_FILEPOS_ERROR        (~(my_off_t) 0)
939#if !defined(__WIN__) && !defined(OS2)
940typedef off_t os_off_t;
941#endif
942
943#if defined(__WIN__)
944#define socket_errno    WSAGetLastError()
945#define SOCKET_EINTR    WSAEINTR
946#define SOCKET_EAGAIN   WSAEINPROGRESS
947#define SOCKET_ETIMEDOUT WSAETIMEDOUT
948#define SOCKET_EWOULDBLOCK WSAEWOULDBLOCK
949#define SOCKET_EADDRINUSE WSAEADDRINUSE
950#define SOCKET_ENFILE   ENFILE
951#define SOCKET_EMFILE   EMFILE
952#elif defined(OS2)
953#define socket_errno    sock_errno()
954#define SOCKET_EINTR    SOCEINTR
955#define SOCKET_EAGAIN   SOCEINPROGRESS
956#define SOCKET_ETIMEDOUT SOCKET_EINTR
957#define SOCKET_EWOULDBLOCK SOCEWOULDBLOCK
958#define SOCKET_EADDRINUSE SOCEADDRINUSE
959#define SOCKET_ENFILE   SOCENFILE
960#define SOCKET_EMFILE   SOCEMFILE
961#define closesocket(A)  soclose(A)
962#else /* Unix */
963#define socket_errno    errno
964#define closesocket(A)  close(A)
965#define SOCKET_EINTR    EINTR
966#define SOCKET_EAGAIN   EAGAIN
967#define SOCKET_ETIMEDOUT SOCKET_EINTR
968#define SOCKET_EWOULDBLOCK EWOULDBLOCK
969#define SOCKET_EADDRINUSE EADDRINUSE
970#define SOCKET_ENFILE   ENFILE
971#define SOCKET_EMFILE   EMFILE
972#endif
973
974typedef uint8           int7;   /* Most effective integer 0 <= x <= 127 */
975typedef short           int15;  /* Most effective integer 0 <= x <= 32767 */
976typedef char            *my_string; /* String of characters */
977typedef unsigned long   size_s; /* Size of strings (In string-funcs) */
978typedef int             myf;    /* Type of MyFlags in my_funcs */
979#ifndef byte_defined
980typedef char            byte;   /* Smallest addressable unit */
981#endif
982typedef char            my_bool; /* Small bool */
983#if !defined(bool) && !defined(bool_defined) && (!defined(HAVE_BOOL) || !defined(__cplusplus))
984typedef char            bool;   /* Ordinary boolean values 0 1 */
985#endif
986        /* Macros for converting *constants* to the right type */
987#define INT8(v)         (int8) (v)
988#define INT16(v)        (int16) (v)
989#define INT32(v)        (int32) (v)
990#define MYF(v)          (myf) (v)
991
992#ifndef LL
993#ifdef HAVE_LONG_LONG
994#define LL(A) A ## LL
995#else
996#define LL(A) A ## L
997#endif
998#endif
999
1000#ifndef ULL
1001#ifdef HAVE_LONG_LONG
1002#define ULL(A) A ## ULL
1003#else
1004#define ULL(A) A ## UL
1005#endif
1006#endif
1007
1008/*
1009  Defines to make it possible to prioritize register assignments. No
1010  longer that important with modern compilers.
1011*/
1012#ifndef USING_X
1013#define reg1 register
1014#define reg2 register
1015#define reg3 register
1016#define reg4 register
1017#define reg5 register
1018#define reg6 register
1019#define reg7 register
1020#define reg8 register
1021#define reg9 register
1022#define reg10 register
1023#define reg11 register
1024#define reg12 register
1025#define reg13 register
1026#define reg14 register
1027#define reg15 register
1028#define reg16 register
1029#endif
1030
1031/*
1032  Sometimes we want to make sure that the variable is not put into
1033  a register in debugging mode so we can see its value in the core
1034*/
1035
1036#ifndef DBUG_OFF
1037#define dbug_volatile volatile
1038#else
1039#define dbug_volatile
1040#endif
1041
1042/* Defines for time function */
1043#define SCALE_SEC       100
1044#define SCALE_USEC      10000
1045#define MY_HOW_OFTEN_TO_ALARM   2       /* How often we want info on screen */
1046#define MY_HOW_OFTEN_TO_WRITE   1000    /* How often we want info on screen */
1047
1048
1049
1050/*
1051  Define-funktions for reading and storing in machine independent format
1052  (low byte first)
1053*/
1054
1055/* Optimized store functions for Intel x86 */
1056#if defined(__i386__) && !defined(_WIN64)
1057#define sint2korr(A)    (*((int16 *) (A)))
1058#define sint3korr(A)    ((int32) ((((uchar) (A)[2]) & 128) ? \
1059                                  (((uint32) 255L << 24) | \
1060                                   (((uint32) (uchar) (A)[2]) << 16) |\
1061                                   (((uint32) (uchar) (A)[1]) << 8) | \
1062                                   ((uint32) (uchar) (A)[0])) : \
1063                                  (((uint32) (uchar) (A)[2]) << 16) |\
1064                                  (((uint32) (uchar) (A)[1]) << 8) | \
1065                                  ((uint32) (uchar) (A)[0])))
1066#define sint4korr(A)    (*((long *) (A)))
1067#define uint2korr(A)    (*((uint16 *) (A)))
1068#ifdef HAVE_purify
1069#define uint3korr(A)    (uint32) (((uint32) ((uchar) (A)[0])) +\
1070                                  (((uint32) ((uchar) (A)[1])) << 8) +\
1071                                  (((uint32) ((uchar) (A)[2])) << 16))
1072#else
1073/*
1074   ATTENTION !
1075   
1076    Please, note, uint3korr reads 4 bytes (not 3) !
1077    It means, that you have to provide enough allocated space !
1078*/
1079#define uint3korr(A)    (long) (*((unsigned int *) (A)) & 0xFFFFFF)
1080#endif
1081#define uint4korr(A)    (*((uint32 *) (A)))
1082#define uint5korr(A)    ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
1083                                    (((uint32) ((uchar) (A)[1])) << 8) +\
1084                                    (((uint32) ((uchar) (A)[2])) << 16) +\
1085                                    (((uint32) ((uchar) (A)[3])) << 24)) +\
1086                                    (((ulonglong) ((uchar) (A)[4])) << 32))
1087#define uint8korr(A)    (*((ulonglong *) (A)))
1088#define sint8korr(A)    (*((longlong *) (A)))
1089#define int2store(T,A)  *((uint16*) (T))= (uint16) (A)
1090#define int3store(T,A)  do { *(T)=  (uchar) ((A));\
1091                            *(T+1)=(uchar) (((uint) (A) >> 8));\
1092                            *(T+2)=(uchar) (((A) >> 16)); } while (0)
1093#define int4store(T,A)  *((long *) (T))= (long) (A)
1094#define int5store(T,A)  do { *(T)= (uchar)((A));\
1095                             *((T)+1)=(uchar) (((A) >> 8));\
1096                             *((T)+2)=(uchar) (((A) >> 16));\
1097                             *((T)+3)=(uchar) (((A) >> 24)); \
1098                             *((T)+4)=(uchar) (((A) >> 32)); } while(0)
1099#define int8store(T,A)  *((ulonglong *) (T))= (ulonglong) (A)
1100
1101typedef union {
1102  double v;
1103  long m[2];
1104} doubleget_union;
1105#define doubleget(V,M)  \
1106do { doubleget_union _tmp; \
1107     _tmp.m[0] = *((long*)(M)); \
1108     _tmp.m[1] = *(((long*) (M))+1); \
1109     (V) = _tmp.v; } while(0)
1110#define doublestore(T,V) do { *((long *) T) = ((doubleget_union *)&V)->m[0]; \
1111                             *(((long *) T)+1) = ((doubleget_union *)&V)->m[1]; \
1112                         } while (0)
1113#define float4get(V,M)   do { *((float *) &(V)) = *((float*) (M)); } while(0)
1114#define float8get(V,M)   doubleget((V),(M))
1115#define float4store(V,M) memcpy((byte*) V,(byte*) (&M),sizeof(float))
1116#define floatstore(T,V)  memcpy((byte*)(T), (byte*)(&V),sizeof(float))
1117#define floatget(V,M)    memcpy((byte*) &V,(byte*) (M),sizeof(float))
1118#define float8store(V,M) doublestore((V),(M))
1119#endif /* __i386__ */
1120
1121#ifndef sint2korr
1122/*
1123  We're here if it's not a IA-32 architecture (Win32 and UNIX IA-32 defines
1124  were done before)
1125*/
1126#define sint2korr(A)    (int16) (((int16) ((uchar) (A)[0])) +\
1127                                 ((int16) ((int16) (A)[1]) << 8))
1128#define sint3korr(A)    ((int32) ((((uchar) (A)[2]) & 128) ? \
1129                                  (((uint32) 255L << 24) | \
1130                                   (((uint32) (uchar) (A)[2]) << 16) |\
1131                                   (((uint32) (uchar) (A)[1]) << 8) | \
1132                                   ((uint32) (uchar) (A)[0])) : \
1133                                  (((uint32) (uchar) (A)[2]) << 16) |\
1134                                  (((uint32) (uchar) (A)[1]) << 8) | \
1135                                  ((uint32) (uchar) (A)[0])))
1136#define sint4korr(A)    (int32) (((int32) ((uchar) (A)[0])) +\
1137                                (((int32) ((uchar) (A)[1]) << 8)) +\
1138                                (((int32) ((uchar) (A)[2]) << 16)) +\
1139                                (((int32) ((int16) (A)[3]) << 24)))
1140#define sint8korr(A)    (longlong) uint8korr(A)
1141#define uint2korr(A)    (uint16) (((uint16) ((uchar) (A)[0])) +\
1142                                  ((uint16) ((uchar) (A)[1]) << 8))
1143#define uint3korr(A)    (uint32) (((uint32) ((uchar) (A)[0])) +\
1144                                  (((uint32) ((uchar) (A)[1])) << 8) +\
1145                                  (((uint32) ((uchar) (A)[2])) << 16))
1146#define uint4korr(A)    (uint32) (((uint32) ((uchar) (A)[0])) +\
1147                                  (((uint32) ((uchar) (A)[1])) << 8) +\
1148                                  (((uint32) ((uchar) (A)[2])) << 16) +\
1149                                  (((uint32) ((uchar) (A)[3])) << 24))
1150#define uint5korr(A)    ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
1151                                    (((uint32) ((uchar) (A)[1])) << 8) +\
1152                                    (((uint32) ((uchar) (A)[2])) << 16) +\
1153                                    (((uint32) ((uchar) (A)[3])) << 24)) +\
1154                                    (((ulonglong) ((uchar) (A)[4])) << 32))
1155#define uint8korr(A)    ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
1156                                    (((uint32) ((uchar) (A)[1])) << 8) +\
1157                                    (((uint32) ((uchar) (A)[2])) << 16) +\
1158                                    (((uint32) ((uchar) (A)[3])) << 24)) +\
1159                        (((ulonglong) (((uint32) ((uchar) (A)[4])) +\
1160                                    (((uint32) ((uchar) (A)[5])) << 8) +\
1161                                    (((uint32) ((uchar) (A)[6])) << 16) +\
1162                                    (((uint32) ((uchar) (A)[7])) << 24))) <<\
1163                                    32))
1164#define int2store(T,A)       do { uint def_temp= (uint) (A) ;\
1165                                  *((uchar*) (T))=  (uchar)(def_temp); \
1166                                   *((uchar*) (T)+1)=(uchar)((def_temp >> 8)); \
1167                             } while(0)
1168#define int3store(T,A)       do { /*lint -save -e734 */\
1169                                  *((uchar*)(T))=(uchar) ((A));\
1170                                  *((uchar*) (T)+1)=(uchar) (((A) >> 8));\
1171                                  *((uchar*)(T)+2)=(uchar) (((A) >> 16)); \
1172                                  /*lint -restore */} while(0)
1173#define int4store(T,A)       do { *((char *)(T))=(char) ((A));\
1174                                  *(((char *)(T))+1)=(char) (((A) >> 8));\
1175                                  *(((char *)(T))+2)=(char) (((A) >> 16));\
1176                                  *(((char *)(T))+3)=(char) (((A) >> 24)); } while(0)
1177#define int5store(T,A)       do { *((char *)(T))=((A));\
1178                                  *(((char *)(T))+1)=(((A) >> 8));\
1179                                  *(((char *)(T))+2)=(((A) >> 16));\
1180                                  *(((char *)(T))+3)=(((A) >> 24)); \
1181                                  *(((char *)(T))+4)=(((A) >> 32)); } while(0)
1182#define int8store(T,A)       do { uint def_temp= (uint) (A), def_temp2= (uint) ((A) >> 32); \
1183                                  int4store((T),def_temp); \
1184                                  int4store((T+4),def_temp2); } while(0)
1185#ifdef WORDS_BIGENDIAN
1186#define float4store(T,A) do { *(T)= ((byte *) &A)[3];\
1187                              *((T)+1)=(char) ((byte *) &A)[2];\
1188                              *((T)+2)=(char) ((byte *) &A)[1];\
1189                              *((T)+3)=(char) ((byte *) &A)[0]; } while(0)
1190
1191#define float4get(V,M)   do { float def_temp;\
1192                              ((byte*) &def_temp)[0]=(M)[3];\
1193                              ((byte*) &def_temp)[1]=(M)[2];\
1194                              ((byte*) &def_temp)[2]=(M)[1];\
1195                              ((byte*) &def_temp)[3]=(M)[0];\
1196                              (V)=def_temp; } while(0)
1197#define float8store(T,V) do { *(T)= ((byte *) &V)[7];\
1198                              *((T)+1)=(char) ((byte *) &V)[6];\
1199                              *((T)+2)=(char) ((byte *) &V)[5];\
1200                              *((T)+3)=(char) ((byte *) &V)[4];\
1201                              *((T)+4)=(char) ((byte *) &V)[3];\
1202                              *((T)+5)=(char) ((byte *) &V)[2];\
1203                              *((T)+6)=(char) ((byte *) &V)[1];\
1204                              *((T)+7)=(char) ((byte *) &V)[0]; } while(0)
1205
1206#define float8get(V,M)   do { double def_temp;\
1207                              ((byte*) &def_temp)[0]=(M)[7];\
1208                              ((byte*) &def_temp)[1]=(M)[6];\
1209                              ((byte*) &def_temp)[2]=(M)[5];\
1210                              ((byte*) &def_temp)[3]=(M)[4];\
1211                              ((byte*) &def_temp)[4]=(M)[3];\
1212                              ((byte*) &def_temp)[5]=(M)[2];\
1213                              ((byte*) &def_temp)[6]=(M)[1];\
1214                              ((byte*) &def_temp)[7]=(M)[0];\
1215                              (V) = def_temp; } while(0)
1216#else
1217#define float4get(V,M)   memcpy_fixed((byte*) &V,(byte*) (M),sizeof(float))
1218#define float4store(V,M) memcpy_fixed((byte*) V,(byte*) (&M),sizeof(float))
1219
1220#if defined(__FLOAT_WORD_ORDER) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN)
1221#define doublestore(T,V) do { *(((char*)T)+0)=(char) ((byte *) &V)[4];\
1222                              *(((char*)T)+1)=(char) ((byte *) &V)[5];\
1223                              *(((char*)T)+2)=(char) ((byte *) &V)[6];\
1224                              *(((char*)T)+3)=(char) ((byte *) &V)[7];\
1225                              *(((char*)T)+4)=(char) ((byte *) &V)[0];\
1226                              *(((char*)T)+5)=(char) ((byte *) &V)[1];\
1227                              *(((char*)T)+6)=(char) ((byte *) &V)[2];\
1228                              *(((char*)T)+7)=(char) ((byte *) &V)[3]; }\
1229                         while(0)
1230#define doubleget(V,M)   do { double def_temp;\
1231                              ((byte*) &def_temp)[0]=(M)[4];\
1232                              ((byte*) &def_temp)[1]=(M)[5];\
1233                              ((byte*) &def_temp)[2]=(M)[6];\
1234                              ((byte*) &def_temp)[3]=(M)[7];\
1235                              ((byte*) &def_temp)[4]=(M)[0];\
1236                              ((byte*) &def_temp)[5]=(M)[1];\
1237                              ((byte*) &def_temp)[6]=(M)[2];\
1238                              ((byte*) &def_temp)[7]=(M)[3];\
1239                              (V) = def_temp; } while(0)
1240#endif /* __FLOAT_WORD_ORDER */
1241
1242#define float8get(V,M)   doubleget((V),(M))
1243#define float8store(V,M) doublestore((V),(M))
1244#endif /* WORDS_BIGENDIAN */
1245
1246#endif /* sint2korr */
1247
1248/*
1249  Macro for reading 32-bit integer from network byte order (big-endian)
1250  from unaligned memory location.
1251*/
1252#define int4net(A)        (int32) (((uint32) ((uchar) (A)[3]))        |\
1253                                  (((uint32) ((uchar) (A)[2])) << 8)  |\
1254                                  (((uint32) ((uchar) (A)[1])) << 16) |\
1255                                  (((uint32) ((uchar) (A)[0])) << 24))
1256/*
1257  Define-funktions for reading and storing in machine format from/to
1258  short/long to/from some place in memory V should be a (not
1259  register) variable, M is a pointer to byte
1260*/
1261
1262#ifdef WORDS_BIGENDIAN
1263
1264#define ushortget(V,M)  do { V = (uint16) (((uint16) ((uchar) (M)[1]))+\
1265                                 ((uint16) ((uint16) (M)[0]) << 8)); } while(0)
1266#define shortget(V,M)   do { V = (short) (((short) ((uchar) (M)[1]))+\
1267                                 ((short) ((short) (M)[0]) << 8)); } while(0)
1268#define longget(V,M)    do { int32 def_temp;\
1269                             ((byte*) &def_temp)[0]=(M)[0];\
1270                             ((byte*) &def_temp)[1]=(M)[1];\
1271                             ((byte*) &def_temp)[2]=(M)[2];\
1272                             ((byte*) &def_temp)[3]=(M)[3];\
1273                             (V)=def_temp; } while(0)
1274#define ulongget(V,M)   do { uint32 def_temp;\
1275                            ((byte*) &def_temp)[0]=(M)[0];\
1276                            ((byte*) &def_temp)[1]=(M)[1];\
1277                            ((byte*) &def_temp)[2]=(M)[2];\
1278                            ((byte*) &def_temp)[3]=(M)[3];\
1279                            (V)=def_temp; } while(0)
1280#define shortstore(T,A) do { uint def_temp=(uint) (A) ;\
1281                             *(((char*)T)+1)=(char)(def_temp); \
1282                             *(((char*)T)+0)=(char)(def_temp >> 8); } while(0)
1283#define longstore(T,A)  do { *(((char*)T)+3)=((A));\
1284                             *(((char*)T)+2)=(((A) >> 8));\
1285                             *(((char*)T)+1)=(((A) >> 16));\
1286                             *(((char*)T)+0)=(((A) >> 24)); } while(0)
1287
1288#define floatget(V,M)    memcpy_fixed((byte*) &V,(byte*) (M),sizeof(float))
1289#define floatstore(T,V)  memcpy_fixed((byte*) (T),(byte*)(&V),sizeof(float))
1290#define doubleget(V,M)   memcpy_fixed((byte*) &V,(byte*) (M),sizeof(double))
1291#define doublestore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(double))
1292#define longlongget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(ulonglong))
1293#define longlongstore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(ulonglong))
1294
1295#else
1296
1297#define ushortget(V,M)  do { V = uint2korr(M); } while(0)
1298#define shortget(V,M)   do { V = sint2korr(M); } while(0)
1299#define longget(V,M)    do { V = sint4korr(M); } while(0)
1300#define ulongget(V,M)   do { V = uint4korr(M); } while(0)
1301#define shortstore(T,V) int2store(T,V)
1302#define longstore(T,V)  int4store(T,V)
1303#ifndef floatstore
1304#define floatstore(T,V)  memcpy_fixed((byte*) (T),(byte*) (&V),sizeof(float))
1305#define floatget(V,M)    memcpy_fixed((byte*) &V, (byte*) (M), sizeof(float))
1306#endif
1307#ifndef doubleget
1308#define doubleget(V,M)   memcpy_fixed((byte*) &V,(byte*) (M),sizeof(double))
1309#define doublestore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(double))
1310#endif /* doubleget */
1311#define longlongget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(ulonglong))
1312#define longlongstore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(ulonglong))
1313
1314#endif /* WORDS_BIGENDIAN */
1315
1316/* sprintf does not always return the number of bytes :- */
1317#ifdef SPRINTF_RETURNS_INT
1318#define my_sprintf(buff,args) sprintf args
1319#else
1320#ifdef SPRINTF_RETURNS_PTR
1321#define my_sprintf(buff,args) ((int)(sprintf args - buff))
1322#else
1323#define my_sprintf(buff,args) ((ulong) sprintf args, (ulong) strlen(buff))
1324#endif
1325#endif
1326
1327#ifndef THREAD
1328#define thread_safe_increment(V,L) (V)++
1329#define thread_safe_add(V,C,L)     (V)+=(C)
1330#define thread_safe_sub(V,C,L)     (V)-=(C)
1331#define statistic_increment(V,L)   (V)++
1332#define statistic_add(V,C,L)       (V)+=(C)
1333#endif
1334
1335#ifdef HAVE_CHARSET_utf8
1336#define MYSQL_UNIVERSAL_CLIENT_CHARSET "utf8"
1337#else
1338#define MYSQL_UNIVERSAL_CLIENT_CHARSET MYSQL_DEFAULT_CHARSET_NAME
1339#endif
1340
1341#if defined(EMBEDDED_LIBRARY) && !defined(HAVE_EMBEDDED_PRIVILEGE_CONTROL)
1342#define NO_EMBEDDED_ACCESS_CHECKS
1343#endif
1344
1345
1346/* Length of decimal number represented by INT32. */
1347
1348#define MY_INT32_NUM_DECIMAL_DIGITS 11
1349
1350/* Length of decimal number represented by INT64. */
1351
1352#define MY_INT64_NUM_DECIMAL_DIGITS 21
1353
1354#endif /* my_global_h */
Note: See TracBrowser for help on using the browser.