~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/global.h

  • Committer: Monty
  • Date: 2008-10-02 05:41:33 UTC
  • mfrom: (398.1.10 codestyle)
  • Revision ID: mordred@scylla.inaugust.com-20081002054133-tyxv5bmqpazfaqqi
Merged up to 408 of stdint-includes-fix.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
#define __i386__
45
45
#endif
46
46
 
47
 
/* Macros to make switching between C and C++ mode easier */
48
 
#ifdef __cplusplus
49
 
#define C_MODE_START    extern "C" {
50
 
#define C_MODE_END      }
51
 
#else
52
 
#define C_MODE_START
53
 
#define C_MODE_END
54
 
#endif
55
 
 
56
47
#include "config.h"
57
48
 
58
49
/*
68
59
#define __builtin_expect(x, expected_value) (x)
69
60
#endif
70
61
 
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)
73
64
 
74
65
/*
75
66
 *   Disable __attribute__ for non GNU compilers, since we're using them
97
88
#include <sys/types.h>
98
89
#endif
99
90
 
100
 
#define __EXTENSIONS__ 1        /* We want some extension */
 
91
#define __EXTENSIONS__ 1  /* We want some extension */
101
92
 
102
93
#if defined(HAVE_STDINT_H)
103
94
/* Need to include this _before_ stdlib, so that all defines are right */
106
97
#undef _STDINT_H
107
98
#define __STDC_FORMAT_MACROS
108
99
#include <inttypes.h>
109
 
/* 
110
 
  We include the following because currently Google #$@#$ Protocol Buffers possibly break stdint defines. 
 
100
/*
 
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.
112
103
 
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
128
119
 
129
120
#define INT8_MIN          -128
130
121
#define INT16_MIN         -32768
131
122
 
132
 
   /*
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.
137
 
   */
 
123
/*
 
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.
 
128
*/
138
129
#define INT32_MIN        (-INT32_MAX-1)
139
130
#define INT64_MIN        (-INT64_MAX-1)
140
131
 
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
145
136
 
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 */
179
170
 
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
183
174
#else
184
175
#define INTPTR_MIN        INT32_MIN
185
176
#define INTPTR_MAX        INT32_MAX
186
177
#endif
187
178
 
188
179
#if __WORDSIZE == 64
189
 
#define UINTPTR_MAX       UINT64_MAX
 
180
#define UINTPTR_MAX    UINT64_MAX
190
181
#else
191
182
#define UINTPTR_MAX       UINT32_MAX
192
183
#endif
199
190
 
200
191
/* 7.18.3 "Other" */
201
192
#if __WORDSIZE == 64
202
 
#define PTRDIFF_MIN       INT64_MIN
203
 
#define PTRDIFF_MAX       INT64_MAX
 
193
#define PTRDIFF_MIN    INT64_MIN
 
194
#define PTRDIFF_MAX    INT64_MAX
204
195
#else
205
196
#define PTRDIFF_MIN       INT32_MIN
206
197
#define PTRDIFF_MAX       INT32_MAX
211
202
   My bet would be on one of {U}INT32_{MIN,MAX}. */
212
203
 
213
204
#if __WORDSIZE == 64
214
 
#define SIZE_MAX          UINT64_MAX
 
205
#define SIZE_MAX    UINT64_MAX
215
206
#else
216
207
#define SIZE_MAX          UINT32_MAX
217
208
#endif
236
227
#  endif
237
228
#endif
238
229
 
239
 
#define WINT_MIN          INT32_MIN
240
 
#define WINT_MAX          INT32_MAX
 
230
#define WINT_MIN    INT32_MIN
 
231
#define WINT_MAX    INT32_MAX
241
232
 
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
244
235
#endif
245
236
 
246
237
#else
251
242
/*
252
243
  Solaris 9 include file <sys/feature_tests.h> refers to X/Open document
253
244
 
254
 
    System Interfaces and Headers, Issue 5
 
245
  System Interfaces and Headers, Issue 5
255
246
 
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 */
285
276
#endif
286
277
 
287
 
#define _REENTRANT      1       /* Some thread libraries require this */
288
 
 
289
 
#include <pthread.h>            /* AIX must have this included first */
290
 
 
291
 
