~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
/* Copyright (C) 2000-2003 MySQL AB
2
3
   This program is free software; you can redistribute it and/or modify
4
   it under the terms of the GNU General Public License as published by
5
   the Free Software Foundation; version 2 of the License.
6
7
   This program is distributed in the hope that it will be useful,
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
   GNU General Public License for more details.
11
12
   You should have received a copy of the GNU General Public License
13
   along with this program; if not, write to the Free Software
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
16
/* This is the include file that should be included 'first' in every C file. */
17
18
#ifndef _global_h
19
#define _global_h
20
21
#define HAVE_REPLICATION
22
#define HAVE_EXTERNAL_CLIENT
23
24
/*
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.
28
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
31
  InnoDB's use.
32
*/
33
#define INNODB_COMPATIBILITY_HOOKS
34
35
/* to make command line shorter we'll define USE_PRAGMA_INTERFACE here */
36
#ifdef USE_PRAGMA_IMPLEMENTATION
37
#define USE_PRAGMA_INTERFACE
38
#endif
39
40
#if defined(i386) && !defined(__i386__)
41
#define __i386__
42
#endif
43
44
/* Macros to make switching between C and C++ mode easier */
45
#ifdef __cplusplus
46
#define C_MODE_START    extern "C" {
47
#define C_MODE_END	}
48
#else
49
#define C_MODE_START
50
#define C_MODE_END
51
#endif
52
77.1.17 by Monty Taylor
Removed the my_config.h copy of config.h nonsense. Not only stupid, but breaks
53
#include <config.h>
1 by brian
clean slate
54
#if defined(__cplusplus) && defined(inline)
55
#undef inline				/* fix configure problem */
56
#endif
57
58
/* Make it easier to add conditionl code for windows */
59
#define IF_WIN(A,B) (B)
60
61
/*
62
  The macros below are borrowed from include/linux/compiler.h in the
63
  Linux kernel. Use them to indicate the likelyhood of the truthfulness
64
  of a condition. This serves two purposes - newer versions of gcc will be
65
  able to optimize for branch predication, which could yield siginficant
66
  performance gains in frequently executed sections of the code, and the
67
  other reason to use them is for documentation
68
*/
69
70
#if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
71
#define __builtin_expect(x, expected_value) (x)
72
#endif
73
74
#define likely(x)	__builtin_expect((x),1)
75
#define unlikely(x)	__builtin_expect((x),0)
76
77
78
/*
79
  The macros below are useful in optimising places where it has been
80
  discovered that cache misses stall the process and where a prefetch
81
  of the cache line can improve matters. This is available in GCC 3.1.1
82
  and later versions.
83
  PREFETCH_READ says that addr is going to be used for reading and that
84
  it is to be kept in caches if possible for a while
85
  PREFETCH_WRITE also says that the item to be cached is likely to be
86
  updated.
87
  The *LOCALITY scripts are also available for experimentation purposes
88
  mostly and should only be used if they are verified to improve matters.
89
  For more input see GCC manual (available in GCC 3.1.1 and later)
90
*/
91
92
#if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR > 10)
93
#define PREFETCH_READ(addr) __builtin_prefetch(addr, 0, 3)
94
#define PREFETCH_WRITE(addr) \
95
  __builtin_prefetch(addr, 1, 3)
96
#define PREFETCH_READ_LOCALITY(addr, locality) \
97
  __builtin_prefetch(addr, 0, locality)
98
#define PREFETCH_WRITE_LOCALITY(addr, locality) \
99
  __builtin_prefetch(addr, 1, locality)
