my_global.h 47 KB
Newer Older
1
/*
Sergei Golubchik's avatar
Sergei Golubchik committed
2
   Copyright (c) 2001, 2013, Oracle and/or its affiliates.
3
   Copyright (c) 2009, 2017, MariaDB Corporation
unknown's avatar
unknown committed
4 5 6

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
unknown's avatar
unknown committed
7
   the Free Software Foundation; version 2 of the License.
unknown's avatar
unknown committed
8 9

   This program is distributed in the hope that it will be useful,
unknown's avatar
unknown committed
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
unknown's avatar
unknown committed
11 12 13 14 15
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
16
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA */
unknown's avatar
unknown committed
17

18
/* This is the include file that should be included 'first' in every C file. */
unknown's avatar
unknown committed
19 20 21 22

#ifndef _global_h
#define _global_h

23 24 25 26 27
/* Client library users on Windows need this macro defined here. */
#if !defined(__WIN__) && defined(_WIN32)
#define __WIN__
#endif

28 29 30 31 32 33 34 35 36 37 38
/*
  InnoDB depends on some MySQL internals which other plugins should not
  need.  This is because of InnoDB's foreign key support, "safe" binlog
  truncation, and other similar legacy features.

  We define accessors for these internals unconditionally, but do not
  expose them in mysql/plugin.h.  They are declared in ha_innodb.h for
  InnoDB's use.
*/
#define INNODB_COMPATIBILITY_HOOKS

unknown's avatar
unknown committed
39 40 41 42 43 44 45 46 47 48
#ifdef __CYGWIN__
/* We use a Unix API, so pretend it's not Windows */
#undef WIN
#undef WIN32
#undef _WIN
#undef _WIN32
#undef _WIN64
#undef __WIN__
#undef __WIN32__
#define HAVE_ERRNO_AS_DEFINE
49 50
#define _POSIX_MONOTONIC_CLOCK
#define _POSIX_THREAD_CPUTIME
unknown's avatar
unknown committed
51 52
#endif /* __CYGWIN__ */

53 54
/* to make command line shorter we'll define USE_PRAGMA_INTERFACE here */
#ifdef USE_PRAGMA_IMPLEMENTATION
55 56 57
#define USE_PRAGMA_INTERFACE
#endif

58 59 60 61
#if defined(__OpenBSD__) && (OpenBSD >= 200411)
#define HAVE_ERRNO_AS_DEFINE
#endif

unknown's avatar
unknown committed
62 63 64 65
#if defined(i386) && !defined(__i386__)
#define __i386__
#endif

66 67 68 69 70 71 72 73
/* Macros to make switching between C and C++ mode easier */
#ifdef __cplusplus
#define C_MODE_START    extern "C" {
#define C_MODE_END	}
#else
#define C_MODE_START
#define C_MODE_END
#endif
unknown's avatar
unknown committed
74

75 76 77 78 79
#ifdef __cplusplus
#define CPP_UNNAMED_NS_START  namespace {
#define CPP_UNNAMED_NS_END    }
#endif

80
#include <my_config.h>
unknown's avatar
unknown committed
81

Marc Alff's avatar
Marc Alff committed
82 83 84 85
#ifdef WITH_PERFSCHEMA_STORAGE_ENGINE
#define HAVE_PSI_INTERFACE
#endif /* WITH_PERFSCHEMA_STORAGE_ENGINE */

86
/* Make it easier to add conditional code in _expressions_ */
87
#ifdef __WIN__
88
#define IF_WIN(A,B) A
89
#else
90 91 92
#define IF_WIN(A,B) B
#endif

93 94 95 96 97 98
#ifdef WITH_PARTITION_STORAGE_ENGINE
#define IF_PARTITIONING(A,B) A
#else
#define IF_PARTITIONING(A,B) B
#endif

99 100 101 102 103 104
#ifndef EMBEDDED_LIBRARY
#ifdef WITH_NDB_BINLOG
#define HAVE_NDB_BINLOG 1
#endif
#endif /* !EMBEDDED_LIBRARY */

105 106 107 108 109
#ifndef EMBEDDED_LIBRARY
#define HAVE_REPLICATION
#define HAVE_EXTERNAL_CLIENT
#endif

110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
#if defined (_WIN32)
/*
 off_t is 32 bit long. We do not use C runtime functions
 with off_t but native Win32 file IO APIs, that work with
 64 bit offsets.
*/
#undef SIZEOF_OFF_T
#define SIZEOF_OFF_T 8

/*
 Prevent inclusion of  Windows GDI headers - they define symbol
 ERROR that conflicts with mysql headers.
*/
#ifndef NOGDI
#define NOGDI
#endif

/* Include common headers.*/
#include <winsock2.h>
#include <ws2tcpip.h> /* SOCKET */
#include <io.h>       /* access(), chmod() */
#include <process.h>  /* getpid() */

#define sleep(a) Sleep((a)*1000)

/* Define missing access() modes. */
#define F_OK 0
#define W_OK 2

/* Define missing file locking constants. */
#define F_RDLCK 1
#define F_WRLCK 2
#define F_UNLCK 3
#define F_TO_EOF 0x3FFFFFFF

/* Shared memory and named pipe connections are supported. */
#define HAVE_SMEM 1
#define HAVE_NAMED_PIPE 1
#define shared_memory_buffer_length 16000
#define default_shared_memory_base_name "MYSQL"
#endif /* _WIN32*/


153 154 155 156 157
/* Workaround for _LARGE_FILES and _LARGE_FILE_API incompatibility on AIX */
#if defined(_AIX) && defined(_LARGE_FILE_API)
#undef _LARGE_FILE_API
#endif

unknown's avatar
unknown committed
158 159 160 161
/*
  The macros below are used to allow build of Universal/fat binaries of
  MySQL and MySQL applications under darwin. 
*/
unknown's avatar
unknown committed
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
#if defined(__APPLE__) && defined(__MACH__)
#  undef SIZEOF_CHARP 
#  undef SIZEOF_SHORT 
#  undef SIZEOF_INT 
#  undef SIZEOF_LONG 
#  undef SIZEOF_LONG_LONG 
#  undef SIZEOF_OFF_T 
#  undef WORDS_BIGENDIAN
#  define SIZEOF_SHORT 2
#  define SIZEOF_INT 4
#  define SIZEOF_LONG_LONG 8
#  define SIZEOF_OFF_T 8
#  if defined(__i386__) || defined(__ppc__)
#    define SIZEOF_CHARP 4
#    define SIZEOF_LONG 4
#  elif defined(__x86_64__) || defined(__ppc64__)
#    define SIZEOF_CHARP 8
#    define SIZEOF_LONG 8
#  else
#    error Building FAT binary for an unknown architecture.
#  endif
#  if defined(__ppc__) || defined(__ppc64__)
#    define WORDS_BIGENDIAN
#  endif
#endif /* defined(__APPLE__) && defined(__MACH__) */
unknown's avatar
unknown committed
187 188


unknown's avatar
unknown committed
189 190 191 192 193 194 195
/*
  The macros below are borrowed from include/linux/compiler.h in the
  Linux kernel. Use them to indicate the likelyhood of the truthfulness
  of a condition. This serves two purposes - newer versions of gcc will be
  able to optimize for branch predication, which could yield siginficant
  performance gains in frequently executed sections of the code, and the
  other reason to use them is for documentation
196 197
*/

unknown's avatar
unknown committed
198
#if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
199 200 201
#define __builtin_expect(x, expected_value) (x)
#endif

202 203 204 205 206 207 208 209
/**
  The semantics of builtin_expect() are that
  1) its two arguments are long
  2) it's likely that they are ==
  Those of our likely(x) are that x can be bool/int/longlong/pointer.
*/
#define likely(x)	__builtin_expect(((x) != 0),1)
#define unlikely(x)	__builtin_expect(((x) != 0),0)
210

unknown's avatar
unknown committed
211
/* Fix problem with S_ISLNK() on Linux */
212
#if defined(TARGET_OS_LINUX) || defined(__GLIBC__)
unknown's avatar
unknown committed
213 214 215 216
#undef  _GNU_SOURCE
#define _GNU_SOURCE 1
#endif

217 218 219 220 221 222 223 224
/*
  Temporary solution to solve bug#7156. Include "sys/types.h" before
  the thread headers, else the function madvise() will not be defined
*/
#if defined(HAVE_SYS_TYPES_H) && ( defined(sun) || defined(__sun) )
#include <sys/types.h>
#endif

unknown's avatar
unknown committed
225 226 227 228 229
#define __EXTENSIONS__ 1	/* We want some extension */
#ifndef __STDC_EXT__
#define __STDC_EXT__ 1          /* To get large file support on hpux */
#endif

