~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to include/my_global.h

MergedĀ fromĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
425
425
/* #define USE_RECORD_LOCK      */
426
426
 
427
427
        /* Unsigned types supported by the compiler */
428
 
#define UNSINT8                 /* unsigned int8 (char) */
429
 
#define UNSINT16                /* unsigned int16 */
430
 
#define UNSINT32                /* unsigned int32 */
 
428
#define UNSINT8                 /* unsigned int8_t (char) */
 
429
#define UNSINT16                /* unsigned int16_t */
 
430
#define UNSINT32                /* unsigned int32_t */
431
431
 
432
432
        /* General constants */
433
433
#define SC_MAXWIDTH     256     /* Max width of screen (for error messages) */
599
599
typedef unsigned char   uchar;  /* Short for unsigned char */
600
600
#endif
601
601
 
602
 
#ifndef HAVE_INT8
603
 
typedef signed char int8;       /* Signed integer >= 8  bits */
604
 
#endif
605
 
#ifndef HAVE_UINT8
606
 
typedef unsigned char uint8;    /* Unsigned integer >= 8  bits */
607
 
#endif
608
 
#ifndef HAVE_INT16
609
 
typedef short int16;
610
 
#endif
611
 
#ifndef HAVE_UINT16
612
 
typedef unsigned short uint16;
613
 
#endif
614
 
#if SIZEOF_INT == 4
615
 
#ifndef HAVE_INT32
616
 
typedef int int32;
617
 
#endif
618
 
#ifndef HAVE_UINT32
619
 
typedef unsigned int uint32;
620
 
#endif
621
 
#elif SIZEOF_LONG == 4
622
 
#ifndef HAVE_INT32
623
 
typedef long int32;
624
 
#endif
625
 
#ifndef HAVE_UINT32
626
 
typedef unsigned long uint32;
627
 
#endif
628
 
#else
629
 
#error Neither int or long is of 4 bytes width
630
 
#endif
631
 
 
632
602
#if !defined(HAVE_ULONG) && !defined(__USE_MISC)
633
603
typedef unsigned long ulong;              /* Short for unsigned long */
634
604
#endif
635
 
#ifndef int64_t_defined
636
 
/* 
637
 
  Using [unsigned] long long is preferable as [u]int64_t because we use 
638
 
  [unsigned] long long unconditionally in many places, 
639
 
  for example in constants with [U]LL suffix.
640
 
*/
641
 
typedef int64_t int64_t;
642
 
#endif
643
605
 
644
606
#define MY_ERRPTR ((void*)(intptr)1)
645
607
 
662
624
#define SOCKET_ENFILE   ENFILE
663
625
#define SOCKET_EMFILE   EMFILE
664
626
 
665
 
typedef uint8           int7;   /* Most effective integer 0 <= x <= 127 */
 
627
typedef uint8_t         int7;   /* Most effective integer 0 <= x <= 127 */
666
628
typedef short           int15;  /* Most effective integer 0 <= x <= 32767 */
667
629
typedef int             myf;    /* Type of MyFlags in my_funcs */
668
630
typedef char            my_bool; /* Small bool */
670
632
typedef char            bool;   /* Ordinary boolean values 0 1 */
671
633
#endif
672
634
        /* Macros for converting *constants* to the right type */
673
 
#define INT8(v)         (int8) (v)
674
 
#define INT16(v)        (int16) (v)
675
 
#define INT32(v)        (int32) (v)
 
635
#define INT8(v)         (int8_t) (v)
 
636
#define INT16(v)        (int16_t) (v)
 
637
#define INT32(v)        (int32_t) (v)
676
638
#define MYF(v)          (myf) (v)
677
639
 
678
640
/* Defines for time function */
690
652
 
691
653
/* Optimized store functions for Intel x86 */
692
654
#if defined(__i386__)
693
 
#define sint2korr(A)    (*((int16 *) (A)))
694
 
#define sint3korr(A)    ((int32) ((((uchar) (A)[2]) & 128) ? \
695
 
                                  (((uint32) 255L << 24) | \
696
 
                                   (((uint32) (uchar) (A)[2]) << 16) |\
697
 
                                   (((uint32) (uchar) (A)[1]) << 8) | \
698
 
                                   ((uint32) (uchar) (A)[0])) : \
699
 
                                  (((uint32) (uchar) (A)[2]) << 16) |\
700
 
                                  (((uint32) (uchar) (A)[1]) << 8) | \
701
 
                                  ((uint32) (uchar) (A)[0])))
 
655
#define sint2korr(A)    (*((int16_t *) (A)))
 
656
#define sint3korr(A)    ((int32_t) ((((uchar) (A)[2]) & 128) ? \
 
