68
59
#define __builtin_expect(x, expected_value) (x)
71
#define likely(x) __builtin_expect((x),1)
72
#define unlikely(x) __builtin_expect((x),0)
62
#define likely(x) __builtin_expect((x),1)
63
#define unlikely(x) __builtin_expect((x),0)
75
66
* Disable __attribute__ for non GNU compilers, since we're using them
107
98
#define __STDC_FORMAT_MACROS
108
99
#include <inttypes.h>
110
We include the following because currently Google #$@#$ Protocol Buffers possibly break stdint defines.
101
We include the following because currently Google #$@#$ Protocol Buffers possibly break stdint defines.
111
102
Or I am wrong, very possible, and hope someone finds the solution.
113
104
Taken from /usr/include/stdint.h
124
115
#define INT8_MAX 127
125
116
#define INT16_MAX 32767
126
117
#define INT32_MAX 2147483647
127
#define INT64_MAX 9223372036854775807LL
118
#define INT64_MAX 9223372036854775807
129
120
#define INT8_MIN -128
130
121
#define INT16_MIN -32768
133
Note: the literal "most negative int" cannot be written in C --
134
the rules in the standard (section 6.4.4.1 in C99) will give it
135
an unsigned type, so INT32_MIN (and the most negative member of
136
any larger signed type) must be written via a constant expression.
124
Note: the literal "most negative int" cannot be written in C --
125
the rules in the standard (section 6.4.4.1 in C99) will give it
126
an unsigned type, so INT32_MIN (and the most negative member of
127
any larger signed type) must be written via a constant expression.
138
129
#define INT32_MIN (-INT32_MAX-1)
139
130
#define INT64_MIN (-INT64_MAX-1)
141
132
#define UINT8_MAX 255
142
133
#define UINT16_MAX 65535
143
134
#define UINT32_MAX 4294967295U
144
#define UINT64_MAX 18446744073709551615ULL
135
#define UINT64_MAX 18446744073709551615U
146
137
/* 7.18.2.2 Limits of minimum-width integer types */
147
138
#define INT_LEAST8_MIN INT8_MIN
178
169
/* 7.18.2.4 Limits of integer types capable of holding object pointers */
180
171
#if __WORDSIZE == 64
181
#define INTPTR_MIN INT64_MIN
182
#define INTPTR_MAX INT64_MAX
172
#define INTPTR_MIN INT64_MIN
173
#define INTPTR_MAX INT64_MAX
184
175
#define INTPTR_MIN INT32_MIN
185
176
#define INTPTR_MAX INT32_MAX
188
179
#if __WORDSIZE == 64
189
#define UINTPTR_MAX UINT64_MAX
180
#define UINTPTR_MAX UINT64_MAX
191
182
#define UINTPTR_MAX UINT32_MAX
239
#define WINT_MIN INT32_MIN
240
#define WINT_MAX INT32_MAX
230
#define WINT_MIN INT32_MIN
231
#define WINT_MAX INT32_MAX
242
#define SIG_ATOMIC_MIN INT32_MIN
243
#define SIG_ATOMIC_MAX INT32_MAX
233
#define SIG_ATOMIC_MIN INT32_MIN
234
#define SIG_ATOMIC_MAX INT32_MAX
252
243
Solaris 9 include file <sys/feature_tests.h> refers to X/Open document
254
System Interfaces and Headers, Issue 5
245
System Interfaces and Headers, Issue 5
256
247
saying we should define _XOPEN_SOURCE=500 to get POSIX.1c prototypes,
257
248
but apparently other systems (namely FreeBSD) don't agree.
284
275
#define _POSIX_PTHREAD_SEMANTICS /* We want posix threads */
287
#define _REENTRANT 1 /* Some thread libraries require this */
289
#include <pthread.h> /* AIX must have this included first */
291
#define _REENTRANT 1 /* Threads requires reentrant code */
278
#define _REENTRANT 1 /* Some thread libraries require this */
280
#include <pthread.h> /* AIX must have this included first */
282
#define _REENTRANT 1 /* Threads requires reentrant code */
294
285
/* gcc/egcs issues */
377
368
/* We can not live without the following defines */
379
#define MASTER 1 /* Compile without unireg */
370
#define MASTER 1 /* Compile without unireg */
381
#define QUOTE_ARG(x) #x /* Quote argument (before cpp) */
382
#define STRINGIFY_ARG(x) QUOTE_ARG(x) /* Quote argument, after cpp */
372
#define QUOTE_ARG(x) #x /* Quote argument (before cpp) */
373
#define STRINGIFY_ARG(x) QUOTE_ARG(x) /* Quote argument, after cpp */
383
374
/* Does the system remember a signal handler after a signal ? */
384
375
#ifndef HAVE_BSD_SIGNALS
385
376
#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
379
#if !defined(HAVE_UINT)
401
381
#define HAVE_UINT
407
387
extern char _dig_vec_upper[];
408
388
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 test(a) ((a) ? 1 : 0)
390
#define test(a) ((a) ? 1 : 0)
413
391
#define set_if_bigger(a,b) do { if ((a) < (b)) (a)=(b); } while(0)
414
392
#define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0)
415
393
#define test_all_bits(a,b) (((a) & (b)) == (b))
431
409
#define my_const_cast(A) (A)
434
/* From old s-system.h */
437
Support macros for non ansi & other old compilers. Since such
438
things are no longer supported we do nothing. We keep then since
439
some of our code may still be needed to upgrade old customers.
441
#define _VARARGS(X) X
442
#define _STATIC_VARARGS(X) X
445
#define MIN_ARRAY_SIZE 0 /* Zero or One. Gcc allows zero*/
446
#define ASCII_BITS_USED 8 /* Bit char used */
448
412
/* Some types that is different between systems */
450
typedef int File; /* File descriptor */
414
typedef int File; /* File descriptor */
451
415
/* Type for fuctions that handles signals */
416
/* RETSIGTYPE is defined by autoconf */
452
417
#define sig_handler RETSIGTYPE
454
typedef void (*sig_return)(void);/* Returns type from signal */
455
typedef int (*qsort_cmp)(const void *,const void *);
456
typedef int (*qsort_cmp2)(void*, const void *,const void *);
458
#define qsort_t RETQSORTTYPE /* Broken GCC cant handle typedef !!!! */
423
typedef void (*sig_return)(void);/* Returns type from signal */
424
typedef int (*qsort_cmp)(const void *,const void *);
425
typedef int (*qsort_cmp2)(void*, const void *,const void *);
459
431
#ifdef HAVE_SYS_SOCKET_H
460
432
#include <sys/socket.h>
468
440
/* file create flags */
470
#ifndef O_SHARE /* Probably not windows */
471
#define O_SHARE 0 /* Flag to my_open for shared files */
442
#ifndef O_SHARE /* Probably not windows */
443
#define O_SHARE 0 /* Flag to my_open for shared files */
472
444
#endif /* O_SHARE */
475
#define O_BINARY 0 /* Flag to my_open for binary files */
447
#define O_BINARY 0 /* Flag to my_open for binary files */
478
450
#ifndef FILE_BINARY
479
#define FILE_BINARY O_BINARY /* Flag to my_fopen for binary streams */
451
#define FILE_BINARY O_BINARY /* Flag to my_fopen for binary streams */
482
#define F_TO_EOF 0L /* Param to lockf() to lock rest of file */
454
#define F_TO_EOF 0L /* Param to lockf() to lock rest of file */
484
456
#ifndef O_TEMPORARY
485
#define O_TEMPORARY 0
457
#define O_TEMPORARY 0
487
459
#ifndef O_SHORT_LIVED
488
#define O_SHORT_LIVED 0
460
#define O_SHORT_LIVED 0
490
462
#ifndef O_NOFOLLOW
491
463
#define O_NOFOLLOW 0
513
485
#define MALLOC_OVERHEAD 8
515
/* get memory in huncs */
516
#define ONCE_ALLOC_INIT (uint) (4096-MALLOC_OVERHEAD)
517
/* Typical record cash */
518
#define RECORD_CACHE_SIZE (uint) (64*1024-MALLOC_OVERHEAD)
519
/* Typical key cash */
520
#define KEY_CACHE_SIZE (uint) (8*1024*1024-MALLOC_OVERHEAD)
521
/* Default size of a key cache block */
522
#define KEY_CACHE_BLOCK_SIZE (uint) 1024
525
/* Some things that this system doesn't have */
487
/* get memory in huncs */
488
#define ONCE_ALLOC_INIT (uint) (4096-MALLOC_OVERHEAD)
489
/* Typical record cash */
490
#define RECORD_CACHE_SIZE (uint) (64*1024-MALLOC_OVERHEAD)
491
/* Typical key cash */
492
#define KEY_CACHE_SIZE (uint) (8*1024*1024-MALLOC_OVERHEAD)
493
/* Default size of a key cache block */
494
#define KEY_CACHE_BLOCK_SIZE (uint) 1024
497
/* Some things that this system doesn't have */
527
499
/* Some defines of functions for portability */
529
#undef remove /* Crashes MySQL on SCO 5.0.0 */
501
#undef remove /* Crashes MySQL on SCO 5.0.0 */
530
502
#ifndef uint64_t2double
531
503
#define uint64_t2double(A) ((double) (uint64_t) (A))
532
504
#define my_off_t2double(A) ((double) (my_off_t) (A))
605
577
#if SIZEOF_CHARP == 4
606
typedef int32_t my_ptrdiff_t;
578
typedef int32_t my_ptrdiff_t;
608
typedef int64_t my_ptrdiff_t;
580
typedef int64_t my_ptrdiff_t;
611
#define MY_ALIGN(A,L) (((A) + (L) - 1) & ~((L) - 1))
612
#define ALIGN_SIZE(A) MY_ALIGN((A),sizeof(double))
583
#define MY_ALIGN(A,L) (((A) + (L) - 1) & ~((L) - 1))
584
#define ALIGN_SIZE(A) MY_ALIGN((A),sizeof(double))
613
585
/* Size to make adressable obj. */
614
586
#define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A),sizeof(t)))
615
/* Offset of field f in structure t */
616
#define OFFSET(t, f) ((size_t)(char *)&((t *)0)->f)
587
/* Offset of field f in structure t */
588
#define OFFSET(t, f) ((size_t)(char *)&((t *)0)->f)
617
589
#define ADD_TO_PTR(ptr,size,type) (type) ((uchar*) (ptr)+size)
618
590
#define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((uchar*) (A) - (uchar*) (B))
632
604
and related routines are refactored.
635
#define my_offsetof(TYPE, MEMBER) \
636
((size_t)((char *)&(((TYPE *)0x10)->MEMBER) - (char*)0x10))
607
#define my_offsetof(TYPE, MEMBER) \
608
((size_t)((char *)&(((TYPE *)0x10)->MEMBER) - (char*)0x10))
638
#define NullS (char *) 0
610
#define NullS (char *) 0
640
612
/* Typdefs for easyier portability */
642
614
#ifndef HAVE_UCHAR
643
typedef unsigned char uchar; /* Short for unsigned char */
615
typedef unsigned char uchar; /* Short for unsigned char */
646
618
#if !defined(HAVE_ULONG) && !defined(__USE_MISC)
647
typedef unsigned long ulong; /* Short for unsigned long */
619
typedef unsigned long ulong; /* Short for unsigned long */
650
622
#if SIZEOF_OFF_T > 4
651
623
typedef uint64_t my_off_t;
653
625
typedef unsigned long my_off_t;
655
#define MY_FILEPOS_ERROR (~(my_off_t) 0)
627
#define MY_FILEPOS_ERROR (~(my_off_t) 0)
657
629
typedef off_t os_off_t;
659
#define socket_errno errno
660
#define SOCKET_EINTR EINTR
661
#define SOCKET_EAGAIN EAGAIN
631
#define socket_errno errno
632
#define SOCKET_EINTR EINTR
633
#define SOCKET_EAGAIN EAGAIN
662
634
#define SOCKET_ETIMEDOUT SOCKET_EINTR
663
635
#define SOCKET_EWOULDBLOCK EWOULDBLOCK
664
636
#define SOCKET_EADDRINUSE EADDRINUSE
665
#define SOCKET_ENFILE ENFILE
666
#define SOCKET_EMFILE EMFILE
637
#define SOCKET_ENFILE ENFILE
638
#define SOCKET_EMFILE EMFILE
668
typedef uint8_t int7; /* Most effective integer 0 <= x <= 127 */
669
typedef short int15; /* Most effective integer 0 <= x <= 32767 */
670
typedef int myf; /* Type of MyFlags in my_funcs */
640
typedef uint8_t int7; /* Most effective integer 0 <= x <= 127 */
641
typedef short int15; /* Most effective integer 0 <= x <= 32767 */
642
typedef int myf; /* Type of MyFlags in my_funcs */
671
643
#if !defined(bool) && (!defined(HAVE_BOOL) || !defined(__cplusplus))
672
typedef char bool; /* Ordinary boolean values 0 1 */
644
typedef char bool; /* Ordinary boolean values 0 1 */
674
646
#define MYF(v) (myf) (v)
676
648
/* Defines for time function */
677
#define SCALE_SEC 100
678
#define SCALE_USEC 10000
679
#define MY_HOW_OFTEN_TO_ALARM 2 /* How often we want info on screen */
680
#define MY_HOW_OFTEN_TO_WRITE 1000 /* How often we want info on screen */
685
/* my_sprintf was here. RIP */
649
#define SCALE_SEC 100
650
#define SCALE_USEC 10000
651
#define MY_HOW_OFTEN_TO_ALARM 2 /* How often we want info on screen */
652
#define MY_HOW_OFTEN_TO_WRITE 1000 /* How often we want info on screen */
687
655
#if defined(HAVE_CHARSET_utf8mb3) || defined(HAVE_CHARSET_utf8mb4)
688
656
#define DRIZZLE_UNIVERSAL_CLIENT_CHARSET "utf8"