unknown's avatar
unknown committed
230
/*
231
  Solaris 9 include file <sys/feature_tests.h> refers to X/Open document
unknown's avatar
unknown committed
232 233 234

    System Interfaces and Headers, Issue 5

235
  saying we should define _XOPEN_SOURCE=500 to get POSIX.1c prototypes,
unknown's avatar
unknown committed
236
  but apparently other systems (namely FreeBSD) don't agree.
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252

  On a newer Solaris 10, the above file recognizes also _XOPEN_SOURCE=600.
  Furthermore, it tests that if a program requires older standard
  (_XOPEN_SOURCE<600 or _POSIX_C_SOURCE<200112L) it cannot be
  run on a new compiler (that defines _STDC_C99) and issues an #error.
  It's also an #error if a program requires new standard (_XOPEN_SOURCE=600
  or _POSIX_C_SOURCE=200112L) and a compiler does not define _STDC_C99.

  To add more to this mess, Sun Studio C compiler defines _STDC_C99 while
  C++ compiler does not!

  So, in a desperate attempt to get correct prototypes for both
  C and C++ code, we define either _XOPEN_SOURCE=600 or _XOPEN_SOURCE=500
  depending on the compiler's announced C standard support.

  Cleaner solutions are welcome.
unknown's avatar
unknown committed
253
*/
254
#ifdef __sun
255 256 257
#if __STDC_VERSION__ - 0 >= 199901L
#define _XOPEN_SOURCE 600
#else
unknown's avatar
unknown committed
258 259
#define _XOPEN_SOURCE 500
#endif
260
#endif
unknown's avatar
unknown committed
261

262
#if !defined(__WIN__)
unknown's avatar
unknown committed
263 264 265
#ifndef _POSIX_PTHREAD_SEMANTICS
#define _POSIX_PTHREAD_SEMANTICS /* We want posix threads */
#endif
266

unknown's avatar
unknown committed
267 268 269 270 271 272
#if !defined(SCO)
#define _REENTRANT	1	/* Some thread libraries require this */
#endif
#if !defined(_THREAD_SAFE) && !defined(_AIX)
#define _THREAD_SAFE            /* Required for OSF1 */
#endif
273 274 275 276 277
#if defined(HPUX10) || defined(HPUX11)
C_MODE_START			/* HPUX needs this, signal.h bug */
#include <pthread.h>
C_MODE_END
#else
unknown's avatar
unknown committed
278
#include <pthread.h>		/* AIX must have this included first */
279
#endif
unknown's avatar
unknown committed
280 281 282
#if !defined(SCO) && !defined(_REENTRANT)
#define _REENTRANT	1	/* Threads requires reentrant code */
#endif
283
#endif /* !defined(__WIN__) */
unknown's avatar
unknown committed
284 285 286 287 288

/* Go around some bugs in different OS and compilers */
#ifdef _AIX			/* By soren@t.dk */
#define _H_STRINGS
#define _SYS_STREAM_H
unknown's avatar
unknown committed
289
/* #define _AIX32_CURSES */	/* XXX: this breaks AIX 4.3.3 (others?). */
290 291
#define ulonglong2double(A) my_ulonglong2double(A)
#define my_off_t2double(A)  my_ulonglong2double(A)
292
C_MODE_START
293
inline double my_ulonglong2double(unsigned long long A) { return (double)A; }
294
C_MODE_END
295
#endif /* _AIX */
unknown's avatar
unknown committed
296 297 298 299 300

#ifdef UNDEF_HAVE_INITGROUPS			/* For AIX 4.3 */
#undef HAVE_INITGROUPS
#endif

301 302 303 304 305 306
/* gcc/egcs issues */

#if defined(__GNUC) && defined(__EXCEPTIONS)
#error "Please add -fno-exceptions to CXXFLAGS and reconfigure/recompile"
#endif

unknown's avatar
unknown committed
307 308 309 310 311 312 313 314 315 316
#if defined(_lint) && !defined(lint)
#define lint
#endif
#if SIZEOF_LONG_LONG > 4 && !defined(_LONG_LONG)
#define _LONG_LONG 1		/* For AIX string library */
#endif

#ifndef stdin
#include <stdio.h>
#endif
Alexander Barkov's avatar
Alexander Barkov committed
317
#include <stdarg.h>
unknown's avatar
unknown committed
318 319 320 321 322 323 324 325 326 327 328 329 330 331
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_STDDEF_H
#include <stddef.h>
#endif

#include <math.h>
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
#ifdef HAVE_FLOAT_H
#include <float.h>
#endif
332 333 334
#ifdef HAVE_FENV_H
#include <fenv.h> /* For fesetround() */
#endif
unknown's avatar
unknown committed
335 336 337 338 339 340 341

#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
unknown's avatar
unknown committed
342 343 344
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
unknown's avatar
unknown committed
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364
#if TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
# if HAVE_SYS_TIME_H
#  include <sys/time.h>
# else
#  include <time.h>
# endif
#endif /* TIME_WITH_SYS_TIME */
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#if defined(__cplusplus) && defined(NO_CPLUSPLUS_ALLOCA)
#undef HAVE_ALLOCA
#undef HAVE_ALLOCA_H
#endif
#ifdef HAVE_ALLOCA_H
#include <alloca.h>
#endif
365

366
#include <errno.h>				/* Recommended by debian */
unknown's avatar
unknown committed
367
/* We need the following to go around a problem with openssl on solaris */
unknown's avatar
unknown committed
368
#if defined(HAVE_CRYPT_H)
unknown's avatar
unknown committed
369 370
#include <crypt.h>
#endif
unknown's avatar
unknown committed
371

372 373 374 375 376 377 378
/*
  A lot of our programs uses asserts, so better to always include it
  This also fixes a problem when people uses DBUG_ASSERT without including
  assert.h
*/
#include <assert.h>

unknown's avatar
unknown committed
379
/* an assert that works at compile-time. only for constant expression */
380
#ifdef _some_old_compiler_that_does_not_understand_the_construct_below_
unknown's avatar
unknown committed
381 382
#define compile_time_assert(X)  do { } while(0)
#else
unknown's avatar
unknown committed
383 384 385
#define compile_time_assert(X)                                  \
  do                                                            \
  {                                                             \
386
    typedef char compile_time_assert[(X) ? 1 : -1] __attribute__((unused)); \
unknown's avatar
unknown committed
387
  } while(0)
unknown's avatar
unknown committed
388
#endif
unknown's avatar
unknown committed
389

unknown's avatar
unknown committed
390
/* Go around some bugs in different OS and compilers */
unknown's avatar
unknown committed
391
#if defined (HPUX11) && defined(_LARGEFILE_SOURCE)
392
#ifndef _LARGEFILE64_SOURCE
unknown's avatar
unknown committed
393 394
#define _LARGEFILE64_SOURCE
#endif
395 396
#endif

unknown's avatar
unknown committed
397 398 399 400
#if defined(_HPUX_SOURCE) && defined(HAVE_SYS_STREAM_H)
#include <sys/stream.h>		/* HPUX 10.20 defines ulong here. UGLY !!! */
#define HAVE_ULONG
#endif
401
#if defined(HPUX10) && defined(_LARGEFILE64_SOURCE)
402 403 404 405
/* Fix bug in setrlimit */
#undef setrlimit
#define setrlimit cma_setrlimit64
#endif
406 407 408 409
/* Declare madvise where it is not declared for C++, like Solaris */
#if HAVE_MADVISE && !HAVE_DECL_MADVISE && defined(__cplusplus)
extern "C" int madvise(void *addr, size_t len, int behav);
#endif
unknown's avatar
unknown committed
410

411 412 413
#define QUOTE_ARG(x)		#x	/* Quote argument (before cpp) */
#define STRINGIFY_ARG(x) QUOTE_ARG(x)	/* Quote argument, after cpp */

unknown's avatar
unknown committed
414 415 416 417 418 419 420
/* Paranoid settings. Define I_AM_PARANOID if you are paranoid */
#ifdef I_AM_PARANOID
#define DONT_ALLOW_USER_CHANGE 1
#define DONT_USE_MYSQL_PWD 1
#endif

/* Does the system remember a signal handler after a signal ? */
421 422
#if !defined(HAVE_BSD_SIGNALS) && !defined(HAVE_SIGACTION)
#define SIGNAL_HANDLER_RESET_ON_DELIVERY
unknown's avatar
unknown committed
423 424
#endif

425 426
/* don't assume that STDERR_FILENO is 2, mysqld can freopen */
#undef STDERR_FILENO
427

428 429 430 431 432 433 434 435 436
/*
  Deprecated workaround for false-positive uninitialized variables
  warnings. Those should be silenced using tool-specific heuristics.

  Enabled by default for g++ due to the bug referenced below.
*/
#if defined(_lint) || defined(FORCE_INIT_OF_VARS) || \
    (defined(__GNUC__) && defined(__cplusplus))
#define LINT_INIT(var) var= 0
unknown's avatar
unknown committed
437 438 439 440
#else
#define LINT_INIT(var)
#endif

441
#ifndef SO_EXT
442 443 444 445 446
#ifdef _WIN32
#define SO_EXT ".dll"
#else
#define SO_EXT ".so"
#endif
447
#endif
448

449
/*
450 451 452
   Suppress uninitialized variable warning without generating code.

   The _cplusplus is a temporary workaround for C++ code pending a fix
453
   for a g++ bug (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34772).
454
*/
455 456
#if defined(_lint) || defined(FORCE_INIT_OF_VARS) || \
    defined(__cplusplus) || !defined(__GNUC__)
