~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to include/my_global.h

  • Committer: Brian Aker
  • Date: 2008-07-22 18:31:32 UTC
  • Revision ID: brian@tangent.org-20080722183132-ne2ntl7g7mdf2eez
uint32 -> uin32_t

Show diffs side-by-side

added added

removed removed

Lines of Context:
431
431
        /* Unsigned types supported by the compiler */
432
432
#define UNSINT8                 /* unsigned int8 (char) */
433
433
#define UNSINT16                /* unsigned int16 */
434
 
#define UNSINT32                /* unsigned int32 */
 
434
#define UNSINT32                /* unsigned int32_t */
435
435
 
436
436
        /* General constants */
437
437
#define SC_MAXWIDTH     256     /* Max width of screen (for error messages) */
606
606
#ifndef HAVE_INT8
607
607
typedef signed char int8;       /* Signed integer >= 8  bits */
608
608
#endif
 
609
 
609
610
#ifndef HAVE_UINT8
610
611
typedef unsigned char uint8;    /* Unsigned integer >= 8  bits */
611
612
#endif
 
613
 
612
614
#ifndef HAVE_INT16
613
615
typedef short int16;
614
616
#endif
 
617
 
615
618
#ifndef HAVE_UINT16
616
619
typedef unsigned short uint16;
617
620
#endif
618
 
#if SIZEOF_INT == 4
619
 
#ifndef HAVE_INT32
620
 
typedef int int32;
621
 
#endif
622
 
#ifndef HAVE_UINT32
623
 
typedef unsigned int uint32;
624
 
#endif
625
 
#elif SIZEOF_LONG == 4
626
 
#ifndef HAVE_INT32
627
 
typedef long int32;
628
 
#endif
629
 
#ifndef HAVE_UINT32
630
 
typedef unsigned long uint32;
631
 
#endif
632
 
#else
633
 
#error Neither int or long is of 4 bytes width
634
 
#endif
635
621
 
636
622
#if !defined(HAVE_ULONG) && !defined(__USE_MISC)
637
623
typedef uint32_t        ulong;            /* Short for unsigned long */
638
624
#endif
639
 
#ifndef int64_t_defined
640
 
/* 
641
 
  Using [unsigned] long long is preferable as [u]int64_t because we use 
642
 
  [unsigned] long long unconditionally in many places, 
643
 
  for example in constants with [U]LL suffix.
644
 
*/
645
 
typedef int64_t int64_t;
646
 
#endif
647
625
 
648
626
#define MY_ERRPTR ((void*)(intptr)1)
649
627
 
676
654
        /* Macros for converting *constants* to the right type */
677
655
#define INT8(v)         (int8) (v)
678
656
#define INT16(v)        (int16) (v)
679
 
#define INT32(v)        (int32) (v)
 
657
#define INT32(v)        (int32_t) (v)
680
658
#define MYF(v)          (myf) (v)
681
659
 
682
660
/* Defines for time function */
695
673
/* Optimized store functions for Intel x86 */
696
674
#if defined(__i386__)
697
675
#define sint2korr(A)    (*((int16 *) (A)))
698
 
#define sint3korr(A)    ((int32) ((((uchar) (A)[2]) & 128) ? \
699
 
                                  (((uint32) 255L << 24) | \
700
 
                                   (((uint32) (uchar) (A)[2]) << 16) |\
701
 
                                   (((uint32) (uchar) (A)[1]) << 8) | \
702
 
                                   ((uint32) (uchar) (A)[0])) : \
703
 
                                  (((uint32) (uchar) (A)[2]) << 16) |\
704
 
                                  (((uint32) (uchar) (A)[1]) << 8) | \
705
 
                                  ((uint32) (uchar) (A)[0])))
 
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])))
706
684
#define sint4korr(A)    (*((long *) (A)))
707
685
#define uint2korr(A)    (*((uint16 *) (A)))
708
686
#if defined(HAVE_purify)
709
 
#define uint3korr(A)    (uint32) (((uint32) ((uchar) (A)[0])) +\
710
 
                                  (((uint32) ((uchar) (A)[1])) << 8) +\
711
 
                                  (((uint32) ((uchar) (A)[2])) << 16))
 
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))
712
690
#else
713
691
/*
714
692
   ATTENTION !
718
696
*/
719
697
#define uint3korr(A)    (long) (*((unsigned int *) (A)) & 0xFFFFFF)
720
698
#endif /* HAVE_purify */
721
 
#define uint4korr(A)    (*((uint32 *) (A)))
722
 
#define uint5korr(A)    ((uint64_t)(((uint32) ((uchar) (A)[0])) +\
723
 
                                    (((uint32) ((uchar) (A)[1])) << 8) +\
724
 
                                    (((uint32) ((uchar) (A)[2])) << 16) +\
725
 
                                    (((uint32) ((uchar) (A)[3])) << 24)) +\
 
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)) +\
726
704
                                    (((uint64_t) ((uchar) (A)[4])) << 32))
727
 
#define uint6korr(A)    ((uint64_t)(((uint32)    ((uchar) (A)[0]))          + \
728
 
                                     (((uint32)    ((uchar) (A)[1])) << 8)   + \
729
 
                                     (((uint32)    ((uchar) (A)[2])) << 16)  + \
730
 
                                     (((uint32)    ((uchar) (A)[3])) << 24)) + \
 
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)) + \
731
709
                         (((uint64_t) ((uchar) (A)[4])) << 32) +       \
732
710
                         (((uint64_t) ((uchar) (A)[5])) << 40))
733
711
#define uint8korr(A)    (*((uint64_t *) (A)))
776
754
*/
777
755
#define sint2korr(A)    (int16) (((int16) ((uchar) (A)[0])) +\
778
756
                                 ((int16) ((int16) (A)[1]) << 8))