100
#else
101
#define PREFETCH_READ(addr)
102
#define PREFETCH_READ_LOCALITY(addr, locality)
103
#define PREFETCH_WRITE(addr)
104
#define PREFETCH_WRITE_LOCALITY(addr, locality)
105
#endif
106
107
/*
108
  now let's figure out if inline functions are supported
109
  autoconf defines 'inline' to be empty, if not
110
*/
53.2.2 by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic
111
#if defined(inline)
1 by brian
clean slate
112
#define HAVE_INLINE
113
#endif
114
/* helper macro for "instantiating" inline functions */
115
#define STATIC_INLINE static inline
116
117
/*
118
  The following macros are used to control inlining a bit more than
119
  usual. These macros are used to ensure that inlining always or
120
  never occurs (independent of compilation mode).
121
  For more input see GCC manual (available in GCC 3.1.1 and later)
122
*/
123
124
#if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR > 10)
125
#define ALWAYS_INLINE __attribute__ ((always_inline))
126
#define NEVER_INLINE __attribute__ ((noinline))
127
#else
128
#define ALWAYS_INLINE
129
#define NEVER_INLINE
130
#endif
131
132
133
/* Fix problem with S_ISLNK() on Linux */
134
#if defined(TARGET_OS_LINUX) || defined(__GLIBC__)
135
#undef  _GNU_SOURCE
136
#define _GNU_SOURCE 1
137
#endif
138
77.1.103 by Monty Taylor
Fixed some format strings to use PRIu64 for the uint64_t types.
139
1 by brian
clean slate
140
/*
141
  Temporary solution to solve bug#7156. Include "sys/types.h" before
142
  the thread headers, else the function madvise() will not be defined
143
*/
144
#if defined(HAVE_SYS_TYPES_H) && ( defined(sun) || defined(__sun) )
145
#include <sys/types.h>
146
#endif
147
148
#ifdef HAVE_THREADS_WITHOUT_SOCKETS
149
/* MIT pthreads does not work with unix sockets */
150
#undef HAVE_SYS_UN_H
151
#endif
152
153
#define __EXTENSIONS__ 1	/* We want some extension */
154
#ifndef __STDC_EXT__
155
#define __STDC_EXT__ 1          /* To get large file support on hpux */
156
#endif
157
158
/*
159
  Solaris 9 include file <sys/feature_tests.h> refers to X/Open document
160
161
    System Interfaces and Headers, Issue 5
162
163
  saying we should define _XOPEN_SOURCE=500 to get POSIX.1c prototypes,
164
  but apparently other systems (namely FreeBSD) don't agree.
165
166
  On a newer Solaris 10, the above file recognizes also _XOPEN_SOURCE=600.
167
  Furthermore, it tests that if a program requires older standard
168
  (_XOPEN_SOURCE<600 or _POSIX_C_SOURCE<200112L) it cannot be
169
  run on a new compiler (that defines _STDC_C99) and issues an #error.
170
  It's also an #error if a program requires new standard (_XOPEN_SOURCE=600
171
  or _POSIX_C_SOURCE=200112L) and a compiler does not define _STDC_C99.
172
173
  To add more to this mess, Sun Studio C compiler defines _STDC_C99 while
174
  C++ compiler does not!
175
176
  So, in a desperate attempt to get correct prototypes for both
177
  C and C++ code, we define either _XOPEN_SOURCE=600 or _XOPEN_SOURCE=500
178
  depending on the compiler's announced C standard support.
179
180
  Cleaner solutions are welcome.
181
*/
182
#ifdef __sun
183
#if __STDC_VERSION__ - 0 >= 199901L
184
#define _XOPEN_SOURCE 600
185
#else
186
#define _XOPEN_SOURCE 500
187
#endif
188
#endif
189
190
#ifndef _POSIX_PTHREAD_SEMANTICS
191
#define _POSIX_PTHREAD_SEMANTICS /* We want posix threads */
192
#endif
193
194
#define _REENTRANT	1	/* Some thread libraries require this */
195
196
#if !defined(_THREAD_SAFE) && !defined(_AIX)
197
#define _THREAD_SAFE            /* Required for OSF1 */
198
#endif
199
200
#include <pthread.h>		/* AIX must have this included first */
201
202
#define _REENTRANT	1	/* Threads requires reentrant code */
203
204
/* Go around some bugs in different OS and compilers */
205
206
#if defined(HAVE_BROKEN_INLINE) && !defined(__cplusplus)
207
#undef inline
208
#define inline
209
#endif
210
211
/* gcc/egcs issues */
212
213
#if defined(__GNUC) && defined(__EXCEPTIONS)
214
#error "Please add -fno-exceptions to CXXFLAGS and reconfigure/recompile"
215
#endif
216
217
#ifndef stdin
218
#include <stdio.h>
219
#endif
220
#ifdef HAVE_STDLIB_H
221
#include <stdlib.h>
222
#endif
223
#ifdef HAVE_STDDEF_H
224
#include <stddef.h>
225
#endif
226
227
#include <math.h>
228
#ifdef HAVE_LIMITS_H
229
#include <limits.h>
230
#endif
231
232
#ifdef HAVE_SYS_TYPES_H
233
#include <sys/types.h>
234
#endif
235
#ifdef HAVE_FCNTL_H
236
#include <fcntl.h>
237
#endif
238
#ifdef HAVE_SYS_TIMEB_H
239
#include <sys/timeb.h>				/* Avoid warnings on SCO */
240
#endif
241
#if TIME_WITH_SYS_TIME
242
# include <sys/time.h>
243
# include <time.h>
244
#else
245
# if HAVE_SYS_TIME_H
246
#  include <sys/time.h>
247
# else
248
#  include <time.h>
249
# endif
250
#endif /* TIME_WITH_SYS_TIME */
251
#ifdef HAVE_UNISTD_H
252
#include <unistd.h>
253
#endif
254
#if defined(__cplusplus) && defined(NO_CPLUSPLUS_ALLOCA)
255
#undef HAVE_ALLOCA
256
#undef HAVE_ALLOCA_H
257
#endif
258
#ifdef HAVE_ALLOCA_H
259
#include <alloca.h>
260
#endif
261
262
#include <errno.h>				/* Recommended by debian */
263
/* We need the following to go around a problem with openssl on solaris */
264
#if defined(HAVE_CRYPT_H)
265
#include <crypt.h>
266
#endif
267
53.2.2 by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic
268
#if defined(HAVE_STDINT_H)
53.2.31 by Monty Taylor
Removed HAVE_LONG_LONG, as this is now assumed.
269
/* We are mixing C and C++, so we wan the C limit macros in the C++ too */
77.1.103 by Monty Taylor
Fixed some format strings to use PRIu64 for the uint64_t types.
270
/* Enable some extra C99 extensions */
53.2.31 by Monty Taylor
Removed HAVE_LONG_LONG, as this is now assumed.
271
#define __STDC_LIMIT_MACROS
77.1.103 by Monty Taylor
Fixed some format strings to use PRIu64 for the uint64_t types.
272
#define __STDC_FORMAT_MACROS
273
#include <inttypes.h>
53.2.2 by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic
274
#include <stdint.h>
275
#endif
77.1.103 by Monty Taylor
Fixed some format strings to use PRIu64 for the uint64_t types.
276
53.2.2 by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic
277
#if defined(HAVE_STDBOOL_H)
278
#include <stdbool.h>
279
#endif
280
281
1 by brian
clean slate
282
/*
283
  A lot of our programs uses asserts, so better to always include it
284
*/
285
#include <assert.h>
286
287
/* an assert that works at compile-time. only for constant expression */
288
#ifndef __GNUC__
289
#define compile_time_assert(X)  do { } while(0)
290
#else
291
#define compile_time_assert(X)                                  \
292
  do                                                            \
293
  {                                                             \
294
    char compile_time_assert[(X) ? 1 : -1]                      \
295
                             __attribute__ ((unused));          \
296
  } while(0)