457 458
#define UNINIT_VAR(x) x= 0
#else
459
/* GCC specific self-initialization which inhibits the warning. */
460 461 462
#define UNINIT_VAR(x) x= x
#endif

463
#if !defined(HAVE_UINT)
464 465
#undef HAVE_UINT
#define HAVE_UINT
unknown's avatar
unknown committed
466 467 468 469
typedef unsigned int uint;
typedef unsigned short ushort;
#endif

unknown's avatar
unknown committed
470
#define swap_variables(t, a, b) { t dummy; dummy= a; a= b; b= dummy; }
unknown's avatar
unknown committed
471
#define test(a)		((a) ? 1 : 0)
472
#define MY_TEST(a) ((a) ? 1 : 0)
473 474
#define set_if_bigger(a,b)  do { if ((a) < (b)) (a)=(b); } while(0)
#define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0)
unknown's avatar
unknown committed
475
#define set_bits(type, bit_count) (sizeof(type)*8 <= (bit_count) ? ~(type) 0 : ((((type) 1) << (bit_count)) - (type) 1))
unknown's avatar
unknown committed
476 477 478
#define test_all_bits(a,b) (((a) & (b)) == (b))
#define array_elements(A) ((uint) (sizeof(A)/sizeof(A[0])))

unknown's avatar
unknown committed
479
/* Define some general constants */
unknown's avatar
unknown committed
480 481 482 483 484
#ifndef TRUE
#define TRUE		(1)	/* Logical true */
#define FALSE		(0)	/* Logical false */
#endif

485
#include <my_compiler.h>
486

unknown's avatar
unknown committed
487 488
/*
  Wen using the embedded library, users might run into link problems,
unknown's avatar
unknown committed
489
  duplicate declaration of __cxa_pure_virtual, solved by declaring it a
unknown's avatar
unknown committed
490 491
  weak symbol.
*/
492
#if defined(USE_MYSYS_NEW) && ! defined(DONT_DECLARE_CXA_PURE_VIRTUAL)
unknown's avatar
unknown committed
493 494 495 496 497
C_MODE_START
int __cxa_pure_virtual () __attribute__ ((weak));
C_MODE_END
#endif

498
/* The DBUG_ON flag always takes precedence over default DBUG_OFF */
unknown's avatar
unknown committed
499 500 501 502
#if defined(DBUG_ON) && defined(DBUG_OFF)
#undef DBUG_OFF
#endif

503 504 505 506 507 508
/* We might be forced to turn debug off, if not turned off already */
#if (defined(FORCE_DBUG_OFF) || defined(_lint)) && !defined(DBUG_OFF)
#  define DBUG_OFF
#  ifdef DBUG_ON
#    undef DBUG_ON
#  endif
unknown's avatar
unknown committed
509 510
#endif

511 512 513 514
#ifdef DBUG_OFF
#undef EXTRA_DEBUG
#endif

unknown's avatar
unknown committed
515 516 517
/* Some types that is different between systems */

typedef int	File;		/* File descriptor */
518 519 520
#ifdef _WIN32
typedef SOCKET my_socket;
#else
unknown's avatar
unknown committed
521 522 523 524 525
typedef int	my_socket;	/* File descriptor for sockets */
#define INVALID_SOCKET -1
#endif
/* Type for fuctions that handles signals */
#define sig_handler RETSIGTYPE
526
C_MODE_START
unknown's avatar
unknown committed
527
typedef void	(*sig_return)();/* Returns type from signal */
528
C_MODE_END
unknown's avatar
unknown committed
529 530 531 532 533 534 535 536 537 538 539 540 541
#if defined(__GNUC__) && !defined(_lint)
typedef char	pchar;		/* Mixed prototypes can take char */
typedef char	puchar;		/* Mixed prototypes can take char */
typedef char	pbool;		/* Mixed prototypes can take char */
typedef short	pshort;		/* Mixed prototypes can take short int */
typedef float	pfloat;		/* Mixed prototypes can take float */
#else
typedef int	pchar;		/* Mixed prototypes can't take char */
typedef uint	puchar;		/* Mixed prototypes can't take char */
typedef int	pbool;		/* Mixed prototypes can't take char */
typedef int	pshort;		/* Mixed prototypes can't take short int */
typedef double	pfloat;		/* Mixed prototypes can't take float */
#endif
542
C_MODE_START
unknown's avatar
unknown committed
543 544
typedef int	(*qsort_cmp)(const void *,const void *);
typedef int	(*qsort_cmp2)(void*, const void *,const void *);
545
C_MODE_END
unknown's avatar
unknown committed
546 547 548 549
#define qsort_t RETQSORTTYPE	/* Broken GCC cant handle typedef !!!! */
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
550
typedef SOCKET_SIZE_TYPE size_socket;
unknown's avatar
unknown committed
551 552 553 554 555 556 557

#ifndef SOCKOPT_OPTLEN_TYPE
#define SOCKOPT_OPTLEN_TYPE size_socket
#endif

/* file create flags */

unknown's avatar
unknown committed
558
#ifndef O_SHARE			/* Probably not windows */
unknown's avatar
unknown committed
559 560 561 562
#define O_SHARE		0	/* Flag to my_open for shared files */
#ifndef O_BINARY
#define O_BINARY	0	/* Flag to my_open for binary files */
#endif
unknown's avatar
unknown committed
563 564 565
#ifndef FILE_BINARY
#define FILE_BINARY	O_BINARY /* Flag to my_fopen for binary streams */
#endif
unknown's avatar
unknown committed
566 567 568 569 570
#ifdef HAVE_FCNTL
#define HAVE_FCNTL_LOCK
#define F_TO_EOF	0L	/* Param to lockf() to lock rest of file */
#endif
#endif /* O_SHARE */
unknown's avatar
unknown committed
571

unknown's avatar
unknown committed
572 573 574 575 576 577
#ifndef O_TEMPORARY
#define O_TEMPORARY	0
#endif
#ifndef O_SHORT_LIVED
#define O_SHORT_LIVED	0
#endif
578 579 580
#ifndef O_NOFOLLOW
#define O_NOFOLLOW      0
#endif
unknown's avatar
unknown committed
581

582 583 584 585 586 587 588 589 590
/* additional file share flags for win32 */
#ifdef __WIN__
#define _SH_DENYRWD     0x110    /* deny read/write mode & delete */
#define _SH_DENYWRD     0x120    /* deny write mode & delete      */
#define _SH_DENYRDD     0x130    /* deny read mode & delete       */
#define _SH_DENYDEL     0x140    /* deny delete only              */
#endif /* __WIN__ */


591
/* General constants */
unknown's avatar
unknown committed
592 593 594 595 596 597 598
#define FN_LEN		256	/* Max file name len */
#define FN_HEADLEN	253	/* Max length of filepart of file name */
#define FN_EXTLEN	20	/* Max length of extension (part of FN_LEN) */
#define FN_REFLEN	512	/* Max length of full path-name */
#define FN_EXTCHAR	'.'
#define FN_HOMELIB	'~'	/* ~/ is used as abbrev for home dir */
#define FN_CURLIB	'.'	/* ./ is used as abbrev for current dir */
unknown's avatar
unknown committed
599
#define FN_PARENTDIR	".."	/* Parent directory; Must be a string */
unknown's avatar
unknown committed
600

601 602
#ifdef _WIN32
#define FN_LIBCHAR	'\\'
603
#define FN_LIBCHAR2	'/'
604
#define FN_DIRSEP       "/\\"               /* Valid directory separators */
605 606
#define FN_EXEEXT   ".exe"
#define FN_SOEXT    ".dll"
607 608 609 610 611
#define FN_ROOTDIR	"\\"
#define FN_DEVCHAR	':'
#define FN_NETWORK_DRIVES	/* Uses \\ to indicate network drives */
#define FN_NO_CASE_SENCE	/* Files are not case-sensitive */
#else
unknown's avatar
unknown committed
612
#define FN_LIBCHAR	'/'
613
#define FN_LIBCHAR2	'/'
614
#define FN_DIRSEP       "/"     /* Valid directory separators */
615 616
#define FN_EXEEXT   ""
#define FN_SOEXT    ".so"
unknown's avatar
unknown committed
617 618
#define FN_ROOTDIR	"/"
#endif
619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653

/* 
  MY_FILE_MIN is  Windows speciality and is used to quickly detect
  the mismatch of CRT and mysys file IO usage on Windows at runtime.
  CRT file descriptors can be in the range 0-2047, whereas descriptors returned
  by my_open() will start with 2048. If a file descriptor with value less then
  MY_FILE_MIN is passed to mysys IO function, chances are it stemms from
  open()/fileno() and not my_open()/my_fileno.

  For Posix,  mysys functions are light wrappers around libc, and MY_FILE_MIN
  is logically 0.
*/

#ifdef _WIN32
#define MY_FILE_MIN  2048
#else
#define MY_FILE_MIN  0
#endif

/* 
  MY_NFILE is the default size of my_file_info array.

  It is larger on Windows, because it all file handles are stored in my_file_info
  Default size is 16384 and this should be enough for most cases.If it is not 
  enough, --max-open-files with larger value can be used.

  For Posix , my_file_info array is only used to store filenames for
  error reporting and its size is not a limitation for number of open files.
*/ 
#ifdef _WIN32
#define MY_NFILE (16384 + MY_FILE_MIN)
#else
#define MY_NFILE 64
#endif