#define _REENTRANT      1       /* Threads requires reentrant code */
 
278
#define _REENTRANT  1  /* Some thread libraries require this */
 
279
 
 
280
#include <pthread.h>    /* AIX must have this included first */
 
281
 
 
282
#define _REENTRANT  1  /* Threads requires reentrant code */
292
283
 
293
284
 
294
285
/* gcc/egcs issues */
319
310
#include <fcntl.h>
320
311
#endif
321
312
#ifdef HAVE_SYS_TIMEB_H
322
 
#include <sys/timeb.h>                          /* Avoid warnings on SCO */
 
313
#include <sys/timeb.h>        /* Avoid warnings on SCO */
323
314
#endif
324
315
#if TIME_WITH_SYS_TIME
325
316
# include <sys/time.h>
342
333
#include <alloca.h>
343
334
#endif
344
335
 
345
 
#include <errno.h>                              /* Recommended by debian */
 
336
#include <errno.h>        /* Recommended by debian */
346
337
 
347
338
#if defined(HAVE_STDBOOL_H)
348
339
#include <stdbool.h>
365
356
  do                                                            \
366
357
  {                                                             \
367
358
    char compile_time_assert[(X) ? 1 : -1]                      \
368
 
                             __attribute__ ((unused));          \
 
359
      __attribute__ ((unused));                                 \
369
360
  } while(0)
370
361
#endif
371
362
 
376
367
 
377
368
/* We can not live without the following defines */
378
369
 
379
 
#define MASTER 1                /* Compile without unireg */
 
370
#define MASTER 1    /* Compile without unireg */
380
371
 
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
386
377
#endif
387
378
 
388
 
/* Define void to stop lint from generating "null effekt" comments */
389
 
#ifndef DONT_DEFINE_VOID
390
 
#ifdef _lint
391
 
int     __void__;
392
 
#define VOID(X)         (__void__ = (int) (X))
393
 
#else
394
 
#undef VOID
395
 
#define VOID(X)         (X)
396
 
#endif
397
 
#endif /* DONT_DEFINE_VOID */
398
 
 
399
379
#if !defined(HAVE_UINT)
400
380
#undef HAVE_UINT
401
381
#define HAVE_UINT
407
387
extern char _dig_vec_upper[];
408
388
extern char _dig_vec_lower[];
409
389
 
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))
420
398
#endif
421
399
 
422
400
#if defined(__GNUC__)
423
 
#define function_volatile       volatile
 
401
#define function_volatile  volatile
424
402
#define my_reinterpret_cast(A) reinterpret_cast<A>
425
403
#define my_const_cast(A) const_cast<A>
426
404
# ifndef GCC_VERSION
431
409
#define my_const_cast(A) (A)
432
410
#endif
433
411
 
434
 
/* From old s-system.h */
435
 
 
436
 
/*
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.
440
 
*/
441
 
#define _VARARGS(X) X
442
 
#define _STATIC_VARARGS(X) X
443
 
#define _PC(X)  X
444
 
 
445
 
#define MIN_ARRAY_SIZE  0       /* Zero or One. Gcc allows zero*/
446
 
#define ASCII_BITS_USED 8       /* Bit char used */
447
 
 
448
412
/* Some types that is different between systems */
449
413
 
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
453
 
C_MODE_START
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 *);
457
 
C_MODE_END
458
 
#define qsort_t RETQSORTTYPE    /* Broken GCC cant handle typedef !!!! */
 
418
 
 
419
#ifdef __cplusplus
 
420
extern "C" {
 
421
#endif
 
422
 
 
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 *);
 
426
 
 
427
#ifdef __cplusplus
 
428
}
 
429
#endif
 
430
 
459
431
#ifdef HAVE_SYS_SOCKET_H
460
432
#include <sys/socket.h>
461
433
#endif
467
439
 
468
440
/* file create flags */
469
441
 
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 */
473
445
 
474
446
#ifndef O_BINARY
475
 
#define O_BINARY        0       /* Flag to my_open for binary files */
 
447
#define O_BINARY  0  /* Flag to my_open for binary files */
476
448
#endif
477
449
 
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 */
480
452
#endif
481
453
 
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 */
483
455
 
484
456
#ifndef O_TEMPORARY
485
 
#define O_TEMPORARY     0
 
