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