654
#ifndef OS_FILE_LIMIT
655
#define OS_FILE_LIMIT	UINT_MAX
unknown's avatar
unknown committed
656 657
#endif

658 659 660 661 662
/*
  Io buffer size; Must be a power of 2 and a multiple of 512. May be
  smaller what the disk page size. This influences the speed of the
  isam btree library. eg to big to slow.
*/
unknown's avatar
unknown committed
663
#define IO_SIZE			4096
664 665 666 667
/*
  How much overhead does malloc have. The code often allocates
  something like 1024-MALLOC_OVERHEAD bytes
*/
unknown's avatar
unknown committed
668
#define MALLOC_OVERHEAD 8
669

unknown's avatar
unknown committed
670
	/* get memory in huncs */
Sergei Golubchik's avatar
Sergei Golubchik committed
671
#define ONCE_ALLOC_INIT		(uint) 4096
Michael Widenius's avatar
Michael Widenius committed
672
	/* Typical record cache */
Sergei Golubchik's avatar
Sergei Golubchik committed
673
#define RECORD_CACHE_SIZE	(uint) (128*1024)
Michael Widenius's avatar
Michael Widenius committed
674
	/* Typical key cache */
Sergei Golubchik's avatar
Sergei Golubchik committed
675
#define KEY_CACHE_SIZE		(uint) (128L*1024L*1024L)
unknown's avatar
unknown committed
676 677 678
	/* Default size of a key cache block  */
#define KEY_CACHE_BLOCK_SIZE	(uint) 1024

unknown's avatar
unknown committed
679 680
	/* Some things that this system doesn't have */

681 682
#ifdef _WIN32
#define NO_DIR_LIBRARY		/* Not standard dir-library */
unknown's avatar
unknown committed
683 684 685 686 687 688 689
#endif

/* Some defines of functions for portability */

#undef remove		/* Crashes MySQL on SCO 5.0.0 */
#ifndef __WIN__
#define closesocket(A)	close(A)
690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714
#endif

#if (_MSC_VER)
#if !defined(_WIN64)
inline double my_ulonglong2double(unsigned long long value)
{
  long long nr=(long long) value;
  if (nr >= 0)
    return (double) nr;
  return (18446744073709551616.0 + (double) nr);
}
#define ulonglong2double my_ulonglong2double
#define my_off_t2double  my_ulonglong2double
#endif /* _WIN64 */
inline unsigned long long my_double2ulonglong(double d)
{
  double t= d - (double) 0x8000000000000000ULL;

  if (t >= 0)
    return  ((unsigned long long) t) + 0x8000000000000000ULL;
  return (unsigned long long) d;
}
#define double2ulonglong my_double2ulonglong
#endif

unknown's avatar
unknown committed
715
#ifndef ulonglong2double
716 717
#define ulonglong2double(A) ((double) (ulonglong) (A))
#define my_off_t2double(A)  ((double) (my_off_t) (A))
unknown's avatar
unknown committed
718
#endif
719 720 721
#ifndef double2ulonglong
#define double2ulonglong(A) ((ulonglong) (double) (A))
#endif
unknown's avatar
unknown committed
722 723 724 725 726 727

#ifndef offsetof
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
#endif
#define ulong_to_double(X) ((double) (ulong) (X))

unknown's avatar
unknown committed
728 729 730 731
#ifndef STACK_DIRECTION
#error "please add -DSTACK_DIRECTION=1 or -1 to your CPPFLAGS"
#endif

732
#if !defined(HAVE_STRTOK_R)
unknown's avatar
unknown committed
733 734 735
#define strtok_r(A,B,C) strtok((A),(B))
#endif

736
#if SIZEOF_LONG_LONG >= 8
unknown's avatar
unknown committed
737
#define HAVE_LONG_LONG 1
738 739
#else
#error WHAT? sizeof(long long) < 8 ???
unknown's avatar
unknown committed
740 741
#endif

742 743 744 745 746
/*
  Some pre-ANSI-C99 systems like AIX 5.1 and Linux/GCC 2.95 define
  ULONGLONG_MAX, LONGLONG_MIN, LONGLONG_MAX; we use them if they're defined.
*/

unknown's avatar
unknown committed
747 748 749 750 751
#if defined(HAVE_LONG_LONG) && !defined(LONGLONG_MIN)
#define LONGLONG_MIN	((long long) 0x8000000000000000LL)
#define LONGLONG_MAX	((long long) 0x7FFFFFFFFFFFFFFFLL)
#endif

unknown's avatar
unknown committed
752
#if defined(HAVE_LONG_LONG) && !defined(ULONGLONG_MAX)
753 754 755 756 757 758
/* First check for ANSI C99 definition: */
#ifdef ULLONG_MAX
#define ULONGLONG_MAX  ULLONG_MAX
#else
#define ULONGLONG_MAX ((unsigned long long)(~0ULL))
#endif
unknown's avatar
unknown committed
759
#endif /* defined (HAVE_LONG_LONG) && !defined(ULONGLONG_MAX)*/
760

761 762
#define INT_MIN64       (~0x7FFFFFFFFFFFFFFFLL)
#define INT_MAX64       0x7FFFFFFFFFFFFFFFLL
unknown's avatar
unknown committed
763 764 765 766 767 768 769
#define INT_MIN32       (~0x7FFFFFFFL)
#define INT_MAX32       0x7FFFFFFFL
#define UINT_MAX32      0xFFFFFFFFL
#define INT_MIN24       (~0x007FFFFF)
#define INT_MAX24       0x007FFFFF
#define UINT_MAX24      0x00FFFFFF
#define INT_MIN16       (~0x7FFF)
770 771
#define INT_MAX16       0x7FFF
#define UINT_MAX16      0xFFFF
unknown's avatar
unknown committed
772 773
#define INT_MIN8        (~0x7F)
#define INT_MAX8        0x7F
774
#define UINT_MAX8       0xFF
unknown's avatar
unknown committed
775 776 777 778 779 780 781 782 783 784

/* From limits.h instead */
#ifndef DBL_MIN
#define DBL_MIN		4.94065645841246544e-324
#define FLT_MIN		((float)1.40129846432481707e-45)
#endif
#ifndef DBL_MAX
#define DBL_MAX		1.79769313486231470e+308
#define FLT_MAX		((float)3.40282346638528860e+38)
#endif
785
#ifndef SIZE_T_MAX
786
#define SIZE_T_MAX      (~((size_t) 0))
787
#endif
unknown's avatar
unknown committed
788

789 790 791 792
#ifndef isfinite
#ifdef HAVE_FINITE
#define isfinite(x) finite(x)
#else
793
#define finite(x) (1.0 / fabs(x) > 0.0)
794 795
#endif /* HAVE_FINITE */
#endif /* isfinite */
796 797 798 799 800

#ifndef HAVE_ISNAN
#define isnan(x) ((x) != (x))
#endif

801
#ifdef HAVE_ISINF
802 803
#define my_isinf(X) isinf(X)
#else /* !HAVE_ISINF */
804
#define my_isinf(X) (!finite(X) && !isnan(X))
unknown's avatar
unknown committed
805 806
#endif

807 808 809 810 811 812 813 814 815 816 817
/* Define missing math constants. */
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#ifndef M_E
#define M_E 2.7182818284590452354
#endif
#ifndef M_LN2
#define M_LN2 0.69314718055994530942
#endif

Sergei Golubchik's avatar
Sergei Golubchik committed
818 819 820 821 822
#ifndef HAVE_LOG2
/*
  This will be slightly slower and perhaps a tiny bit less accurate than
  doing it the IEEE754 way but log2() should be available on C99 systems.
*/
823
static inline double log2(double x)
Sergei Golubchik's avatar
Sergei Golubchik committed
824 825 826 827 828
{
  return (log(x) / M_LN2);
}
#endif

829 830 831 832
/*
  Max size that must be added to a so that we know Size to make
  adressable obj.
*/
833
#if SIZEOF_CHARP == 4
unknown's avatar
unknown committed
834
typedef long		my_ptrdiff_t;
835 836 837 838
#else
typedef long long	my_ptrdiff_t;
#endif

unknown's avatar
unknown committed
839 840
#define MY_ALIGN(A,L)	(((A) + (L) - 1) & ~((L) - 1))
#define ALIGN_SIZE(A)	MY_ALIGN((A),sizeof(double))
841
#define ALIGN_MAX_UNIT  (sizeof(double))
unknown's avatar
unknown committed
842
/* Size to make adressable obj. */
Sergey Petrunya's avatar
Sergey Petrunya committed
843
#define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A), sizeof(double)))
844 845
#define ADD_TO_PTR(ptr,size,type) (type) ((uchar*) (ptr)+size)
#define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((uchar*) (A) - (uchar*) (B))
846
#define PREV_BITS(type,A)	((type) (((type) 1 << (A)) -1))
unknown's avatar
unknown committed
847