297
#endif
298
299
/* Declare madvise where it is not declared for C++, like Solaris */
53.2.2 by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic
300
#if HAVE_MADVISE && !defined(HAVE_DECL_MADVISE) && defined(__cplusplus)
1 by brian
clean slate
301
extern "C" int madvise(void *addr, size_t len, int behav);
302
#endif
303
304
/* We can not live without the following defines */
305
306
#define USE_MYFUNC 1		/* Must use syscall indirection */
307
#define MASTER 1		/* Compile without unireg */
308
#define ENGLISH 1		/* Messages in English */
309
#define POSIX_MISTAKE 1		/* regexp: Fix stupid spec error */
310
/* Do not define for ultra sparcs */
311
#define USE_BMOVE512 1		/* Use this unless system bmove is faster */
312
313
#define QUOTE_ARG(x)		#x	/* Quote argument (before cpp) */
314
#define STRINGIFY_ARG(x) QUOTE_ARG(x)	/* Quote argument, after cpp */
315
/* Does the system remember a signal handler after a signal ? */
316
#ifndef HAVE_BSD_SIGNALS
317
#define DONT_REMEMBER_SIGNAL
318
#endif
319
320
/* Define void to stop lint from generating "null effekt" comments */
321
#ifndef DONT_DEFINE_VOID
322
#ifdef _lint
323
int	__void__;
324
#define VOID(X)		(__void__ = (int) (X))
325
#else
326
#undef VOID
327
#define VOID(X)		(X)
328
#endif
329
#endif /* DONT_DEFINE_VOID */
330
331
#if !defined(HAVE_UINT)
332
#undef HAVE_UINT
333
#define HAVE_UINT
334
typedef unsigned int uint;
335
typedef unsigned short ushort;
336
#endif
337
338
#define CMP_NUM(a,b)    (((a) < (b)) ? -1 : ((a) == (b)) ? 0 : 1)
339
#define sgn(a)		(((a) < 0) ? -1 : ((a) > 0) ? 1 : 0)
340
#define swap_variables(t, a, b) { register t dummy; dummy= a; a= b; b= dummy; }
341
#define test(a)		((a) ? 1 : 0)
342
#define set_if_bigger(a,b)  do { if ((a) < (b)) (a)=(b); } while(0)
343
#define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0)
344
#define test_all_bits(a,b) (((a) & (b)) == (b))
345
#define set_bits(type, bit_count) (sizeof(type)*8 <= (bit_count) ? ~(type) 0 : ((((type) 1) << (bit_count)) - (type) 1))
53.2.32 by Monty Taylor
First large swath at getting handler stuff clean.
346
#define array_elements(A) ((uint32_t) (sizeof(A)/sizeof(A[0])))
1 by brian
clean slate
347
#ifndef HAVE_RINT
348
#define rint(A) floor((A)+(((A) < 0)? -0.5 : 0.5))
349
#endif
350
351
#if defined(__GNUC__)
352
#define function_volatile	volatile
353
#define my_reinterpret_cast(A) reinterpret_cast<A>
354
#define my_const_cast(A) const_cast<A>
355
# ifndef GCC_VERSION
356
#  define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
357
# endif
358
#elif !defined(my_reinterpret_cast)
359
#define my_reinterpret_cast(A) (A)
360
#define my_const_cast(A) (A)
361
#endif
362
363
#include <my_attribute.h>
364
365
/* From old s-system.h */
366
367
/*
368
  Support macros for non ansi & other old compilers. Since such
369
  things are no longer supported we do nothing. We keep then since
370
  some of our code may still be needed to upgrade old customers.
371
*/
372
#define _VARARGS(X) X
373
#define _STATIC_VARARGS(X) X
374
#define _PC(X)	X
375
376
#define MIN_ARRAY_SIZE	0	/* Zero or One. Gcc allows zero*/
377
#define ASCII_BITS_USED 8	/* Bit char used */
378
379
/* Some types that is different between systems */
380
381
typedef int	File;		/* File descriptor */
382
#ifndef Socket_defined
383
typedef int	my_socket;	/* File descriptor for sockets */
384
#define INVALID_SOCKET -1
385
#endif
386
/* Type for fuctions that handles signals */
387
#define sig_handler RETSIGTYPE
388
C_MODE_START
53.2.2 by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic
389
typedef void	(*sig_return)(void);/* Returns type from signal */
1 by brian
clean slate
390
typedef int	(*qsort_cmp)(const void *,const void *);
391
typedef int	(*qsort_cmp2)(void*, const void *,const void *);
392
C_MODE_END
393
#define qsort_t RETQSORTTYPE	/* Broken GCC cant handle typedef !!!! */
394
#ifdef HAVE_SYS_SOCKET_H
395
#include <sys/socket.h>
396
#endif
397
typedef SOCKET_SIZE_TYPE size_socket;
398
399
#ifndef SOCKOPT_OPTLEN_TYPE
400
#define SOCKOPT_OPTLEN_TYPE size_socket
401
#endif
402
403
/* file create flags */
404
405
#ifndef O_SHARE			/* Probably not windows */
406
#define O_SHARE		0	/* Flag to my_open for shared files */
77.1.24 by Monty Taylor
Removed non-fcntl code and made it a fatal configure error if it's not there.
407
#endif /* O_SHARE */
408
1 by brian
clean slate
409
#ifndef O_BINARY
410
#define O_BINARY	0	/* Flag to my_open for binary files */
411
#endif
77.1.24 by Monty Taylor
Removed non-fcntl code and made it a fatal configure error if it's not there.
412
1 by brian
clean slate
413
#ifndef FILE_BINARY
414
#define FILE_BINARY	O_BINARY /* Flag to my_fopen for binary streams */
415
#endif
77.1.24 by Monty Taylor
Removed non-fcntl code and made it a fatal configure error if it's not there.
416
1 by brian
clean slate
417
#define F_TO_EOF	0L	/* Param to lockf() to lock rest of file */
418
419
#ifndef O_TEMPORARY
420
#define O_TEMPORARY	0
421
#endif
422
#ifndef O_SHORT_LIVED
423
#define O_SHORT_LIVED	0
424
#endif
425
#ifndef O_NOFOLLOW
426
#define O_NOFOLLOW      0
427
#endif
428
429
/* #define USE_RECORD_LOCK	*/
430
431
	/* Unsigned types supported by the compiler */
432
#define UNSINT8			/* unsigned int8 (char) */
433
#define UNSINT16		/* unsigned int16 */
205 by Brian Aker
uint32 -> uin32_t
434
#define UNSINT32		/* unsigned int32_t */
1 by brian
clean slate
435
436
	/* General constants */
437
#define SC_MAXWIDTH	256	/* Max width of screen (for error messages) */
438
#define FN_LEN		256	/* Max file name len */
439
#define FN_HEADLEN	253	/* Max length of filepart of file name */
440
#define FN_EXTLEN	20	/* Max length of extension (part of FN_LEN) */
441
#define FN_REFLEN	512	/* Max length of full path-name */
442
#define FN_EXTCHAR	'.'
443
#define FN_HOMELIB	'~'	/* ~/ is used as abbrev for home dir */
444
#define FN_CURLIB	'.'	/* ./ is used as abbrev for current dir */
445
#define FN_PARENTDIR	".."	/* Parent directory; Must be a string */
446
447
#ifndef FN_LIBCHAR
448
#define FN_LIBCHAR	'/'
449
#define FN_ROOTDIR	"/"
450
#endif
451
#define MY_NFILE	64	/* This is only used to save filenames */
452
#ifndef OS_FILE_LIMIT
453
#define OS_FILE_LIMIT	65535
454
#endif
455
456
/* #define EXT_IN_LIBNAME     */
457
/* #define FN_NO_CASE_SENCE   */
458
/* #define FN_UPPER_CASE TRUE */
459
460
/*
461
  Io buffer size; Must be a power of 2 and a multiple of 512. May be
462
  smaller what the disk page size. This influences the speed of the
463
  isam btree library. eg to big to slow.
464
*/
465
#define IO_SIZE			4096
466
/*
467
  How much overhead does malloc have. The code often allocates
468
  something like 1024-MALLOC_OVERHEAD bytes
469
*/
470
#define MALLOC_OVERHEAD 8
471
472
	/* get memory in huncs */
