00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef _global_h
00020 #define _global_h
00021
00022 #ifndef EMBEDDED_LIBRARY
00023 #define HAVE_REPLICATION
00024 #define HAVE_EXTERNAL_CLIENT
00025 #endif
00026
00027 #if defined( __EMX__) && !defined( MYSQL_SERVER)
00028
00029 #define INCL_BASE
00030 #define INCL_NOPMAPI
00031 #include <os2.h>
00032 #endif
00033
00034 #ifdef __CYGWIN__
00035
00036 #undef WIN
00037 #undef WIN32
00038 #undef _WIN
00039 #undef _WIN32
00040 #undef _WIN64
00041 #undef __WIN__
00042 #undef __WIN32__
00043 #define HAVE_ERRNO_AS_DEFINE
00044 #endif
00045
00046 #if defined(i386) && !defined(__i386__)
00047 #define __i386__
00048 #endif
00049
00050
00051 #ifdef __cplusplus
00052 #define C_MODE_START extern "C" {
00053 #define C_MODE_END }
00054 #else
00055 #define C_MODE_START
00056 #define C_MODE_END
00057 #endif
00058
00059 #if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32)
00060 #include <config-win.h>
00061 #elif defined(OS2)
00062 #include <config-os2.h>
00063 #elif defined(__NETWARE__)
00064 #include <my_config.h>
00065 #include <config-netware.h>
00066 #if defined(__cplusplus) && defined(inline)
00067 #undef inline
00068 #endif
00069 #else
00070 #include <my_config.h>
00071 #if defined(__cplusplus) && defined(inline)
00072 #undef inline
00073 #endif
00074 #endif
00075
00076
00077 #ifndef NETWARE_YIELD
00078 #define NETWARE_YIELD
00079 #define NETWARE_SET_SCREEN_MODE(A)
00080 #endif
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091 #if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
00092 #define __builtin_expect(x, expected_value) (x)
00093 #endif
00094
00095 #define likely(x) __builtin_expect((x),1)
00096 #define unlikely(x) __builtin_expect((x),0)
00097
00098
00099
00100 #if defined(HAVE_LINUXTHREADS)
00101 #undef _GNU_SOURCE
00102 #define _GNU_SOURCE 1
00103 #endif
00104
00105
00106 #if defined(UNDEF_THREADS_HACK)
00107 #undef THREAD
00108 #undef HAVE_mit_thread
00109 #undef HAVE_LINUXTHREADS
00110 #undef HAVE_UNIXWARE7_THREADS
00111 #endif
00112
00113 #ifdef HAVE_THREADS_WITHOUT_SOCKETS
00114
00115 #undef HAVE_SYS_UN_H
00116 #endif
00117
00118 #define __EXTENSIONS__ 1
00119 #ifndef __STDC_EXT__
00120 #define __STDC_EXT__ 1
00121 #endif
00122
00123 #if defined(THREAD) && !defined(__WIN__) && !defined(OS2)
00124 #ifndef _POSIX_PTHREAD_SEMANTICS
00125 #define _POSIX_PTHREAD_SEMANTICS
00126 #endif
00127
00128 #if !defined(SCO)
00129 #define _REENTRANT 1
00130 #endif
00131 #if !defined(_THREAD_SAFE) && !defined(_AIX)
00132 #define _THREAD_SAFE
00133 #endif
00134 #ifndef HAVE_mit_thread
00135 #ifdef HAVE_UNIXWARE7_THREADS
00136 #include <thread.h>
00137 #else
00138 #include <pthread.h>
00139 #endif
00140 #endif
00141 #if !defined(SCO) && !defined(_REENTRANT)
00142 #define _REENTRANT 1
00143 #endif
00144 #endif
00145
00146
00147 #ifdef _AIX
00148 #define _H_STRINGS
00149 #define _SYS_STREAM_H
00150
00151 #define ulonglong2double(A) my_ulonglong2double(A)
00152 #define my_off_t2double(A) my_ulonglong2double(A)
00153 C_MODE_START
00154 double my_ulonglong2double(unsigned long long A);
00155 C_MODE_END
00156 #endif
00157
00158 #ifdef HAVE_BROKEN_SNPRINTF
00159 #undef HAVE_SNPRINTF
00160 #endif
00161 #ifdef HAVE_BROKEN_PREAD
00162
00163
00164
00165
00166 #undef HAVE_PREAD
00167 #undef HAVE_PWRITE
00168 #endif
00169 #if defined(HAVE_BROKEN_INLINE) && !defined(__cplusplus)
00170 #undef inline
00171 #define inline
00172 #endif
00173
00174 #ifdef UNDEF_HAVE_GETHOSTBYNAME_R
00175 #undef HAVE_GETHOSTBYNAME_R
00176 #endif
00177 #ifdef UNDEF_HAVE_INITGROUPS
00178 #undef HAVE_INITGROUPS
00179 #endif
00180
00181
00182
00183 #if defined(__GNUC) && defined(__EXCEPTIONS)
00184 #error "Please add -fno-exceptions to CXXFLAGS and reconfigure/recompile"
00185 #endif
00186
00187
00188
00189 #if SIZEOF_LONG == 4 && defined(__LONG_MAX__)
00190 #undef __LONG_MAX__
00191 #define __LONG_MAX__ 2147483647
00192 #endif
00193
00194
00195 #ifdef DEFINE_CXA_PURE_VIRTUAL
00196 #define FIX_GCC_LINKING_PROBLEM \
00197 C_MODE_START int __cxa_pure_virtual() {\
00198 DBUG_ASSERT("Pure virtual method called." == "Aborted");\
00199 return 0;\
00200 } C_MODE_END
00201 #else
00202 #define FIX_GCC_LINKING_PROBLEM
00203 #endif
00204
00205
00206 #if defined(__GNUC__) && defined(__alpha__) && ! (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95))
00207 #define BAD_MEMCPY
00208 #endif
00209
00210
00211 #if defined(HAVE_LINUXTHREADS) && defined(__GNUC__) && defined(__alpha__) && (__GNUC__ > 2 || ( __GNUC__ == 2 && __GNUC_MINOR__ >= 95)) && !defined(HAVE_ATOMIC_ADD)
00212 #define HAVE_ATOMIC_ADD
00213 #define HAVE_ATOMIC_SUB
00214 #endif
00215
00216
00217 #if (defined(HAVE_LINUXTHREADS) && defined(__GNUC__) && (defined(__ia64__)||defined(__powerpc64__))) || !defined(THREAD)
00218 #undef HAVE_ATOMIC_ADD
00219 #undef HAVE_ATOMIC_SUB
00220 #endif
00221
00222 #if defined(_lint) && !defined(lint)
00223 #define lint
00224 #endif
00225 #if SIZEOF_LONG_LONG > 4 && !defined(_LONG_LONG)
00226 #define _LONG_LONG 1
00227 #endif
00228
00229 #ifndef stdin
00230 #include <stdio.h>
00231 #endif
00232 #ifdef HAVE_STDLIB_H
00233 #include <stdlib.h>
00234 #endif
00235 #ifdef HAVE_STDDEF_H
00236 #include <stddef.h>
00237 #endif
00238
00239 #include <math.h>
00240 #ifdef HAVE_LIMITS_H
00241 #include <limits.h>
00242 #endif
00243 #ifdef HAVE_FLOAT_H
00244 #include <float.h>
00245 #endif
00246
00247 #ifdef HAVE_SYS_TYPES_H
00248 #include <sys/types.h>
00249 #endif
00250 #ifdef HAVE_FCNTL_H
00251 #include <fcntl.h>
00252 #endif
00253 #ifdef HAVE_SYS_TIMEB_H
00254 #include <sys/timeb.h>
00255 #endif
00256 #if TIME_WITH_SYS_TIME
00257 # include <sys/time.h>
00258 # include <time.h>
00259 #else
00260 # if HAVE_SYS_TIME_H
00261 # include <sys/time.h>
00262 # else
00263 # include <time.h>
00264 # endif
00265 #endif
00266 #ifdef HAVE_UNISTD_H
00267 #if defined(HAVE_OPENSSL) && !defined(__FreeBSD__) && !defined(NeXT) && !defined(__OpenBSD__)
00268 #define crypt unistd_crypt
00269 #endif
00270 #include <unistd.h>
00271 #ifdef HAVE_OPENSSL
00272 #undef crypt
00273 #endif
00274 #endif
00275 #if defined(__cplusplus) && defined(NO_CPLUSPLUS_ALLOCA)
00276 #undef HAVE_ALLOCA
00277 #undef HAVE_ALLOCA_H
00278 #endif
00279 #ifdef HAVE_ALLOCA_H
00280 #include <alloca.h>
00281 #endif
00282 #ifdef HAVE_ATOMIC_ADD
00283 #define __SMP__
00284 #ifdef HAVE_LINUX_CONFIG_H
00285 #include <linux/config.h>
00286 #endif
00287 #ifndef CONFIG_SMP
00288 #define CONFIG_SMP
00289 #endif
00290 C_MODE_START
00291 #include <asm/atomic.h>
00292 C_MODE_END
00293 #endif
00294 #include <errno.h>
00295
00296 #if defined(HAVE_CRYPT_H)
00297 #include <crypt.h>
00298 #endif
00299
00300
00301
00302
00303
00304
00305 #include <assert.h>
00306
00307
00308 #if defined(_HPUX_SOURCE) && defined(HAVE_SYS_STREAM_H)
00309 #include <sys/stream.h>
00310 #define HAVE_ULONG
00311 #endif
00312 #ifdef DONT_USE_FINITE
00313 #undef HAVE_FINITE
00314 #endif
00315 #if defined(HPUX10) && defined(_LARGEFILE64_SOURCE) && defined(THREAD)
00316
00317 #undef setrlimit
00318 #define setrlimit cma_setrlimit64
00319 #endif
00320
00321 #ifdef __QNXNTO__
00322
00323 #define HAVE_ERRNO_AS_DEFINE
00324 #define HAVE_FCNTL_LOCK
00325 #undef HAVE_FINITE
00326 #undef LONGLONG_MIN
00327 #undef LONGLONG_MAX
00328 #endif
00329
00330
00331
00332 #define USE_MYFUNC 1
00333 #define MASTER 1
00334 #define ENGLISH 1
00335 #define POSIX_MISTAKE 1
00336 #define USE_REGEX 1
00337
00338 #ifndef OS2
00339 #define USE_BMOVE512 1
00340 #endif
00341
00342 #define QUOTE_ARG(x) #x
00343 #define STRINGIFY_ARG(x) QUOTE_ARG(x)
00344
00345
00346 #ifdef I_AM_PARANOID
00347 #define DONT_ALLOW_USER_CHANGE 1
00348 #define DONT_USE_MYSQL_PWD 1
00349 #endif
00350
00351
00352 #ifndef HAVE_BSD_SIGNALS
00353 #define DONT_REMEMBER_SIGNAL
00354 #endif
00355
00356
00357 #ifndef DONT_DEFINE_VOID
00358 #ifdef _lint
00359 int __void__;
00360 #define VOID(X) (__void__ = (int) (X))
00361 #else
00362 #undef VOID
00363 #define VOID(X) (X)
00364 #endif
00365 #endif
00366
00367 #if defined(_lint) || defined(FORCE_INIT_OF_VARS)
00368 #define LINT_INIT(var) var=0
00369 #else
00370 #define LINT_INIT(var)
00371 #endif
00372
00373 #if defined(_lint) || defined(FORCE_INIT_OF_VARS) || defined(HAVE_purify)
00374 #define PURIFY_OR_LINT_INIT(var) var=0
00375 #else
00376 #define PURIFY_OR_LINT_INIT(var)
00377 #endif
00378
00379
00380 #if defined(__cplusplus) && defined(__GNUC__)
00381 #define max(a, b) ((a) >? (b))
00382 #define min(a, b) ((a) <? (b))
00383 #elif !defined(max)
00384 #define max(a, b) ((a) > (b) ? (a) : (b))
00385 #define min(a, b) ((a) < (b) ? (a) : (b))
00386 #endif
00387
00388 #if defined(__EMX__) || !defined(HAVE_UINT)
00389 typedef unsigned int uint;
00390 typedef unsigned short ushort;
00391 #endif
00392
00393 #define CMP_NUM(a,b) (((a) < (b)) ? -1 : ((a) == (b)) ? 0 : 1)
00394 #define sgn(a) (((a) < 0) ? -1 : ((a) > 0) ? 1 : 0)
00395 #define swap_variables(t, a, b) { register t dummy; dummy= a; a= b; b= dummy; }
00396 #define test(a) ((a) ? 1 : 0)
00397 #define set_if_bigger(a,b) do { if ((a) < (b)) (a)=(b); } while(0)
00398 #define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0)
00399 #define test_all_bits(a,b) (((a) & (b)) == (b))
00400 #define set_bits(type, bit_count) (sizeof(type)*8 <= (bit_count) ? ~(type) 0 : ((((type) 1) << (bit_count)) - (type) 1))
00401 #define array_elements(A) ((uint) (sizeof(A)/sizeof(A[0])))
00402 #ifndef HAVE_RINT
00403 #define rint(A) floor((A)+(((A) < 0)? -0.5 : 0.5))
00404 #endif
00405
00406
00407 #ifndef TRUE
00408 #define TRUE (1)
00409 #define FALSE (0)
00410 #endif
00411
00412 #if defined(__GNUC__)
00413 #define function_volatile volatile
00414 #define my_reinterpret_cast(A) reinterpret_cast<A>
00415 #define my_const_cast(A) const_cast<A>
00416 #elif !defined(my_reinterpret_cast)
00417 #define my_reinterpret_cast(A) (A)
00418 #define my_const_cast(A) (A)
00419 #endif
00420 #if !defined(__attribute__) && (defined(__cplusplus) || !defined(__GNUC__) || __GNUC__ == 2 && __GNUC_MINOR__ < 8)
00421 #define __attribute__(A)
00422 #endif
00423
00424
00425
00426
00427
00428
00429
00430
00431 #define _VARARGS(X) X
00432 #define _STATIC_VARARGS(X) X
00433 #define _PC(X) X
00434
00435 #if defined(DBUG_ON) && defined(DBUG_OFF)
00436 #undef DBUG_OFF
00437 #endif
00438
00439 #if defined(_lint) && !defined(DBUG_OFF)
00440 #define DBUG_OFF
00441 #endif
00442
00443 #include <my_dbug.h>
00444
00445 #define MIN_ARRAY_SIZE 0
00446 #define ASCII_BITS_USED 8
00447 #define NEAR_F
00448
00449
00450
00451 typedef int File;
00452 #ifndef Socket_defined
00453 typedef int my_socket;
00454 #define INVALID_SOCKET -1
00455 #endif
00456
00457 #define sig_handler RETSIGTYPE
00458 C_MODE_START
00459 typedef void (*sig_return)();
00460 C_MODE_END
00461 #if defined(__GNUC__) && !defined(_lint)
00462 typedef char pchar;
00463 typedef char puchar;
00464 typedef char pbool;
00465 typedef short pshort;
00466 typedef float pfloat;
00467 #else
00468 typedef int pchar;
00469 typedef uint puchar;
00470 typedef int pbool;
00471 typedef int pshort;
00472 typedef double pfloat;
00473 #endif
00474 C_MODE_START
00475 typedef int (*qsort_cmp)(const void *,const void *);
00476 typedef int (*qsort_cmp2)(void*, const void *,const void *);
00477 C_MODE_END
00478 #ifdef HAVE_mit_thread
00479 #define qsort_t void
00480 #undef QSORT_TYPE_IS_VOID
00481 #define QSORT_TYPE_IS_VOID
00482 #else
00483 #define qsort_t RETQSORTTYPE
00484 #endif
00485 #ifdef HAVE_mit_thread
00486 #define size_socket socklen_t
00487 #else
00488 #ifdef HAVE_SYS_SOCKET_H
00489 #include <sys/socket.h>
00490 #endif
00491 typedef SOCKET_SIZE_TYPE size_socket;
00492 #endif
00493
00494 #ifndef SOCKOPT_OPTLEN_TYPE
00495 #define SOCKOPT_OPTLEN_TYPE size_socket
00496 #endif
00497
00498
00499
00500 #ifndef O_SHARE
00501 #define O_SHARE 0
00502 #ifndef O_BINARY
00503 #define O_BINARY 0
00504 #endif
00505 #ifndef FILE_BINARY
00506 #define FILE_BINARY O_BINARY
00507 #endif
00508 #ifdef HAVE_FCNTL
00509 #define HAVE_FCNTL_LOCK
00510 #define F_TO_EOF 0L
00511 #endif
00512 #endif
00513
00514 #ifndef O_TEMPORARY
00515 #define O_TEMPORARY 0
00516 #endif
00517 #ifndef O_SHORT_LIVED
00518 #define O_SHORT_LIVED 0
00519 #endif
00520
00521
00522
00523
00524 #define UNSINT8
00525 #define UNSINT16
00526 #define UNSINT32
00527
00528
00529 #define SC_MAXWIDTH 256
00530 #define FN_LEN 256
00531 #define FN_HEADLEN 253
00532 #define FN_EXTLEN 20
00533 #define FN_REFLEN 512
00534 #define FN_EXTCHAR '.'
00535 #define FN_HOMELIB '~'
00536 #define FN_CURLIB '.'
00537 #define FN_PARENTDIR ".."
00538 #define FN_DEVCHAR ':'
00539
00540 #ifndef FN_LIBCHAR
00541 #ifdef __EMX__
00542 #define FN_LIBCHAR '\\'
00543 #define FN_ROOTDIR "\\"
00544 #else
00545 #define FN_LIBCHAR '/'
00546 #define FN_ROOTDIR "/"
00547 #endif
00548 #endif
00549 #define MY_NFILE 64
00550 #ifndef OS_FILE_LIMIT
00551 #define OS_FILE_LIMIT 65535
00552 #endif
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563 #define IO_SIZE 4096
00564
00565
00566
00567
00568 #ifdef SAFEMALLOC
00569 #define MALLOC_OVERHEAD (8+24+4)
00570 #else
00571 #define MALLOC_OVERHEAD 8
00572 #endif
00573
00574 #define ONCE_ALLOC_INIT (uint) (4096-MALLOC_OVERHEAD)
00575
00576 #define RECORD_CACHE_SIZE (uint) (64*1024-MALLOC_OVERHEAD)
00577
00578 #define KEY_CACHE_SIZE (uint) (8*1024*1024-MALLOC_OVERHEAD)
00579
00580 #define KEY_CACHE_BLOCK_SIZE (uint) 1024
00581
00582
00583
00584
00585 #define NO_HASH
00586 #ifdef __WIN__
00587 #define NO_DIR_LIBRARY
00588 #define USE_MY_STAT_STRUCT
00589 #endif
00590
00591
00592
00593 #undef remove
00594 #ifndef __WIN__
00595 #ifdef OS2
00596 #define closesocket(A) soclose(A)
00597 #else
00598 #define closesocket(A) close(A)
00599 #endif
00600 #ifndef ulonglong2double
00601 #define ulonglong2double(A) ((double) (ulonglong) (A))
00602 #define my_off_t2double(A) ((double) (my_off_t) (A))
00603 #endif
00604 #endif
00605
00606 #ifndef offsetof
00607 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
00608 #endif
00609 #define ulong_to_double(X) ((double) (ulong) (X))
00610 #define SET_STACK_SIZE(X)
00611
00612 #if !defined(HAVE_mit_thread) && !defined(HAVE_STRTOK_R)
00613 #define strtok_r(A,B,C) strtok((A),(B))
00614 #endif
00615
00616
00617 #if defined(HAVE_mit_thread) && defined(THREAD)
00618 #undef HAVE_PREAD
00619 #undef HAVE_REALPATH
00620 #undef HAVE_MLOCK
00621 #undef HAVE_TEMPNAM
00622 #undef HAVE_PTHREAD_SETPRIO
00623 #undef HAVE_FTRUNCATE
00624 #undef HAVE_READLINK
00625 #endif
00626
00627
00628
00629 #if SIZEOF_LONG_LONG > 4
00630 #define HAVE_LONG_LONG 1
00631 #endif
00632
00633
00634
00635
00636
00637
00638
00639 #if defined(HAVE_LONG_LONG) && !defined(LONGLONG_MIN)
00640 #define LONGLONG_MIN ((long long) 0x8000000000000000LL)
00641 #define LONGLONG_MAX ((long long) 0x7FFFFFFFFFFFFFFFLL)
00642 #endif
00643
00644 #if defined(HAVE_LONG_LONG) && !defined(ULONGLONG_MAX)
00645
00646 #ifdef ULLONG_MAX
00647 #define ULONGLONG_MAX ULLONG_MAX
00648 #else
00649 #define ULONGLONG_MAX ((unsigned long long)(~0ULL))
00650 #endif
00651 #endif
00652
00653 #define INT_MIN32 (~0x7FFFFFFFL)
00654 #define INT_MAX32 0x7FFFFFFFL
00655 #define UINT_MAX32 0xFFFFFFFFL
00656 #define INT_MIN24 (~0x007FFFFF)
00657 #define INT_MAX24 0x007FFFFF
00658 #define UINT_MAX24 0x00FFFFFF
00659 #define INT_MIN16 (~0x7FFF)
00660 #define INT_MAX16 0x7FFF
00661 #define UINT_MAX16 0xFFFF
00662 #define INT_MIN8 (~0x7F)
00663 #define INT_MAX8 0x7F
00664
00665
00666 #ifndef DBL_MIN
00667 #define DBL_MIN 4.94065645841246544e-324
00668 #define FLT_MIN ((float)1.40129846432481707e-45)
00669 #endif
00670 #ifndef DBL_MAX
00671 #define DBL_MAX 1.79769313486231470e+308
00672 #define FLT_MAX ((float)3.40282346638528860e+38)
00673 #endif
00674
00675 #if !defined(HAVE_ISINF) && !defined(isinf)
00676 #define isinf(X) 0
00677 #endif
00678
00679
00680 #ifndef M_PI
00681 #define M_PI 3.14159265358979323846
00682 #endif
00683 #ifndef M_E
00684 #define M_E 2.7182818284590452354
00685 #endif
00686 #ifndef M_LN2
00687 #define M_LN2 0.69314718055994530942
00688 #endif
00689
00690
00691
00692
00693
00694 #if SIZEOF_CHARP == 4
00695 typedef long my_ptrdiff_t;
00696 #else
00697 typedef long long my_ptrdiff_t;
00698 #endif
00699
00700 #define MY_ALIGN(A,L) (((A) + (L) - 1) & ~((L) - 1))
00701 #define ALIGN_SIZE(A) MY_ALIGN((A),sizeof(double))
00702
00703 #define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A),sizeof(t)))
00704
00705 #define OFFSET(t, f) ((size_t)(char *)&((t *)0)->f)
00706 #define ADD_TO_PTR(ptr,size,type) (type) ((byte*) (ptr)+size)
00707 #define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((byte*) (A) - (byte*) (B))
00708
00709 #define NullS (char *) 0
00710
00711 #ifndef NEAR
00712 #define NEAR
00713 #define FAR
00714 #ifndef HUGE_PTR
00715 #define HUGE_PTR
00716 #endif
00717 #endif
00718 #if defined(__IBMC__) || defined(__IBMCPP__)
00719
00720 #define STDCALL
00721 #elif !defined( STDCALL)
00722 #define STDCALL
00723 #endif
00724
00725
00726
00727 #if defined(VOIDTYPE)
00728 typedef void *gptr;
00729 #else
00730 typedef char *gptr;
00731 #endif
00732 #ifndef HAVE_INT_8_16_32
00733 typedef signed char int8;
00734 typedef short int16;
00735 #endif
00736 #ifndef HAVE_UCHAR
00737 typedef unsigned char uchar;
00738 #endif
00739 typedef unsigned char uint8;
00740 typedef unsigned short uint16;
00741
00742 #if SIZEOF_INT == 4
00743 #ifndef HAVE_INT_8_16_32
00744 typedef int int32;
00745 #endif
00746 typedef unsigned int uint32;
00747 #elif SIZEOF_LONG == 4
00748 #ifndef HAVE_INT_8_16_32
00749 typedef long int32;
00750 #endif
00751 typedef unsigned long uint32;
00752 #else
00753 error "Neither int or long is of 4 bytes width"
00754 #endif
00755
00756 #if !defined(HAVE_ULONG) && !defined(HAVE_LINUXTHREADS) && !defined(__USE_MISC)
00757 typedef unsigned long ulong;
00758 #endif
00759 #ifndef longlong_defined
00760 #if defined(HAVE_LONG_LONG) && SIZEOF_LONG != 8
00761 typedef unsigned long long int ulonglong;
00762 typedef long long int longlong;
00763 #else
00764 typedef unsigned long ulonglong;
00765 typedef long longlong;
00766 #endif
00767 #endif
00768
00769 #if defined(NO_CLIENT_LONG_LONG)
00770 typedef unsigned long my_ulonglong;
00771 #elif defined (__WIN__)
00772 typedef unsigned __int64 my_ulonglong;
00773 #else
00774 typedef unsigned long long my_ulonglong;
00775 #endif
00776
00777 #ifdef USE_RAID
00778
00779
00780
00781
00782 #if SIZEOF_OFF_T == 4
00783 #define SYSTEM_SIZEOF_OFF_T 4
00784 #else
00785 #define SYSTEM_SIZEOF_OFF_T 8
00786 #endif
00787 #undef SIZEOF_OFF_T
00788 #define SIZEOF_OFF_T 8
00789 #else
00790 #define SYSTEM_SIZEOF_OFF_T SIZEOF_OFF_T
00791 #endif
00792
00793 #if SIZEOF_OFF_T > 4
00794 typedef ulonglong my_off_t;
00795 #else
00796 typedef unsigned long my_off_t;
00797 #endif
00798 #define MY_FILEPOS_ERROR (~(my_off_t) 0)
00799 #if !defined(__WIN__) && !defined(OS2)
00800 typedef off_t os_off_t;
00801 #endif
00802
00803 #if defined(__WIN__)
00804 #define socket_errno WSAGetLastError()
00805 #define SOCKET_EINTR WSAEINTR
00806 #define SOCKET_EAGAIN WSAEINPROGRESS
00807 #define SOCKET_EWOULDBLOCK WSAEINPROGRESS
00808 #define SOCKET_ENFILE ENFILE
00809 #define SOCKET_EMFILE EMFILE
00810 #elif defined(OS2)
00811 #define socket_errno sock_errno()
00812 #define SOCKET_EINTR SOCEINTR
00813 #define SOCKET_EAGAIN SOCEINPROGRESS
00814 #define SOCKET_EWOULDBLOCK SOCEWOULDBLOCK
00815 #define SOCKET_ENFILE SOCENFILE
00816 #define SOCKET_EMFILE SOCEMFILE
00817 #define closesocket(A) soclose(A)
00818 #else
00819 #define socket_errno errno
00820 #define closesocket(A) close(A)
00821 #define SOCKET_EINTR EINTR
00822 #define SOCKET_EAGAIN EAGAIN
00823 #define SOCKET_EWOULDBLOCK EWOULDBLOCK
00824 #define SOCKET_ENFILE ENFILE
00825 #define SOCKET_EMFILE EMFILE
00826 #endif
00827
00828 typedef uint8 int7;
00829 typedef short int15;
00830 typedef char *my_string;
00831 typedef unsigned long size_s;
00832 typedef int myf;
00833 #ifndef byte_defined
00834 typedef char byte;
00835 #endif
00836 typedef char my_bool;
00837 #if !defined(bool) && !defined(bool_defined) && (!defined(HAVE_BOOL) || !defined(__cplusplus))
00838 typedef char bool;
00839 #endif
00840
00841 #define INT8(v) (int8) (v)
00842 #define INT16(v) (int16) (v)
00843 #define INT32(v) (int32) (v)
00844 #define MYF(v) (myf) (v)
00845
00846 #ifndef LL
00847 #ifdef HAVE_LONG_LONG
00848 #define LL(A) A ## LL
00849 #else
00850 #define LL(A) A ## L
00851 #endif
00852 #endif
00853
00854 #ifndef ULL
00855 #ifdef HAVE_LONG_LONG
00856 #define ULL(A) A ## ULL
00857 #else
00858 #define ULL(A) A ## UL
00859 #endif
00860 #endif
00861
00862
00863
00864
00865
00866 #ifndef USING_X
00867 #define reg1 register
00868 #define reg2 register
00869 #define reg3 register
00870 #define reg4 register
00871 #define reg5 register
00872 #define reg6 register
00873 #define reg7 register
00874 #define reg8 register
00875 #define reg9 register
00876 #define reg10 register
00877 #define reg11 register
00878 #define reg12 register
00879 #define reg13 register
00880 #define reg14 register
00881 #define reg15 register
00882 #define reg16 register
00883 #endif
00884
00885
00886
00887
00888
00889
00890 #ifndef DBUG_OFF
00891 #define dbug_volatile volatile
00892 #else
00893 #define dbug_volatile
00894 #endif
00895
00896
00897 #define SCALE_SEC 100
00898 #define SCALE_USEC 10000
00899 #define MY_HOW_OFTEN_TO_ALARM 2
00900 #define MY_HOW_OFTEN_TO_WRITE 1000
00901
00902 #ifndef set_timespec
00903 #ifdef HAVE_TIMESPEC_TS_SEC
00904 #define set_timespec(ABSTIME,SEC) { (ABSTIME).ts_sec=time(0) + (time_t) (SEC); (ABSTIME).ts_nsec=0; }
00905 #else
00906 #define set_timespec(ABSTIME,SEC) \
00907 {\
00908 struct timeval tv;\
00909 gettimeofday(&tv,0);\
00910 (ABSTIME).tv_sec=tv.tv_sec+(time_t) (SEC);\
00911 (ABSTIME).tv_nsec=tv.tv_usec*1000;\
00912 }
00913 #endif
00914 #endif
00915
00916
00917
00918
00919
00920
00921
00922 #if defined(__i386__) && !defined(_WIN64)
00923 #define sint2korr(A) (*((int16 *) (A)))
00924 #define sint3korr(A) ((int32) ((((uchar) (A)[2]) & 128) ? \
00925 (((uint32) 255L << 24) | \
00926 (((uint32) (uchar) (A)[2]) << 16) |\
00927 (((uint32) (uchar) (A)[1]) << 8) | \
00928 ((uint32) (uchar) (A)[0])) : \
00929 (((uint32) (uchar) (A)[2]) << 16) |\
00930 (((uint32) (uchar) (A)[1]) << 8) | \
00931 ((uint32) (uchar) (A)[0])))
00932 #define sint4korr(A) (*((long *) (A)))
00933 #define uint2korr(A) (*((uint16 *) (A)))
00934 #ifdef HAVE_purify
00935 #define uint3korr(A) (uint32) (((uint32) ((uchar) (A)[0])) +\
00936 (((uint32) ((uchar) (A)[1])) << 8) +\
00937 (((uint32) ((uchar) (A)[2])) << 16))
00938 #else
00939
00940
00941
00942
00943
00944
00945 #define uint3korr(A) (long) (*((unsigned int *) (A)) & 0xFFFFFF)
00946 #endif
00947 #define uint4korr(A) (*((unsigned long *) (A)))
00948 #define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
00949 (((uint32) ((uchar) (A)[1])) << 8) +\
00950 (((uint32) ((uchar) (A)[2])) << 16) +\
00951 (((uint32) ((uchar) (A)[3])) << 24)) +\
00952 (((ulonglong) ((uchar) (A)[4])) << 32))
00953 #define uint8korr(A) (*((ulonglong *) (A)))
00954 #define sint8korr(A) (*((longlong *) (A)))
00955 #define int2store(T,A) *((uint16*) (T))= (uint16) (A)
00956 #define int3store(T,A) do { *(T)= (uchar) ((A));\
00957 *(T+1)=(uchar) (((uint) (A) >> 8));\
00958 *(T+2)=(uchar) (((A) >> 16)); } while (0)
00959 #define int4store(T,A) *((long *) (T))= (long) (A)
00960 #define int5store(T,A) do { *(T)= (uchar)((A));\
00961 *((T)+1)=(uchar) (((A) >> 8));\
00962 *((T)+2)=(uchar) (((A) >> 16));\
00963 *((T)+3)=(uchar) (((A) >> 24)); \
00964 *((T)+4)=(uchar) (((A) >> 32)); } while(0)
00965 #define int8store(T,A) *((ulonglong *) (T))= (ulonglong) (A)
00966
00967 typedef union {
00968 double v;
00969 long m[2];
00970 } doubleget_union;
00971 #define doubleget(V,M) \
00972 do { doubleget_union _tmp; \
00973 _tmp.m[0] = *((long*)(M)); \
00974 _tmp.m[1] = *(((long*) (M))+1); \
00975 (V) = _tmp.v; } while(0)
00976 #define doublestore(T,V) do { *((long *) T) = ((doubleget_union *)&V)->m[0]; \
00977 *(((long *) T)+1) = ((doubleget_union *)&V)->m[1]; \
00978 } while (0)
00979 #define float4get(V,M) do { *((long *) &(V)) = *((long*) (M)); } while(0)
00980 #define float8get(V,M) doubleget((V),(M))
00981 #define float4store(V,M) memcpy((byte*) V,(byte*) (&M),sizeof(float))
00982 #define floatstore(T,V) memcpy((byte*)(T), (byte*)(&V), sizeof(float))
00983 #define float8store(V,M) doublestore((V),(M))
00984 #endif
00985
00986 #ifndef sint2korr
00987
00988
00989
00990
00991 #define sint2korr(A) (int16) (((int16) ((uchar) (A)[0])) +\
00992 ((int16) ((int16) (A)[1]) << 8))
00993 #define sint3korr(A) ((int32) ((((uchar) (A)[2]) & 128) ? \
00994 (((uint32) 255L << 24) | \
00995 (((uint32) (uchar) (A)[2]) << 16) |\
00996 (((uint32) (uchar) (A)[1]) << 8) | \
00997 ((uint32) (uchar) (A)[0])) : \
00998 (((uint32) (uchar) (A)[2]) << 16) |\
00999 (((uint32) (uchar) (A)[1]) << 8) | \
01000 ((uint32) (uchar) (A)[0])))
01001 #define sint4korr(A) (int32) (((int32) ((uchar) (A)[0])) +\
01002 (((int32) ((uchar) (A)[1]) << 8)) +\
01003 (((int32) ((uchar) (A)[2]) << 16)) +\
01004 (((int32) ((int16) (A)[3]) << 24)))
01005 #define sint8korr(A) (longlong) uint8korr(A)
01006 #define uint2korr(A) (uint16) (((uint16) ((uchar) (A)[0])) +\
01007 ((uint16) ((uchar) (A)[1]) << 8))
01008 #define uint3korr(A) (uint32) (((uint32) ((uchar) (A)[0])) +\
01009 (((uint32) ((uchar) (A)[1])) << 8) +\
01010 (((uint32) ((uchar) (A)[2])) << 16))
01011 #define uint4korr(A) (uint32) (((uint32) ((uchar) (A)[0])) +\
01012 (((uint32) ((uchar) (A)[1])) << 8) +\
01013 (((uint32) ((uchar) (A)[2])) << 16) +\
01014 (((uint32) ((uchar) (A)[3])) << 24))
01015 #define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
01016 (((uint32) ((uchar) (A)[1])) << 8) +\
01017 (((uint32) ((uchar) (A)[2])) << 16) +\
01018 (((uint32) ((uchar) (A)[3])) << 24)) +\
01019 (((ulonglong) ((uchar) (A)[4])) << 32))
01020 #define uint8korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
01021 (((uint32) ((uchar) (A)[1])) << 8) +\
01022 (((uint32) ((uchar) (A)[2])) << 16) +\
01023 (((uint32) ((uchar) (A)[3])) << 24)) +\
01024 (((ulonglong) (((uint32) ((uchar) (A)[4])) +\
01025 (((uint32) ((uchar) (A)[5])) << 8) +\
01026 (((uint32) ((uchar) (A)[6])) << 16) +\
01027 (((uint32) ((uchar) (A)[7])) << 24))) <<\
01028 32))
01029 #define int2store(T,A) do { uint def_temp= (uint) (A) ;\
01030 *((uchar*) (T))= (uchar)(def_temp); \
01031 *((uchar*) (T)+1)=(uchar)((def_temp >> 8)); \
01032 } while(0)
01033 #define int3store(T,A) do { \
01034 *((uchar*)(T))=(uchar) ((A));\
01035 *((uchar*) (T)+1)=(uchar) (((A) >> 8));\
01036 *((uchar*)(T)+2)=(uchar) (((A) >> 16)); \
01037 } while(0)
01038 #define int4store(T,A) do { *((char *)(T))=(char) ((A));\
01039 *(((char *)(T))+1)=(char) (((A) >> 8));\
01040 *(((char *)(T))+2)=(char) (((A) >> 16));\
01041 *(((char *)(T))+3)=(char) (((A) >> 24)); } while(0)
01042 #define int5store(T,A) do { *((char *)(T))=((A));\
01043 *(((char *)(T))+1)=(((A) >> 8));\
01044 *(((char *)(T))+2)=(((A) >> 16));\
01045 *(((char *)(T))+3)=(((A) >> 24)); \
01046 *(((char *)(T))+4)=(((A) >> 32)); } while(0)
01047 #define int8store(T,A) do { uint def_temp= (uint) (A), def_temp2= (uint) ((A) >> 32); \
01048 int4store((T),def_temp); \
01049 int4store((T+4),def_temp2); } while(0)
01050 #ifdef WORDS_BIGENDIAN
01051 #define float4store(T,A) do { *(T)= ((byte *) &A)[3];\
01052 *((T)+1)=(char) ((byte *) &A)[2];\
01053 *((T)+2)=(char) ((byte *) &A)[1];\
01054 *((T)+3)=(char) ((byte *) &A)[0]; } while(0)
01055
01056 #define float4get(V,M) do { float def_temp;\
01057 ((byte*) &def_temp)[0]=(M)[3];\
01058 ((byte*) &def_temp)[1]=(M)[2];\
01059 ((byte*) &def_temp)[2]=(M)[1];\
01060 ((byte*) &def_temp)[3]=(M)[0];\
01061 (V)=def_temp; } while(0)
01062 #define float8store(T,V) do { *(T)= ((byte *) &V)[7];\
01063 *((T)+1)=(char) ((byte *) &V)[6];\
01064 *((T)+2)=(char) ((byte *) &V)[5];\
01065 *((T)+3)=(char) ((byte *) &V)[4];\
01066 *((T)+4)=(char) ((byte *) &V)[3];\
01067 *((T)+5)=(char) ((byte *) &V)[2];\
01068 *((T)+6)=(char) ((byte *) &V)[1];\
01069 *((T)+7)=(char) ((byte *) &V)[0]; } while(0)
01070
01071 #define float8get(V,M) do { double def_temp;\
01072 ((byte*) &def_temp)[0]=(M)[7];\
01073 ((byte*) &def_temp)[1]=(M)[6];\
01074 ((byte*) &def_temp)[2]=(M)[5];\
01075 ((byte*) &def_temp)[3]=(M)[4];\
01076 ((byte*) &def_temp)[4]=(M)[3];\
01077 ((byte*) &def_temp)[5]=(M)[2];\
01078 ((byte*) &def_temp)[6]=(M)[1];\
01079 ((byte*) &def_temp)[7]=(M)[0];\
01080 (V) = def_temp; } while(0)
01081 #else
01082 #define float4get(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(float))
01083 #define float4store(V,M) memcpy_fixed((byte*) V,(byte*) (&M),sizeof(float))
01084
01085 #if defined(__FLOAT_WORD_ORDER) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN)
01086 #define doublestore(T,V) do { *(T)= ((byte *) &V)[4];\
01087 *(((char*)T)+1)=(char) ((byte *) &V)[5];\
01088 *(((char*)T)+2)=(char) ((byte *) &V)[6];\
01089 *(((char*)T)+3)=(char) ((byte *) &V)[7];\
01090 *(((char*)T)+4)=(char) ((byte *) &V)[0];\
01091 *(((char*)T)+5)=(char) ((byte *) &V)[1];\
01092 *(((char*)T)+6)=(char) ((byte *) &V)[2];\
01093 *(((char*)T)+7)=(char) ((byte *) &V)[3]; }\
01094 while(0)
01095 #define doubleget(V,M) do { double def_temp;\
01096 ((byte*) &def_temp)[0]=(M)[4];\
01097 ((byte*) &def_temp)[1]=(M)[5];\
01098 ((byte*) &def_temp)[2]=(M)[6];\
01099 ((byte*) &def_temp)[3]=(M)[7];\
01100 ((byte*) &def_temp)[4]=(M)[0];\
01101 ((byte*) &def_temp)[5]=(M)[1];\
01102 ((byte*) &def_temp)[6]=(M)[2];\
01103 ((byte*) &def_temp)[7]=(M)[3];\
01104 (V) = def_temp; } while(0)
01105 #endif
01106
01107 #define float8get(V,M) doubleget((V),(M))
01108 #define float8store(V,M) doublestore((V),(M))
01109 #endif
01110
01111 #endif
01112
01113
01114
01115
01116
01117 #define int4net(A) (int32) (((uint32) ((uchar) (A)[3])) |\
01118 (((uint32) ((uchar) (A)[2])) << 8) |\
01119 (((uint32) ((uchar) (A)[1])) << 16) |\
01120 (((uint32) ((uchar) (A)[0])) << 24))
01121
01122
01123
01124
01125
01126
01127 #ifdef WORDS_BIGENDIAN
01128
01129 #define ushortget(V,M) do { V = (uint16) (((uint16) ((uchar) (M)[1]))+\
01130 ((uint16) ((uint16) (M)[0]) << 8)); } while(0)
01131 #define shortget(V,M) do { V = (short) (((short) ((uchar) (M)[1]))+\
01132 ((short) ((short) (M)[0]) << 8)); } while(0)
01133 #define longget(V,M) do { int32 def_temp;\
01134 ((byte*) &def_temp)[0]=(M)[0];\
01135 ((byte*) &def_temp)[1]=(M)[1];\
01136 ((byte*) &def_temp)[2]=(M)[2];\
01137 ((byte*) &def_temp)[3]=(M)[3];\
01138 (V)=def_temp; } while(0)
01139 #define ulongget(V,M) do { uint32 def_temp;\
01140 ((byte*) &def_temp)[0]=(M)[0];\
01141 ((byte*) &def_temp)[1]=(M)[1];\
01142 ((byte*) &def_temp)[2]=(M)[2];\
01143 ((byte*) &def_temp)[3]=(M)[3];\
01144 (V)=def_temp; } while(0)
01145 #define shortstore(T,A) do { uint def_temp=(uint) (A) ;\
01146 *(((char*)T)+1)=(char)(def_temp); \
01147 *(((char*)T)+0)=(char)(def_temp >> 8); } while(0)
01148 #define longstore(T,A) do { *(((char*)T)+3)=((A));\
01149 *(((char*)T)+2)=(((A) >> 8));\
01150 *(((char*)T)+1)=(((A) >> 16));\
01151 *(((char*)T)+0)=(((A) >> 24)); } while(0)
01152
01153 #define floatstore(T,V) memcpy_fixed((byte*)(T), (byte*)(&V), sizeof(float))
01154 #define doubleget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(double))
01155 #define doublestore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(double))
01156 #define longlongget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(ulonglong))
01157 #define longlongstore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(ulonglong))
01158
01159 #else
01160
01161 #define ushortget(V,M) do { V = uint2korr(M); } while(0)
01162 #define shortget(V,M) do { V = sint2korr(M); } while(0)
01163 #define longget(V,M) do { V = sint4korr(M); } while(0)
01164 #define ulongget(V,M) do { V = uint4korr(M); } while(0)
01165 #define shortstore(T,V) int2store(T,V)
01166 #define longstore(T,V) int4store(T,V)
01167 #ifndef floatstore
01168 #define floatstore(T,V) memcpy_fixed((byte*)(T), (byte*)(&V), sizeof(float))
01169 #endif
01170 #ifndef doubleget
01171 #define doubleget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(double))
01172 #define doublestore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(double))
01173 #endif
01174 #define longlongget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(ulonglong))
01175 #define longlongstore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(ulonglong))
01176
0