unknown's avatar
unknown committed
848 849 850 851 852 853 854 855 856 857 858 859
/*
  Custom version of standard offsetof() macro which can be used to get
  offsets of members in class for non-POD types (according to the current
  version of C++ standard offsetof() macro can't be used in such cases and
  attempt to do so causes warnings to be emitted, OTOH in many cases it is
  still OK to assume that all instances of the class has the same offsets
  for the same members).

  This is temporary solution which should be removed once File_parser class
  and related routines are refactored.
*/

860
#define my_offsetof(TYPE, MEMBER) PTR_BYTE_DIFF(&((TYPE *)0x10)->MEMBER, 0x10)
unknown's avatar
unknown committed
861

unknown's avatar
unknown committed
862
#define NullS		(char *) 0
863 864 865 866 867 868 869 870

#ifdef STDCALL
#undef STDCALL
#endif

#ifdef _WIN32
#define STDCALL __stdcall
#else
unknown's avatar
unknown committed
871 872 873 874 875 876 877 878 879
#define STDCALL
#endif

/* Typdefs for easyier portability */

#ifndef HAVE_UCHAR
typedef unsigned char	uchar;	/* Short for unsigned char */
#endif

unknown's avatar
unknown committed
880 881 882 883 884 885 886 887 888 889 890 891
#ifndef HAVE_INT8
typedef signed char int8;       /* Signed integer >= 8  bits */
#endif
#ifndef HAVE_UINT8
typedef unsigned char uint8;    /* Unsigned integer >= 8  bits */
#endif
#ifndef HAVE_INT16
typedef short int16;
#endif
#ifndef HAVE_UINT16
typedef unsigned short uint16;
#endif
unknown's avatar
unknown committed
892
#if SIZEOF_INT == 4
unknown's avatar
unknown committed
893 894 895 896 897
#ifndef HAVE_INT32
typedef int int32;
#endif
#ifndef HAVE_UINT32
typedef unsigned int uint32;
unknown's avatar
unknown committed
898 899
#endif
#elif SIZEOF_LONG == 4
unknown's avatar
unknown committed
900 901 902 903 904
#ifndef HAVE_INT32
typedef long int32;
#endif
#ifndef HAVE_UINT32
typedef unsigned long uint32;
unknown's avatar
unknown committed
905 906
#endif
#else
907
#error Neither int or long is of 4 bytes width
unknown's avatar
unknown committed
908 909
#endif

910
#if !defined(HAVE_ULONG) && !defined(__USE_MISC)
911
typedef unsigned long	ulong;		  /* Short for unsigned long */
unknown's avatar
unknown committed
912 913
#endif
#ifndef longlong_defined
914 915 916 917 918 919
/* 
  Using [unsigned] long long is preferable as [u]longlong because we use 
  [unsigned] long long unconditionally in many places, 
  for example in constants with [U]LL suffix.
*/
#if defined(HAVE_LONG_LONG) && SIZEOF_LONG_LONG == 8
920 921
typedef unsigned long long int ulonglong; /* ulong or unsigned long long */
typedef long long int	longlong;
unknown's avatar
unknown committed
922
#else
923
typedef unsigned long	ulonglong;	  /* ulong or unsigned long long */
unknown's avatar
unknown committed
924 925 926
typedef long		longlong;
#endif
#endif
unknown's avatar
unknown committed
927
#ifndef HAVE_INT64
unknown's avatar
unknown committed
928
typedef longlong int64;
unknown's avatar
unknown committed
929 930
#endif
#ifndef HAVE_UINT64
unknown's avatar
unknown committed
931
typedef ulonglong uint64;
unknown's avatar
unknown committed
932
#endif
unknown's avatar
unknown committed
933

unknown's avatar
SCRUM  
unknown committed
934 935 936 937 938 939 940 941
#if defined(NO_CLIENT_LONG_LONG)
typedef unsigned long my_ulonglong;
#elif defined (__WIN__)
typedef unsigned __int64 my_ulonglong;
#else
typedef unsigned long long my_ulonglong;
#endif

942
#if SIZEOF_CHARP == SIZEOF_INT
Sergei Golubchik's avatar
Sergei Golubchik committed
943
typedef unsigned int intptr;
944
#elif SIZEOF_CHARP == SIZEOF_LONG
Sergei Golubchik's avatar
Sergei Golubchik committed
945
typedef unsigned long intptr;
946
#elif SIZEOF_CHARP == SIZEOF_LONG_LONG
Sergei Golubchik's avatar
Sergei Golubchik committed
947
typedef unsigned long long intptr;
948
#else
949
#error sizeof(void *) is neither sizeof(int) nor sizeof(long) nor sizeof(long long)
950 951
#endif

952 953
#define MY_ERRPTR ((void*)(intptr)1)

954 955 956 957 958
#if defined(_WIN32)
typedef unsigned long long my_off_t;
typedef unsigned long long os_off_t;
#else
typedef off_t os_off_t;
unknown's avatar
unknown committed
959 960 961 962 963
#if SIZEOF_OFF_T > 4
typedef ulonglong my_off_t;
#else
typedef unsigned long my_off_t;
#endif
964
#endif /*_WIN32*/
unknown's avatar
unknown committed
965 966
#define MY_FILEPOS_ERROR	(~(my_off_t) 0)

967 968 969 970 971 972
/*
  TODO Convert these to use Bitmap class.
 */
typedef ulonglong table_map;          /* Used for table bits in join */
typedef ulong nesting_map;  /* Used for flags of nesting constructs */

973 974 975 976
/* often used type names - opaque declarations */
typedef const struct charset_info_st CHARSET_INFO;
typedef struct st_mysql_lex_string LEX_STRING;

unknown's avatar
unknown committed
977 978
#if defined(__WIN__)
#define socket_errno	WSAGetLastError()
unknown's avatar
unknown committed
979
#define SOCKET_EINTR	WSAEINTR
unknown's avatar
unknown committed
980
#define SOCKET_EAGAIN	WSAEINPROGRESS
981
#define SOCKET_ETIMEDOUT WSAETIMEDOUT
982
#define SOCKET_EWOULDBLOCK WSAEWOULDBLOCK
983
#define SOCKET_EADDRINUSE WSAEADDRINUSE
unknown's avatar
unknown committed
984 985 986 987 988 989 990
#define SOCKET_ENFILE	ENFILE
#define SOCKET_EMFILE	EMFILE
#else /* Unix */
#define socket_errno	errno
#define closesocket(A)	close(A)
#define SOCKET_EINTR	EINTR
#define SOCKET_EAGAIN	EAGAIN
991
#define SOCKET_ETIMEDOUT SOCKET_EINTR
unknown's avatar
unknown committed
992
#define SOCKET_EWOULDBLOCK EWOULDBLOCK
993
#define SOCKET_EADDRINUSE EADDRINUSE
unknown's avatar
unknown committed
994 995 996 997 998 999
#define SOCKET_ENFILE	ENFILE
#define SOCKET_EMFILE	EMFILE
#endif

typedef int		myf;	/* Type of MyFlags in my_funcs */
typedef char		my_bool; /* Small bool */
1000 1001

/* Macros for converting *constants* to the right type */
unknown's avatar
unknown committed
1002 1003
#define MYF(v)		(myf) (v)

unknown's avatar
unknown committed
1004 1005 1006 1007 1008 1009 1010 1011
#ifndef LL
#ifdef HAVE_LONG_LONG
#define LL(A) A ## LL
#else
#define LL(A) A ## L
#endif
#endif

1012 1013 1014 1015 1016 1017 1018 1019
#ifndef ULL
#ifdef HAVE_LONG_LONG
#define ULL(A) A ## ULL
#else
#define ULL(A) A ## UL
#endif
#endif

1020 1021 1022 1023
/*
  Defines to make it possible to prioritize register assignments. No
  longer that important with modern compilers.
*/
unknown's avatar
unknown committed
1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042
#ifndef USING_X
#define reg1 register
#define reg2 register
#define reg3 register
#define reg4 register
#define reg5 register
#define reg6 register
#define reg7 register
#define reg8 register
#define reg9 register
#define reg10 register
#define reg11 register
#define reg12 register
#define reg13 register
#define reg14 register
#define reg15 register
#define reg16 register
#endif

1043 1044
#include <my_dbug.h>

1045 1046 1047
/* Some helper macros */
#define YESNO(X) ((X) ? "yes" : "no")

unknown's avatar
unknown committed
1048
#define MY_HOW_OFTEN_TO_ALARM	2	/* How often we want info on screen */
1049
#define MY_HOW_OFTEN_TO_WRITE	10000	/* How often we want info on screen */
1050

unknown's avatar
unknown committed
1051
/*
1052 1053
  Define-funktions for reading and storing in machine independent format
  (low byte first)
unknown's avatar
unknown committed
1054 1055 1056
*/

/* Optimized store functions for Intel x86 */
1057
#if defined(__i386__) || defined(_WIN32)
1058
#define sint2korr(A)	(*((const int16 *) (A)))
unknown's avatar
unknown committed
1059 1060 1061 1062 1063 1064 1065 1066
#define sint3korr(A)	((int32) ((((uchar) (A)[2]) & 128) ? \
				  (((uint32) 255L << 24) | \
				   (((uint32) (uchar) (A)[2]) << 16) |\
				   (((uint32) (uchar) (A)[1]) << 8) | \
				   ((uint32) (uchar) (A)[0])) : \
				  (((uint32) (uchar) (A)[2]) << 16) |\
				  (((uint32) (uchar) (A)[1]) << 8) | \
				  ((uint32) (uchar) (A)[0])))
