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