473
#define ONCE_ALLOC_INIT		(uint) (4096-MALLOC_OVERHEAD)
474
	/* Typical record cash */
475
#define RECORD_CACHE_SIZE	(uint) (64*1024-MALLOC_OVERHEAD)
476
	/* Typical key cash */
477
#define KEY_CACHE_SIZE		(uint) (8*1024*1024-MALLOC_OVERHEAD)
478
	/* Default size of a key cache block  */
479
#define KEY_CACHE_BLOCK_SIZE	(uint) 1024
480
481
482
	/* Some things that this system doesn't have */
483
484
/* Some defines of functions for portability */
485
486
#undef remove		/* Crashes MySQL on SCO 5.0.0 */
487
#define closesocket(A)	close(A)
151 by Brian Aker
Ulonglong to uint64_t
488
#ifndef uint64_t2double
489
#define uint64_t2double(A) ((double) (uint64_t) (A))
1 by brian
clean slate
490
#define my_off_t2double(A)  ((double) (my_off_t) (A))
491
#endif
492
493
#ifndef offsetof
494
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
495
#endif
496
#define ulong_to_double(X) ((double) (ulong) (X))
497
#define SET_STACK_SIZE(X)	/* Not needed on real machines */
498
499
#ifndef STACK_DIRECTION
500
#error "please add -DSTACK_DIRECTION=1 or -1 to your CPPFLAGS"
501
#endif
502
503
#if !defined(HAVE_STRTOK_R)
504
#define strtok_r(A,B,C) strtok((A),(B))
505
#endif
506
77.1.24 by Monty Taylor
Removed non-fcntl code and made it a fatal configure error if it's not there.
507
#ifdef HAVE_FLOAT_H
508
#include <float.h>
509
#else
510
#if !defined(FLT_MIN)
511
#define FLT_MIN         ((float)1.40129846432481707e-45)
512
#endif
513
#if !defined(FLT_MAX)
514
#define FLT_MAX         ((float)3.40282346638528860e+38)
515
#endif
516
#endif
517
1 by brian
clean slate
518
/* From limits.h instead */
519
#ifndef DBL_MIN
520
#define DBL_MIN		4.94065645841246544e-324
521
#endif
522
#ifndef DBL_MAX
523
#define DBL_MAX		1.79769313486231470e+308
524
#endif
525
#ifndef SIZE_T_MAX
526
#define SIZE_T_MAX ~((size_t) 0)
527
#endif
528
529
#ifndef isfinite
530
#ifdef HAVE_FINITE
531
#define isfinite(x) finite(x)
532
#else
533
#define finite(x) (1.0 / fabs(x) > 0.0)
534
#endif /* HAVE_FINITE */
535
#endif /* isfinite */
536
537
#ifndef HAVE_ISNAN
538
#define isnan(x) ((x) != (x))
539
#endif
540
541
#ifdef HAVE_ISINF
542
/* isinf() can be used in both C and C++ code */
543
#define my_isinf(X) isinf(X)
544
#else
545
#define my_isinf(X) (!isfinite(X) && !isnan(X))
546
#endif
547
548
/* Define missing math constants. */
549
#ifndef M_PI
550
#define M_PI 3.14159265358979323846
551
#endif
552
#ifndef M_E
553
#define M_E 2.7182818284590452354
554
#endif
555
#ifndef M_LN2
556
#define M_LN2 0.69314718055994530942
557
#endif
558
559
/*
560
  Max size that must be added to a so that we know Size to make
561
  adressable obj.
562
*/
563
#if SIZEOF_CHARP == 4
53.2.2 by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic
564
typedef int32_t		my_ptrdiff_t;
1 by brian
clean slate
565
#else
53.2.2 by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic
566
typedef int64_t 	my_ptrdiff_t;
1 by brian
clean slate
567
#endif
568
569
#define MY_ALIGN(A,L)	(((A) + (L) - 1) & ~((L) - 1))
570
#define ALIGN_SIZE(A)	MY_ALIGN((A),sizeof(double))
571
/* Size to make adressable obj. */
572
#define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A),sizeof(t)))
573
			 /* Offset of field f in structure t */
574
#define OFFSET(t, f)	((size_t)(char *)&((t *)0)->f)
575
#define ADD_TO_PTR(ptr,size,type) (type) ((uchar*) (ptr)+size)
576
#define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((uchar*) (A) - (uchar*) (B))
577
578
#define MY_DIV_UP(A, B) (((A) + (B) - 1) / (B))
579
#define MY_ALIGNED_BYTE_ARRAY(N, S, T) T N[MY_DIV_UP(S, sizeof(T))]
580
581
/*
582
  Custom version of standard offsetof() macro which can be used to get
583
  offsets of members in class for non-POD types (according to the current
584
  version of C++ standard offsetof() macro can't be used in such cases and
585
  attempt to do so causes warnings to be emitted, OTOH in many cases it is
586
  still OK to assume that all instances of the class has the same offsets
587
  for the same members).
588
589
  This is temporary solution which should be removed once File_parser class
590
  and related routines are refactored.
591
*/
592
593
#define my_offsetof(TYPE, MEMBER) \
594
        ((size_t)((char *)&(((TYPE *)0x10)->MEMBER) - (char*)0x10))