457
#define O_TEMPORARY  0
486
458
#endif
487
459
#ifndef O_SHORT_LIVED
488
 
#define O_SHORT_LIVED   0
 
460
#define O_SHORT_LIVED  0
489
461
#endif
490
462
#ifndef O_NOFOLLOW
491
463
#define O_NOFOLLOW      0
494
466
 
495
467
 
496
468
#ifndef FN_LIBCHAR
497
 
#define FN_LIBCHAR      '/'
498
 
#define FN_ROOTDIR      "/"
 
469
#define FN_LIBCHAR  '/'
 
470
#define FN_ROOTDIR  "/"
499
471
#endif
500
 
#define MY_NFILE        64      /* This is only used to save filenames */
 
472
#define MY_NFILE  64  /* This is only used to save filenames */
501
473
#ifndef OS_FILE_LIMIT
502
 
#define OS_FILE_LIMIT   65535
 
474
#define OS_FILE_LIMIT  65535
503
475
#endif
504
476
 
505
477
/* #define EXT_IN_LIBNAME     */
512
484
*/
513
485
#define MALLOC_OVERHEAD 8
514
486
 
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
523
 
 
524
 
 
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
 
495
 
 
496
 
 
497
/* Some things that this system doesn't have */
526
498
 
527
499
/* Some defines of functions for portability */
528
500
 
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))
536
508
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
537
509
#endif
538
510
#define ulong_to_double(X) ((double) (ulong) (X))
539
 
#define SET_STACK_SIZE(X)       /* Not needed on real machines */
 
511
#define SET_STACK_SIZE(X)  /* Not needed on real machines */
540
512
 
541
513
#ifndef STACK_DIRECTION
542
514
#error "please add -DSTACK_DIRECTION=1 or -1 to your CPPFLAGS"
559
531
 
560
532
/* From limits.h instead */
561
533
#ifndef DBL_MIN
562
 
#define DBL_MIN         4.94065645841246544e-324
 
534
#define DBL_MIN    4.94065645841246544e-324
563
535
#endif
564
536
#ifndef DBL_MAX
565
 
#define DBL_MAX         1.79769313486231470e+308
 
537
#define DBL_MAX    1.79769313486231470e+308
566
538
#endif
567
539
#ifndef SIZE_T_MAX
568
540
#define SIZE_T_MAX ~((size_t) 0)
603
575
  adressable obj.
604
576
*/
605
577
#if SIZEOF_CHARP == 4
606
 
typedef int32_t         my_ptrdiff_t;
 
578
typedef int32_t    my_ptrdiff_t;
607
579
#else
608
 
typedef int64_t         my_ptrdiff_t;
 
580
typedef int64_t   my_ptrdiff_t;
609
581
#endif
610
582
 
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))
619
591
 
632
604
  and related routines are refactored.
633
605
*/
634
606
 
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))
637
609
 
638
 
#define NullS           (char *) 0
 
610
#define NullS    (char *) 0
639
611
 
640
612
/* Typdefs for easyier portability */
641
613
 
642
614
#ifndef HAVE_UCHAR
643
 
typedef unsigned char   uchar;  /* Short for unsigned char */
 
615
typedef unsigned char  uchar;  /* Short for unsigned char */
644
616
#endif
645
617
 
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 */
648
620
#endif
649
621
 
650
622
#if SIZEOF_OFF_T > 4 
651
623
typedef uint64_t my_off_t;
652
624
#else
653
625
typedef unsigned long my_off_t;
654
 
#endif 
655
 
#define MY_FILEPOS_ERROR        (~(my_off_t) 0)
 
626
#endif
 
627
#define MY_FILEPOS_ERROR  (~(my_off_t) 0)
656
628
 
657
629
typedef off_t os_off_t;
658
630
 
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
667
639
 
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 */
673
645
#endif
674
646
#define MYF(v)          (myf) (v)
675
647
 
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 */
681
 
 
682
 
 
683
 
 
684
 
 
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 */
 
653
 
686
654
 
687
655
#if defined(HAVE_CHARSET_utf8mb3) || defined(HAVE_CHARSET_utf8mb4)
688
656
#define DRIZZLE_UNIVERSAL_CLIENT_CHARSET "utf8"