PageRenderTime 74ms CodeModel.GetById 13ms app.highlight 45ms RepoModel.GetById 1ms app.codeStats 1ms

/External/Mysql-5.0/include/my_global.h

http://awoe.googlecode.com/
C++ Header | 1570 lines | 1089 code | 166 blank | 315 comment | 100 complexity | 4593438213b648ecf3820652afeac332 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

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

Large files files are truncated, but you can click here to view the full file