1
/* Copyright (C) 2000-2003 MySQL AB
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.
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.
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 */
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16
20
/* This is the include file that should be included 'first' in every C file. */
18
22
#ifndef DRIZZLE_SERVER_GLOBAL_H
19
23
#define DRIZZLE_SERVER_GLOBAL_H
21
#define HAVE_REPLICATION
22
#define HAVE_EXTERNAL_CLIENT
25
InnoDB depends on some MySQL internals which other plugins should not
26
need. This is because of InnoDB's foreign key support, "safe" binlog
27
truncation, and other similar legacy features.
29
We define accessors for these internals unconditionally, but do not
30
expose them in mysql/plugin.h. They are declared in ha_innodb.h for
33
#define INNODB_COMPATIBILITY_HOOKS
35
/* to make command line shorter we'll define USE_PRAGMA_INTERFACE here */
36
#ifdef USE_PRAGMA_IMPLEMENTATION
37
#define USE_PRAGMA_INTERFACE
40
25
#if defined(i386) && !defined(__i386__)
44
/* Macros to make switching between C and C++ mode easier */
46
#define C_MODE_START extern "C" {
29
#if defined(__sun) && defined(_FILE_OFFSET_BITS)
30
#undef _FILE_OFFSET_BITS
35
#if defined(__cplusplus)
45
# if defined(HAVE_MEMORY)
48
# if defined(HAVE_TR1_MEMORY)
49
# include <tr1/memory>
51
# if defined(HAVE_BOOST_SHARED_PTR_HPP)
52
# include <boost/shared_ptr.hpp>
56
# include <inttypes.h>
60
# include <errno.h> /* Recommended by debian */
56
The macros below are borrowed from include/linux/compiler.h in the
57
Linux kernel. Use them to indicate the likelyhood of the truthfulness
58
of a condition. This serves two purposes - newer versions of gcc will be
59
able to optimize for branch predication, which could yield siginficant
60
performance gains in frequently executed sections of the code, and the
61
other reason to use them is for documentation
62
A lot of our programs uses asserts, so better to always include it
64
#if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
65
#define __builtin_expect(x, expected_value) (x)
68
#define likely(x) __builtin_expect((x),1)
69
#define unlikely(x) __builtin_expect((x),0)
72
* Disable __attribute__ for non GNU compilers, since we're using them
73
* only to either generate or suppress warnings.
76
# if !defined(__GNUC__)
77
# define __attribute__(A)
82
/* Fix problem with S_ISLNK() on Linux */
83
#if defined(TARGET_OS_LINUX) || defined(__GLIBC__)
75
#if TIME_WITH_SYS_TIME
76
# include <sys/time.h>
80
# include <sys/time.h>
87
#if defined(__cplusplus)
88
# if !defined(SHARED_PTR_NAMESPACE)
89
# error SHARED_PTR_NAMESPACE not defined, configure error!
91
# if defined(SHARED_PTR_NAMESPACE)
92
//We aren't using this yet - don't actually put in code yet.
93
//using SHARED_PTR_NAMESPACE::shared_ptr;
95
#endif /* defined(SHARED_PTR_NAMESPACE) */
90
98
Temporary solution to solve bug#7156. Include "sys/types.h" before
94
102
#include <sys/types.h>
97
#define __EXTENSIONS__ 1 /* We want some extension */
99
#if defined(HAVE_STDINT_H)
100
/* Need to include this _before_ stdlib, so that all defines are right */
101
/* We are mixing C and C++, so we wan the C limit macros in the C++ too */
102
/* Enable some extra C99 extensions */
104
#define __STDC_FORMAT_MACROS
105
#include <inttypes.h>
107
We include the following because currently Google #$@#$ Protocol Buffers possibly break stdint defines.
108
Or I am wrong, very possible, and hope someone finds the solution.
110
Taken from /usr/include/stdint.h
113
/* 7.18.2 Limits of specified-width integer types:
114
* These #defines specify the minimum and maximum limits
115
* of each of the types declared above.
119
#if (!defined(INT16_MAX))
120
/* 7.18.2.1 Limits of exact-width integer types */
122
#define INT16_MAX 32767
123
#define INT32_MAX 2147483647
124
#define INT64_MAX 9223372036854775807LL
126
#define INT8_MIN -128
127
#define INT16_MIN -32768
130
Note: the literal "most negative int" cannot be written in C --
131
the rules in the standard (section 6.4.4.1 in C99) will give it
132
an unsigned type, so INT32_MIN (and the most negative member of
133
any larger signed type) must be written via a constant expression.
135
#define INT32_MIN (-INT32_MAX-1)
136
#define INT64_MIN (-INT64_MAX-1)
138
#define UINT8_MAX 255
139
#define UINT16_MAX 65535
140
#define UINT32_MAX 4294967295U
141
#define UINT64_MAX 18446744073709551615ULL
143
/* 7.18.2.2 Limits of minimum-width integer types */
144
#define INT_LEAST8_MIN INT8_MIN
145
#define INT_LEAST16_MIN INT16_MIN
146
#define INT_LEAST32_MIN INT32_MIN
147
#define INT_LEAST64_MIN INT64_MIN
149
#define INT_LEAST8_MAX INT8_MAX
150
#define INT_LEAST16_MAX INT16_MAX
151
#define INT_LEAST32_MAX INT32_MAX
152
#define INT_LEAST64_MAX INT64_MAX
154
#define UINT_LEAST8_MAX UINT8_MAX
155
#define UINT_LEAST16_MAX UINT16_MAX
156
#define UINT_LEAST32_MAX UINT32_MAX
157
#define UINT_LEAST64_MAX UINT64_MAX
159
/* 7.18.2.3 Limits of fastest minimum-width integer types */
160
#define INT_FAST8_MIN INT8_MIN
161
#define INT_FAST16_MIN INT16_MIN
162
#define INT_FAST32_MIN INT32_MIN
163
#define INT_FAST64_MIN INT64_MIN
165
#define INT_FAST8_MAX INT8_MAX
166
#define INT_FAST16_MAX INT16_MAX
167
#define INT_FAST32_MAX INT32_MAX
168
#define INT_FAST64_MAX INT64_MAX
170
#define UINT_FAST8_MAX UINT8_MAX
171
#define UINT_FAST16_MAX UINT16_MAX
172
#define UINT_FAST32_MAX UINT32_MAX
173
#define UINT_FAST64_MAX UINT64_MAX
175
/* 7.18.2.4 Limits of integer types capable of holding object pointers */
178
#define INTPTR_MIN INT64_MIN
179
#define INTPTR_MAX INT64_MAX
181
#define INTPTR_MIN INT32_MIN
182
#define INTPTR_MAX INT32_MAX
186
#define UINTPTR_MAX UINT64_MAX
188
#define UINTPTR_MAX UINT32_MAX
191
/* 7.18.2.5 Limits of greatest-width integer types */
192
#define INTMAX_MIN INT64_MIN
193
#define INTMAX_MAX INT64_MAX
195
#define UINTMAX_MAX UINT64_MAX
199
#define PTRDIFF_MIN INT64_MIN
200
#define PTRDIFF_MAX INT64_MAX
202
#define PTRDIFF_MIN INT32_MIN
203
#define PTRDIFF_MAX INT32_MAX
206
/* We have no sig_atomic_t yet, so no SIG_ATOMIC_{MIN,MAX}.
207
Should end up being {-127,127} or {0,255} ... or bigger.
208
My bet would be on one of {U}INT32_{MIN,MAX}. */
211
#define SIZE_MAX UINT64_MAX
213
#define SIZE_MAX UINT32_MAX
217
# ifdef __WCHAR_MAX__
218
# define WCHAR_MAX __WCHAR_MAX__
220
# define WCHAR_MAX 0x7fffffff
224
/* WCHAR_MIN should be 0 if wchar_t is an unsigned type and
225
(-WCHAR_MAX-1) if wchar_t is a signed type. Unfortunately,
226
it turns out that -fshort-wchar changes the signedness of
229
# if WCHAR_MAX == 0xffff
232
# define WCHAR_MIN (-WCHAR_MAX-1)
236
#define WINT_MIN INT32_MIN
237
#define WINT_MAX INT32_MAX
239
#define SIG_ATOMIC_MIN INT32_MIN
240
#define SIG_ATOMIC_MAX INT32_MAX
244
#error "You must have inttypes!"
249
Solaris 9 include file <sys/feature_tests.h> refers to X/Open document
251
System Interfaces and Headers, Issue 5
253
saying we should define _XOPEN_SOURCE=500 to get POSIX.1c prototypes,
254
but apparently other systems (namely FreeBSD) don't agree.
256
On a newer Solaris 10, the above file recognizes also _XOPEN_SOURCE=600.
257
Furthermore, it tests that if a program requires older standard
258
(_XOPEN_SOURCE<600 or _POSIX_C_SOURCE<200112L) it cannot be
259
run on a new compiler (that defines _STDC_C99) and issues an #error.
260
It's also an #error if a program requires new standard (_XOPEN_SOURCE=600
261
or _POSIX_C_SOURCE=200112L) and a compiler does not define _STDC_C99.
263
To add more to this mess, Sun Studio C compiler defines _STDC_C99 while
264
C++ compiler does not!
266
So, in a desperate attempt to get correct prototypes for both
267
C and C++ code, we define either _XOPEN_SOURCE=600 or _XOPEN_SOURCE=500
268
depending on the compiler's announced C standard support.
270
Cleaner solutions are welcome.
273
#if __STDC_VERSION__ - 0 >= 199901L
274
#define _XOPEN_SOURCE 600
276
#define _XOPEN_SOURCE 500
280
#ifndef _POSIX_PTHREAD_SEMANTICS
281
#define _POSIX_PTHREAD_SEMANTICS /* We want posix threads */
284
#define _REENTRANT 1 /* Some thread libraries require this */
286
#include <pthread.h> /* AIX must have this included first */
288
#define _REENTRANT 1 /* Threads requires reentrant code */
291
/* gcc/egcs issues */
293
#if defined(__GNUC) && defined(__EXCEPTIONS)
294
#error "Please add -fno-exceptions to CXXFLAGS and reconfigure/recompile"
106
#include <pthread.h> /* AIX must have this included first */
108
#define _REENTRANT 1 /* Threads requires reentrant code */
308
110
#ifdef HAVE_LIMITS_H
309
111
#include <limits.h>
315
117
#ifdef HAVE_FCNTL_H
316
118
#include <fcntl.h>
318
#ifdef HAVE_SYS_TIMEB_H
319
#include <sys/timeb.h> /* Avoid warnings on SCO */
321
#if TIME_WITH_SYS_TIME
322
# include <sys/time.h>
326
# include <sys/time.h>
330
#endif /* TIME_WITH_SYS_TIME */
331
121
#ifdef HAVE_UNISTD_H
332
122
#include <unistd.h>
334
#if defined(__cplusplus) && defined(NO_CPLUSPLUS_ALLOCA)
342
#include <errno.h> /* Recommended by debian */
344
#if defined(HAVE_STDBOOL_H)
348
126
#ifdef HAVE_SYS_STAT_H
349
127
# include <sys/stat.h>
353
A lot of our programs uses asserts, so better to always include it
357
/* an assert that works at compile-time. only for constant expression */
359
#define compile_time_assert(X) do { } while(0)
361
#define compile_time_assert(X) \
364
char compile_time_assert[(X) ? 1 : -1] \
365
__attribute__ ((unused)); \
369
/* Declare madvise where it is not declared for C++, like Solaris */
370
#if HAVE_MADVISE && !defined(HAVE_DECL_MADVISE) && defined(__cplusplus)
371
extern "C" int madvise(void *addr, size_t len, int behav);
374
/* We can not live without the following defines */
376
#define USE_MYFUNC 1 /* Must use syscall indirection */
377
#define MASTER 1 /* Compile without unireg */
378
#define ENGLISH 1 /* Messages in English */
379
#define POSIX_MISTAKE 1 /* regexp: Fix stupid spec error */
381
#define QUOTE_ARG(x) #x /* Quote argument (before cpp) */
382
#define STRINGIFY_ARG(x) QUOTE_ARG(x) /* Quote argument, after cpp */
383
/* Does the system remember a signal handler after a signal ? */
384
#ifndef HAVE_BSD_SIGNALS
385
#define DONT_REMEMBER_SIGNAL
388
/* Define void to stop lint from generating "null effekt" comments */
389
#ifndef DONT_DEFINE_VOID
392
#define VOID(X) (__void__ = (int) (X))
397
#endif /* DONT_DEFINE_VOID */
399
#if !defined(HAVE_UINT)
402
typedef unsigned int uint;
403
typedef unsigned short ushort;
406
130
/* Declared in int2str() */
407
131
extern char _dig_vec_upper[];
408
132
extern char _dig_vec_lower[];
410
#define CMP_NUM(a,b) (((a) < (b)) ? -1 : ((a) == (b)) ? 0 : 1)
411
#define sgn(a) (((a) < 0) ? -1 : ((a) > 0) ? 1 : 0)
412
#define swap_variables(t, a, b) { register t dummy; dummy= a; a= b; b= dummy; }
413
#define test(a) ((a) ? 1 : 0)
135
template <class T> void set_if_bigger(T &a, const T &b)
141
template <class T> void set_if_smaller(T &a, const T &b)
148
#define set_if_bigger(a,b) do { \
149
const typeof(a) _a = (a); \
150
const typeof(b) _b = (b); \
151
(void) (&_a == &_b); \
152
if ((a) < (b)) (a)=(b); \
154
#define set_if_smaller(a,b) do { \
155
const typeof(a) _a = (a); \
156
const typeof(b) _b = (b); \
157
(void) (&_a == &_b); \
158
if ((a) > (b)) (a)=(b); \
414
162
#define set_if_bigger(a,b) do { if ((a) < (b)) (a)=(b); } while(0)
415
163
#define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0)
416
#define test_all_bits(a,b) (((a) & (b)) == (b))
417
#define set_bits(type, bit_count) (sizeof(type)*8 <= (bit_count) ? ~(type) 0 : ((((type) 1) << (bit_count)) - (type) 1))
418
#define array_elements(A) ((uint32_t) (sizeof(A)/sizeof(A[0])))
420
#define rint(A) floor((A)+(((A) < 0)? -0.5 : 0.5))
423
#if defined(__GNUC__)
424
#define function_volatile volatile
425
#define my_reinterpret_cast(A) reinterpret_cast<A>
426
#define my_const_cast(A) const_cast<A>
428
# define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
430
#elif !defined(my_reinterpret_cast)
431
#define my_reinterpret_cast(A) (A)
432
#define my_const_cast(A) (A)
435
/* From old s-system.h */
438
Support macros for non ansi & other old compilers. Since such
439
things are no longer supported we do nothing. We keep then since
440
some of our code may still be needed to upgrade old customers.
442
#define _VARARGS(X) X
443
#define _STATIC_VARARGS(X) X
446
#define MIN_ARRAY_SIZE 0 /* Zero or One. Gcc allows zero*/
447
#define ASCII_BITS_USED 8 /* Bit char used */
167
#define array_elements(A) ((size_t) (sizeof(A)/sizeof(A[0])))
449
169
/* Some types that is different between systems */
451
typedef int File; /* File descriptor */
452
/* Type for fuctions that handles signals */
453
#define sig_handler RETSIGTYPE
455
typedef void (*sig_return)(void);/* Returns type from signal */
456
typedef int (*qsort_cmp)(const void *,const void *);
457
typedef int (*qsort_cmp2)(void*, const void *,const void *);
459
#define qsort_t RETQSORTTYPE /* Broken GCC cant handle typedef !!!! */
171
typedef int File; /* File descriptor */
460
173
#ifdef HAVE_SYS_SOCKET_H
461
174
#include <sys/socket.h>
463
typedef SOCKET_SIZE_TYPE size_socket;
465
#ifndef SOCKOPT_OPTLEN_TYPE
466
#define SOCKOPT_OPTLEN_TYPE size_socket
469
/* file create flags */
471
#ifndef O_SHARE /* Probably not windows */
472
#define O_SHARE 0 /* Flag to my_open for shared files */
476
#define O_BINARY 0 /* Flag to my_open for binary files */
480
#define FILE_BINARY O_BINARY /* Flag to my_fopen for binary streams */
483
#define F_TO_EOF 0L /* Param to lockf() to lock rest of file */
486
#define O_TEMPORARY 0
488
#ifndef O_SHORT_LIVED
489
#define O_SHORT_LIVED 0
495
/* #define USE_RECORD_LOCK */
497
/* Unsigned types supported by the compiler */
498
#define UNSINT8 /* unsigned int8_t (char) */
499
#define UNSINT16 /* unsigned int16_t */
500
#define UNSINT32 /* unsigned int32_t */
502
/* General constants */
503
#define SC_MAXWIDTH 256 /* Max width of screen (for error messages) */
504
#define FN_LEN 256 /* Max file name len */
505
#define FN_HEADLEN 253 /* Max length of filepart of file name */
506
#define FN_EXTLEN 20 /* Max length of extension (part of FN_LEN) */
507
#define FN_REFLEN 512 /* Max length of full path-name */
508
#define FN_EXTCHAR '.'
509
#define FN_HOMELIB '~' /* ~/ is used as abbrev for home dir */
510
#define FN_CURLIB '.' /* ./ is used as abbrev for current dir */
511
#define FN_PARENTDIR ".." /* Parent directory; Must be a string */
513
178
#ifndef FN_LIBCHAR
514
#define FN_LIBCHAR '/'
515
#define FN_ROOTDIR "/"
179
#define FN_LIBCHAR '/'
180
#define FN_ROOTDIR "/"
517
#define MY_NFILE 64 /* This is only used to save filenames */
182
#define MY_NFILE 64 /* This is only used to save filenames */
518
183
#ifndef OS_FILE_LIMIT
519
#define OS_FILE_LIMIT 65535
184
#define OS_FILE_LIMIT 65535
522
/* #define EXT_IN_LIBNAME */
523
/* #define FN_NO_CASE_SENCE */
524
/* #define FN_UPPER_CASE TRUE */
527
Io buffer size; Must be a power of 2 and a multiple of 512. May be
528
smaller what the disk page size. This influences the speed of the
529
isam btree library. eg to big to slow.
533
188
How much overhead does malloc have. The code often allocates
534
189
something like 1024-MALLOC_OVERHEAD bytes
536
191
#define MALLOC_OVERHEAD 8
538
/* get memory in huncs */
539
#define ONCE_ALLOC_INIT (uint) (4096-MALLOC_OVERHEAD)
540
/* Typical record cash */
541
#define RECORD_CACHE_SIZE (uint) (64*1024-MALLOC_OVERHEAD)
542
/* Typical key cash */
543
#define KEY_CACHE_SIZE (uint) (8*1024*1024-MALLOC_OVERHEAD)
544
/* Default size of a key cache block */
545
#define KEY_CACHE_BLOCK_SIZE (uint) 1024
548
/* Some things that this system doesn't have */
193
/* get memory in huncs */
194
static const uint32_t ONCE_ALLOC_INIT= 4096;
195
/* Typical record cash */
196
static const uint32_t RECORD_CACHE_SIZE= 64*1024;
197
/* Typical key cash */
198
static const uint32_t KEY_CACHE_SIZE= 8*1024*1024;
200
/* Default size of a key cache block */
201
static const uint32_t KEY_CACHE_BLOCK_SIZE= 1024;
204
/* Some things that this system doesn't have */
550
206
/* Some defines of functions for portability */
552
#undef remove /* Crashes MySQL on SCO 5.0.0 */
208
#undef remove /* Crashes MySQL on SCO 5.0.0 */
553
209
#ifndef uint64_t2double
554
210
#define uint64_t2double(A) ((double) (uint64_t) (A))
555
211
#define my_off_t2double(A) ((double) (my_off_t) (A))
625
258
Max size that must be added to a so that we know Size to make
628
#if SIZEOF_CHARP == 4
629
typedef int32_t my_ptrdiff_t;
631
typedef int64_t my_ptrdiff_t;
261
typedef ptrdiff_t my_ptrdiff_t;
634
#define MY_ALIGN(A,L) (((A) + (L) - 1) & ~((L) - 1))
635
#define ALIGN_SIZE(A) MY_ALIGN((A),sizeof(double))
263
#define MY_ALIGN(A,L) (((A) + (L) - 1) & ~((L) - 1))
264
#define ALIGN_SIZE(A) MY_ALIGN((A),sizeof(double))
636
265
/* Size to make adressable obj. */
637
266
#define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A),sizeof(t)))
638
/* Offset of field f in structure t */
639
#define OFFSET(t, f) ((size_t)(char *)&((t *)0)->f)
640
#define ADD_TO_PTR(ptr,size,type) (type) ((uchar*) (ptr)+size)
641
#define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((uchar*) (A) - (uchar*) (B))
267
/* Offset of field f in structure t */
268
#define OFFSET(t, f) ((size_t)(char *)&((t *)0)->f)
269
#define ADD_TO_PTR(ptr,size,type) (type) ((unsigned char*) (ptr)+size)
270
#define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((unsigned char*) (A) - (unsigned char*) (B))
643
272
#define MY_DIV_UP(A, B) (((A) + (B) - 1) / (B))
644
273
#define MY_ALIGNED_BYTE_ARRAY(N, S, T) T N[MY_DIV_UP(S, sizeof(T))]
647
Custom version of standard offsetof() macro which can be used to get
648
offsets of members in class for non-POD types (according to the current
649
version of C++ standard offsetof() macro can't be used in such cases and
650
attempt to do so causes warnings to be emitted, OTOH in many cases it is
651
still OK to assume that all instances of the class has the same offsets
652
for the same members).
654
This is temporary solution which should be removed once File_parser class
655
and related routines are refactored.
658
#define my_offsetof(TYPE, MEMBER) \
659
((size_t)((char *)&(((TYPE *)0x10)->MEMBER) - (char*)0x10))
661
#define NullS (char *) 0
663
275
/* Typdefs for easyier portability */
666
typedef unsigned char uchar; /* Short for unsigned char */
669
277
#if !defined(HAVE_ULONG) && !defined(__USE_MISC)
670
typedef unsigned long ulong; /* Short for unsigned long */
278
typedef unsigned long ulong; /* Short for unsigned long */
673
#define MY_ERRPTR ((void*)(intptr)1)
676
281
typedef uint64_t my_off_t;
678
typedef unsigned long my_off_t;
680
#define MY_FILEPOS_ERROR (~(my_off_t) 0)
682
typedef off_t os_off_t;
684
#define socket_errno errno
685
#define SOCKET_EINTR EINTR
686
#define SOCKET_EAGAIN EAGAIN
687
#define SOCKET_ETIMEDOUT SOCKET_EINTR
688
#define SOCKET_EWOULDBLOCK EWOULDBLOCK
689
#define SOCKET_EADDRINUSE EADDRINUSE
690
#define SOCKET_ENFILE ENFILE
691
#define SOCKET_EMFILE EMFILE
693
typedef uint8_t int7; /* Most effective integer 0 <= x <= 127 */
694
typedef short int15; /* Most effective integer 0 <= x <= 32767 */
695
typedef int myf; /* Type of MyFlags in my_funcs */
696
#if !defined(bool) && (!defined(HAVE_BOOL) || !defined(__cplusplus))
697
typedef char bool; /* Ordinary boolean values 0 1 */
283
#if defined(SIZEOF_OFF_T)
284
# if (SIZEOF_OFF_T == 8)
285
# define OFF_T_MAX (INT64_MAX)
287
# define OFF_T_MAX (INT32_MAX)
699
/* Macros for converting *constants* to the right type */
700
#define INT8(v) (int8_t) (v)
701
#define INT16(v) (int16_t) (v)
702
#define INT32(v) (int32_t) (v)
703
#define MYF(v) (myf) (v)
291
#define MY_FILEPOS_ERROR -1
705
293
/* Defines for time function */
706
#define SCALE_SEC 100
707
#define SCALE_USEC 10000
708
#define MY_HOW_OFTEN_TO_ALARM 2 /* How often we want info on screen */
709
#define MY_HOW_OFTEN_TO_WRITE 1000 /* How often we want info on screen */
714
Define-funktions for reading and storing in machine independent format
718
/* Optimized store functions for Intel x86 */
719
#if defined(__i386__)
720
#define sint2korr(A) (*((int16_t *) (A)))
721
#define sint3korr(A) ((int32_t) ((((uchar) (A)[2]) & 128) ? \
722
(((uint32_t) 255L << 24) | \
723
(((uint32_t) (uchar) (A)[2]) << 16) |\
724
(((uint32_t) (uchar) (A)[1]) << 8) | \
725
((uint32_t) (uchar) (A)[0])) : \
726
(((uint32_t) (uchar) (A)[2]) << 16) |\
727
(((uint32_t) (uchar) (A)[1]) << 8) | \
728
((uint32_t) (uchar) (A)[0])))
729
#define sint4korr(A) (*((long *) (A)))
730
#define uint2korr(A) (*((uint16_t *) (A)))
731
#if defined(HAVE_purify)
732
#define uint3korr(A) (uint32_t) (((uint32_t) ((uchar) (A)[0])) +\
733
(((uint32_t) ((uchar) (A)[1])) << 8) +\
734
(((uint32_t) ((uchar) (A)[2])) << 16))
739
Please, note, uint3korr reads 4 bytes (not 3) !
740
It means, that you have to provide enough allocated space !
742
#define uint3korr(A) (long) (*((unsigned int *) (A)) & 0xFFFFFF)
743
#endif /* HAVE_purify */
744
#define uint4korr(A) (*((uint32_t *) (A)))
745
#define uint5korr(A) ((uint64_t)(((uint32_t) ((uchar) (A)[0])) +\
746
(((uint32_t) ((uchar) (A)[1])) << 8) +\
747
(((uint32_t) ((uchar) (A)[2])) << 16) +\
748
(((uint32_t) ((uchar) (A)[3])) << 24)) +\
749
(((uint64_t) ((uchar) (A)[4])) << 32))
750
#define uint6korr(A) ((uint64_t)(((uint32_t) ((uchar) (A)[0])) + \
751
(((uint32_t) ((uchar) (A)[1])) << 8) + \
752
(((uint32_t) ((uchar) (A)[2])) << 16) + \
753
(((uint32_t) ((uchar) (A)[3])) << 24)) + \
754
(((uint64_t) ((uchar) (A)[4])) << 32) + \
755
(((uint64_t) ((uchar) (A)[5])) << 40))
756
#define uint8korr(A) (*((uint64_t *) (A)))
757
#define sint8korr(A) (*((int64_t *) (A)))
758
#define int2store(T,A) *((uint16_t*) (T))= (uint16_t) (A)
759
#define int3store(T,A) do { *(T)= (uchar) ((A));\
760
*(T+1)=(uchar) (((uint) (A) >> 8));\
761
*(T+2)=(uchar) (((A) >> 16)); } while (0)
762
#define int4store(T,A) *((long *) (T))= (long) (A)
763
#define int5store(T,A) do { *(T)= (uchar)((A));\
764
*((T)+1)=(uchar) (((A) >> 8));\
765
*((T)+2)=(uchar) (((A) >> 16));\
766
*((T)+3)=(uchar) (((A) >> 24)); \
767
*((T)+4)=(uchar) (((A) >> 32)); } while(0)
768
#define int6store(T,A) do { *(T)= (uchar)((A)); \
769
*((T)+1)=(uchar) (((A) >> 8)); \
770
*((T)+2)=(uchar) (((A) >> 16)); \
771
*((T)+3)=(uchar) (((A) >> 24)); \
772
*((T)+4)=(uchar) (((A) >> 32)); \
773
*((T)+5)=(uchar) (((A) >> 40)); } while(0)
774
#define int8store(T,A) *((uint64_t *) (T))= (uint64_t) (A)
780
#define doubleget(V,M) \
781
do { doubleget_union _tmp; \
782
_tmp.m[0] = *((long*)(M)); \
783
_tmp.m[1] = *(((long*) (M))+1); \
784
(V) = _tmp.v; } while(0)
785
#define doublestore(T,V) do { *((long *) T) = ((doubleget_union *)&V)->m[0]; \
786
*(((long *) T)+1) = ((doubleget_union *)&V)->m[1]; \
788
#define float4get(V,M) do { *((float *) &(V)) = *((float*) (M)); } while(0)
789
#define float8get(V,M) doubleget((V),(M))
790
#define float4store(V,M) memcpy(V, (&M), sizeof(float))
791
#define floatstore(T,V) memcpy((T), (&V), sizeof(float))
792
#define floatget(V,M) memcpy(&V, (M), sizeof(float))
793
#define float8store(V,M) doublestore((V),(M))
797
We're here if it's not a IA-32 architecture (Win32 and UNIX IA-32 defines
800
#define sint2korr(A) (int16_t) (((int16_t) ((uchar) (A)[0])) +\
801
((int16_t) ((int16_t) (A)[1]) << 8))
802
#define sint3korr(A) ((int32_t) ((((uchar) (A)[2]) & 128) ? \
803
(((uint32_t) 255L << 24) | \
804
(((uint32_t) (uchar) (A)[2]) << 16) |\
805
(((uint32_t) (uchar) (A)[1]) << 8) | \
806
((uint32_t) (uchar) (A)[0])) : \
807
(((uint32_t) (uchar) (A)[2]) << 16) |\
808
(((uint32_t) (uchar) (A)[1]) << 8) | \
809
((uint32_t) (uchar) (A)[0])))
810
#define sint4korr(A) (int32_t) (((int32_t) ((uchar) (A)[0])) +\
811
(((int32_t) ((uchar) (A)[1]) << 8)) +\
812
(((int32_t) ((uchar) (A)[2]) << 16)) +\
813
(((int32_t) ((int16_t) (A)[3]) << 24)))
814
#define sint8korr(A) (int64_t) uint8korr(A)
815
#define uint2korr(A) (uint16_t) (((uint16_t) ((uchar) (A)[0])) +\
816
((uint16_t) ((uchar) (A)[1]) << 8))
817
#define uint3korr(A) (uint32_t) (((uint32_t) ((uchar) (A)[0])) +\
818
(((uint32_t) ((uchar) (A)[1])) << 8) +\
819
(((uint32_t) ((uchar) (A)[2])) << 16))
820
#define uint4korr(A) (uint32_t) (((uint32_t) ((uchar) (A)[0])) +\
821
(((uint32_t) ((uchar) (A)[1])) << 8) +\
822
(((uint32_t) ((uchar) (A)[2])) << 16) +\
823
(((uint32_t) ((uchar) (A)[3])) << 24))
824
#define uint5korr(A) ((uint64_t)(((uint32_t) ((uchar) (A)[0])) +\
825
(((uint32_t) ((uchar) (A)[1])) << 8) +\
826
(((uint32_t) ((uchar) (A)[2])) << 16) +\
827
(((uint32_t) ((uchar) (A)[3])) << 24)) +\
828
(((uint64_t) ((uchar) (A)[4])) << 32))
829
#define uint6korr(A) ((uint64_t)(((uint32_t) ((uchar) (A)[0])) + \
830
(((uint32_t) ((uchar) (A)[1])) << 8) + \
831
(((uint32_t) ((uchar) (A)[2])) << 16) + \
832
(((uint32_t) ((uchar) (A)[3])) << 24)) + \
833
(((uint64_t) ((uchar) (A)[4])) << 32) + \
834
(((uint64_t) ((uchar) (A)[5])) << 40))
835
#define uint8korr(A) ((uint64_t)(((uint32_t) ((uchar) (A)[0])) +\
836
(((uint32_t) ((uchar) (A)[1])) << 8) +\
837
(((uint32_t) ((uchar) (A)[2])) << 16) +\
838
(((uint32_t) ((uchar) (A)[3])) << 24)) +\
839
(((uint64_t) (((uint32_t) ((uchar) (A)[4])) +\
840
(((uint32_t) ((uchar) (A)[5])) << 8) +\
841
(((uint32_t) ((uchar) (A)[6])) << 16) +\
842
(((uint32_t) ((uchar) (A)[7])) << 24))) <<\
844
#define int2store(T,A) do { uint def_temp= (uint) (A) ;\
845
*((uchar*) (T))= (uchar)(def_temp); \
846
*((uchar*) (T)+1)=(uchar)((def_temp >> 8)); \
848
#define int3store(T,A) do { /*lint -save -e734 */\
849
*((uchar*)(T))=(uchar) ((A));\
850
*((uchar*) (T)+1)=(uchar) (((A) >> 8));\
851
*((uchar*)(T)+2)=(uchar) (((A) >> 16)); \
852
/*lint -restore */} while(0)
853
#define int4store(T,A) do { *((char *)(T))=(char) ((A));\
854
*(((char *)(T))+1)=(char) (((A) >> 8));\
855
*(((char *)(T))+2)=(char) (((A) >> 16));\
856
*(((char *)(T))+3)=(char) (((A) >> 24)); } while(0)
857
#define int5store(T,A) do { *((char *)(T))= (char)((A)); \
858
*(((char *)(T))+1)= (char)(((A) >> 8)); \
859
*(((char *)(T))+2)= (char)(((A) >> 16)); \
860
*(((char *)(T))+3)= (char)(((A) >> 24)); \
861
*(((char *)(T))+4)= (char)(((A) >> 32)); \
863
#define int6store(T,A) do { *((char *)(T))= (char)((A)); \
864
*(((char *)(T))+1)= (char)(((A) >> 8)); \
865
*(((char *)(T))+2)= (char)(((A) >> 16)); \
866
*(((char *)(T))+3)= (char)(((A) >> 24)); \
867
*(((char *)(T))+4)= (char)(((A) >> 32)); \
868
*(((char *)(T))+5)= (char)(((A) >> 40)); \
870
#define int8store(T,A) do { uint def_temp= (uint) (A), def_temp2= (uint) ((A) >> 32); \
871
int4store((T),def_temp); \
872
int4store((T+4),def_temp2); } while(0)
873
#ifdef WORDS_BIGENDIAN
874
#define float4store(T,A) do { *(T)= ((uchar *) &A)[3];\
875
*((T)+1)=(char) ((uchar *) &A)[2];\
876
*((T)+2)=(char) ((uchar *) &A)[1];\
877
*((T)+3)=(char) ((uchar *) &A)[0]; } while(0)
879
#define float4get(V,M) do { float def_temp;\
880
((uchar*) &def_temp)[0]=(M)[3];\
881
((uchar*) &def_temp)[1]=(M)[2];\
882
((uchar*) &def_temp)[2]=(M)[1];\
883
((uchar*) &def_temp)[3]=(M)[0];\
884
(V)=def_temp; } while(0)
885
#define float8store(T,V) do { *(T)= ((uchar *) &V)[7];\
886
*((T)+1)=(char) ((uchar *) &V)[6];\
887
*((T)+2)=(char) ((uchar *) &V)[5];\
888
*((T)+3)=(char) ((uchar *) &V)[4];\
889
*((T)+4)=(char) ((uchar *) &V)[3];\
890
*((T)+5)=(char) ((uchar *) &V)[2];\
891
*((T)+6)=(char) ((uchar *) &V)[1];\
892
*((T)+7)=(char) ((uchar *) &V)[0]; } while(0)
894
#define float8get(V,M) do { double def_temp;\
895
((uchar*) &def_temp)[0]=(M)[7];\
896
((uchar*) &def_temp)[1]=(M)[6];\
897
((uchar*) &def_temp)[2]=(M)[5];\
898
((uchar*) &def_temp)[3]=(M)[4];\
899
((uchar*) &def_temp)[4]=(M)[3];\
900
((uchar*) &def_temp)[5]=(M)[2];\
901
((uchar*) &def_temp)[6]=(M)[1];\
902
((uchar*) &def_temp)[7]=(M)[0];\
903
(V) = def_temp; } while(0)
905
#define float4get(V,M) memcpy(&V, (M), sizeof(float))
906
#define float4store(V,M) memcpy(V, (&M), sizeof(float))
908
#if defined(__FLOAT_WORD_ORDER) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN)
909
#define doublestore(T,V) do { *(((char*)T)+0)=(char) ((uchar *) &V)[4];\
910
*(((char*)T)+1)=(char) ((uchar *) &V)[5];\
911
*(((char*)T)+2)=(char) ((uchar *) &V)[6];\
912
*(((char*)T)+3)=(char) ((uchar *) &V)[7];\
913
*(((char*)T)+4)=(char) ((uchar *) &V)[0];\
914
*(((char*)T)+5)=(char) ((uchar *) &V)[1];\
915
*(((char*)T)+6)=(char) ((uchar *) &V)[2];\
916
*(((char*)T)+7)=(char) ((uchar *) &V)[3]; }\
918
#define doubleget(V,M) do { double def_temp;\
919
((uchar*) &def_temp)[0]=(M)[4];\
920
((uchar*) &def_temp)[1]=(M)[5];\
921
((uchar*) &def_temp)[2]=(M)[6];\
922
((uchar*) &def_temp)[3]=(M)[7];\
923
((uchar*) &def_temp)[4]=(M)[0];\
924
((uchar*) &def_temp)[5]=(M)[1];\
925
((uchar*) &def_temp)[6]=(M)[2];\
926
((uchar*) &def_temp)[7]=(M)[3];\
927
(V) = def_temp; } while(0)
928
#endif /* __FLOAT_WORD_ORDER */
930
#define float8get(V,M) doubleget((V),(M))
931
#define float8store(V,M) doublestore((V),(M))
932
#endif /* WORDS_BIGENDIAN */
934
#endif /* __i386__ */
937
Macro for reading 32-bit integer from network byte order (big-endian)
938
from unaligned memory location.
940
#define int4net(A) (int32_t) (((uint32_t) ((uchar) (A)[3])) |\
941
(((uint32_t) ((uchar) (A)[2])) << 8) |\
942
(((uint32_t) ((uchar) (A)[1])) << 16) |\
943
(((uint32_t) ((uchar) (A)[0])) << 24))
945
Define-funktions for reading and storing in machine format from/to
946
short/long to/from some place in memory V should be a (not
947
register) variable, M is a pointer to byte
950
#ifdef WORDS_BIGENDIAN
952
#define ushortget(V,M) do { V = (uint16_t) (((uint16_t) ((uchar) (M)[1]))+\
953
((uint16_t) ((uint16_t) (M)[0]) << 8)); } while(0)
954
#define shortget(V,M) do { V = (short) (((short) ((uchar) (M)[1]))+\
955
((short) ((short) (M)[0]) << 8)); } while(0)
956
#define longget(V,M) do { int32_t def_temp;\
957
((uchar*) &def_temp)[0]=(M)[0];\
958
((uchar*) &def_temp)[1]=(M)[1];\
959
((uchar*) &def_temp)[2]=(M)[2];\
960
((uchar*) &def_temp)[3]=(M)[3];\
961
(V)=def_temp; } while(0)
962
#define ulongget(V,M) do { uint32_t def_temp;\
963
((uchar*) &def_temp)[0]=(M)[0];\
964
((uchar*) &def_temp)[1]=(M)[1];\
965
((uchar*) &def_temp)[2]=(M)[2];\
966
((uchar*) &def_temp)[3]=(M)[3];\
967
(V)=def_temp; } while(0)
968
#define shortstore(T,A) do { uint def_temp=(uint) (A) ;\
969
*(((char*)T)+1)=(char)(def_temp); \
970
*(((char*)T)+0)=(char)(def_temp >> 8); } while(0)
971
#define longstore(T,A) do { *(((char*)T)+3)=((A));\
972
*(((char*)T)+2)=(((A) >> 8));\
973
*(((char*)T)+1)=(((A) >> 16));\
974
*(((char*)T)+0)=(((A) >> 24)); } while(0)
976
#define floatget(V,M) memcpy(&V, (M), sizeof(float))
977
#define floatstore(T, V) memcpy((T), (&V), sizeof(float))
978
#define doubleget(V, M) memcpy(&V, (M), sizeof(double))
979
#define doublestore(T, V) memcpy((T), &V, sizeof(double))
980
#define int64_tget(V, M) memcpy(&V, (M), sizeof(uint64_t))
981
#define int64_tstore(T, V) memcpy((T), &V, sizeof(uint64_t))
985
#define ushortget(V,M) do { V = uint2korr(M); } while(0)
986
#define shortget(V,M) do { V = sint2korr(M); } while(0)
987
#define longget(V,M) do { V = sint4korr(M); } while(0)
988
#define ulongget(V,M) do { V = uint4korr(M); } while(0)
989
#define shortstore(T,V) int2store(T,V)
990
#define longstore(T,V) int4store(T,V)
992
#define floatstore(T,V) memcpy((T), (&V), sizeof(float))
993
#define floatget(V,M) memcpy(&V, (M), sizeof(float))
996
#define doubleget(V, M) memcpy(&V, (M), sizeof(double))
997
#define doublestore(T,V) memcpy((T), &V, sizeof(double))
998
#endif /* doubleget */
999
#define int64_tget(V,M) memcpy(&V, (M), sizeof(uint64_t))
1000
#define int64_tstore(T,V) memcpy((T), &V, sizeof(uint64_t))
1002
#endif /* WORDS_BIGENDIAN */
1004
/* my_sprintf was here. RIP */
1006
#if defined(HAVE_CHARSET_utf8mb3) || defined(HAVE_CHARSET_utf8mb4)
1007
#define DRIZZLE_UNIVERSAL_CLIENT_CHARSET "utf8"
1009
#define DRIZZLE_UNIVERSAL_CLIENT_CHARSET DRIZZLE_DEFAULT_CHARSET_NAME
294
#define SCALE_SEC 100
295
#define SCALE_USEC 10000
296
#define MY_HOW_OFTEN_TO_ALARM 2 /* How often we want info on screen */
297
#define MY_HOW_OFTEN_TO_WRITE 1000 /* How often we want info on screen */
1012
300
#include <dlfcn.h>