Eneboo - Documentación para desarrolladores
src/libmysql_std/include/my_global.h
Ir a la documentación de este archivo.
00001 /* Copyright (C) 2000-2003 MySQL AB
00002 
00003    This program is free software; you can redistribute it and/or modify
00004    it under the terms of the GNU General Public License as published by
00005    the Free Software Foundation; version 2 of the License.
00006 
00007    This program is distributed in the hope that it will be useful,
00008    but WITHOUT ANY WARRANTY; without even the implied warranty of
00009    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00010    GNU General Public License for more details.
00011 
00012    You should have received a copy of the GNU General Public License
00013    along with this program; if not, write to the Free Software
00014    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
00015 
00016 /* This is the include file that should be included 'first' in every C file. */
00017 
00018 #ifndef _global_h
00019 #define _global_h
00020 
00021 #ifndef EMBEDDED_LIBRARY
00022 #define HAVE_REPLICATION
00023 #define HAVE_EXTERNAL_CLIENT
00024 #endif
00025 
00026 #if defined( __EMX__) && !defined( MYSQL_SERVER)
00027 /* moved here to use below VOID macro redefinition */
00028 #define INCL_BASE
00029 #define INCL_NOPMAPI
00030 #include <os2.h>
00031 #endif /* __EMX__ */
00032 
00033 #ifdef __CYGWIN__
00034 /* We use a Unix API, so pretend it's not Windows */
00035 #undef WIN
00036 #undef WIN32
00037 #undef _WIN
00038 #undef _WIN32
00039 #undef _WIN64
00040 #undef __WIN__
00041 #undef __WIN32__
00042 #define HAVE_ERRNO_AS_DEFINE
00043 #endif /* __CYGWIN__ */
00044 
00045 #if defined(__QNXNTO__) && !defined(FD_SETSIZE)
00046 #define FD_SETSIZE 1024         /* Max number of file descriptor bits in
00047                                    fd_set, used when calling 'select'
00048                                    Must be defined before including
00049                                    "sys/select.h" and "sys/time.h"
00050                                  */
00051 #endif
00052 
00053 
00054 /* to make command line shorter we'll define USE_PRAGMA_INTERFACE here */
00055 #ifdef USE_PRAGMA_IMPLEMENTATION
00056 #define USE_PRAGMA_INTERFACE
00057 #endif
00058 
00059 #if defined(i386) && !defined(__i386__)
00060 #define __i386__
00061 #endif
00062 
00063 /* Macros to make switching between C and C++ mode easier */
00064 #ifdef __cplusplus
00065 #define C_MODE_START    extern "C" {
00066 #define C_MODE_END      }
00067 #else
00068 #define C_MODE_START
00069 #define C_MODE_END
00070 #endif
00071 
00072 #if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32)
00073 #include <config-win.h>
00074 #elif defined(OS2)
00075 #include <config-os2.h>
00076 #elif defined(__NETWARE__)
00077 #include <my_config.h>
00078 #include <config-netware.h>
00079 #if defined(__cplusplus) && defined(inline)
00080 #undef inline                           /* fix configure problem */
00081 #endif
00082 #else
00083 #include <my_config.h>
00084 #if defined(__cplusplus) && defined(inline)
00085 #undef inline                           /* fix configure problem */
00086 #endif
00087 #endif /* _WIN32... */
00088 
00089 /* Make it easier to add conditionl code for windows */
00090 #ifdef __WIN__
00091 #define IF_WIN(A,B) (A)
00092 #else
00093 #define IF_WIN(A,B) (B)
00094 #endif
00095 
00096 
00097 /* Some defines to avoid ifdefs in the code */
00098 #ifndef NETWARE_YIELD
00099 #define NETWARE_YIELD
00100 #define NETWARE_SET_SCREEN_MODE(A)
00101 #endif
00102 
00103 /*
00104   The macros below are used to allow build of Universal/fat binaries of
00105   MySQL and MySQL applications under darwin. 
00106 */
00107 #ifdef TARGET_FAT_BINARY
00108 # undef SIZEOF_CHARP 
00109 # undef SIZEOF_INT 
00110 # undef SIZEOF_LONG 
00111 # undef SIZEOF_LONG_LONG 
00112 # undef SIZEOF_OFF_T 
00113 # undef SIZEOF_SHORT 
00114 
00115 #if defined(__i386__)
00116 # undef WORDS_BIGENDIAN
00117 # define SIZEOF_CHARP 4
00118 # define SIZEOF_INT 4
00119 # define SIZEOF_LONG 4
00120 # define SIZEOF_LONG_LONG 8
00121 # define SIZEOF_OFF_T 8
00122 # define SIZEOF_SHORT 2
00123 
00124 #elif defined(__ppc__)
00125 # define WORDS_BIGENDIAN
00126 # define SIZEOF_CHARP 4
00127 # define SIZEOF_INT 4
00128 # define SIZEOF_LONG 4
00129 # define SIZEOF_LONG_LONG 8
00130 # define SIZEOF_OFF_T 8
00131 # define SIZEOF_SHORT 2
00132 
00133 #else
00134 # error Building FAT binary for an unknown architecture.
00135 #endif
00136 #endif /* TARGET_FAT_BINARY */
00137 
00138 
00139 /*
00140   The macros below are borrowed from include/linux/compiler.h in the
00141   Linux kernel. Use them to indicate the likelyhood of the truthfulness
00142   of a condition. This serves two purposes - newer versions of gcc will be
00143   able to optimize for branch predication, which could yield siginficant
00144   performance gains in frequently executed sections of the code, and the
00145   other reason to use them is for documentation
00146 */
00147 
00148 #if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
00149 #define __builtin_expect(x, expected_value) (x)
00150 #endif
00151 
00152 #define likely(x)       __builtin_expect((x),1)
00153 #define unlikely(x)     __builtin_expect((x),0)
00154 
00155 
00156 /* Fix problem with S_ISLNK() on Linux */
00157 #if defined(TARGET_OS_LINUX) || defined(__GLIBC__)
00158 #undef  _GNU_SOURCE
00159 #define _GNU_SOURCE 1
00160 #endif
00161 
00162 /*
00163   Temporary solution to solve bug#7156. Include "sys/types.h" before
00164   the thread headers, else the function madvise() will not be defined
00165 */
00166 #if defined(HAVE_SYS_TYPES_H) && ( defined(sun) || defined(__sun) )
00167 #include <sys/types.h>
00168 #endif
00169 
00170 /* The client defines this to avoid all thread code */
00171 #if defined(UNDEF_THREADS_HACK)
00172 #undef THREAD
00173 #undef HAVE_mit_thread
00174 #undef HAVE_LINUXTHREADS
00175 #undef HAVE_NPTL
00176 #undef HAVE_UNIXWARE7_THREADS
00177 #endif
00178 
00179 #ifdef HAVE_THREADS_WITHOUT_SOCKETS
00180 /* MIT pthreads does not work with unix sockets */
00181 #undef HAVE_SYS_UN_H
00182 #endif
00183 
00184 #define __EXTENSIONS__ 1        /* We want some extension */
00185 #ifndef __STDC_EXT__
00186 #define __STDC_EXT__ 1          /* To get large file support on hpux */
00187 #endif
00188 
00189 /*
00190   Solaris 9 include file <sys/feature_tests.h> refers to X/Open document
00191 
00192     System Interfaces and Headers, Issue 5
00193 
00194   saying we should define _XOPEN_SOURCE=500 to get POSIX.1c prototypes,
00195   but apparently other systems (namely FreeBSD) don't agree.
00196 
00197   On a newer Solaris 10, the above file recognizes also _XOPEN_SOURCE=600.
00198   Furthermore, it tests that if a program requires older standard
00199   (_XOPEN_SOURCE<600 or _POSIX_C_SOURCE<200112L) it cannot be
00200   run on a new compiler (that defines _STDC_C99) and issues an #error.
00201   It's also an #error if a program requires new standard (_XOPEN_SOURCE=600
00202   or _POSIX_C_SOURCE=200112L) and a compiler does not define _STDC_C99.
00203 
00204   To add more to this mess, Sun Studio C compiler defines _STDC_C99 while
00205   C++ compiler does not!
00206 
00207   So, in a desperate attempt to get correct prototypes for both
00208   C and C++ code, we define either _XOPEN_SOURCE=600 or _XOPEN_SOURCE=500
00209   depending on the compiler's announced C standard support.
00210 
00211   Cleaner solutions are welcome.
00212 */
00213 #ifdef __sun
00214 #if __STDC_VERSION__ - 0 >= 199901L
00215 #define _XOPEN_SOURCE 600
00216 #else
00217 #define _XOPEN_SOURCE 500
00218 #endif
00219 #endif
00220 
00221 #if defined(THREAD) && !defined(__WIN__) && !defined(OS2)
00222 #ifndef _POSIX_PTHREAD_SEMANTICS
00223 #define _POSIX_PTHREAD_SEMANTICS /* We want posix threads */
00224 #endif
00225 
00226 #if !defined(SCO)
00227 #define _REENTRANT      1       /* Some thread libraries require this */
00228 #endif
00229 #if !defined(_THREAD_SAFE) && !defined(_AIX)
00230 #define _THREAD_SAFE            /* Required for OSF1 */
00231 #endif
00232 #ifndef HAVE_mit_thread
00233 #ifdef HAVE_UNIXWARE7_THREADS
00234 #include <thread.h>
00235 #else
00236 #if defined(HPUX10) || defined(HPUX11)
00237 C_MODE_START                    /* HPUX needs this, signal.h bug */
00238 #include <pthread.h>
00239 C_MODE_END
00240 #else
00241 #include <pthread.h>            /* AIX must have this included first */
00242 #endif
00243 #endif /* HAVE_UNIXWARE7_THREADS */
00244 #endif /* HAVE_mit_thread */
00245 #if !defined(SCO) && !defined(_REENTRANT)
00246 #define _REENTRANT      1       /* Threads requires reentrant code */
00247 #endif
00248 #endif /* THREAD */
00249 
00250 /* Go around some bugs in different OS and compilers */
00251 #ifdef _AIX                     /* By soren@t.dk */
00252 #define _H_STRINGS
00253 #define _SYS_STREAM_H
00254 /* #define _AIX32_CURSES */     /* XXX: this breaks AIX 4.3.3 (others?). */
00255 #define ulonglong2double(A) my_ulonglong2double(A)
00256 #define my_off_t2double(A)  my_ulonglong2double(A)
00257 C_MODE_START
00258 double my_ulonglong2double(unsigned long long A);
00259 C_MODE_END
00260 #endif /* _AIX */
00261 
00262 #ifdef HAVE_BROKEN_SNPRINTF     /* HPUX 10.20 don't have this defined */
00263 #undef HAVE_SNPRINTF
00264 #endif
00265 #ifdef HAVE_BROKEN_PREAD
00266 /*
00267   pread()/pwrite() are not 64 bit safe on HP-UX 11.0 without
00268   installing the kernel patch PHKL_20349 or greater
00269 */
00270 #undef HAVE_PREAD
00271 #undef HAVE_PWRITE
00272 #endif
00273 #if defined(HAVE_BROKEN_INLINE) && !defined(__cplusplus)
00274 #undef inline
00275 #define inline
00276 #endif
00277 
00278 #ifdef UNDEF_HAVE_GETHOSTBYNAME_R               /* For OSF4.x */
00279 #undef HAVE_GETHOSTBYNAME_R
00280 #endif
00281 #ifdef UNDEF_HAVE_INITGROUPS                    /* For AIX 4.3 */
00282 #undef HAVE_INITGROUPS
00283 #endif
00284 
00285 /* gcc/egcs issues */
00286 
00287 #if defined(__GNUC) && defined(__EXCEPTIONS)
00288 #error "Please add -fno-exceptions to CXXFLAGS and reconfigure/recompile"
00289 #endif
00290 
00291 
00292 /* Fix a bug in gcc 2.8.0 on IRIX 6.2 */
00293 #if SIZEOF_LONG == 4 && defined(__LONG_MAX__) && (__GNUC__ == 2 && __GNUC_MINOR__ == 8)
00294 #undef __LONG_MAX__             /* Is a longlong value in gcc 2.8.0 ??? */
00295 #define __LONG_MAX__ 2147483647
00296 #endif
00297 
00298 /* egcs 1.1.2 has a problem with memcpy on Alpha */
00299 #if defined(__GNUC__) && defined(__alpha__) && ! (__GNUC__ > 2 || (__GNUC__ == 2 &&  __GNUC_MINOR__ >= 95))
00300 #define BAD_MEMCPY
00301 #endif
00302 
00303 #if defined(_lint) && !defined(lint)
00304 #define lint
00305 #endif
00306 #if SIZEOF_LONG_LONG > 4 && !defined(_LONG_LONG)
00307 #define _LONG_LONG 1            /* For AIX string library */
00308 #endif
00309 
00310 #ifndef stdin
00311 #include <stdio.h>
00312 #endif
00313 #ifdef HAVE_STDLIB_H
00314 #include <stdlib.h>
00315 #endif
00316 #ifdef HAVE_STDDEF_H
00317 #include <stddef.h>
00318 #endif
00319 
00320 #include <math.h>
00321 #ifdef HAVE_LIMITS_H
00322 #include <limits.h>
00323 #endif
00324 #ifdef HAVE_FLOAT_H
00325 #include <float.h>
00326 #endif
00327 
00328 #ifdef HAVE_SYS_TYPES_H
00329 #include <sys/types.h>
00330 #endif
00331 #ifdef HAVE_FCNTL_H
00332 #include <fcntl.h>
00333 #endif
00334 #ifdef HAVE_SYS_TIMEB_H
00335 #include <sys/timeb.h>                          /* Avoid warnings on SCO */
00336 #endif
00337 #if TIME_WITH_SYS_TIME
00338 # include <sys/time.h>
00339 # include <time.h>
00340 #else
00341 # if HAVE_SYS_TIME_H
00342 #  include <sys/time.h>
00343 # else
00344 #  include <time.h>
00345 # endif
00346 #endif /* TIME_WITH_SYS_TIME */
00347 #ifdef HAVE_UNISTD_H
00348 #include <unistd.h>
00349 #endif
00350 #if defined(__cplusplus) && defined(NO_CPLUSPLUS_ALLOCA)
00351 #undef HAVE_ALLOCA
00352 #undef HAVE_ALLOCA_H
00353 #endif
00354 #ifdef HAVE_ALLOCA_H
00355 #include <alloca.h>
00356 #endif
00357 #ifdef HAVE_ATOMIC_ADD
00358 #define new my_arg_new
00359 #define need_to_restore_new 1
00360 C_MODE_START
00361 #include <asm/atomic.h>
00362 C_MODE_END
00363 #ifdef need_to_restore_new /* probably safer than #ifdef new */
00364 #undef new
00365 #undef need_to_restore_new
00366 #endif
00367 #endif
00368 #include <errno.h>                              /* Recommended by debian */
00369 /* We need the following to go around a problem with openssl on solaris */
00370 #if defined(HAVE_CRYPT_H)
00371 #include <crypt.h>
00372 #endif
00373 
00374 /*
00375   A lot of our programs uses asserts, so better to always include it
00376   This also fixes a problem when people uses DBUG_ASSERT without including
00377   assert.h
00378 */
00379 #include <assert.h>
00380 
00381 /* Go around some bugs in different OS and compilers */
00382 #if defined(_HPUX_SOURCE) && defined(HAVE_SYS_STREAM_H)
00383 #include <sys/stream.h>         /* HPUX 10.20 defines ulong here. UGLY !!! */
00384 #define HAVE_ULONG
00385 #endif
00386 #ifdef DONT_USE_FINITE          /* HPUX 11.x has is_finite() */
00387 #undef HAVE_FINITE
00388 #endif
00389 #if defined(HPUX10) && defined(_LARGEFILE64_SOURCE) && defined(THREAD)
00390 /* Fix bug in setrlimit */
00391 #undef setrlimit
00392 #define setrlimit cma_setrlimit64
00393 #endif
00394 /* Declare madvise where it is not declared for C++, like Solaris */
00395 #if HAVE_MADVISE && !HAVE_DECL_MADVISE && defined(__cplusplus)
00396 extern "C" int madvise(void *addr, size_t len, int behav);
00397 #endif
00398 
00399 #ifdef __QNXNTO__
00400 /* This has to be after include limits.h */
00401 #define HAVE_ERRNO_AS_DEFINE
00402 #define HAVE_FCNTL_LOCK
00403 #undef  HAVE_FINITE
00404 #undef  LONGLONG_MIN            /* These get wrongly defined in QNX 6.2 */
00405 #undef  LONGLONG_MAX            /* standard system library 'limits.h' */
00406 #ifdef __cplusplus
00407 #ifndef HAVE_RINT
00408 #define HAVE_RINT
00409 #endif                          /* rint() and isnan() functions are not */
00410 #define rint(a) std::rint(a)    /* visible in C++ scope due to an error */
00411 #define isnan(a) std::isnan(a)  /* in the usr/include/math.h on QNX     */
00412 #endif
00413 #endif
00414 
00415 /* We can not live without the following defines */
00416 
00417 #define USE_MYFUNC 1            /* Must use syscall indirection */
00418 #define MASTER 1                /* Compile without unireg */
00419 #define ENGLISH 1               /* Messages in English */
00420 #define POSIX_MISTAKE 1         /* regexp: Fix stupid spec error */
00421 #define USE_REGEX 1             /* We want the use the regex library */
00422 /* Do not define for ultra sparcs */
00423 #ifndef OS2
00424 #define USE_BMOVE512 1          /* Use this unless system bmove is faster */
00425 #endif
00426 
00427 #define QUOTE_ARG(x)            #x      /* Quote argument (before cpp) */
00428 #define STRINGIFY_ARG(x) QUOTE_ARG(x)   /* Quote argument, after cpp */
00429 
00430 /* Paranoid settings. Define I_AM_PARANOID if you are paranoid */
00431 #ifdef I_AM_PARANOID
00432 #define DONT_ALLOW_USER_CHANGE 1
00433 #define DONT_USE_MYSQL_PWD 1
00434 #endif
00435 
00436 /* Does the system remember a signal handler after a signal ? */
00437 #ifndef HAVE_BSD_SIGNALS
00438 #define DONT_REMEMBER_SIGNAL
00439 #endif
00440 
00441 /* Define void to stop lint from generating "null effekt" comments */
00442 #ifndef DONT_DEFINE_VOID
00443 #ifdef _lint
00444 int     __void__;
00445 #define VOID(X)         (__void__ = (int) (X))
00446 #else
00447 #undef VOID
00448 #define VOID(X)         (X)
00449 #endif
00450 #endif /* DONT_DEFINE_VOID */
00451 
00452 #if defined(_lint) || defined(FORCE_INIT_OF_VARS)
00453 #define LINT_INIT(var)  var=0                   /* No uninitialize-warning */
00454 #else
00455 #define LINT_INIT(var)
00456 #endif
00457 
00458 #if defined(_lint) || defined(FORCE_INIT_OF_VARS) || defined(HAVE_purify)
00459 #define PURIFY_OR_LINT_INIT(var) var=0
00460 #else
00461 #define PURIFY_OR_LINT_INIT(var)
00462 #endif
00463 
00464 /* Define some useful general macros */
00465 #if !defined(max)
00466 #define max(a, b)       ((a) > (b) ? (a) : (b))
00467 #define min(a, b)       ((a) < (b) ? (a) : (b))
00468 #endif
00469 
00470 #if defined(__EMX__) || !defined(HAVE_UINT)
00471 #undef HAVE_UINT
00472 #define HAVE_UINT
00473 typedef unsigned int uint;
00474 typedef unsigned short ushort;
00475 #endif
00476 
00477 #define CMP_NUM(a,b)    (((a) < (b)) ? -1 : ((a) == (b)) ? 0 : 1)
00478 #define sgn(a)          (((a) < 0) ? -1 : ((a) > 0) ? 1 : 0)
00479 #define swap_variables(t, a, b) { register t dummy; dummy= a; a= b; b= dummy; }
00480 #define test(a)         ((a) ? 1 : 0)
00481 #define set_if_bigger(a,b)  do { if ((a) < (b)) (a)=(b); } while(0)
00482 #define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0)
00483 #define test_all_bits(a,b) (((a) & (b)) == (b))
00484 #define set_bits(type, bit_count) (sizeof(type)*8 <= (bit_count) ? ~(type) 0 : ((((type) 1) << (bit_count)) - (type) 1))
00485 #define array_elements(A) ((uint) (sizeof(A)/sizeof(A[0])))
00486 #ifndef HAVE_RINT
00487 #define rint(A) floor((A)+(((A) < 0)? -0.5 : 0.5))
00488 #endif
00489 
00490 /* Define some general constants */
00491 #ifndef TRUE
00492 #define TRUE            (1)     /* Logical true */
00493 #define FALSE           (0)     /* Logical false */
00494 #endif
00495 
00496 #if defined(__GNUC__)
00497 #define function_volatile       volatile
00498 #define my_reinterpret_cast(A) reinterpret_cast<A>
00499 #define my_const_cast(A) const_cast<A>
00500 # ifndef GCC_VERSION
00501 #  define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
00502 # endif
00503 #elif !defined(my_reinterpret_cast)
00504 #define my_reinterpret_cast(A) (A)
00505 #define my_const_cast(A) (A)
00506 #endif
00507 
00508 #include <my_attribute.h>
00509 
00510 /*
00511   Wen using the embedded library, users might run into link problems,
00512   duplicate declaration of __cxa_pure_virtual, solved by declaring it a
00513   weak symbol.
00514 */
00515 #if defined(USE_MYSYS_NEW) && ! defined(DONT_DECLARE_CXA_PURE_VIRTUAL)
00516 C_MODE_START
00517 int __cxa_pure_virtual () __attribute__ ((weak));
00518 C_MODE_END
00519 #endif
00520 
00521 /* From old s-system.h */
00522 
00523 /*
00524   Support macros for non ansi & other old compilers. Since such
00525   things are no longer supported we do nothing. We keep then since
00526   some of our code may still be needed to upgrade old customers.
00527 */
00528 #define _VARARGS(X) X
00529 #define _STATIC_VARARGS(X) X
00530 #define _PC(X)  X
00531 
00532 #if defined(DBUG_ON) && defined(DBUG_OFF)
00533 #undef DBUG_OFF
00534 #endif
00535 
00536 #if defined(_lint) && !defined(DBUG_OFF)
00537 #define DBUG_OFF
00538 #endif
00539 
00540 #include <my_dbug.h>
00541 
00542 #define MIN_ARRAY_SIZE  0       /* Zero or One. Gcc allows zero*/
00543 #define ASCII_BITS_USED 8       /* Bit char used */
00544 #define NEAR_F                  /* No near function handling */
00545 
00546 /* Some types that is different between systems */
00547 
00548 typedef int     File;           /* File descriptor */
00549 #ifndef Socket_defined
00550 typedef int     my_socket;      /* File descriptor for sockets */
00551 #define INVALID_SOCKET -1
00552 #endif
00553 /* Type for fuctions that handles signals */
00554 #define sig_handler RETSIGTYPE
00555 C_MODE_START
00556 typedef void    (*sig_return)();/* Returns type from signal */
00557 C_MODE_END
00558 #if defined(__GNUC__) && !defined(_lint)
00559 typedef char    pchar;          /* Mixed prototypes can take char */
00560 typedef char    puchar;         /* Mixed prototypes can take char */
00561 typedef char    pbool;          /* Mixed prototypes can take char */
00562 typedef short   pshort;         /* Mixed prototypes can take short int */
00563 typedef float   pfloat;         /* Mixed prototypes can take float */
00564 #else
00565 typedef int     pchar;          /* Mixed prototypes can't take char */
00566 typedef uint    puchar;         /* Mixed prototypes can't take char */
00567 typedef int     pbool;          /* Mixed prototypes can't take char */
00568 typedef int     pshort;         /* Mixed prototypes can't take short int */
00569 typedef double  pfloat;         /* Mixed prototypes can't take float */
00570 #endif
00571 C_MODE_START
00572 typedef int     (*qsort_cmp)(const void *,const void *);
00573 typedef int     (*qsort_cmp2)(void*, const void *,const void *);
00574 C_MODE_END
00575 #ifdef HAVE_mit_thread
00576 #define qsort_t void
00577 #undef QSORT_TYPE_IS_VOID
00578 #define QSORT_TYPE_IS_VOID
00579 #else
00580 #define qsort_t RETQSORTTYPE    /* Broken GCC cant handle typedef !!!! */
00581 #endif
00582 #ifdef HAVE_mit_thread
00583 #define size_socket socklen_t   /* Type of last arg to accept */
00584 #else
00585 #ifdef HAVE_SYS_SOCKET_H
00586 #include <sys/socket.h>
00587 #endif
00588 typedef SOCKET_SIZE_TYPE size_socket;
00589 #endif
00590 
00591 #ifndef SOCKOPT_OPTLEN_TYPE
00592 #define SOCKOPT_OPTLEN_TYPE size_socket
00593 #endif
00594 
00595 /* file create flags */
00596 
00597 #ifndef O_SHARE                 /* Probably not windows */
00598 #define O_SHARE         0       /* Flag to my_open for shared files */
00599 #ifndef O_BINARY
00600 #define O_BINARY        0       /* Flag to my_open for binary files */
00601 #endif
00602 #ifndef FILE_BINARY
00603 #define FILE_BINARY     O_BINARY /* Flag to my_fopen for binary streams */
00604 #endif
00605 #ifdef HAVE_FCNTL
00606 #define HAVE_FCNTL_LOCK
00607 #define F_TO_EOF        0L      /* Param to lockf() to lock rest of file */
00608 #endif
00609 #endif /* O_SHARE */
00610 
00611 #ifndef O_TEMPORARY
00612 #define O_TEMPORARY     0
00613 #endif
00614 #ifndef O_SHORT_LIVED
00615 #define O_SHORT_LIVED   0
00616 #endif
00617 #ifndef O_NOFOLLOW
00618 #define O_NOFOLLOW      0
00619 #endif
00620 
00621 /* additional file share flags for win32 */
00622 #ifdef __WIN__
00623 #define _SH_DENYRWD     0x110    /* deny read/write mode & delete */
00624 #define _SH_DENYWRD     0x120    /* deny write mode & delete      */
00625 #define _SH_DENYRDD     0x130    /* deny read mode & delete       */
00626 #define _SH_DENYDEL     0x140    /* deny delete only              */
00627 #endif /* __WIN__ */
00628 
00629 
00630 /* #define USE_RECORD_LOCK      */
00631 
00632         /* Unsigned types supported by the compiler */
00633 #define UNSINT8                 /* unsigned int8 (char) */
00634 #define UNSINT16                /* unsigned int16 */
00635 #define UNSINT32                /* unsigned int32 */
00636 
00637         /* General constants */
00638 #define SC_MAXWIDTH     256     /* Max width of screen (for error messages) */
00639 #define FN_LEN          256     /* Max file name len */
00640 #define FN_HEADLEN      253     /* Max length of filepart of file name */
00641 #define FN_EXTLEN       20      /* Max length of extension (part of FN_LEN) */
00642 #define FN_REFLEN       512     /* Max length of full path-name */
00643 #define FN_EXTCHAR      '.'
00644 #define FN_HOMELIB      '~'     /* ~/ is used as abbrev for home dir */
00645 #define FN_CURLIB       '.'     /* ./ is used as abbrev for current dir */
00646 #define FN_PARENTDIR    ".."    /* Parent directory; Must be a string */
00647 
00648 #ifndef FN_LIBCHAR
00649 #ifdef __EMX__
00650 #define FN_LIBCHAR      '\\'
00651 #define FN_ROOTDIR      "\\"
00652 #else
00653 #define FN_LIBCHAR      '/'
00654 #define FN_ROOTDIR      "/"
00655 #endif
00656 #endif
00657 #define MY_NFILE        64      /* This is only used to save filenames */
00658 #ifndef OS_FILE_LIMIT
00659 #define OS_FILE_LIMIT   65535
00660 #endif
00661 
00662 /* #define EXT_IN_LIBNAME     */
00663 /* #define FN_NO_CASE_SENCE   */
00664 /* #define FN_UPPER_CASE TRUE */
00665 
00666 /*
00667   Io buffer size; Must be a power of 2 and a multiple of 512. May be
00668   smaller what the disk page size. This influences the speed of the
00669   isam btree library. eg to big to slow.
00670 */
00671 #define IO_SIZE                 4096
00672 /*
00673   How much overhead does malloc have. The code often allocates
00674   something like 1024-MALLOC_OVERHEAD bytes
00675 */
00676 #ifdef SAFEMALLOC
00677 #define MALLOC_OVERHEAD (8+24+4)
00678 #else
00679 #define MALLOC_OVERHEAD 8
00680 #endif
00681         /* get memory in huncs */
00682 #define ONCE_ALLOC_INIT         (uint) (4096-MALLOC_OVERHEAD)
00683         /* Typical record cash */
00684 #define RECORD_CACHE_SIZE       (uint) (64*1024-MALLOC_OVERHEAD)
00685         /* Typical key cash */
00686 #define KEY_CACHE_SIZE          (uint) (8*1024*1024-MALLOC_OVERHEAD)
00687         /* Default size of a key cache block  */
00688 #define KEY_CACHE_BLOCK_SIZE    (uint) 1024
00689 
00690 
00691         /* Some things that this system doesn't have */
00692 
00693 #define NO_HASH                 /* Not needed anymore */
00694 #ifdef __WIN__
00695 #define NO_DIR_LIBRARY          /* Not standar dir-library */
00696 #define USE_MY_STAT_STRUCT      /* For my_lib */
00697 #endif
00698 
00699 /* Some defines of functions for portability */
00700 
00701 #undef remove           /* Crashes MySQL on SCO 5.0.0 */
00702 #ifndef __WIN__
00703 #ifdef OS2
00704 #define closesocket(A)  soclose(A)
00705 #else
00706 #define closesocket(A)  close(A)
00707 #endif
00708 #ifndef ulonglong2double
00709 #define ulonglong2double(A) ((double) (ulonglong) (A))
00710 #define my_off_t2double(A)  ((double) (my_off_t) (A))
00711 #endif
00712 #endif
00713 
00714 #ifndef offsetof
00715 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
00716 #endif
00717 #define ulong_to_double(X) ((double) (ulong) (X))
00718 #define SET_STACK_SIZE(X)       /* Not needed on real machines */
00719 
00720 #if !defined(HAVE_mit_thread) && !defined(HAVE_STRTOK_R)
00721 #define strtok_r(A,B,C) strtok((A),(B))
00722 #endif
00723 
00724 /* Remove some things that mit_thread break or doesn't support */
00725 #if defined(HAVE_mit_thread) && defined(THREAD)
00726 #undef HAVE_PREAD
00727 #undef HAVE_REALPATH
00728 #undef HAVE_MLOCK
00729 #undef HAVE_TEMPNAM                             /* Use ours */
00730 #undef HAVE_PTHREAD_SETPRIO
00731 #undef HAVE_FTRUNCATE
00732 #undef HAVE_READLINK
00733 #endif
00734 
00735 /* This is from the old m-machine.h file */
00736 
00737 #if SIZEOF_LONG_LONG > 4
00738 #define HAVE_LONG_LONG 1
00739 #endif
00740 
00741 /*
00742   Some pre-ANSI-C99 systems like AIX 5.1 and Linux/GCC 2.95 define
00743   ULONGLONG_MAX, LONGLONG_MIN, LONGLONG_MAX; we use them if they're defined.
00744   Also on Windows we define these constants by hand in config-win.h.
00745 */
00746 
00747 #if defined(HAVE_LONG_LONG) && !defined(LONGLONG_MIN)
00748 #define LONGLONG_MIN    ((long long) 0x8000000000000000LL)
00749 #define LONGLONG_MAX    ((long long) 0x7FFFFFFFFFFFFFFFLL)
00750 #endif
00751 
00752 #if defined(HAVE_LONG_LONG) && !defined(ULONGLONG_MAX)
00753 /* First check for ANSI C99 definition: */
00754 #ifdef ULLONG_MAX
00755 #define ULONGLONG_MAX  ULLONG_MAX
00756 #else
00757 #define ULONGLONG_MAX ((unsigned long long)(~0ULL))
00758 #endif
00759 #endif /* defined (HAVE_LONG_LONG) && !defined(ULONGLONG_MAX)*/
00760 
00761 #define INT_MIN32       (~0x7FFFFFFFL)
00762 #define INT_MAX32       0x7FFFFFFFL
00763 #define UINT_MAX32      0xFFFFFFFFL
00764 #define INT_MIN24       (~0x007FFFFF)
00765 #define INT_MAX24       0x007FFFFF
00766 #define UINT_MAX24      0x00FFFFFF
00767 #define INT_MIN16       (~0x7FFF)
00768 #define INT_MAX16       0x7FFF
00769 #define UINT_MAX16      0xFFFF
00770 #define INT_MIN8        (~0x7F)
00771 #define INT_MAX8        0x7F
00772 #define UINT_MAX8       0xFF
00773 
00774 /* From limits.h instead */
00775 #ifndef DBL_MIN
00776 #define DBL_MIN         4.94065645841246544e-324
00777 #define FLT_MIN         ((float)1.40129846432481707e-45)
00778 #endif
00779 #ifndef DBL_MAX
00780 #define DBL_MAX         1.79769313486231470e+308
00781 #define FLT_MAX         ((float)3.40282346638528860e+38)
00782 #endif
00783 #ifndef SSIZE_MAX
00784 #define SSIZE_MAX ((~((size_t) 0)) / 2)
00785 #endif
00786 
00787 #ifndef HAVE_FINITE
00788 #define finite(x) (1.0 / fabs(x) > 0.0)
00789 #endif
00790 
00791 #ifndef HAVE_ISNAN
00792 #define isnan(x) ((x) != (x))
00793 #endif
00794 
00795 #ifdef HAVE_ISINF
00796 /* isinf() can be used in both C and C++ code */
00797 #define my_isinf(X) isinf(X)
00798 #else
00799 #define my_isinf(X) (!finite(X) && !isnan(X))
00800 #endif
00801 
00802 /* Define missing math constants. */
00803 #ifndef M_PI
00804 #define M_PI 3.14159265358979323846
00805 #endif
00806 #ifndef M_E
00807 #define M_E 2.7182818284590452354
00808 #endif
00809 #ifndef M_LN2
00810 #define M_LN2 0.69314718055994530942
00811 #endif
00812 
00813 /*
00814   Max size that must be added to a so that we know Size to make
00815   adressable obj.
00816 */
00817 #if SIZEOF_CHARP == 4
00818 typedef long            my_ptrdiff_t;
00819 #else
00820 typedef long long       my_ptrdiff_t;
00821 #endif
00822 
00823 #define MY_ALIGN(A,L)   (((A) + (L) - 1) & ~((L) - 1))
00824 #define ALIGN_SIZE(A)   MY_ALIGN((A),sizeof(double))
00825 /* Size to make adressable obj. */
00826 #define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A),sizeof(t)))
00827                          /* Offset of field f in structure t */
00828 #define OFFSET(t, f)    ((size_t)(char *)&((t *)0)->f)
00829 #define ADD_TO_PTR(ptr,size,type) (type) ((byte*) (ptr)+size)
00830 #define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((byte*) (A) - (byte*) (B))
00831 
00832 /*
00833   Custom version of standard offsetof() macro which can be used to get
00834   offsets of members in class for non-POD types (according to the current
00835   version of C++ standard offsetof() macro can't be used in such cases and
00836   attempt to do so causes warnings to be emitted, OTOH in many cases it is
00837   still OK to assume that all instances of the class has the same offsets
00838   for the same members).
00839 
00840   This is temporary solution which should be removed once File_parser class
00841   and related routines are refactored.
00842 */
00843 
00844 #define my_offsetof(TYPE, MEMBER) \
00845         ((size_t)((char *)&(((TYPE *)0x10)->MEMBER) - (char*)0x10))
00846 
00847 #define NullS           (char *) 0
00848 /* Nowdays we do not support MessyDos */
00849 #ifndef NEAR
00850 #define NEAR                            /* Who needs segments ? */
00851 #define FAR                             /* On a good machine */
00852 #ifndef HUGE_PTR
00853 #define HUGE_PTR
00854 #endif
00855 #endif
00856 #if defined(__IBMC__) || defined(__IBMCPP__)
00857 /* This was  _System _Export but caused a lot of warnings on _AIX43 */
00858 #define STDCALL
00859 #elif !defined( STDCALL)
00860 #define STDCALL
00861 #endif
00862 
00863 /* Typdefs for easyier portability */
00864 
00865 #if defined(VOIDTYPE)
00866 typedef void    *gptr;          /* Generic pointer */
00867 #else
00868 typedef char    *gptr;          /* Generic pointer */
00869 #endif
00870 #ifndef HAVE_INT_8_16_32
00871 typedef signed char int8;       /* Signed integer >= 8  bits */
00872 typedef short   int16;          /* Signed integer >= 16 bits */
00873 #endif
00874 #ifndef HAVE_UCHAR
00875 typedef unsigned char   uchar;  /* Short for unsigned char */
00876 #endif
00877 typedef unsigned char   uint8;  /* Short for unsigned integer >= 8  bits */
00878 typedef unsigned short  uint16; /* Short for unsigned integer >= 16 bits */
00879 
00880 #if SIZEOF_INT == 4
00881 #ifndef HAVE_INT_8_16_32
00882 typedef int             int32;
00883 #endif
00884 typedef unsigned int    uint32; /* Short for unsigned integer >= 32 bits */
00885 #elif SIZEOF_LONG == 4
00886 #ifndef HAVE_INT_8_16_32
00887 typedef long            int32;
00888 #endif
00889 typedef unsigned long   uint32; /* Short for unsigned integer >= 32 bits */
00890 #else
00891 #error "Neither int or long is of 4 bytes width"
00892 #endif
00893 
00894 #if !defined(HAVE_ULONG) && !defined(TARGET_OS_LINUX) && !defined(__USE_MISC)
00895 typedef unsigned long   ulong;            /* Short for unsigned long */
00896 #endif
00897 #ifndef longlong_defined
00898 /* 
00899   Using [unsigned] long long is preferable as [u]longlong because we use 
00900   [unsigned] long long unconditionally in many places, 
00901   for example in constants with [U]LL suffix.
00902 */
00903 #if defined(HAVE_LONG_LONG) && SIZEOF_LONG_LONG == 8
00904 typedef unsigned long long int ulonglong; /* ulong or unsigned long long */
00905 typedef long long int   longlong;
00906 #else
00907 typedef unsigned long   ulonglong;        /* ulong or unsigned long long */
00908 typedef long            longlong;
00909 #endif
00910 #endif
00911 
00912 #if defined(NO_CLIENT_LONG_LONG)
00913 typedef unsigned long my_ulonglong;
00914 #elif defined (__WIN__)
00915 typedef unsigned __int64 my_ulonglong;
00916 #else
00917 typedef unsigned long long my_ulonglong;
00918 #endif
00919 
00920 #ifdef USE_RAID
00921 /*
00922   The following is done with a if to not get problems with pre-processors
00923   with late define evaluation
00924 */
00925 #if SIZEOF_OFF_T == 4
00926 #define SYSTEM_SIZEOF_OFF_T 4
00927 #else
00928 #define SYSTEM_SIZEOF_OFF_T 8
00929 #endif
00930 #undef  SIZEOF_OFF_T
00931 #define SIZEOF_OFF_T        8
00932 #else
00933 #define SYSTEM_SIZEOF_OFF_T SIZEOF_OFF_T
00934 #endif /* USE_RAID */
00935 
00936 #if SIZEOF_OFF_T > 4
00937 typedef ulonglong my_off_t;
00938 #else
00939 typedef unsigned long my_off_t;
00940 #endif
00941 #define MY_FILEPOS_ERROR        (~(my_off_t) 0)
00942 #if !defined(__WIN__) && !defined(OS2)
00943 typedef off_t os_off_t;
00944 #endif
00945 
00946 #if defined(__WIN__)
00947 #define socket_errno    WSAGetLastError()
00948 #define SOCKET_EINTR    WSAEINTR
00949 #define SOCKET_EAGAIN   WSAEINPROGRESS
00950 #define SOCKET_ETIMEDOUT WSAETIMEDOUT
00951 #define SOCKET_EWOULDBLOCK WSAEWOULDBLOCK
00952 #define SOCKET_EADDRINUSE WSAEADDRINUSE
00953 #define SOCKET_ENFILE   ENFILE
00954 #define SOCKET_EMFILE   EMFILE
00955 #elif defined(OS2)
00956 #define socket_errno    sock_errno()
00957 #define SOCKET_EINTR    SOCEINTR
00958 #define SOCKET_EAGAIN   SOCEINPROGRESS
00959 #define SOCKET_ETIMEDOUT SOCKET_EINTR
00960 #define SOCKET_EWOULDBLOCK SOCEWOULDBLOCK
00961 #define SOCKET_EADDRINUSE SOCEADDRINUSE
00962 #define SOCKET_ENFILE   SOCENFILE
00963 #define SOCKET_EMFILE   SOCEMFILE
00964 #define closesocket(A)  soclose(A)
00965 #else /* Unix */
00966 #define socket_errno    errno
00967 #define closesocket(A)  close(A)
00968 #define SOCKET_EINTR    EINTR
00969 #define SOCKET_EAGAIN   EAGAIN
00970 #define SOCKET_ETIMEDOUT SOCKET_EINTR
00971 #define SOCKET_EWOULDBLOCK EWOULDBLOCK
00972 #define SOCKET_EADDRINUSE EADDRINUSE
00973 #define SOCKET_ENFILE   ENFILE
00974 #define SOCKET_EMFILE   EMFILE
00975 #endif
00976 
00977 typedef uint8           int7;   /* Most effective integer 0 <= x <= 127 */
00978 typedef short           int15;  /* Most effective integer 0 <= x <= 32767 */
00979 typedef char            *my_string; /* String of characters */
00980 typedef unsigned long   size_s; /* Size of strings (In string-funcs) */
00981 typedef int             myf;    /* Type of MyFlags in my_funcs */
00982 #ifndef byte_defined
00983 typedef char            byte;   /* Smallest addressable unit */
00984 #endif
00985 typedef char            my_bool; /* Small bool */
00986 #if !defined(bool) && !defined(bool_defined) && (!defined(HAVE_BOOL) || !defined(__cplusplus))
00987 typedef char            bool;   /* Ordinary boolean values 0 1 */
00988 #endif
00989         /* Macros for converting *constants* to the right type */
00990 #define INT8(v)         (int8) (v)
00991 #define INT16(v)        (int16) (v)
00992 #define INT32(v)        (int32) (v)
00993 #define MYF(v)          (myf) (v)
00994 
00995 #ifndef LL
00996 #ifdef HAVE_LONG_LONG
00997 #define LL(A) A ## LL
00998 #else
00999 #define LL(A) A ## L
01000 #endif
01001 #endif
01002 
01003 #ifndef ULL
01004 #ifdef HAVE_LONG_LONG
01005 #define ULL(A) A ## ULL
01006 #else
01007 #define ULL(A) A ## UL
01008 #endif
01009 #endif
01010 
01011 /*
01012   Defines to make it possible to prioritize register assignments. No
01013   longer that important with modern compilers.
01014 */
01015 #ifndef USING_X
01016 #define reg1 register
01017 #define reg2 register
01018 #define reg3 register
01019 #define reg4 register
01020 #define reg5 register
01021 #define reg6 register
01022 #define reg7 register
01023 #define reg8 register
01024 #define reg9 register
01025 #define reg10 register
01026 #define reg11 register
01027 #define reg12 register
01028 #define reg13 register
01029 #define reg14 register
01030 #define reg15 register
01031 #define reg16 register
01032 #endif
01033 
01034 /*
01035   Sometimes we want to make sure that the variable is not put into
01036   a register in debugging mode so we can see its value in the core
01037 */
01038 
01039 #ifndef DBUG_OFF
01040 #define dbug_volatile volatile
01041 #else
01042 #define dbug_volatile
01043 #endif
01044 
01045 /* Defines for time function */
01046 #define SCALE_SEC       100
01047 #define SCALE_USEC      10000
01048 #define MY_HOW_OFTEN_TO_ALARM   2       /* How often we want info on screen */
01049 #define MY_HOW_OFTEN_TO_WRITE   1000    /* How often we want info on screen */
01050 
01051 
01052 
01053 /*
01054   Define-funktions for reading and storing in machine independent format
01055   (low byte first)
01056 */
01057 
01058 /* Optimized store functions for Intel x86 */
01059 #if defined(__i386__) && !defined(_WIN64)
01060 #define sint2korr(A)    (*((int16 *) (A)))
01061 #define sint3korr(A)    ((int32) ((((uchar) (A)[2]) & 128) ? \
01062                                   (((uint32) 255L << 24) | \
01063                                    (((uint32) (uchar) (A)[2]) << 16) |\
01064                                    (((uint32) (uchar) (A)[1]) << 8) | \
01065                                    ((uint32) (uchar) (A)[0])) : \
01066                                   (((uint32) (uchar) (A)[2]) << 16) |\
01067                                   (((uint32) (uchar) (A)[1]) << 8) | \
01068                                   ((uint32) (uchar) (A)[0])))
01069 #define sint4korr(A)    (*((long *) (A)))
01070 #define uint2korr(A)    (*((uint16 *) (A)))
01071 #ifdef HAVE_purify
01072 #define uint3korr(A)    (uint32) (((uint32) ((uchar) (A)[0])) +\
01073                                   (((uint32) ((uchar) (A)[1])) << 8) +\
01074                                   (((uint32) ((uchar) (A)[2])) << 16))
01075 #else
01076 /*
01077    ATTENTION !
01078    
01079     Please, note, uint3korr reads 4 bytes (not 3) !
01080     It means, that you have to provide enough allocated space !
01081 */
01082 #define uint3korr(A)    (long) (*((unsigned int *) (A)) & 0xFFFFFF)
01083 #endif
01084 #define uint4korr(A)    (*((uint32 *) (A)))
01085 #define uint5korr(A)    ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
01086                                     (((uint32) ((uchar) (A)[1])) << 8) +\
01087                                     (((uint32) ((uchar) (A)[2])) << 16) +\
01088                                     (((uint32) ((uchar) (A)[3])) << 24)) +\
01089                                     (((ulonglong) ((uchar) (A)[4])) << 32))
01090 #define uint8korr(A)    (*((ulonglong *) (A)))
01091 #define sint8korr(A)    (*((longlong *) (A)))
01092 #define int2store(T,A)  *((uint16*) (T))= (uint16) (A)
01093 #define int3store(T,A)  do { *(T)=  (uchar) ((A));\
01094                             *(T+1)=(uchar) (((uint) (A) >> 8));\
01095                             *(T+2)=(uchar) (((A) >> 16)); } while (0)
01096 #define int4store(T,A)  *((long *) (T))= (long) (A)
01097 #define int5store(T,A)  do { *(T)= (uchar)((A));\
01098                              *((T)+1)=(uchar) (((A) >> 8));\
01099                              *((T)+2)=(uchar) (((A) >> 16));\
01100                              *((T)+3)=(uchar) (((A) >> 24)); \
01101                              *((T)+4)=(uchar) (((A) >> 32)); } while(0)
01102 #define int8store(T,A)  *((ulonglong *) (T))= (ulonglong) (A)
01103 
01104 typedef union {
01105   double v;
01106   long m[2];
01107 } doubleget_union;
01108 #define doubleget(V,M)  \
01109 do { doubleget_union _tmp; \
01110      _tmp.m[0] = *((long*)(M)); \
01111      _tmp.m[1] = *(((long*) (M))+1); \
01112      (V) = _tmp.v; } while(0)
01113 #define doublestore(T,V) do { *((long *) T) = ((doubleget_union *)&V)->m[0]; \
01114                              *(((long *) T)+1) = ((doubleget_union *)&V)->m[1]; \
01115                          } while (0)
01116 #define float4get(V,M)   do { *((float *) &(V)) = *((float*) (M)); } while(0)
01117 #define float8get(V,M)   doubleget((V),(M))
01118 #define float4store(V,M) memcpy((byte*) V,(byte*) (&M),sizeof(float))
01119 #define floatstore(T,V)  memcpy((byte*)(T), (byte*)(&V),sizeof(float))
01120 #define floatget(V,M)    memcpy((byte*) &V,(byte*) (M),sizeof(float))
01121 #define float8store(V,M) doublestore((V),(M))
01122 #endif /* __i386__ */
01123 
01124 #ifndef sint2korr
01125 /*
01126   We're here if it's not a IA-32 architecture (Win32 and UNIX IA-32 defines
01127   were done before)
01128 */
01129 #define sint2korr(A)    (int16) (((int16) ((uchar) (A)[0])) +\
01130                                  ((int16) ((int16) (A)[1]) << 8))
01131 #define sint3korr(A)    ((int32) ((((uchar) (A)[2]) & 128) ? \
01132                                   (((uint32) 255L << 24) | \
01133                                    (((uint32) (uchar) (A)[2]) << 16) |\
01134                                    (((uint32) (uchar) (A)[1]) << 8) | \
01135                                    ((uint32) (uchar) (A)[0])) : \
01136                                   (((uint32) (uchar) (A)[2]) << 16) |\
01137                                   (((uint32) (uchar) (A)[1]) << 8) | \
01138                                   ((uint32) (uchar) (A)[0])))
01139 #define sint4korr(A)    (int32) (((int32) ((uchar) (A)[0])) +\
01140                                 (((int32) ((uchar) (A)[1]) << 8)) +\
01141                                 (((int32) ((uchar) (A)[2]) << 16)) +\
01142                                 (((int32) ((int16) (A)[3]) << 24)))
01143 #define sint8korr(A)    (longlong) uint8korr(A)
01144 #define uint2korr(A)    (uint16) (((uint16) ((uchar) (A)[0])) +\
01145                                   ((uint16) ((uchar) (A)[1]) << 8))
01146 #define uint3korr(A)    (uint32) (((uint32) ((uchar) (A)[0])) +\
01147                                   (((uint32) ((uchar) (A)[1])) << 8) +\
01148                                   (((uint32) ((uchar) (A)[2])) << 16))
01149 #define uint4korr(A)    (uint32) (((uint32) ((uchar) (A)[0])) +\
01150                                   (((uint32) ((uchar) (A)[1])) << 8) +\
01151                                   (((uint32) ((uchar) (A)[2])) << 16) +\
01152                                   (((uint32) ((uchar) (A)[3])) << 24))
01153 #define uint5korr(A)    ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
01154                                     (((uint32) ((uchar) (A)[1])) << 8) +\
01155                                     (((uint32) ((uchar) (A)[2])) << 16) +\
01156                                     (((uint32) ((uchar) (A)[3])) << 24)) +\
01157                                     (((ulonglong) ((uchar) (A)[4])) << 32))
01158 #define uint8korr(A)    ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
01159                                     (((uint32) ((uchar) (A)[1])) << 8) +\
01160                                     (((uint32) ((uchar) (A)[2])) << 16) +\
01161                                     (((uint32) ((uchar) (A)[3])) << 24)) +\
01162                         (((ulonglong) (((uint32) ((uchar) (A)[4])) +\
01163                                     (((uint32) ((uchar) (A)[5])) << 8) +\
01164                                     (((uint32) ((uchar) (A)[6])) << 16) +\
01165                                     (((uint32) ((uchar) (A)[7])) << 24))) <<\
01166                                     32))
01167 #define int2store(T,A)       do { uint def_temp= (uint) (A) ;\
01168                                   *((uchar*) (T))=  (uchar)(def_temp); \
01169                                    *((uchar*) (T)+1)=(uchar)((def_temp >> 8)); \
01170                              } while(0)
01171 #define int3store(T,A)       do { /*lint -save -e734 */\
01172                                   *((uchar*)(T))=(uchar) ((A));\
01173                                   *((uchar*) (T)+1)=(uchar) (((A) >> 8));\
01174                                   *((uchar*)(T)+2)=(uchar) (((A) >> 16)); \
01175                                   /*lint -restore */} while(0)
01176 #define int4store(T,A)       do { *((char *)(T))=(char) ((A));\
01177                                   *(((char *)(T))+1)=(char) (((A) >> 8));\
01178                                   *(((char *)(T))+2)=(char) (((A) >> 16));\
01179                                   *(((char *)(T))+3)=(char) (((A) >> 24)); } while(0)
01180 #define int5store(T,A)       do { *((char *)(T))=((A));\
01181                                   *(((char *)(T))+1)=(((A) >> 8));\
01182                                   *(((char *)(T))+2)=(((A) >> 16));\
01183                                   *(((char *)(T))+3)=(((A) >> 24)); \
01184                                   *(((char *)(T))+4)=(((A) >> 32)); } while(0)
01185 #define int8store(T,A)       do { uint def_temp= (uint) (A), def_temp2= (uint) ((A) >> 32); \
01186                                   int4store((T),def_temp); \
01187                                   int4store((T+4),def_temp2); } while(0)
01188 #ifdef WORDS_BIGENDIAN
01189 #define float4store(T,A) do { *(T)= ((byte *) &A)[3];\
01190                               *((T)+1)=(char) ((byte *) &A)[2];\
01191                               *((T)+2)=(char) ((byte *) &A)[1];\
01192                               *((T)+3)=(char) ((byte *) &A)[0]; } while(0)
01193 
01194 #define float4get(V,M)   do { float def_temp;\
01195                               ((byte*) &def_temp)[0]=(M)[3];\
01196                               ((byte*) &def_temp)[1]=(M)[2];\
01197                               ((byte*) &def_temp)[2]=(M)[1];\
01198                               ((byte*) &def_temp)[3]=(M)[0];\
01199                               (V)=def_temp; } while(0)
01200 #define float8store(T,V) do { *(T)= ((byte *) &V)[7];\
01201                               *((T)+1)=(char) ((byte *) &V)[6];\
01202                               *((T)+2)=(char) ((byte *) &V)[5];\
01203                               *((T)+3)=(char) ((byte *) &V)[4];\
01204                               *((T)+4)=(char) ((byte *) &V)[3];\
01205                               *((T)+5)=(char) ((byte *) &V)[2];\
01206                               *((T)+6)=(char) ((byte *) &V)[1];\
01207                               *((T)+7)=(char) ((byte *) &V)[0]; } while(0)
01208 
01209 #define float8get(V,M)   do { double def_temp;\
01210                               ((byte*) &def_temp)[0]=(M)[7];\
01211                               ((byte*) &def_temp)[1]=(M)[6];\
01212                               ((byte*) &def_temp)[2]=(M)[5];\
01213                               ((byte*) &def_temp)[3]=(M)[4];\
01214                               ((byte*) &def_temp)[4]=(M)[3];\
01215                               ((byte*) &def_temp)[5]=(M)[2];\
01216                               ((byte*) &def_temp)[6]=(M)[1];\
01217                               ((byte*) &def_temp)[7]=(M)[0];\
01218                               (V) = def_temp; } while(0)
01219 #else
01220 #define float4get(V,M)   memcpy_fixed((byte*) &V,(byte*) (M),sizeof(float))
01221 #define float4store(V,M) memcpy_fixed((byte*) V,(byte*) (&M),sizeof(float))
01222 
01223 #if defined(__FLOAT_WORD_ORDER) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN)
01224 #define doublestore(T,V) do { *(((char*)T)+0)=(char) ((byte *) &V)[4];\
01225                               *(((char*)T)+1)=(char) ((byte *) &V)[5];\
01226                               *(((char*)T)+2)=(char) ((byte *) &V)[6];\
01227                               *(((char*)T)+3)=(char) ((byte *) &V)[7];\
01228                               *(((char*)T)+4)=(char) ((byte *) &V)[0];\
01229                               *(((char*)T)+5)=(char) ((byte *) &V)[1];\
01230                               *(((char*)T)+6)=(char) ((byte *) &V)[2];\
01231                               *(((char*)T)+7)=(char) ((byte *) &V)[3]; }\
01232                          while(0)
01233 #define doubleget(V,M)   do { double def_temp;\
01234                               ((byte*) &def_temp)[0]=(M)[4];\
01235                               ((byte*) &def_temp)[1]=(M)[5];\
01236                               ((byte*) &def_temp)[2]=(M)[6];\
01237                               ((byte*) &def_temp)[3]=(M)[7];\
01238                               ((byte*) &def_temp)[4]=(M)[0];\
01239                               ((byte*) &def_temp)[5]=(M)[1];\
01240                               ((byte*) &def_temp)[6]=(M)[2];\
01241                               ((byte*) &def_temp)[7]=(M)[3];\
01242                               (V) = def_temp; } while(0)
01243 #endif /* __FLOAT_WORD_ORDER */
01244 
01245 #define float8get(V,M)   doubleget((V),(M))
01246 #define float8store(V,M) doublestore((V),(M))
01247 #endif /* WORDS_BIGENDIAN */
01248 
01249 #endif /* sint2korr */
01250 
01251 /*
01252   Macro for reading 32-bit integer from network byte order (big-endian)
01253   from unaligned memory location.
01254 */
01255 #define int4net(A)        (int32) (((uint32) ((uchar) (A)[3]))        |\
01256                                   (((uint32) ((uchar) (A)[2])) << 8)  |\
01257                                   (((uint32) ((uchar) (A)[1])) << 16) |\
01258                                   (((uint32) ((uchar) (A)[0])) << 24))
01259 /*
01260   Define-funktions for reading and storing in machine format from/to
01261   short/long to/from some place in memory V should be a (not
01262   register) variable, M is a pointer to byte
01263 */
01264 
01265 #ifdef WORDS_BIGENDIAN
01266 
01267 #define ushortget(V,M)  do { V = (uint16) (((uint16) ((uchar) (M)[1]))+\
01268                                  ((uint16) ((uint16) (M)[0]) << 8)); } while(0)
01269 #define shortget(V,M)   do { V = (short) (((short) ((uchar) (M)[1]))+\
01270                                  ((short) ((short) (M)[0]) << 8)); } while(0)
01271 #define longget(V,M)    do { int32 def_temp;\
01272                              ((byte*) &def_temp)[0]=(M)[0];\
01273                              ((byte*) &def_temp)[1]=(M)[1];\
01274                              ((byte*) &def_temp)[2]=(M)[2];\
01275                              ((byte*) &def_temp)[3]=(M)[3];\
01276                              (V)=def_temp; } while(0)
01277 #define ulongget(V,M)   do { uint32 def_temp;\
01278                             ((byte*) &def_temp)[0]=(M)[0];\
01279                             ((byte*) &def_temp)[1]=(M)[1];\
01280                             ((byte*) &def_temp)[2]=(M)[2];\
01281                             ((byte*) &def_temp)[3]=(M)[3];\
01282                             (V)=def_temp; } while(0)
01283 #define shortstore(T,A) do { uint def_temp=(uint) (A) ;\
01284                              *(((char*)T)+1)=(char)(def_temp); \
01285                              *(((char*)T)+0)=(char)(def_temp >> 8); } while(0)
01286 #define longstore(T,A)  do { *(((char*)T)+3)=((A));\
01287                              *(((char*)T)+2)=(((A) >> 8));\
01288                              *(((char*)T)+1)=(((A) >> 16));\
01289                              *(((char*)T)+0)=(((A) >> 24)); } while(0)
01290 
01291 #define floatget(V,M)    memcpy_fixed((byte*) &V,(byte*) (M),sizeof(float))
01292 #define floatstore(T,V)  memcpy_fixed((byte*) (T),(byte*)(&V),sizeof(float))
01293 #define doubleget(V,M)   memcpy_fixed((byte*) &V,(byte*) (M),sizeof(double))
01294 #define doublestore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(double))
01295 #define longlongget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(ulonglong))
01296 #define longlongstore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(ulonglong))
01297 
01298 #else
01299 
01300 #define ushortget(V,M)  do { V = uint2korr(M); } while(0)
01301 #define shortget(V,M)   do { V = sint2korr(M); } while(0)
01302 #define longget(V,M)    do { V = sint4korr(M); } while(0)
01303 #define ulongget(V,M)   do { V = uint4korr(M); } while(0)
01304 #define shortstore(T,V) int2store(T,V)
01305 #define longstore(T,V)  int4store(T,V)
01306 #ifndef floatstore
01307 #define floatstore(T,V)  memcpy_fixed((byte*) (T),(byte*) (&V),sizeof(float))
01308 #define floatget(V,M)    memcpy_fixed((byte*) &V, (byte*) (M), sizeof(float))
01309 #endif
01310 #ifndef doubleget
01311 #define doubleget(V,M)   memcpy_fixed((byte*) &V,(byte*) (M),sizeof(double))
01312 #define doublestore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(double))
01313 #endif /* doubleget */
01314 #define longlongget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(ulonglong))
01315 #define longlongstore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(ulonglong))
01316 
01317 #endif /* WORDS_BIGENDIAN */
01318 
01319 /* sprintf does not always return the number of bytes :- */
01320 #ifdef SPRINTF_RETURNS_INT
01321 #define my_sprintf(buff,args) sprintf args
01322 #else
01323 #ifdef SPRINTF_RETURNS_PTR
01324 #define my_sprintf(buff,args) ((int)(sprintf args - buff))
01325 #else
01326 #define my_sprintf(buff,args) ((ulong) sprintf args, (ulong) strlen(buff))
01327 #endif
01328 #endif
01329 
01330 #ifndef THREAD
01331 #define thread_safe_increment(V,L) (V)++
01332 #define thread_safe_add(V,C,L)     (V)+=(C)
01333 #define thread_safe_sub(V,C,L)     (V)-=(C)
01334 #define statistic_increment(V,L)   (V)++
01335 #define statistic_add(V,C,L)       (V)+=(C)
01336 #endif
01337 
01338 #ifdef HAVE_CHARSET_utf8
01339 #define MYSQL_UNIVERSAL_CLIENT_CHARSET "utf8"
01340 #else
01341 #define MYSQL_UNIVERSAL_CLIENT_CHARSET MYSQL_DEFAULT_CHARSET_NAME
01342 #endif
01343 
01344 #if defined(EMBEDDED_LIBRARY) && !defined(HAVE_EMBEDDED_PRIVILEGE_CONTROL)
01345 #define NO_EMBEDDED_ACCESS_CHECKS
01346 #endif
01347 
01348 
01349 /* Length of decimal number represented by INT32. */
01350 
01351 #define MY_INT32_NUM_DECIMAL_DIGITS 11
01352 
01353 /* Length of decimal number represented by INT64. */
01354 
01355 #define MY_INT64_NUM_DECIMAL_DIGITS 21
01356 
01357 #endif /* my_global_h */
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'