595
596
#define NullS		(char *) 0
597
598
#define STDCALL
599
600
/* Typdefs for easyier portability */
601
602
#ifndef HAVE_UCHAR
603
typedef unsigned char	uchar;	/* Short for unsigned char */
604
#endif
605
606
#ifndef HAVE_INT8
607
typedef signed char int8;       /* Signed integer >= 8  bits */
608
#endif
205 by Brian Aker
uint32 -> uin32_t
609
1 by brian
clean slate
610
#ifndef HAVE_UINT8
611
typedef unsigned char uint8;    /* Unsigned integer >= 8  bits */
612
#endif
205 by Brian Aker
uint32 -> uin32_t
613
1 by brian
clean slate
614
#ifndef HAVE_INT16
615
typedef short int16;
616
#endif
205 by Brian Aker
uint32 -> uin32_t
617
1 by brian
clean slate
618
#ifndef HAVE_UINT16
619
typedef unsigned short uint16;
620
#endif
621
622
#if !defined(HAVE_ULONG) && !defined(__USE_MISC)
53.2.2 by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic
623
typedef uint32_t	ulong;		  /* Short for unsigned long */
1 by brian
clean slate
624
#endif
53.2.2 by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic
625
1 by brian
clean slate
626
#define MY_ERRPTR ((void*)(intptr)1)
627
77.1.103 by Monty Taylor
Fixed some format strings to use PRIu64 for the uint64_t types.
628
#if SIZEOF_OFF_T > 4 
151 by Brian Aker
Ulonglong to uint64_t
629
typedef uint64_t my_off_t;
1 by brian
clean slate
630
#else
631
typedef unsigned long my_off_t;
77.1.103 by Monty Taylor
Fixed some format strings to use PRIu64 for the uint64_t types.
632
#endif 
1 by brian
clean slate
633
#define MY_FILEPOS_ERROR	(~(my_off_t) 0)
634
635
typedef off_t os_off_t;
636
637
#define socket_errno	errno
638
#define closesocket(A)	close(A)
639
#define SOCKET_EINTR	EINTR
640
#define SOCKET_EAGAIN	EAGAIN
641
#define SOCKET_ETIMEDOUT SOCKET_EINTR
642
#define SOCKET_EWOULDBLOCK EWOULDBLOCK
643
#define SOCKET_EADDRINUSE EADDRINUSE
644
#define SOCKET_ENFILE	ENFILE
645
#define SOCKET_EMFILE	EMFILE
646
647
typedef uint8		int7;	/* Most effective integer 0 <= x <= 127 */
648
typedef short		int15;	/* Most effective integer 0 <= x <= 32767 */
649
typedef int		myf;	/* Type of MyFlags in my_funcs */
650
typedef char		my_bool; /* Small bool */
651
#if !defined(bool) && (!defined(HAVE_BOOL) || !defined(__cplusplus))
652
typedef char		bool;	/* Ordinary boolean values 0 1 */
653
#endif
654
	/* Macros for converting *constants* to the right type */
655
#define INT8(v)		(int8) (v)
656
#define INT16(v)	(int16) (v)
205 by Brian Aker
uint32 -> uin32_t
657
#define INT32(v)	(int32_t) (v)
1 by brian
clean slate
658
#define MYF(v)		(myf) (v)
659
660
/* Defines for time function */
661
#define SCALE_SEC	100
662
#define SCALE_USEC	10000
663
#define MY_HOW_OFTEN_TO_ALARM	2	/* How often we want info on screen */
664
#define MY_HOW_OFTEN_TO_WRITE	1000	/* How often we want info on screen */
665
666
667
668
/*
669
  Define-funktions for reading and storing in machine independent format
670
  (low byte first)
671
*/
672
673
/* Optimized store functions for Intel x86 */
674
#if defined(__i386__)
675
#define sint2korr(A)	(*((int16 *) (A)))
205 by Brian Aker
uint32 -> uin32_t
676
#define sint3korr(A)	((int32_t) ((((uchar) (A)[2]) & 128) ? \
677
				  (((uint32_t) 255L << 24) | \
678
				   (((uint32_t) (uchar) (A)[2]) << 16) |\
679
				   (((uint32_t) (uchar) (A)[1]) << 8) | \
680
				   ((uint32_t) (uchar) (A)[0])) : \
681
				  (((uint32_t) (uchar) (A)[2]) << 16) |\
682
				  (((uint32_t) (uchar) (A)[1]) << 8) | \
683
				  ((uint32_t) (uchar) (A)[0])))
1 by brian
clean slate
684
#define sint4korr(A)	(*((long *) (A)))
685
#define uint2korr(A)	(*((uint16 *) (A)))
686
#if defined(HAVE_purify)
205 by Brian Aker
uint32 -> uin32_t
687
#define uint3korr(A)	(uint32_t) (((uint32_t) ((uchar) (A)[0])) +\
688
				  (((uint32_t) ((uchar) (A)[1])) << 8) +\
689
				  (((uint32_t) ((uchar) (A)[2])) << 16))
1 by brian
clean slate
690
#else
691
/*
692
   ATTENTION !
693
   
694
    Please, note, uint3korr reads 4 bytes (not 3) !
695
    It means, that you have to provide enough allocated space !
696
*/
697
#define uint3korr(A)	(long) (*((unsigned int *) (A)) & 0xFFFFFF)
698
#endif /* HAVE_purify */
205 by Brian Aker
uint32 -> uin32_t
699
#define uint4korr(A)	(*((uint32_t *) (A)))
700
#define uint5korr(A)	((uint64_t)(((uint32_t) ((uchar) (A)[0])) +\
701
				    (((uint32_t) ((uchar) (A)[1])) << 8) +\
702
				    (((uint32_t) ((uchar) (A)[2])) << 16) +\
703
				    (((uint32_t) ((uchar) (A)[3])) << 24)) +\
151 by Brian Aker
Ulonglong to uint64_t
704
				    (((uint64_t) ((uchar) (A)[4])) << 32))
205 by Brian Aker
uint32 -> uin32_t
705
#define uint6korr(A)	((uint64_t)(((uint32_t)    ((uchar) (A)[0]))          + \
706
                                     (((uint32_t)    ((uchar) (A)[1])) << 8)   + \
707
                                     (((uint32_t)    ((uchar) (A)[2])) << 16)  + \
708
                                     (((uint32_t)    ((uchar) (A)[3])) << 24)) + \
151 by Brian Aker
Ulonglong to uint64_t
709
                         (((uint64_t) ((uchar) (A)[4])) << 32) +       \
710
                         (((uint64_t) ((uchar) (A)[5])) << 40))
711
#define uint8korr(A)	(*((uint64_t *) (A)))
152 by Brian Aker
longlong replacement
712
#define sint8korr(A)	(*((int64_t *) (A)))
1 by brian
clean slate
713
#define int2store(T,A)	*((uint16*) (T))= (uint16) (A)
714
#define int3store(T,A)  do { *(T)=  (uchar) ((A));\
715
                            *(T+1)=(uchar) (((uint) (A) >> 8));\
716
                            *(T+2)=(uchar) (((A) >> 16)); } while (0)
717
#define int4store(T,A)	*((long *) (T))= (long) (A)
718
#define int5store(T,A)  do { *(T)= (uchar)((A));\
719
                             *((T)+1)=(uchar) (((A) >> 8));\
