home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 March (DVD) / PCWorld_2008-03_DVD.iso / komunikace / mysql / mysql-essential-5.0.45-win32.msi / product.cab / fili170 < prev    next >
Encoding:
Text File  |  2007-07-06  |  42.3 KB  |  1,353 lines

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