root/src/mysql/my_global.h @ 1

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