1067 1068
#define sint4korr(A)	(*((const long *) (A)))
#define uint2korr(A)	(*((const uint16 *) (A)))
1069
#if defined(HAVE_valgrind) && !defined(_WIN32)
1070 1071 1072 1073
#define uint3korr(A)	(uint32) (((uint32) ((uchar) (A)[0])) +\
				  (((uint32) ((uchar) (A)[1])) << 8) +\
				  (((uint32) ((uchar) (A)[2])) << 16))
#else
1074 1075 1076 1077 1078 1079
/*
   ATTENTION !
   
    Please, note, uint3korr reads 4 bytes (not 3) !
    It means, that you have to provide enough allocated space !
*/
1080
#define uint3korr(A)	(long) (*((const unsigned int *) (A)) & 0xFFFFFF)
1081
#endif /* HAVE_valgrind && !_WIN32 */
1082
#define uint4korr(A)	(*((const uint32 *) (A)))
unknown's avatar
unknown committed
1083 1084 1085 1086
#define uint5korr(A)	((ulonglong)(((uint32) ((uchar) (A)[0])) +\
				    (((uint32) ((uchar) (A)[1])) << 8) +\
				    (((uint32) ((uchar) (A)[2])) << 16) +\
				    (((uint32) ((uchar) (A)[3])) << 24)) +\
unknown's avatar
unknown committed
1087
				    (((ulonglong) ((uchar) (A)[4])) << 32))
1088 1089 1090 1091 1092 1093
#define uint6korr(A)	((ulonglong)(((uint32)    ((uchar) (A)[0]))          + \
                                     (((uint32)    ((uchar) (A)[1])) << 8)   + \
                                     (((uint32)    ((uchar) (A)[2])) << 16)  + \
                                     (((uint32)    ((uchar) (A)[3])) << 24)) + \
                         (((ulonglong) ((uchar) (A)[4])) << 32) +       \
                         (((ulonglong) ((uchar) (A)[5])) << 40))
1094 1095
#define uint8korr(A)	(*((const ulonglong *) (A)))
#define sint8korr(A)	(*((const longlong *) (A)))
unknown's avatar
unknown committed
1096
#define int2store(T,A)	*((uint16*) (T))= (uint16) (A)
unknown's avatar
unknown committed
1097 1098 1099
#define int3store(T,A)  do { *(T)=  (uchar) ((A));\
                            *(T+1)=(uchar) (((uint) (A) >> 8));\
                            *(T+2)=(uchar) (((A) >> 16)); } while (0)
unknown's avatar
unknown committed
1100
#define int4store(T,A)	*((long *) (T))= (long) (A)
unknown's avatar
unknown committed
1101 1102 1103 1104 1105
#define int5store(T,A)  do { *(T)= (uchar)((A));\
                             *((T)+1)=(uchar) (((A) >> 8));\
                             *((T)+2)=(uchar) (((A) >> 16));\
                             *((T)+3)=(uchar) (((A) >> 24)); \
                             *((T)+4)=(uchar) (((A) >> 32)); } while(0)
1106 1107 1108 1109 1110 1111
#define int6store(T,A)  do { *(T)=    (uchar)((A));          \
                             *((T)+1)=(uchar) (((A) >> 8));  \
                             *((T)+2)=(uchar) (((A) >> 16)); \
                             *((T)+3)=(uchar) (((A) >> 24)); \
                             *((T)+4)=(uchar) (((A) >> 32)); \
                             *((T)+5)=(uchar) (((A) >> 40)); } while(0)
unknown's avatar
unknown committed
1112 1113 1114 1115 1116 1117
#define int8store(T,A)	*((ulonglong *) (T))= (ulonglong) (A)

typedef union {
  double v;
  long m[2];
} doubleget_union;
1118
#define doubleget(V,M)	\
unknown's avatar
unknown committed
1119
do { doubleget_union _tmp; \
1120 1121
     _tmp.m[0] = *((const long*)(M)); \
     _tmp.m[1] = *(((const long*) (M))+1); \
unknown's avatar
unknown committed
1122
     (V) = _tmp.v; } while(0)
1123 1124
#define doublestore(T,V) do { *((long *) T) = ((const doubleget_union *)&V)->m[0]; \
			     *(((long *) T)+1) = ((const doubleget_union *)&V)->m[1]; \
unknown's avatar
unknown committed
1125
                         } while (0)
1126
#define float4get(V,M)   do { *((float *) &(V)) = *((const float*) (M)); } while(0)
unknown's avatar
unknown committed
1127
#define float8get(V,M)   doubleget((V),(M))
1128 1129 1130
#define float4store(V,M) memcpy((uchar*) V,(uchar*) (&M),sizeof(float))
#define floatstore(T,V)  memcpy((uchar*)(T), (uchar*)(&V),sizeof(float))
#define floatget(V,M)    memcpy((uchar*) &V,(uchar*) (M),sizeof(float))
unknown's avatar
unknown committed
1131
#define float8store(V,M) doublestore((V),(M))
1132
#else
unknown's avatar
unknown committed
1133

1134 1135 1136 1137
/*
  We're here if it's not a IA-32 architecture (Win32 and UNIX IA-32 defines
  were done before)
*/
unknown's avatar
unknown committed
1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165
#define sint2korr(A)	(int16) (((int16) ((uchar) (A)[0])) +\
				 ((int16) ((int16) (A)[1]) << 8))
#define sint3korr(A)	((int32) ((((uchar) (A)[2]) & 128) ? \
				  (((uint32) 255L << 24) | \
				   (((uint32) (uchar) (A)[2]) << 16) |\
				   (((uint32) (uchar) (A)[1]) << 8) | \
				   ((uint32) (uchar) (A)[0])) : \
				  (((uint32) (uchar) (A)[2]) << 16) |\
				  (((uint32) (uchar) (A)[1]) << 8) | \
				  ((uint32) (uchar) (A)[0])))
#define sint4korr(A)	(int32) (((int32) ((uchar) (A)[0])) +\
				(((int32) ((uchar) (A)[1]) << 8)) +\
				(((int32) ((uchar) (A)[2]) << 16)) +\
				(((int32) ((int16) (A)[3]) << 24)))
#define sint8korr(A)	(longlong) uint8korr(A)
#define uint2korr(A)	(uint16) (((uint16) ((uchar) (A)[0])) +\
				  ((uint16) ((uchar) (A)[1]) << 8))
#define uint3korr(A)	(uint32) (((uint32) ((uchar) (A)[0])) +\
				  (((uint32) ((uchar) (A)[1])) << 8) +\
				  (((uint32) ((uchar) (A)[2])) << 16))
#define uint4korr(A)	(uint32) (((uint32) ((uchar) (A)[0])) +\
				  (((uint32) ((uchar) (A)[1])) << 8) +\
				  (((uint32) ((uchar) (A)[2])) << 16) +\
				  (((uint32) ((uchar) (A)[3])) << 24))
#define uint5korr(A)	((ulonglong)(((uint32) ((uchar) (A)[0])) +\
				    (((uint32) ((uchar) (A)[1])) << 8) +\
				    (((uint32) ((uchar) (A)[2])) << 16) +\
				    (((uint32) ((uchar) (A)[3])) << 24)) +\
unknown's avatar
unknown committed
1166
				    (((ulonglong) ((uchar) (A)[4])) << 32))
1167 1168 1169 1170 1171 1172
#define uint6korr(A)	((ulonglong)(((uint32)    ((uchar) (A)[0]))          + \
                                     (((uint32)    ((uchar) (A)[1])) << 8)   + \
                                     (((uint32)    ((uchar) (A)[2])) << 16)  + \
                                     (((uint32)    ((uchar) (A)[3])) << 24)) + \
                         (((ulonglong) ((uchar) (A)[4])) << 32) +       \
                         (((ulonglong) ((uchar) (A)[5])) << 40))
unknown's avatar
unknown committed
1173 1174 1175 1176 1177 1178 1179 1180
#define uint8korr(A)	((ulonglong)(((uint32) ((uchar) (A)[0])) +\
				    (((uint32) ((uchar) (A)[1])) << 8) +\
				    (((uint32) ((uchar) (A)[2])) << 16) +\
				    (((uint32) ((uchar) (A)[3])) << 24)) +\
			(((ulonglong) (((uint32) ((uchar) (A)[4])) +\
				    (((uint32) ((uchar) (A)[5])) << 8) +\
				    (((uint32) ((uchar) (A)[6])) << 16) +\
				    (((uint32) ((uchar) (A)[7])) << 24))) <<\
unknown's avatar
unknown committed
1181 1182 1183
				    32))
#define int2store(T,A)       do { uint def_temp= (uint) (A) ;\
                                  *((uchar*) (T))=  (uchar)(def_temp); \
unknown's avatar
unknown committed
1184
                                   *((uchar*) (T)+1)=(uchar)((def_temp >> 8)); \