720
                             *((T)+2)=(uchar) (((A) >> 16));\
721
                             *((T)+3)=(uchar) (((A) >> 24)); \
722
                             *((T)+4)=(uchar) (((A) >> 32)); } while(0)
723
#define int6store(T,A)  do { *(T)=    (uchar)((A));          \
724
                             *((T)+1)=(uchar) (((A) >> 8));  \
725
                             *((T)+2)=(uchar) (((A) >> 16)); \
726
                             *((T)+3)=(uchar) (((A) >> 24)); \
727
                             *((T)+4)=(uchar) (((A) >> 32)); \
728
                             *((T)+5)=(uchar) (((A) >> 40)); } while(0)
151 by Brian Aker
Ulonglong to uint64_t
729
#define int8store(T,A)	*((uint64_t *) (T))= (uint64_t) (A)
1 by brian
clean slate
730
731
typedef union {
732
  double v;
733
  long m[2];
734
} doubleget_union;
735
#define doubleget(V,M)	\
736
do { doubleget_union _tmp; \
737
     _tmp.m[0] = *((long*)(M)); \
738
     _tmp.m[1] = *(((long*) (M))+1); \
739
     (V) = _tmp.v; } while(0)
740
#define doublestore(T,V) do { *((long *) T) = ((doubleget_union *)&V)->m[0]; \
741
			     *(((long *) T)+1) = ((doubleget_union *)&V)->m[1]; \
742
                         } while (0)
743
#define float4get(V,M)   do { *((float *) &(V)) = *((float*) (M)); } while(0)
744
#define float8get(V,M)   doubleget((V),(M))
745
#define float4store(V,M) memcpy((uchar*) V,(uchar*) (&M),sizeof(float))
746
#define floatstore(T,V)  memcpy((uchar*)(T), (uchar*)(&V),sizeof(float))
747
#define floatget(V,M)    memcpy((uchar*) &V,(uchar*) (M),sizeof(float))
748
#define float8store(V,M) doublestore((V),(M))
749
#else
750
751
/*
752
  We're here if it's not a IA-32 architecture (Win32 and UNIX IA-32 defines
753
  were done before)
754
*/
755
#define sint2korr(A)	(int16) (((int16) ((uchar) (A)[0])) +\
756
				 ((int16) ((int16) (A)[1]) << 8))
205 by Brian Aker
uint32 -> uin32_t
757
#define sint3korr(A)	((int32_t) ((((uchar) (A)[2]) & 128) ? \
758
				  (((uint32_t) 255L << 24) | \
759
				   (((uint32_t) (uchar) (A)[2]) << 16) |\
760
				   (((uint32_t) (uchar) (A)[1]) << 8) | \
761
				   ((uint32_t) (uchar) (A)[0])) : \
762
				  (((uint32_t) (uchar) (A)[2]) << 16) |\
763
				  (((uint32_t) (uchar) (A)[1]) << 8) | \
764
				  ((uint32_t) (uchar) (A)[0])))
765
#define sint4korr(A)	(int32_t) (((int32_t) ((uchar) (A)[0])) +\
766
				(((int32_t) ((uchar) (A)[1]) << 8)) +\
767
				(((int32_t) ((uchar) (A)[2]) << 16)) +\
768
				(((int32_t) ((int16) (A)[3]) << 24)))
152 by Brian Aker
longlong replacement
769
#define sint8korr(A)	(int64_t) uint8korr(A)
1 by brian
clean slate
770
#define uint2korr(A)	(uint16) (((uint16) ((uchar) (A)[0])) +\
771
				  ((uint16) ((uchar) (A)[1]) << 8))
205 by Brian Aker
uint32 -> uin32_t
772
#define uint3korr(A)	(uint32_t) (((uint32_t) ((uchar) (A)[0])) +\
773
				  (((uint32_t) ((uchar) (A)[1])) << 8) +\
774
				  (((uint32_t) ((uchar) (A)[2])) << 16))
775
#define uint4korr(A)	(uint32_t) (((uint32_t) ((uchar) (A)[0])) +\
776
				  (((uint32_t) ((uchar) (A)[1])) << 8) +\
777
				  (((uint32_t) ((uchar) (A)[2])) << 16) +\
778
				  (((uint32_t) ((uchar) (A)[3])) << 24))
779
#define uint5korr(A)	((uint64_t)(((uint32_t) ((uchar) (A)[0])) +\
780
				    (((uint32_t) ((uchar) (A)[1])) << 8) +\
781
				    (((uint32_t) ((uchar) (A)[2])) << 16) +\
782
				    (((uint32_t) ((uchar) (A)[3])) << 24)) +\
151 by Brian Aker
Ulonglong to uint64_t
783
				    (((uint64_t) ((uchar) (A)[4])) << 32))
205 by Brian Aker
uint32 -> uin32_t
784
#define uint6korr(A)	((uint64_t)(((uint32_t)    ((uchar) (A)[0]))          + \
785
                                     (((uint32_t)    ((uchar) (A)[1])) << 8)   + \
786
                                     (((uint32_t)    ((uchar) (A)[2])) << 16)  + \
787
                                     (((uint32_t)    ((uchar) (A)[3])) << 24)) + \
151 by Brian Aker
Ulonglong to uint64_t
788
                         (((uint64_t) ((uchar) (A)[4])) << 32) +       \
789
                         (((uint64_t) ((uchar) (A)[5])) << 40))
205 by Brian Aker
uint32 -> uin32_t
790
#define uint8korr(A)	((uint64_t)(((uint32_t) ((uchar) (A)[0])) +\
791
				    (((uint32_t) ((uchar) (A)[1])) << 8) +\
792
				    (((uint32_t) ((uchar) (A)[2])) << 16) +\
793
				    (((uint32_t) ((uchar) (A)[3])) << 24)) +\
794
			(((uint64_t) (((uint32_t) ((uchar) (A)[4])) +\
795
				    (((uint32_t) ((uchar) (A)[5])) << 8) +\
796
				    (((uint32_t) ((uchar) (A)[6])) << 16) +\
797
				    (((uint32_t) ((uchar) (A)[7])) << 24))) <<\
1 by brian
clean slate
798
				    32))
799
#define int2store(T,A)       do { uint def_temp= (uint) (A) ;\
800
                                  *((uchar*) (T))=  (uchar)(def_temp); \
801
                                   *((uchar*) (T)+1)=(uchar)((def_temp >> 8)); \