657
                                  (((uint32_t) 255L << 24) | \
 
658
                                   (((uint32_t) (uchar) (A)[2]) << 16) |\
 
659
                                   (((uint32_t) (uchar) (A)[1]) << 8) | \
 
660
                                   ((uint32_t) (uchar) (A)[0])) : \
 
661
                                  (((uint32_t) (uchar) (A)[2]) << 16) |\
 
662
                                  (((uint32_t) (uchar) (A)[1]) << 8) | \
 
663
                                  ((uint32_t) (uchar) (A)[0])))
702
664
#define sint4korr(A)    (*((long *) (A)))
703
 
#define uint2korr(A)    (*((uint16 *) (A)))
 
665
#define uint2korr(A)    (*((uint16_t *) (A)))
704
666
#if defined(HAVE_purify)
705
 
#define uint3korr(A)    (uint32) (((uint32) ((uchar) (A)[0])) +\
706
 
                                  (((uint32) ((uchar) (A)[1])) << 8) +\
707
 
                                  (((uint32) ((uchar) (A)[2])) << 16))
 
667
#define uint3korr(A)    (uint32_t) (((uint32_t) ((uchar) (A)[0])) +\
 
668
                                  (((uint32_t) ((uchar) (A)[1])) << 8) +\
 
669
                                  (((uint32_t) ((uchar) (A)[2])) << 16))
708
670
#else
709
671
/*
710
672
   ATTENTION !
714
676
*/
715
677
#define uint3korr(A)    (long) (*((unsigned int *) (A)) & 0xFFFFFF)
716
678
#endif /* HAVE_purify */
717
 
#define uint4korr(A)    (*((uint32 *) (A)))
718
 
#define uint5korr(A)    ((uint64_t)(((uint32) ((uchar) (A)[0])) +\
719
 
                                    (((uint32) ((uchar) (A)[1])) << 8) +\
720
 
                                    (((uint32) ((uchar) (A)[2])) << 16) +\
721
 
                                    (((uint32) ((uchar) (A)[3])) << 24)) +\
 
679
#define uint4korr(A)    (*((uint32_t *) (A)))
 
680
#define uint5korr(A)    ((uint64_t)(((uint32_t) ((uchar) (A)[0])) +\
 
681
                                    (((uint32_t) ((uchar) (A)[1])) << 8) +\
 
682
                                    (((uint32_t) ((uchar) (A)[2])) << 16) +\
 
683
                                    (((uint32_t) ((uchar) (A)[3])) << 24)) +\
722
684
                                    (((uint64_t) ((uchar) (A)[4])) << 32))
723
 
#define uint6korr(A)    ((uint64_t)(((uint32)    ((uchar) (A)[0]))          + \
724
 
                                     (((uint32)    ((uchar) (A)[1])) << 8)   + \
725
 
                                     (((uint32)    ((uchar) (A)[2])) << 16)  + \
726
 
                                     (((uint32)    ((uchar) (A)[3])) << 24)) + \
 
685
#define uint6korr(A)    ((uint64_t)(((uint32_t)    ((uchar) (A)[0]))          + \
 
686
                                     (((uint32_t)    ((uchar) (A)[1])) << 8)   + \
 
687
                                     (((uint32_t)    ((uchar) (A)[2])) << 16)  + \
 
688
                                     (((uint32_t)    ((uchar) (A)[3])) << 24)) + \
727
689
                         (((uint64_t) ((uchar) (A)[4])) << 32) +       \
728
690
                         (((uint64_t) ((uchar) (A)[5])) << 40))
729
691
#define uint8korr(A)    (*((uint64_t *) (A)))
730
692
#define sint8korr(A)    (*((int64_t *) (A)))
731
 
#define int2store(T,A)  *((uint16*) (T))= (uint16) (A)
 
693
#define int2store(T,A)  *((uint16_t*) (T))= (uint16_t) (A)
732
694
#define int3store(T,A)  do { *(T)=  (uchar) ((A));\
733
695
                            *(T+1)=(uchar) (((uint) (A) >> 8));\
734
696
                            *(T+2)=(uchar) (((A) >> 16)); } while (0)
770
732
  We're here if it's not a IA-32 architecture (Win32 and UNIX IA-32 defines
771
733
  were done before)
772
734
*/
773
 
#define sint2korr(A)    (int16) (((int16) ((uchar) (A)[0])) +\
774
 
                                 ((int16) ((int16) (A)[1]) << 8))
775
 
#define sint3korr(A)    ((int32) ((((uchar) (A)[2]) & 128) ? \
776
 
                                  (((uint32) 255L << 24) | \
777
 
                                   (((uint32) (uchar) (A)[2]) << 16) |\
778
 
                                   (((uint32) (uchar) (A)[1]) << 8) | \
779
 
                                   ((uint32) (uchar) (A)[0])) : \