unknown's avatar
unknown committed
1185 1186 1187 1188 1189 1190
                             } while(0)
#define int3store(T,A)       do { /*lint -save -e734 */\
                                  *((uchar*)(T))=(uchar) ((A));\
                                  *((uchar*) (T)+1)=(uchar) (((A) >> 8));\
                                  *((uchar*)(T)+2)=(uchar) (((A) >> 16)); \
                                  /*lint -restore */} while(0)
unknown's avatar
unknown committed
1191 1192 1193 1194
#define int4store(T,A)       do { *((char *)(T))=(char) ((A));\
                                  *(((char *)(T))+1)=(char) (((A) >> 8));\
                                  *(((char *)(T))+2)=(char) (((A) >> 16));\
                                  *(((char *)(T))+3)=(char) (((A) >> 24)); } while(0)
unknown's avatar
unknown committed
1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207
#define int5store(T,A)       do { *((char *)(T))=     (char)((A));  \
                                  *(((char *)(T))+1)= (char)(((A) >> 8)); \
                                  *(((char *)(T))+2)= (char)(((A) >> 16)); \
                                  *(((char *)(T))+3)= (char)(((A) >> 24)); \
                                  *(((char *)(T))+4)= (char)(((A) >> 32)); \
		                } while(0)
#define int6store(T,A)       do { *((char *)(T))=     (char)((A)); \
                                  *(((char *)(T))+1)= (char)(((A) >> 8)); \
                                  *(((char *)(T))+2)= (char)(((A) >> 16)); \
                                  *(((char *)(T))+3)= (char)(((A) >> 24)); \
                                  *(((char *)(T))+4)= (char)(((A) >> 32)); \
                                  *(((char *)(T))+5)= (char)(((A) >> 40)); \
                                } while(0)
unknown's avatar
unknown committed
1208 1209 1210
#define int8store(T,A)       do { uint def_temp= (uint) (A), def_temp2= (uint) ((A) >> 32); \
                                  int4store((T),def_temp); \
                                  int4store((T+4),def_temp2); } while(0)
unknown's avatar
unknown committed
1211
#ifdef WORDS_BIGENDIAN
1212 1213 1214 1215
#define float4store(T,A) do { *(T)= ((uchar *) &A)[3];\
                              *((T)+1)=(char) ((uchar *) &A)[2];\
                              *((T)+2)=(char) ((uchar *) &A)[1];\
                              *((T)+3)=(char) ((uchar *) &A)[0]; } while(0)
unknown's avatar
unknown committed
1216

unknown's avatar
unknown committed
1217
#define float4get(V,M)   do { float def_temp;\
1218 1219 1220 1221
                              ((uchar*) &def_temp)[0]=(M)[3];\
                              ((uchar*) &def_temp)[1]=(M)[2];\
                              ((uchar*) &def_temp)[2]=(M)[1];\
                              ((uchar*) &def_temp)[3]=(M)[0];\
unknown's avatar
unknown committed
1222
                              (V)=def_temp; } while(0)
1223 1224 1225 1226 1227 1228 1229 1230
#define float8store(T,V) do { *(T)= ((uchar *) &V)[7];\
                              *((T)+1)=(char) ((uchar *) &V)[6];\
                              *((T)+2)=(char) ((uchar *) &V)[5];\
                              *((T)+3)=(char) ((uchar *) &V)[4];\
                              *((T)+4)=(char) ((uchar *) &V)[3];\
                              *((T)+5)=(char) ((uchar *) &V)[2];\
                              *((T)+6)=(char) ((uchar *) &V)[1];\
                              *((T)+7)=(char) ((uchar *) &V)[0]; } while(0)
unknown's avatar
unknown committed
1231

unknown's avatar
unknown committed
1232
#define float8get(V,M)   do { double def_temp;\
1233 1234 1235 1236 1237 1238 1239 1240
                              ((uchar*) &def_temp)[0]=(M)[7];\
                              ((uchar*) &def_temp)[1]=(M)[6];\
                              ((uchar*) &def_temp)[2]=(M)[5];\
                              ((uchar*) &def_temp)[3]=(M)[4];\
                              ((uchar*) &def_temp)[4]=(M)[3];\
                              ((uchar*) &def_temp)[5]=(M)[2];\
                              ((uchar*) &def_temp)[6]=(M)[1];\
                              ((uchar*) &def_temp)[7]=(M)[0];\
unknown's avatar
unknown committed
1241
                              (V) = def_temp; } while(0)
unknown's avatar
unknown committed
1242
#else
1243 1244
#define float4get(V,M)   memcpy(&V, (M), sizeof(float))
#define float4store(V,M) memcpy(V, (&M), sizeof(float))
unknown's avatar
unknown committed
1245 1246

#if defined(__FLOAT_WORD_ORDER) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN)
1247 1248 1249 1250 1251 1252 1253 1254
#define doublestore(T,V) do { *(((char*)T)+0)=(char) ((uchar *) &V)[4];\
                              *(((char*)T)+1)=(char) ((uchar *) &V)[5];\
                              *(((char*)T)+2)=(char) ((uchar *) &V)[6];\
                              *(((char*)T)+3)=(char) ((uchar *) &V)[7];\
                              *(((char*)T)+4)=(char) ((uchar *) &V)[0];\
                              *(((char*)T)+5)=(char) ((uchar *) &V)[1];\
                              *(((char*)T)+6)=(char) ((uchar *) &V)[2];\
                              *(((char*)T)+7)=(char) ((uchar *) &V)[3]; }\
1255
                         while(0)
unknown's avatar
unknown committed
1256
#define doubleget(V,M)   do { double def_temp;\
1257 1258 1259 1260 1261 1262 1263 1264
                              ((uchar*) &def_temp)[0]=(M)[4];\
                              ((uchar*) &def_temp)[1]=(M)[5];\
                              ((uchar*) &def_temp)[2]=(M)[6];\
                              ((uchar*) &def_temp)[3]=(M)[7];\
                              ((uchar*) &def_temp)[4]=(M)[0];\
                              ((uchar*) &def_temp)[5]=(M)[1];\
                              ((uchar*) &def_temp)[6]=(M)[2];\
                              ((uchar*) &def_temp)[7]=(M)[3];\
unknown's avatar
unknown committed
1265
                              (V) = def_temp; } while(0)
unknown's avatar
unknown committed
1266 1267 1268 1269 1270 1271
#endif /* __FLOAT_WORD_ORDER */

#define float8get(V,M)   doubleget((V),(M))
#define float8store(V,M) doublestore((V),(M))
#endif /* WORDS_BIGENDIAN */

1272
#endif /* __i386__ OR _WIN32 */
unknown's avatar
unknown committed
1273

1274 1275 1276 1277 1278 1279 1280 1281
/*
  Macro for reading 32-bit integer from network byte order (big-endian)
  from unaligned memory location.
*/
#define int4net(A)        (int32) (((uint32) ((uchar) (A)[3]))        |\
				  (((uint32) ((uchar) (A)[2])) << 8)  |\
				  (((uint32) ((uchar) (A)[1])) << 16) |\
				  (((uint32) ((uchar) (A)[0])) << 24))
1282 1283 1284 1285 1286
/*
  Define-funktions for reading and storing in machine format from/to
  short/long to/from some place in memory V should be a (not
  register) variable, M is a pointer to byte
*/
unknown's avatar
unknown committed
1287 1288 1289

#ifdef WORDS_BIGENDIAN

unknown's avatar
unknown committed
1290 1291 1292 1293 1294
#define ushortget(V,M)  do { V = (uint16) (((uint16) ((uchar) (M)[1]))+\
                                 ((uint16) ((uint16) (M)[0]) << 8)); } while(0)
#define shortget(V,M)   do { V = (short) (((short) ((uchar) (M)[1]))+\
                                 ((short) ((short) (M)[0]) << 8)); } while(0)
#define longget(V,M)    do { int32 def_temp;\
1295 1296 1297 1298
                             ((uchar*) &def_temp)[0]=(M)[0];\
                             ((uchar*) &def_temp)[1]=(M)[1];\
                             ((uchar*) &def_temp)[2]=(M)[2];\
                             ((uchar*) &def_temp)[3]=(M)[3];\
unknown's avatar
unknown committed
1299 1300
                             (V)=def_temp; } while(0)
#define ulongget(V,M)   do { uint32 def_temp;\
1301 1302 1303 1304
                            ((uchar*) &def_temp)[0]=(M)[0];\
                            ((uchar*) &def_temp)[1]=(M)[1];\
                            ((uchar*) &def_temp)[2]=(M)[2];\
                            ((uchar*) &def_temp)[3]=(M)[3];\
unknown's avatar
unknown committed
1305 1306
                            (V)=def_temp; } while(0)
#define shortstore(T,A) do { uint def_temp=(uint) (A) ;\
1307 1308 1309 1310 1311 1312
                             *(((char*)T)+1)=(char)(def_temp); \
                             *(((char*)T)+0)=(char)(def_temp >> 8); } while(0)