802
                             } while(0)
803
#define int3store(T,A)       do { /*lint -save -e734 */\
804
                                  *((uchar*)(T))=(uchar) ((A));\
805
                                  *((uchar*) (T)+1)=(uchar) (((A) >> 8));\
806
                                  *((uchar*)(T)+2)=(uchar) (((A) >> 16)); \
807
                                  /*lint -restore */} while(0)
808
#define int4store(T,A)       do { *((char *)(T))=(char) ((A));\
809
                                  *(((char *)(T))+1)=(char) (((A) >> 8));\
810
                                  *(((char *)(T))+2)=(char) (((A) >> 16));\
811
                                  *(((char *)(T))+3)=(char) (((A) >> 24)); } while(0)
812
#define int5store(T,A)       do { *((char *)(T))=     (char)((A));  \
813
                                  *(((char *)(T))+1)= (char)(((A) >> 8)); \
814
                                  *(((char *)(T))+2)= (char)(((A) >> 16)); \
815
                                  *(((char *)(T))+3)= (char)(((A) >> 24)); \
816
                                  *(((char *)(T))+4)= (char)(((A) >> 32)); \
817
		                } while(0)
818
#define int6store(T,A)       do { *((char *)(T))=     (char)((A)); \
819
                                  *(((char *)(T))+1)= (char)(((A) >> 8)); \
820
                                  *(((char *)(T))+2)= (char)(((A) >> 16)); \
821
                                  *(((char *)(T))+3)= (char)(((A) >> 24)); \
822
                                  *(((char *)(T))+4)= (char)(((A) >> 32)); \
823
                                  *(((char *)(T))+5)= (char)(((A) >> 40)); \
824
                                } while(0)
825
#define int8store(T,A)       do { uint def_temp= (uint) (A), def_temp2= (uint) ((A) >> 32); \
826
                                  int4store((T),def_temp); \
827
                                  int4store((T+4),def_temp2); } while(0)
828
#ifdef WORDS_BIGENDIAN
829
#define float4store(T,A) do { *(T)= ((uchar *) &A)[3];\
830
                              *((T)+1)=(char) ((uchar *) &A)[2];\
831
                              *((T)+2)=(char) ((uchar *) &A)[1];\
832
                              *((T)+3)=(char) ((uchar *) &A)[0]; } while(0)
833
834
#define float4get(V,M)   do { float def_temp;\
835
                              ((uchar*) &def_temp)[0]=(M)[3];\
836
                              ((uchar*) &def_temp)[1]=(M)[2];\
837
                              ((uchar*) &def_temp)[2]=(M)[1];\
838
                              ((uchar*) &def_temp)[3]=(M)[0];\
839
                              (V)=def_temp; } while(0)
840
#define float8store(T,V) do { *(T)= ((uchar *) &V)[7];\
841
                              *((T)+1)=(char) ((uchar *) &V)[6];\
842
                              *((T)+2)=(char) ((uchar *) &V)[5];\
843
                              *((T)+3)=(char) ((uchar *) &V)[4];\
844
                              *((T)+4)=(char) ((uchar *) &V)[3];\
845
                              *((T)+5)=(char) ((uchar *) &V)[2];\
846
                              *((T)+6)=(char) ((uchar *) &V)[1];\
847
                              *((T)+7)=(char) ((uchar *) &V)[0]; } while(0)
848
849
#define float8get(V,M)   do { double def_temp;\
850
                              ((uchar*) &def_temp)[0]=(M)[7];\
851
                              ((uchar*) &def_temp)[1]=(M)[6];\
852
                              ((uchar*) &def_temp)[2]=(M)[5];\
853
                              ((uchar*) &def_temp)[3]=(M)[4];\
854
                              ((uchar*) &def_temp)[4]=(M)[3];\
855
                              ((uchar*) &def_temp)[5]=(M)[2];\
856
                              ((uchar*) &def_temp)[6]=(M)[1];\
857
                              ((uchar*) &def_temp)[7]=(M)[0];\
858
                              (V) = def_temp; } while(0)
859
#else
860
#define float4get(V,M)   memcpy_fixed((uchar*) &V,(uchar*) (M),sizeof(float))
861
#define float4store(V,M) memcpy_fixed((uchar*) V,(uchar*) (&M),sizeof(float))
862
863
#if defined(__FLOAT_WORD_ORDER) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN)
864
#define doublestore(T,V) do { *(((char*)T)+0)=(char) ((uchar *) &V)[4];\
865
                              *(((char*)T)+1)=(char) ((uchar *) &V)[5];\
866
                              *(((char*)T)+2)=(char) ((uchar *) &V)[6];\
867
                              *(((char*)T)+3)=(char) ((uchar *) &V)[7];\
868
                              *(((char*)T)+4)=(char) ((uchar *) &V)[0];\
869
                              *(((char*)T)+5)=(char) ((uchar *) &V)[1];\
870
                              *(((char*)T)+6)=(char) ((uchar *) &V)[2];\
871
                              *(((char*)T)+7)=(char) ((uchar *) &V)[3]; }\
872
                         while(0)
873
#define doubleget(V,M)   do { double def_temp;\
874
                              ((uchar*) &def_temp)[0]=(M)[4];\
875
                              ((uchar*) &def_temp)[1]=(M)[5];\
876
                              ((uchar*) &def_temp)[2]=(M)[6];\
877
                              ((uchar*) &def_temp)[3]=(M)[7];\
878
                              ((uchar*) &def_temp)[4]=(M)[0];\
879
                              ((uchar*) &def_temp)[5]=(M)[1];\
880
                              ((uchar*) &def_temp)[6]=(M)[2];\
881
                              ((uchar*) &def_temp)[7]=(M)[3];\
882
                              (V) = def_temp; } while(0)
883
#endif /* __FLOAT_WORD_ORDER */
884
885
#define float8get(V,M)   doubleget((V),(M))
886
#define float8store(V,M) doublestore((V),(M))
887
#endif /* WORDS_BIGENDIAN */
888
889
#endif /* __i386__ */
890
891
/*
892
  Macro for reading 32-bit integer from network byte order (big-endian)
893
  from unaligned memory location.
894
*/
205 by Brian Aker
uint32 -> uin32_t
895
#define int4net(A)        (int32_t) (((uint32_t) ((uchar) (A)[3]))        |\
896
				  (((uint32_t) ((uchar) (A)[2])) << 8)  |\
897
				  (((uint32_t) ((uchar) (A)[1])) << 16) |\