780
 
                                  (((uint32) (uchar) (A)[2]) << 16) |\
781
 
                                  (((uint32) (uchar) (A)[1]) << 8) | \
782
 
                                  ((uint32) (uchar) (A)[0])))
783
 
#define sint4korr(A)    (int32) (((int32) ((uchar) (A)[0])) +\
784
 
                                (((int32) ((uchar) (A)[1]) << 8)) +\
785
 
                                (((int32) ((uchar) (A)[2]) << 16)) +\
786
 
                                (((int32) ((int16) (A)[3]) << 24)))
 
735
#define sint2korr(A)    (int16_t) (((int16_t) ((uchar) (A)[0])) +\
 
736
                                 ((int16_t) ((int16_t) (A)[1]) << 8))
 
737
#define sint3korr(A)    ((int32_t) ((((uchar) (A)[2]) & 128) ? \
 
738
                                  (((uint32_t) 255L << 24) | \
 
739
                                   (((uint32_t) (uchar) (A)[2]) << 16) |\
 
740
                                   (((uint32_t) (uchar) (A)[1]) << 8) | \
 
741
                                   ((uint32_t) (uchar) (A)[0])) : \
 
742
                                  (((uint32_t) (uchar) (A)[2]) << 16) |\
 
743
                                  (((uint32_t) (uchar) (A)[1]) << 8) | \
 
744
                                  ((uint32_t) (uchar) (A)[0])))
 
745
#define sint4korr(A)    (int32_t) (((int32_t) ((uchar) (A)[0])) +\
 
746
                                (((int32_t) ((uchar) (A)[1]) << 8)) +\
 
747
                                (((int32_t) ((uchar) (A)[2]) << 16)) +\
 
748
                                (((int32_t) ((int16_t) (A)[3]) << 24)))
787
749
#define sint8korr(A)    (int64_t) uint8korr(A)
788
 
#define uint2korr(A)    (uint16) (((uint16) ((uchar) (A)[0])) +\
789
 
                                  ((uint16) ((uchar) (A)[1]) << 8))
790
 
#define uint3korr(A)    (uint32) (((uint32) ((uchar) (A)[0])) +\
791
 
                                  (((uint32) ((uchar) (A)[1])) << 8) +\
792
 
                                  (((uint32) ((uchar) (A)[2])) << 16))
793
 
#define uint4korr(A)    (uint32) (((uint32) ((uchar) (A)[0])) +\
794
 
                                  (((uint32) ((uchar) (A)[1])) << 8) +\
795
 
                                  (((uint32) ((uchar) (A)[2])) << 16) +\
796
 
                                  (((uint32) ((uchar) (A)[3])) << 24))
797
 
#define uint5korr(A)    ((uint64_t)(((uint32) ((uchar) (A)[0])) +\
798
 
                                    (((uint32) ((uchar) (A)[1])) << 8) +\
799
 
                                    (((uint32) ((uchar) (A)[2])) << 16) +\
800
 
                                    (((uint32) ((uchar) (A)[3])) << 24)) +\
 
750
#define uint2korr(A)    (uint16_t) (((uint16_t) ((uchar) (A)[0])) +\
 
751
                                  ((uint16_t) ((uchar) (A)[1]) << 8))
 
752
#define uint3korr(A)    (uint32_t) (((uint32_t) ((uchar) (A)[0])) +\
 
753
                                  (((uint32_t) ((uchar) (A)[1])) << 8) +\
 
754
                                  (((uint32_t) ((uchar) (A)[2])) << 16))
 
755
#define uint4korr(A)    (uint32_t) (((uint32_t) ((uchar) (A)[0])) +\
 
756
                                  (((uint32_t) ((uchar) (A)[1])) << 8) +\
 
757
                                  (((uint32_t) ((uchar) (A)[2])) << 16) +\
 
758
                                  (((uint32_t) ((uchar) (A)[3])) << 24))
 
759
#define uint5korr(A)    ((uint64_t)(((uint32_t) ((uchar) (A)[0])) +\
 
760
                                    (((uint32_t) ((uchar) (A)[1])) << 8) +\
 
761
                                    (((uint32_t) ((uchar) (A)[2])) << 16) +\
 
762
                                    (((uint32_t) ((uchar) (A)[3])) << 24)) +\
801
763
                                    (((uint64_t) ((uchar) (A)[4])) << 32))
802
 
#define uint6korr(A)    ((uint64_t)(((uint32)    ((uchar) (A)[0]))          + \
803
 
                                     (((uint32)    ((uchar) (A)[1])) << 8)   + \
