17 #ifndef MY_GLOBAL_INCLUDED
18 #define MY_GLOBAL_INCLUDED
23 #if !defined(__WIN__) && defined(_WIN32)
36 #define INNODB_COMPATIBILITY_HOOKS
47 #define HAVE_ERRNO_AS_DEFINE
50 #if defined(i386) && !defined(__i386__)
56 #define C_MODE_START extern "C" {
64 #define CPP_UNNAMED_NS_START namespace {
65 #define CPP_UNNAMED_NS_END }
68 #include <my_config.h>
70 #ifdef WITH_PERFSCHEMA_STORAGE_ENGINE
71 #define HAVE_PSI_INTERFACE
82 #define IF_PURIFY(A,B) A
84 #define IF_PURIFY(A,B) B
87 #ifndef EMBEDDED_LIBRARY
88 #ifdef WITH_NDB_BINLOG
89 #define HAVE_NDB_BINLOG 1
93 #ifndef EMBEDDED_LIBRARY
94 #define HAVE_REPLICATION
95 #define HAVE_EXTERNAL_CLIENT
105 #define SIZEOF_OFF_T 8
116 #include <winsock2.h>
117 #include <ws2tcpip.h>
121 #define sleep(a) Sleep((a)*1000)
132 #define F_TO_EOF 0x3FFFFFFF
136 #define HAVE_NAMED_PIPE 1
137 #define shared_memory_buffer_length 16000
138 #define default_shared_memory_base_name "MYSQL"
143 #if defined(_AIX) && defined(_LARGE_FILE_API)
144 #undef _LARGE_FILE_API
151 #if defined(__APPLE__) && defined(__MACH__)
156 # undef SIZEOF_LONG_LONG
158 # undef WORDS_BIGENDIAN
159 # define SIZEOF_SHORT 2
160 # define SIZEOF_INT 4
161 # define SIZEOF_LONG_LONG 8
162 # define SIZEOF_OFF_T 8
163 # if defined(__i386__) || defined(__ppc__)
164 # define SIZEOF_CHARP 4
165 # define SIZEOF_LONG 4
166 # elif defined(__x86_64__) || defined(__ppc64__)
167 # define SIZEOF_CHARP 8
168 # define SIZEOF_LONG 8
170 # error Building FAT binary for an unknown architecture.
172 # if defined(__ppc__) || defined(__ppc64__)
173 # define WORDS_BIGENDIAN
187 #if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
188 #define __builtin_expect(x, expected_value) (x)
191 #define likely(x) __builtin_expect((x),1)
192 #define unlikely(x) __builtin_expect((x),0)
195 #if defined(TARGET_OS_LINUX) || defined(__GLIBC__)
197 #define _GNU_SOURCE 1
204 #if defined(HAVE_SYS_TYPES_H) && ( defined(sun) || defined(__sun) )
205 #include <sys/types.h>
208 #ifdef HAVE_THREADS_WITHOUT_SOCKETS
213 #define __EXTENSIONS__ 1
215 #define __STDC_EXT__ 1
243 #if __STDC_VERSION__ - 0 >= 199901L
244 #define _XOPEN_SOURCE 600
246 #define _XOPEN_SOURCE 500
250 #if !defined(__WIN__)
251 #ifndef _POSIX_PTHREAD_SEMANTICS
252 #define _POSIX_PTHREAD_SEMANTICS
258 #if !defined(_THREAD_SAFE) && !defined(_AIX)
261 #if defined(HPUX10) || defined(HPUX11)
268 #if !defined(SCO) && !defined(_REENTRANT)
276 #define _SYS_STREAM_H
278 #define ulonglong2double(A) my_ulonglong2double(A)
279 #define my_off_t2double(A) my_ulonglong2double(A)
281 inline double my_ulonglong2double(
unsigned long long A) {
return (
double A); }
285 #ifdef HAVE_BROKEN_SNPRINTF
288 #ifdef HAVE_BROKEN_PREAD
297 #ifdef UNDEF_HAVE_INITGROUPS
298 #undef HAVE_INITGROUPS
301 #if defined(_lint) && !defined(lint)
304 #if SIZEOF_LONG_LONG > 4 && !defined(_LONG_LONG)
330 #ifdef HAVE_SYS_TYPES_H
331 #include <sys/types.h>
336 #ifdef HAVE_SYS_TIMEB_H
337 #include <sys/timeb.h>
339 #if TIME_WITH_SYS_TIME
340 # include <sys/time.h>
344 # include <sys/time.h>
352 #if defined(__cplusplus) && defined(NO_CPLUSPLUS_ALLOCA)
362 #if defined(HAVE_CRYPT_H)
374 #ifdef _some_old_compiler_that_does_not_understand_the_construct_below_
375 #define compile_time_assert(X) do { } while(0)
377 #define compile_time_assert(X) \
380 typedef char compile_time_assert[(X) ? 1 : -1] __attribute__((unused)); \
385 #if defined (HPUX11) && defined(_LARGEFILE_SOURCE)
386 #ifndef _LARGEFILE64_SOURCE
387 #define _LARGEFILE64_SOURCE
391 #if defined(_HPUX_SOURCE) && defined(HAVE_SYS_STREAM_H)
392 #include <sys/stream.h>
395 #if defined(HPUX10) && defined(_LARGEFILE64_SOURCE)
398 #define setrlimit cma_setrlimit64
401 #if HAVE_MADVISE && !HAVE_DECL_MADVISE && defined(__cplusplus)
402 extern "C" int madvise(
void *addr,
size_t len,
int behav);
405 #define QUOTE_ARG(x) #x
406 #define STRINGIFY_ARG(x) QUOTE_ARG(x)
410 #define DONT_ALLOW_USER_CHANGE 1
411 #define DONT_USE_MYSQL_PWD 1
415 #if !defined(HAVE_BSD_SIGNALS) && !defined(HAVE_SIGACTION)
416 #define SIGNAL_HANDLER_RESET_ON_DELIVERY
425 #if defined(_lint) || defined(FORCE_INIT_OF_VARS) || \
426 (defined(__GNUC__) && defined(__cplusplus))
427 #define LINT_INIT(var) var= 0
429 #define LINT_INIT(var)
434 #define SO_EXT ".dll"
435 #elif defined(__APPLE__)
436 #define SO_EXT ".dylib"
448 #if defined(_lint) || defined(FORCE_INIT_OF_VARS) || \
449 defined(__cplusplus) || !defined(__GNUC__)
450 #define UNINIT_VAR(x) x= 0
453 #define UNINIT_VAR(x) x= x
456 #if !defined(HAVE_UINT)
459 typedef unsigned int uint;
460 typedef unsigned short ushort;
463 #define swap_variables(t, a, b) { t dummy; dummy= a; a= b; b= dummy; }
464 #define test(a) ((a) ? 1 : 0)
465 #define set_if_bigger(a,b) do { if ((a) < (b)) (a)=(b); } while(0)
466 #define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0)
467 #define test_all_bits(a,b) (((a) & (b)) == (b))
468 #define array_elements(A) ((uint) (sizeof(A)/sizeof(A[0])))
476 #include <my_compiler.h>
479 #if defined(DBUG_ON) && defined(DBUG_OFF)
484 #if (defined(FORCE_DBUG_OFF) || defined(_lint)) && !defined(DBUG_OFF)
495 typedef SOCKET my_socket;
497 typedef int my_socket;
498 #define INVALID_SOCKET -1
501 #define sig_handler RETSIGTYPE
503 typedef void (*sig_return)();
505 #if defined(__GNUC__) && !defined(_lint)
509 typedef short pshort;
510 typedef float pfloat;
516 typedef double pfloat;
519 typedef int (*qsort_cmp)(
const void *,
const void *);
520 typedef int (*qsort_cmp2)(
const void*,
const void *,
const void *);
522 #define qsort_t RETQSORTTYPE
523 #ifdef HAVE_SYS_SOCKET_H
524 #include <sys/socket.h>
526 typedef SOCKET_SIZE_TYPE size_socket;
528 #ifndef SOCKOPT_OPTLEN_TYPE
529 #define SOCKOPT_OPTLEN_TYPE size_socket
540 #define FILE_BINARY O_BINARY
543 #define HAVE_FCNTL_LOCK
549 #define O_TEMPORARY 0
551 #ifndef O_SHORT_LIVED
552 #define O_SHORT_LIVED 0
560 #define _SH_DENYRWD 0x110
561 #define _SH_DENYWRD 0x120
562 #define _SH_DENYRDD 0x130
563 #define _SH_DENYDEL 0x140
569 #define FN_HEADLEN 253
571 #define FN_REFLEN 512
572 #define FN_EXTCHAR '.'
573 #define FN_HOMELIB '~'
574 #define FN_CURLIB '.'
575 #define FN_PARENTDIR ".."
578 #define FN_LIBCHAR '\\'
579 #define FN_LIBCHAR2 '/'
580 #define FN_DIRSEP "/\\"
581 #define FN_EXEEXT ".exe"
582 #define FN_SOEXT ".dll"
583 #define FN_ROOTDIR "\\"
584 #define FN_DEVCHAR ':'
585 #define FN_NETWORK_DRIVES
586 #define FN_NO_CASE_SENCE
588 #define FN_LIBCHAR '/'
589 #define FN_LIBCHAR2 '/'
590 #define FN_DIRSEP "/"
592 #define FN_SOEXT ".so"
593 #define FN_ROOTDIR "/"
609 #define MY_FILE_MIN 2048
611 #define MY_FILE_MIN 0
625 #define MY_NFILE (16384 + MY_FILE_MIN)
630 #ifndef OS_FILE_LIMIT
631 #define OS_FILE_LIMIT UINT_MAX
644 #define MALLOC_OVERHEAD 8
647 #define ONCE_ALLOC_INIT (uint) (4096-MALLOC_OVERHEAD)
649 #define RECORD_CACHE_SIZE (uint) (64*1024-MALLOC_OVERHEAD)
651 #define KEY_CACHE_SIZE (uint) (8*1024*1024)
653 #define KEY_CACHE_BLOCK_SIZE (uint) 1024
659 #define NO_DIR_LIBRARY
666 #define closesocket(A) close(A)
671 inline double my_ulonglong2double(
unsigned long long value)
673 long long nr=(
long long) value;
676 return (18446744073709551616.0 + (
double) nr);
678 #define ulonglong2double my_ulonglong2double
679 #define my_off_t2double my_ulonglong2double
681 inline unsigned long long my_double2ulonglong(
double d)
683 double t= d - (double) 0x8000000000000000ULL;
686 return ((
unsigned long long) t) + 0x8000000000000000ULL;
687 return (
unsigned long long) d;
689 #define double2ulonglong my_double2ulonglong
692 #ifndef ulonglong2double
693 #define ulonglong2double(A) ((double) (ulonglong) (A))
694 #define my_off_t2double(A) ((double) (my_off_t) (A))
696 #ifndef double2ulonglong
697 #define double2ulonglong(A) ((ulonglong) (double) (A))
701 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
703 #define ulong_to_double(X) ((double) (ulong) (X))
705 #ifndef STACK_DIRECTION
706 #error "please add -DSTACK_DIRECTION=1 or -1 to your CPPFLAGS"
709 #if !defined(HAVE_STRTOK_R)
710 #define strtok_r(A,B,C) strtok((A),(B))
715 #if SIZEOF_LONG_LONG > 4
716 #define HAVE_LONG_LONG 1
724 #if defined(HAVE_LONG_LONG) && !defined(LONGLONG_MIN)
725 #define LONGLONG_MIN ((long long) 0x8000000000000000LL)
726 #define LONGLONG_MAX ((long long) 0x7FFFFFFFFFFFFFFFLL)
729 #if defined(HAVE_LONG_LONG) && !defined(ULONGLONG_MAX)
732 #define ULONGLONG_MAX ULLONG_MAX
734 #define ULONGLONG_MAX ((unsigned long long)(~0ULL))
738 #define INT_MIN64 (~0x7FFFFFFFFFFFFFFFLL)
739 #define INT_MAX64 0x7FFFFFFFFFFFFFFFLL
740 #define INT_MIN32 (~0x7FFFFFFFL)
741 #define INT_MAX32 0x7FFFFFFFL
742 #define UINT_MAX32 0xFFFFFFFFL
743 #define INT_MIN24 (~0x007FFFFF)
744 #define INT_MAX24 0x007FFFFF
745 #define UINT_MAX24 0x00FFFFFF
746 #define INT_MIN16 (~0x7FFF)
747 #define INT_MAX16 0x7FFF
748 #define UINT_MAX16 0xFFFF
749 #define INT_MIN8 (~0x7F)
750 #define INT_MAX8 0x7F
751 #define UINT_MAX8 0xFF
755 #define DBL_MIN 4.94065645841246544e-324
756 #define FLT_MIN ((float)1.40129846432481707e-45)
759 #define DBL_MAX 1.79769313486231470e+308
760 #define FLT_MAX ((float)3.40282346638528860e+38)
763 #define SIZE_T_MAX (~((size_t) 0))
768 #define isfinite(x) finite(x)
770 #define finite(x) (1.0 / fabs(x) > 0.0)
776 #define isnan(x) ((x) != (x))
779 extern double my_double_isnan(
double x);
784 #if !defined(__cplusplus) && defined(HAVE_BROKEN_ISINF)
786 static inline double my_isinf(
double x)
788 volatile double t= x;
793 #define my_isinf(X) isinf(X)
796 #define my_isinf(X) (!finite(X) && !isnan(X))
801 #define M_PI 3.14159265358979323846
804 #define M_E 2.7182818284590452354
807 #define M_LN2 0.69314718055994530942
814 #if SIZEOF_CHARP == 4
815 typedef long my_ptrdiff_t;
817 typedef long long my_ptrdiff_t;
820 #define MY_ALIGN(A,L) (((A) + (L) - 1) & ~((L) - 1))
821 #define ALIGN_SIZE(A) MY_ALIGN((A),sizeof(double))
823 #define ADD_TO_PTR(ptr,size,type) (type) ((uchar*) (ptr)+size)
824 #define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((uchar*) (A) - (uchar*) (B))
838 #define my_offsetof(TYPE, MEMBER) \
839 ((size_t)((char *)&(((TYPE *)0x10)->MEMBER) - (char*)0x10))
841 #define NullS (char *) 0
848 #define STDCALL __stdcall
856 typedef unsigned char uchar;
860 typedef signed char int8;
863 typedef unsigned char uint8;
869 typedef unsigned short uint16;
876 typedef unsigned int uint32;
878 #elif SIZEOF_LONG == 4
883 typedef unsigned long uint32;
886 #error Neither int or long is of 4 bytes width
889 #if !defined(HAVE_ULONG) && !defined(__USE_MISC)
890 typedef unsigned long ulong;
892 #ifndef longlong_defined
898 #if defined(HAVE_LONG_LONG) && SIZEOF_LONG_LONG == 8
899 typedef unsigned long long int ulonglong;
900 typedef long long int longlong;
902 typedef unsigned long ulonglong;
903 typedef long longlong;
907 typedef longlong int64;
910 typedef ulonglong uint64;
913 #if defined(NO_CLIENT_LONG_LONG)
914 typedef unsigned long my_ulonglong;
915 #elif defined (__WIN__)
916 typedef unsigned __int64 my_ulonglong;
918 typedef unsigned long long my_ulonglong;
921 #if SIZEOF_CHARP == SIZEOF_INT
923 #elif SIZEOF_CHARP == SIZEOF_LONG
925 #elif SIZEOF_CHARP == SIZEOF_LONG_LONG
926 typedef long long intptr;
928 #error sizeof(void *) is neither sizeof(int) nor sizeof(long) nor sizeof(long long)
931 #define MY_ERRPTR ((void*)(intptr)1)
934 typedef unsigned long long my_off_t;
935 typedef unsigned long long os_off_t;
937 typedef off_t os_off_t;
939 typedef ulonglong my_off_t;
941 typedef unsigned long my_off_t;
944 #define MY_FILEPOS_ERROR (~(my_off_t) 0)
949 typedef ulonglong table_map;
950 typedef ulonglong nesting_map;
953 #define socket_errno WSAGetLastError()
954 #define SOCKET_EINTR WSAEINTR
955 #define SOCKET_EAGAIN WSAEINPROGRESS
956 #define SOCKET_EWOULDBLOCK WSAEWOULDBLOCK
957 #define SOCKET_EADDRINUSE WSAEADDRINUSE
958 #define SOCKET_ETIMEDOUT WSAETIMEDOUT
959 #define SOCKET_ECONNRESET WSAECONNRESET
960 #define SOCKET_ENFILE ENFILE
961 #define SOCKET_EMFILE EMFILE
963 #define socket_errno errno
964 #define closesocket(A) close(A)
965 #define SOCKET_EINTR EINTR
966 #define SOCKET_EAGAIN EAGAIN
967 #define SOCKET_EWOULDBLOCK EWOULDBLOCK
968 #define SOCKET_EADDRINUSE EADDRINUSE
969 #define SOCKET_ETIMEDOUT ETIMEDOUT
970 #define SOCKET_ECONNRESET ECONNRESET
971 #define SOCKET_ENFILE ENFILE
972 #define SOCKET_EMFILE EMFILE
976 typedef char my_bool;
979 #define MYF(v) (myf) (v)
982 #ifdef HAVE_LONG_LONG
983 #define LL(A) A ## LL
990 #ifdef HAVE_LONG_LONG
991 #define ULL(A) A ## ULL
993 #define ULL(A) A ## UL
1002 #define reg1 register
1003 #define reg2 register
1004 #define reg3 register
1005 #define reg4 register
1006 #define reg5 register
1007 #define reg6 register
1008 #define reg7 register
1009 #define reg8 register
1010 #define reg9 register
1011 #define reg10 register
1012 #define reg11 register
1013 #define reg12 register
1014 #define reg13 register
1015 #define reg14 register
1016 #define reg15 register
1017 #define reg16 register
1021 #define YESNO(X) ((X) ? "yes" : "no")
1023 #define MY_HOW_OFTEN_TO_ALARM 2
1024 #define MY_HOW_OFTEN_TO_WRITE 1000
1026 #include <my_byteorder.h>
1028 #ifdef HAVE_CHARSET_utf8
1029 #define MYSQL_UNIVERSAL_CLIENT_CHARSET "utf8"
1031 #define MYSQL_UNIVERSAL_CLIENT_CHARSET MYSQL_DEFAULT_CHARSET_NAME
1034 #if defined(EMBEDDED_LIBRARY) && !defined(HAVE_EMBEDDED_PRIVILEGE_CONTROL)
1035 #define NO_EMBEDDED_ACCESS_CHECKS
1039 #define dlsym(lib, name) (void*)GetProcAddress((HMODULE)lib, name)
1040 #define dlopen(libname, unused) LoadLibraryEx(libname, NULL, 0)
1041 #define dlclose(lib) FreeLibrary((HMODULE)lib)
1048 #if defined(HAVE_DLFCN_H)
1053 #ifndef HAVE_DLERROR
1055 #define DLERROR_GENERATE(errmsg, error_number) \
1056 char win_errormsg[2048]; \
1057 if(FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, \
1058 0, error_number, 0, win_errormsg, 2048, NULL)) \
1061 for (ptr= &win_errormsg[0] + strlen(win_errormsg) - 1; \
1062 ptr >= &win_errormsg[0] && strchr("\r\n\t\0x20", *ptr); \
1065 errmsg= win_errormsg; \
1069 #define dlerror() ""
1070 #define dlopen_errno GetLastError()
1072 #define dlerror() "No support for dynamic loading (static build?)"
1073 #define DLERROR_GENERATE(errmsg, error_number) errmsg= dlerror()
1074 #define dlopen_errno errno
1077 #define DLERROR_GENERATE(errmsg, error_number) errmsg= dlerror()
1078 #define dlopen_errno errno
1090 #define MY_INT32_NUM_DECIMAL_DIGITS 11U
1093 #define MY_INT64_NUM_DECIMAL_DIGITS 21U
1096 #define MY_MAX(a, b) ((a) > (b) ? (a) : (b))
1097 #define MY_MIN(a, b) ((a) < (b) ? (a) : (b))
1103 #ifdef TARGET_OS_LINUX
1104 #define NEED_EXPLICIT_SYNC_DIR 1
1113 #define WT_RWLOCKS_USE_MUTEXES 1
1116 #if !defined(__cplusplus) && !defined(bool)
1117 #define bool In_C_you_should_use_my_bool_instead()
1121 #if __STDC_VERSION__ < 199901L
1123 # define __func__ __FUNCTION__
1125 # define __func__ "<unknown>"
1127 #elif defined(_MSC_VER)
1128 # if _MSC_VER < 1300
1129 # define __func__ "<unknown>"
1131 # define __func__ __FUNCTION__
1133 #elif defined(__BORLANDC__)
1134 # define __func__ __FUNC__
1136 # define __func__ "<unknown>"
1144 #define MAX_EXACT_INTEGER ((1LL << DBL_MANT_DIG) - 1)
1154 static inline double rint(
double x)
1163 i += (double) ((f > 0.5) || (f == 0.5 &&
1164 i <= (double) MAX_EXACT_INTEGER &&
1167 i -= (double) ((f < -0.5) || (f == -0.5 &&
1168 i >= (double) -MAX_EXACT_INTEGER &&
1179 #ifndef MYSQL_PLUGIN_IMPORT
1180 #if (defined(_WIN32) && defined(MYSQL_DYNAMIC_PLUGIN))
1181 #define MYSQL_PLUGIN_IMPORT __declspec(dllimport)
1183 #define MYSQL_PLUGIN_IMPORT
1187 #include <my_dbug.h>
1191 #ifdef EMBEDDED_LIBRARY
1205 INFORMATION_LEVEL= 2
1213 #if defined(_MSC_VER) && (_MSC_VER < 1600)
1221 #endif // MY_GLOBAL_INCLUDED