898
				  (((uint32_t) ((uchar) (A)[0])) << 24))
1 by brian
clean slate
899
/*
900
  Define-funktions for reading and storing in machine format from/to
901
  short/long to/from some place in memory V should be a (not
902
  register) variable, M is a pointer to byte
903
*/
904
905
#ifdef WORDS_BIGENDIAN
906
907
#define ushortget(V,M)  do { V = (uint16) (((uint16) ((uchar) (M)[1]))+\
908
                                 ((uint16) ((uint16) (M)[0]) << 8)); } while(0)
909
#define shortget(V,M)   do { V = (short) (((short) ((uchar) (M)[1]))+\
910
                                 ((short) ((short) (M)[0]) << 8)); } while(0)
205 by Brian Aker
uint32 -> uin32_t
911
#define longget(V,M)    do { int32_t def_temp;\
1 by brian
clean slate
912
                             ((uchar*) &def_temp)[0]=(M)[0];\
913
                             ((uchar*) &def_temp)[1]=(M)[1];\
914
                             ((uchar*) &def_temp)[2]=(M)[2];\
915
                             ((uchar*) &def_temp)[3]=(M)[3];\
916
                             (V)=def_temp; } while(0)
205 by Brian Aker
uint32 -> uin32_t
917
#define ulongget(V,M)   do { uint32_t def_temp;\
1 by brian
clean slate
918
                            ((uchar*) &def_temp)[0]=(M)[0];\
919
                            ((uchar*) &def_temp)[1]=(M)[1];\
920
                            ((uchar*) &def_temp)[2]=(M)[2];\
921
                            ((uchar*) &def_temp)[3]=(M)[3];\
922
                            (V)=def_temp; } while(0)
923
#define shortstore(T,A) do { uint def_temp=(uint) (A) ;\
924
                             *(((char*)T)+1)=(char)(def_temp); \
925
                             *(((char*)T)+0)=(char)(def_temp >> 8); } while(0)
926
#define longstore(T,A)  do { *(((char*)T)+3)=((A));\
927
                             *(((char*)T)+2)=(((A) >> 8));\
928
                             *(((char*)T)+1)=(((A) >> 16));\
929
                             *(((char*)T)+0)=(((A) >> 24)); } while(0)
930
931
#define floatget(V,M)    memcpy_fixed((uchar*) &V,(uchar*) (M),sizeof(float))
932
#define floatstore(T,V)  memcpy_fixed((uchar*) (T),(uchar*)(&V),sizeof(float))
933
#define doubleget(V,M)	 memcpy_fixed((uchar*) &V,(uchar*) (M),sizeof(double))
934
#define doublestore(T,V) memcpy_fixed((uchar*) (T),(uchar*) &V,sizeof(double))
152 by Brian Aker
longlong replacement
935
#define int64_tget(V,M) memcpy_fixed((uchar*) &V,(uchar*) (M),sizeof(uint64_t))
936
#define int64_tstore(T,V) memcpy_fixed((uchar*) (T),(uchar*) &V,sizeof(uint64_t))
1 by brian
clean slate
937
938
#else
939
940
#define ushortget(V,M)	do { V = uint2korr(M); } while(0)
941
#define shortget(V,M)	do { V = sint2korr(M); } while(0)
942
#define longget(V,M)	do { V = sint4korr(M); } while(0)
943
#define ulongget(V,M)   do { V = uint4korr(M); } while(0)
944
#define shortstore(T,V) int2store(T,V)
945
#define longstore(T,V)	int4store(T,V)
946
#ifndef floatstore
947
#define floatstore(T,V)  memcpy_fixed((uchar*) (T),(uchar*) (&V),sizeof(float))
948
#define floatget(V,M)    memcpy_fixed((uchar*) &V, (uchar*) (M), sizeof(float))
949
#endif
950
#ifndef doubleget
951
#define doubleget(V,M)	 memcpy_fixed((uchar*) &V,(uchar*) (M),sizeof(double))
952
#define doublestore(T,V) memcpy_fixed((uchar*) (T),(uchar*) &V,sizeof(double))
953
#endif /* doubleget */
152 by Brian Aker
longlong replacement
954
#define int64_tget(V,M) memcpy_fixed((uchar*) &V,(uchar*) (M),sizeof(uint64_t))
955
#define int64_tstore(T,V) memcpy_fixed((uchar*) (T),(uchar*) &V,sizeof(uint64_t))
1 by brian
clean slate
956
957
#endif /* WORDS_BIGENDIAN */
958
171.1.1 by Patrick Galbraith
Dar, I forgot to commit this earlier.
959
/* my_sprintf  was here. RIP */
1 by brian
clean slate
960
961
#if defined(HAVE_CHARSET_utf8mb3) || defined(HAVE_CHARSET_utf8mb4)
962
#define MYSQL_UNIVERSAL_CLIENT_CHARSET "utf8"
963
#else
964
#define MYSQL_UNIVERSAL_CLIENT_CHARSET MYSQL_DEFAULT_CHARSET_NAME
965
#endif
966
967
#include <dlfcn.h>
968
969
/* FreeBSD 2.2.2 does not define RTLD_NOW) */
970
#ifndef RTLD_NOW
971
#define RTLD_NOW 1
972
#endif
973
974
/*
975
 *  Include standard definitions of operator new and delete.
976
 */
977
#ifdef __cplusplus
978
#include <new>
979
#endif
980
981
/* Length of decimal number represented by INT32. */
982
#define MY_INT32_NUM_DECIMAL_DIGITS 11
983
984
/* Length of decimal number represented by INT64. */
985
#define MY_INT64_NUM_DECIMAL_DIGITS 21
986
77.1.31 by Monty Taylor
Replaced regex lib with pcre. Reworked mysqltest to use it.
987
#ifdef _cplusplus
988
#include <string>
989
#endif
990
1 by brian
clean slate
991
/* Define some useful general macros (should be done after all headers). */
992
#if !defined(max)
993
#define max(a, b)	((a) > (b) ? (a) : (b))
994
#define min(a, b)	((a) < (b) ? (a) : (b))
995
#endif  
996
/*
997
  Only Linux is known to need an explicit sync of the directory to make sure a
998
  file creation/deletion/renaming in(from,to) this directory durable.
999
*/
1000
#ifdef TARGET_OS_LINUX
1001
#define NEED_EXPLICIT_SYNC_DIR 1
1002
#endif
1003
1004
#endif /* my_global_h */