804
 
                                     (((uint32)    ((uchar) (A)[2])) << 16)  + \
805
 
                                     (((uint32)    ((uchar) (A)[3])) << 24)) + \
 
764
#define uint6korr(A)    ((uint64_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)) + \
806
768
                         (((uint64_t) ((uchar) (A)[4])) << 32) +       \
807
769
                         (((uint64_t) ((uchar) (A)[5])) << 40))
808
 
#define uint8korr(A)    ((uint64_t)(((uint32) ((uchar) (A)[0])) +\
809
 
                                    (((uint32) ((uchar) (A)[1])) << 8) +\
810
 
                                    (((uint32) ((uchar) (A)[2])) << 16) +\
811
 
                                    (((uint32) ((uchar) (A)[3])) << 24)) +\
812
 
                        (((uint64_t) (((uint32) ((uchar) (A)[4])) +\
813
 
                                    (((uint32) ((uchar) (A)[5])) << 8) +\
814
 
                                    (((uint32) ((uchar) (A)[6])) << 16) +\
815
 
                                    (((uint32) ((uchar) (A)[7])) << 24))) <<\
 
770
#define uint8korr(A)    ((uint64_t)(((uint32_t) ((uchar) (A)[0])) +\
 
771
                                    (((uint32_t) ((uchar) (A)[1])) << 8) +\
 
772
                                    (((uint32_t) ((uchar) (A)[2])) << 16) +\
 
773
                                    (((uint32_t) ((uchar) (A)[3])) << 24)) +\
 
774
                        (((uint64_t) (((uint32_t) ((uchar) (A)[4])) +\
 
775
                                    (((uint32_t) ((uchar) (A)[5])) << 8) +\
 
776
                                    (((uint32_t) ((uchar) (A)[6])) << 16) +\
 
777
                                    (((uint32_t) ((uchar) (A)[7])) << 24))) <<\
816
778
                                    32))
817
779
#define int2store(T,A)       do { uint def_temp= (uint) (A) ;\
818
780
                                  *((uchar*) (T))=  (uchar)(def_temp); \
910
872
  Macro for reading 32-bit integer from network byte order (big-endian)
911
873
  from unaligned memory location.
912
874
*/
913
 
#define int4net(A)        (int32) (((uint32) ((uchar) (A)[3]))        |\
914
 
                                  (((uint32) ((uchar) (A)[2])) << 8)  |\
915
 
                                  (((uint32) ((uchar) (A)[1])) << 16) |\
916
 
                                  (((uint32) ((uchar) (A)[0])) << 24))
 
875
#define int4net(A)        (int32_t) (((uint32_t) ((uchar) (A)[3]))        |\
 
876
                                  (((uint32_t) ((uchar) (A)[2])) << 8)  |\
 
877
                                  (((uint32_t) ((uchar) (A)[1])) << 16) |\
 
878
                                  (((uint32_t) ((uchar) (A)[0])) << 24))
917
879
/*
918
880
  Define-funktions for reading and storing in machine format from/to
919
881
  short/long to/from some place in memory V should be a (not
922
884
 
923
885
#ifdef WORDS_BIGENDIAN
924
886
 
925
 
#define ushortget(V,M)  do { V = (uint16) (((uint16) ((uchar) (M)[1]))+\
926
 
                                 ((uint16) ((uint16) (M)[0]) << 8)); } while(0)
 
887
#define ushortget(V,M)  do { V = (uint16_t) (((uint16_t) ((uchar) (M)[1]))+\
 
888
                                 ((uint16_t) ((uint16_t) (M)[0]) << 8)); } while(0)
927
889
#define shortget(V,M)   do { V = (short) (((short) ((uchar) (M)[1]))+\
928
890
                                 ((short) ((short) (M)[0]) << 8)); } while(0)
929
 
#define longget(V,M)    do { int32 def_temp;\
 
891
#define longget(V,M)    do { int32_t def_temp;\
930
892
                             ((uchar*) &def_temp)[0]=(M)[0];\
931
893
                             ((uchar*) &def_temp)[1]=(M)[1];\
932
894
                             ((uchar*) &def_temp)[2]=(M)[2];\
933
895
                             ((uchar*) &def_temp)[3]=(M)[3];\
934
896
                             (V)=def_temp; } while(0)
935
 
#define ulongget(V,M)   do { uint32 def_temp;\
 
897
#define ulongget(V,M)   do { uint32_t def_temp;\
936
898
                            ((uchar*) &def_temp)[0]=(M)[0];\
937
899
                            ((uchar*) &def_temp)[1]=(M)[1];\
938
900
                            ((uchar*) &def_temp)[2]=(M)[2];\