#define longstore(T,A)  do { *(((char*)T)+3)=((A));\
                             *(((char*)T)+2)=(((A) >> 8));\
                             *(((char*)T)+1)=(((A) >> 16));\
                             *(((char*)T)+0)=(((A) >> 24)); } while(0)
unknown's avatar
unknown committed
1313

1314 1315 1316 1317 1318 1319
#define floatget(V,M)    memcpy(&V, (M), sizeof(float))
#define floatstore(T,V)  memcpy((T), (void*) (&V), sizeof(float))
#define doubleget(V,M)	 memcpy(&V, (M), sizeof(double))
#define doublestore(T,V) memcpy((T), (void *) &V, sizeof(double))
#define longlongget(V,M) memcpy(&V, (M), sizeof(ulonglong))
#define longlongstore(T,V) memcpy((T), &V, sizeof(ulonglong))
unknown's avatar
unknown committed
1320 1321 1322

#else

unknown's avatar
unknown committed
1323 1324 1325 1326
#define ushortget(V,M)	do { V = uint2korr(M); } while(0)
#define shortget(V,M)	do { V = sint2korr(M); } while(0)
#define longget(V,M)	do { V = sint4korr(M); } while(0)
#define ulongget(V,M)   do { V = uint4korr(M); } while(0)
unknown's avatar
unknown committed
1327 1328
#define shortstore(T,V) int2store(T,V)
#define longstore(T,V)	int4store(T,V)
1329
#ifndef floatstore
1330 1331
#define floatstore(T,V)  memcpy((T), (void *) (&V), sizeof(float))
#define floatget(V,M)    memcpy(&V, (M), sizeof(float))
1332
#endif
unknown's avatar
unknown committed
1333
#ifndef doubleget
1334 1335
#define doubleget(V,M)	 memcpy(&V, (M), sizeof(double))
#define doublestore(T,V) memcpy((T), (void *) &V, sizeof(double))
unknown's avatar
unknown committed
1336
#endif /* doubleget */
1337 1338
#define longlongget(V,M) memcpy(&V, (M), sizeof(ulonglong))
#define longlongstore(T,V) memcpy((T), &V, sizeof(ulonglong))
unknown's avatar
unknown committed
1339 1340 1341

#endif /* WORDS_BIGENDIAN */

1342 1343 1344 1345 1346 1347
#ifdef HAVE_CHARSET_utf8
#define MYSQL_UNIVERSAL_CLIENT_CHARSET "utf8"
#else
#define MYSQL_UNIVERSAL_CLIENT_CHARSET MYSQL_DEFAULT_CHARSET_NAME
#endif

1348 1349 1350 1351
#if defined(EMBEDDED_LIBRARY) && !defined(HAVE_EMBEDDED_PRIVILEGE_CONTROL)
#define NO_EMBEDDED_ACCESS_CHECKS
#endif

Sergei Golubchik's avatar
Sergei Golubchik committed
1352
#ifdef _WIN32
1353
#define dlsym(lib, name) (void*)GetProcAddress((HMODULE)lib, name)
1354 1355
#define dlopen(libname, unused) LoadLibraryEx(libname, NULL, 0)
#define dlclose(lib) FreeLibrary((HMODULE)lib)
Sergei Golubchik's avatar
Sergei Golubchik committed
1356 1357 1358 1359 1360 1361 1362 1363
static inline char *dlerror(void)
{
  static char win_errormsg[2048];
  if(FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
                   0, GetLastError(), 0, win_errormsg, 2048, NULL))
    return win_errormsg;
  return "";
}
Sergei Golubchik's avatar
Sergei Golubchik committed
1364 1365
#define HAVE_DLOPEN 1
#define HAVE_DLERROR 1
1366 1367 1368
#endif

#ifdef HAVE_DLFCN_H
1369 1370
#include <dlfcn.h>
#endif
1371

Sergei Golubchik's avatar
Sergei Golubchik committed
1372
#ifdef HAVE_DLOPEN
Sergei Golubchik's avatar
Sergei Golubchik committed
1373 1374 1375
#ifndef HAVE_DLERROR
#define dlerror() ""
#endif
1376 1377 1378
#ifndef HAVE_DLADDR
#define dladdr(A, B) 0
#endif
Sergei Golubchik's avatar
Sergei Golubchik committed
1379
#else
1380
#define dlerror() "No support for dynamic loading (static build?)"
1381 1382 1383
#define dlopen(A,B) 0
#define dlsym(A,B) 0
#define dlclose(A) 0
1384
#define dladdr(A, B) 0
1385 1386
#endif

1387
/*
unknown's avatar
unknown committed
1388
 *  Include standard definitions of operator new and delete.
1389 1390
 */
#ifdef __cplusplus
1391
#include <new>
1392 1393
#endif

1394 1395 1396 1397 1398 1399
/* Length of decimal number represented by INT32. */
#define MY_INT32_NUM_DECIMAL_DIGITS 11

/* Length of decimal number represented by INT64. */
#define MY_INT64_NUM_DECIMAL_DIGITS 21

1400 1401 1402 1403
#ifdef __cplusplus
#include <limits> /* should be included before min/max macros */
#endif

1404 1405 1406 1407
/* Define some useful general macros (should be done after all headers). */
#if !defined(max)
#define max(a, b)	((a) > (b) ? (a) : (b))
#define min(a, b)	((a) < (b) ? (a) : (b))
1408 1409
#endif  

1410 1411
#define CMP_NUM(a,b)    (((a) < (b)) ? -1 : ((a) == (b)) ? 0 : 1)

1412 1413 1414 1415 1416 1417
/*
  Only Linux is known to need an explicit sync of the directory to make sure a
  file creation/deletion/renaming in(from,to) this directory durable.
*/
#ifdef TARGET_OS_LINUX
#define NEED_EXPLICIT_SYNC_DIR 1
1418 1419 1420 1421 1422 1423 1424 1425 1426
#else
/*
  On linux default rwlock scheduling policy is good enough for
  waiting_threads.c, on other systems use our special implementation
  (which is slower).

  QQ perhaps this should be tested in configure ? how ?
*/
#define WT_RWLOCKS_USE_MUTEXES 1
1427 1428
#endif

1429 1430 1431 1432
#if !defined(__cplusplus) && !defined(bool)
#define bool In_C_you_should_use_my_bool_instead()
#endif

Konstantin Osipov's avatar
Konstantin Osipov committed
1433
/* Provide __func__ macro definition for platforms that miss it. */
1434
#if !defined (__func__)
Konstantin Osipov's avatar
Konstantin Osipov committed
1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451
#if __STDC_VERSION__ < 199901L
#  if __GNUC__ >= 2
#    define __func__ __FUNCTION__
#  else
#    define __func__ "<unknown>"
#  endif
#elif defined(_MSC_VER)
#  if _MSC_VER < 1300
#    define __func__ "<unknown>"
#  else
#    define __func__ __FUNCTION__
#  endif
#elif defined(__BORLANDC__)
#  define __func__ __FUNC__
#else
#  define __func__ "<unknown>"
#endif
1452
#endif /* !defined(__func__) */
Konstantin Osipov's avatar
Konstantin Osipov committed
1453

1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488
#ifndef HAVE_RINT
/**
   All integers up to this number can be represented exactly as double precision
   values (DBL_MANT_DIG == 53 for IEEE 754 hardware).
*/
#define MAX_EXACT_INTEGER ((1LL << DBL_MANT_DIG) - 1)

/**
   rint(3) implementation for platforms that do not have it.
   Always rounds to the nearest integer with ties being rounded to the nearest
   even integer to mimic glibc's rint() behavior in the "round-to-nearest"
   FPU mode. Hardware-specific optimizations are possible (frndint on x86).
   Unlike this implementation, hardware will also honor the FPU rounding mode.
*/

static inline double rint(double x)
{
  double f, i;
  f = modf(x, &i);
  /*
    All doubles with absolute values > MAX_EXACT_INTEGER are even anyway,
    no need to check it.
  */
  if (x > 0.0)
    i += (double) ((f > 0.5) || (f == 0.5 &&
                                 i <= (double) MAX_EXACT_INTEGER &&
                                 (longlong) i % 2));
  else
    i -= (double) ((f < -0.5) || (f == -0.5 &&
                                  i >= (double) -MAX_EXACT_INTEGER &&
                                  (longlong) i % 2));
  return i;
}
#endif /* HAVE_RINT */

1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501
/* 
  MYSQL_PLUGIN_IMPORT macro is used to export mysqld data
  (i.e variables) for usage in storage engine loadable plugins.
  Outside of Windows, it is dummy.
*/
#ifndef MYSQL_PLUGIN_IMPORT
#if (defined(_WIN32) && defined(MYSQL_DYNAMIC_PLUGIN))
#define MYSQL_PLUGIN_IMPORT __declspec(dllimport)
#else
#define MYSQL_PLUGIN_IMPORT
#endif
#endif

1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512
/* Defines that are unique to the embedded version of MySQL */

#ifdef EMBEDDED_LIBRARY

/* Things we don't need in the embedded version of MySQL */
/* TODO HF add #undef HAVE_VIO if we don't want client in embedded library */

#undef HAVE_SMEM				/* No shared memory */

#endif /* EMBEDDED_LIBRARY */

1513
#endif /* my_global_h */