779
 
#define sint3korr(A)    ((int32) ((((uchar) (A)[2]) & 128) ? \
780
 
                                  (((uint32) 255L << 24) | \
781
 
                                   (((uint32) (uchar) (A)[2]) << 16) |\
782
 
                                   (((uint32) (uchar) (A)[1]) << 8) | \
783
 
                                   ((uint32) (uchar) (A)[0])) : \
784
 
                                  (((uint32) (uchar) (A)[2]) << 16) |\
785
 
                                  (((uint32) (uchar) (A)[1]) << 8) | \
786
 
                                  ((uint32) (uchar) (A)[0])))
787
 
#define sint4korr(A)    (int32) (((int32) ((uchar) (A)[0])) +\
788
 
                                (((int32) ((uchar) (A)[1]) << 8)) +\
789
 
                                (((int32) ((uchar) (A)[2]) << 16)) +\
790
 
                                (((int32) ((int16) (A)[3]) << 24)))
 
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)))
791
769
#define sint8korr(A)    (int64_t) uint8korr(A)
792
770
#define uint2korr(A)    (uint16) (((uint16) ((uchar) (A)[0])) +\
793
771
                                  ((uint16) ((uchar) (A)[1]) << 8))
794
 
#define uint3korr(A)    (uint32) (((uint32) ((uchar) (A)[0])) +\
795
 
                                  (((uint32) ((uchar) (A)[1])) << 8) +\
796
 
                                  (((uint32) ((uchar) (A)[2])) << 16))
797
 
#define uint4korr(A)    (uint32) (((uint32) ((uchar) (A)[0])) +\
798
 
                                  (((uint32) ((uchar) (A)[1])) << 8) +\
799
 
                                  (((uint32) ((uchar) (A)[2])) << 16) +\
800
 
                                  (((uint32) ((uchar) (A)[3])) << 24))
801
 
#define uint5korr(A)    ((uint64_t)(((uint32) ((uchar) (A)[0])) +\
802
 
                                    (((uint32) ((uchar) (A)[1])) << 8) +\
803
 
                                    (((uint32) ((uchar) (A)[2])) << 16) +\
804
 
                                    (((uint32) ((uchar) (A)[3])) << 24)) +\
 
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)) +\
805
783
                                    (((uint64_t) ((uchar) (A)[4])) << 32))
806
 
#define uint6korr(A)    ((uint64_t)(((uint32)    ((uchar) (A)[0]))          + \
807
 
                                     (((uint32)    ((uchar) (A)[1])) << 8)   + \
808
 
                                     (((uint32)    ((uchar) (A)[2])) << 16)  + \
809
 
                                     (((uint32)    ((uchar) (A)[3])) << 24)) + \
 
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)) + \
810
788
                         (((uint64_t) ((uchar) (A)[4])) << 32) +       \
811
789
                         (((uint64_t) ((uchar) (A)[5])) << 40))
812
 
#define uint8korr(A)    ((uint64_t)(((uint32) ((uchar) (A)[0])) +\
813
 
                                    (((uint32) ((uchar) (A)[1])) << 8) +\
814
 
                                    (((uint32) ((uchar) (A)[2])) << 16) +\
815
 
                                    (((uint32) ((uchar) (A)[3])) << 24)) +\
816
 
                        (((uint64_t) (((uint32) ((uchar) (A)[4])) +\
817
 
                                    (((uint32) ((uchar) (A)[5])) << 8) +\
818
 
                                    (((uint32) ((uchar) (A)[6])) << 16) +\
819
 
                                    (((uint32) ((uchar) (A)[7])) << 24))) <<\
 
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))) <<\
820
798
                                    32))
821
799
#define int2store(T,A)       do { uint def_temp= (uint) (A) ;\
822
800
                                  *((uchar*) (T))=  (uchar)(def_temp); \
914
892
  Macro for reading 32-bit integer from network byte order (big-endian)
915
893
  from unaligned memory location.
916
894
*/
917
 
#define int4net(A)        (int32) (((uint32) ((uchar) (A)[3]))        |\
918
 
                                  (((uint32) ((uchar) (A)[2])) << 8)  |\
919
 
                                  (((uint32) ((uchar) (A)[1])) << 16) |\
920
 
                                  (((uint32) ((uchar) (A)[0])) << 24))
 
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))
921
899
/*
922
900
  Define-funktions for reading and storing in machine format from/to
923
901
  short/long to/from some place in memory V should be a (not
930
908
                                 ((uint16) ((uint16) (M)[0]) << 8)); } while(0)
931
909
#define shortget(V,M)   do { V = (short) (((short) ((uchar) (M)[1]))+\
932
910
                                 ((short) ((short) (M)[0]) << 8)); } while(0)
933
 
#define longget(V,M)    do { int32 def_temp;\
 
911
#define longget(V,M)    do { int32_t def_temp;\
934
912
                             ((uchar*) &def_temp)[0]=(M)[0];\
935
913
                             ((uchar*) &def_temp)[1]=(M)[1];\
936
914
                             ((uchar*) &def_temp)[2]=(M)[2];\
937
915
                             ((uchar*) &def_temp)[3]=(M)[3];\
938
916
                             (V)=def_temp; } while(0)
939
 
#define ulongget(V,M)   do { uint32 def_temp;\
 
917
#define ulongget(V,M)   do { uint32_t def_temp;\
940
918
                            ((uchar*) &def_temp)[0]=(M)[0];\
941
919
                            ((uchar*) &def_temp)[1]=(M)[1];\
942
920
                            ((uchar*) &def_temp)[2]=(M)[2];\