~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/global.h

  • Committer: Monty Taylor
  • Date: 2008-09-16 04:26:53 UTC
  • mto: This revision was merged to the branch mainline in revision 391.
  • Revision ID: monty@inaugust.com-20080916042653-59fgd0y0lbw6ohna
Oh dear god the changes. The changes. I'd tell you what they are, but I'd just be making stuff up. Suffice it to day it's mostly all around splitting files in libdrizzle into different files and removing interdepends. And whatever else I happened to see... 

Show diffs side-by-side

added added

removed removed

Lines of Context:
495
495
#define O_NOFOLLOW      0
496
496
#endif
497
497
 
498
 
/* #define USE_RECORD_LOCK      */
499
 
 
500
 
        /* Unsigned types supported by the compiler */
501
 
#define UNSINT8                 /* unsigned int8_t (char) */
502
 
#define UNSINT16                /* unsigned int16_t */
503
 
#define UNSINT32                /* unsigned int32_t */
504
 
 
505
 
        /* General constants */
506
 
#define SC_MAXWIDTH     256     /* Max width of screen (for error messages) */
507
 
#define FN_LEN          256     /* Max file name len */
508
 
#define FN_HEADLEN      253     /* Max length of filepart of file name */
509
 
#define FN_EXTLEN       20      /* Max length of extension (part of FN_LEN) */
510
 
#define FN_REFLEN       512     /* Max length of full path-name */
511
 
#define FN_EXTCHAR      '.'
512
 
#define FN_HOMELIB      '~'     /* ~/ is used as abbrev for home dir */
513
 
#define FN_CURLIB       '.'     /* ./ is used as abbrev for current dir */
514
 
#define FN_PARENTDIR    ".."    /* Parent directory; Must be a string */
 
498
 
515
499
 
516
500
#ifndef FN_LIBCHAR
517
501
#define FN_LIBCHAR      '/'
527
511
/* #define FN_UPPER_CASE TRUE */
528
512
 
529
513
/*
530
 
  Io buffer size; Must be a power of 2 and a multiple of 512. May be
531
 
  smaller what the disk page size. This influences the speed of the
532
 
  isam btree library. eg to big to slow.
533
 
*/
534
 
#define IO_SIZE                 4096
535
 
/*
536
514
  How much overhead does malloc have. The code often allocates
537
515
  something like 1024-MALLOC_OVERHEAD bytes
538
516
*/
713
691
 
714
692
 
715
693
 
716
 
/*
717
 
  Define-funktions for reading and storing in machine independent format
718
 
  (low byte first)
719
 
*/
720
 
 
721
 
/* Optimized store functions for Intel x86 */
722
 
#if defined(__i386__)
723
 
#define sint2korr(A)    (*((int16_t *) (A)))
724
 
#define sint3korr(A)    ((int32_t) ((((uchar) (A)[2]) & 128) ? \
725
 
                                  (((uint32_t) 255L << 24) | \
726
 
                                   (((uint32_t) (uchar) (A)[2]) << 16) |\
727
 
                                   (((uint32_t) (uchar) (A)[1]) << 8) | \
728
 
                                   ((uint32_t) (uchar) (A)[0])) : \
729
 
                                  (((uint32_t) (uchar) (A)[2]) << 16) |\
730
 
                                  (((uint32_t) (uchar) (A)[1]) << 8) | \
731
 
                                  ((uint32_t) (uchar) (A)[0])))
732
 
#define sint4korr(A)    (*((long *) (A)))
733
 
#define uint2korr(A)    (*((uint16_t *) (A)))
734
 
#if defined(HAVE_purify)
735
 
#define uint3korr(A)    (uint32_t) (((uint32_t) ((uchar) (A)[0])) +\
736
 
                                  (((uint32_t) ((uchar) (A)[1])) << 8) +\
737
 
                                  (((uint32_t) ((uchar) (A)[2])) << 16))
738
 
#else
739
 
/*
740
 
   ATTENTION !
741
 
   
742
 
    Please, note, uint3korr reads 4 bytes (not 3) !
743
 
    It means, that you have to provide enough allocated space !
744
 
*/
745
 
#define uint3korr(A)    (long) (*((unsigned int *) (A)) & 0xFFFFFF)
746
 
#endif /* HAVE_purify */
747
 
#define uint4korr(A)    (*((uint32_t *) (A)))
748
 
#define uint5korr(A)    ((uint64_t)(((uint32_t) ((uchar) (A)[0])) +\
749
 
                                    (((uint32_t) ((uchar) (A)[1])) << 8) +\
750
 
                                    (((uint32_t) ((uchar) (A)[2])) << 16) +\
751
 
                                    (((uint32_t) ((uchar) (A)[3])) << 24)) +\
752
 
                                    (((uint64_t) ((uchar) (A)[4])) << 32))
753
 
#define uint6korr(A)    ((uint64_t)(((uint32_t)    ((uchar) (A)[0]))          + \
754
 
                                     (((uint32_t)    ((uchar) (A)[1])) << 8)   + \
755
 
                                     (((uint32_t)    ((uchar) (A)[2])) << 16)  + \
756
 
                                     (((uint32_t)    ((uchar) (A)[3])) << 24)) + \
757
 
                         (((uint64_t) ((uchar) (A)[4])) << 32) +       \
758
 
                         (((uint64_t) ((uchar) (A)[5])) << 40))
759
 
#define uint8korr(A)    (*((uint64_t *) (A)))
760
 
#define sint8korr(A)    (*((int64_t *) (A)))
761
 
#define int2store(T,A)  *((uint16_t*) (T))= (uint16_t) (A)
762
 
#define int3store(T,A)  do { *(T)=  (uchar) ((A));\
763
 
                            *(T+1)=(uchar) (((uint) (A) >> 8));\
764
 
                            *(T+2)=(uchar) (((A) >> 16)); } while (0)
765
 
#define int4store(T,A)  *((long *) (T))= (long) (A)
766
 
#define int5store(T,A)  do { *(T)= (uchar)((A));\
767
 
                             *((T)+1)=(uchar) (((A) >> 8));\
768
 
                             *((T)+2)=(uchar) (((A) >> 16));\
769
 
                             *((T)+3)=(uchar) (((A) >> 24)); \
770
 
                             *((T)+4)=(uchar) (((A) >> 32)); } while(0)
771
 
#define int6store(T,A)  do { *(T)=    (uchar)((A));          \
772
 
                             *((T)+1)=(uchar) (((A) >> 8));  \
773
 
                             *((T)+2)=(uchar) (((A) >> 16)); \
774
 
                             *((T)+3)=(uchar) (((A) >> 24)); \
775
 
                             *((T)+4)=(uchar) (((A) >> 32)); \
776
 
                             *((T)+5)=(uchar) (((A) >> 40)); } while(0)
777
 
#define int8store(T,A)  *((uint64_t *) (T))= (uint64_t) (A)
778
 
 
779
 
typedef union {
780
 
  double v;
781
 
  long m[2];
782
 
} doubleget_union;
783
 
#define doubleget(V,M)  \
784
 
do { doubleget_union _tmp; \
785
 
     _tmp.m[0] = *((long*)(M)); \
786
 
     _tmp.m[1] = *(((long*) (M))+1); \
787
 
     (V) = _tmp.v; } while(0)
788
 
#define doublestore(T,V) do { *((long *) T) = ((doubleget_union *)&V)->m[0]; \
789
 
                             *(((long *) T)+1) = ((doubleget_union *)&V)->m[1]; \
790
 
                         } while (0)
791
 
#define float4get(V,M)   do { *((float *) &(V)) = *((float*) (M)); } while(0)
792
 
#define float8get(V,M)   doubleget((V),(M))
793
 
#define float4store(V,M) memcpy(V, (&M), sizeof(float))
794
 
#define floatstore(T,V)  memcpy((T), (&V), sizeof(float))
795
 
#define floatget(V,M)    memcpy(&V, (M), sizeof(float))
796
 
#define float8store(V,M) doublestore((V),(M))
797
 
#else
798
 
 
799
 
/*
800
 
  We're here if it's not a IA-32 architecture (Win32 and UNIX IA-32 defines
801
 
  were done before)
802
 
*/
803
 
#define sint2korr(A)    (int16_t) (((int16_t) ((uchar) (A)[0])) +\
804
 
                                 ((int16_t) ((int16_t) (A)[1]) << 8))
805
 
#define sint3korr(A)    ((int32_t) ((((uchar) (A)[2]) & 128) ? \
806
 
                                  (((uint32_t) 255L << 24) | \
807
 
                                   (((uint32_t) (uchar) (A)[2]) << 16) |\
808
 
                                   (((uint32_t) (uchar) (A)[1]) << 8) | \
809
 
                                   ((uint32_t) (uchar) (A)[0])) : \
810
 
                                  (((uint32_t) (uchar) (A)[2]) << 16) |\
811
 
                                  (((uint32_t) (uchar) (A)[1]) << 8) | \
812
 
                                  ((uint32_t) (uchar) (A)[0])))
813
 
#define sint4korr(A)    (int32_t) (((int32_t) ((uchar) (A)[0])) +\
814
 
                                (((int32_t) ((uchar) (A)[1]) << 8)) +\
815
 
                                (((int32_t) ((uchar) (A)[2]) << 16)) +\
816
 
                                (((int32_t) ((int16_t) (A)[3]) << 24)))
817
 
#define sint8korr(A)    (int64_t) uint8korr(A)
818
 
#define uint2korr(A)    (uint16_t) (((uint16_t) ((uchar) (A)[0])) +\
819
 
                                  ((uint16_t) ((uchar) (A)[1]) << 8))
820
 
#define uint3korr(A)    (uint32_t) (((uint32_t) ((uchar) (A)[0])) +\
821
 
                                  (((uint32_t) ((uchar) (A)[1])) << 8) +\
822
 
                                  (((uint32_t) ((uchar) (A)[2])) << 16))
823
 
#define uint4korr(A)    (uint32_t) (((uint32_t) ((uchar) (A)[0])) +\
824
 
                                  (((uint32_t) ((uchar) (A)[1])) << 8) +\
825
 
                                  (((uint32_t) ((uchar) (A)[2])) << 16) +\
826
 
                                  (((uint32_t) ((uchar) (A)[3])) << 24))
827
 
#define uint5korr(A)    ((uint64_t)(((uint32_t) ((uchar) (A)[0])) +\
828
 
                                    (((uint32_t) ((uchar) (A)[1])) << 8) +\
829
 
                                    (((uint32_t) ((uchar) (A)[2])) << 16) +\
830
 
                                    (((uint32_t) ((uchar) (A)[3])) << 24)) +\
831
 
                                    (((uint64_t) ((uchar) (A)[4])) << 32))
832
 
#define uint6korr(A)    ((uint64_t)(((uint32_t)    ((uchar) (A)[0]))          + \
833
 
                                     (((uint32_t)    ((uchar) (A)[1])) << 8)   + \
834
 
                                     (((uint32_t)    ((uchar) (A)[2])) << 16)  + \
835
 
                                     (((uint32_t)    ((uchar) (A)[3])) << 24)) + \
836
 
                         (((uint64_t) ((uchar) (A)[4])) << 32) +       \
837
 
                         (((uint64_t) ((uchar) (A)[5])) << 40))
838
 
#define uint8korr(A)    ((uint64_t)(((uint32_t) ((uchar) (A)[0])) +\
839
 
                                    (((uint32_t) ((uchar) (A)[1])) << 8) +\
840
 
                                    (((uint32_t) ((uchar) (A)[2])) << 16) +\
841
 
                                    (((uint32_t) ((uchar) (A)[3])) << 24)) +\
842
 
                        (((uint64_t) (((uint32_t) ((uchar) (A)[4])) +\
843
 
                                    (((uint32_t) ((uchar) (A)[5])) << 8) +\
844
 
                                    (((uint32_t) ((uchar) (A)[6])) << 16) +\
845
 
                                    (((uint32_t) ((uchar) (A)[7])) << 24))) <<\
846
 
                                    32))
847
 
#define int2store(T,A)       do { uint def_temp= (uint) (A) ;\
848
 
                                  *((uchar*) (T))=  (uchar)(def_temp); \
849
 
                                   *((uchar*) (T)+1)=(uchar)((def_temp >> 8)); \
850
 
                             } while(0)
851
 
#define int3store(T,A)       do { /*lint -save -e734 */\
852
 
                                  *((uchar*)(T))=(uchar) ((A));\
853
 
                                  *((uchar*) (T)+1)=(uchar) (((A) >> 8));\
854
 
                                  *((uchar*)(T)+2)=(uchar) (((A) >> 16)); \
855
 
                                  /*lint -restore */} while(0)
856
 
#define int4store(T,A)       do { *((char *)(T))=(char) ((A));\
857
 
                                  *(((char *)(T))+1)=(char) (((A) >> 8));\
858
 
                                  *(((char *)(T))+2)=(char) (((A) >> 16));\
859
 
                                  *(((char *)(T))+3)=(char) (((A) >> 24)); } while(0)
860
 
#define int5store(T,A)       do { *((char *)(T))=     (char)((A));  \
861
 
                                  *(((char *)(T))+1)= (char)(((A) >> 8)); \
862
 
                                  *(((char *)(T))+2)= (char)(((A) >> 16)); \
863
 
                                  *(((char *)(T))+3)= (char)(((A) >> 24)); \
864
 
                                  *(((char *)(T))+4)= (char)(((A) >> 32)); \
865
 
                                } while(0)
866
 
#define int6store(T,A)       do { *((char *)(T))=     (char)((A)); \
867
 
                                  *(((char *)(T))+1)= (char)(((A) >> 8)); \
868
 
                                  *(((char *)(T))+2)= (char)(((A) >> 16)); \
869
 
                                  *(((char *)(T))+3)= (char)(((A) >> 24)); \
870
 
                                  *(((char *)(T))+4)= (char)(((A) >> 32)); \
871
 
                                  *(((char *)(T))+5)= (char)(((A) >> 40)); \
872
 
                                } while(0)
873
 
#define int8store(T,A)       do { uint def_temp= (uint) (A), def_temp2= (uint) ((A) >> 32); \
874
 
                                  int4store((T),def_temp); \
875
 
                                  int4store((T+4),def_temp2); } while(0)
876
 
#ifdef WORDS_BIGENDIAN
877
 
#define float4store(T,A) do { *(T)= ((uchar *) &A)[3];\
878
 
                              *((T)+1)=(char) ((uchar *) &A)[2];\
879
 
                              *((T)+2)=(char) ((uchar *) &A)[1];\
880
 
                              *((T)+3)=(char) ((uchar *) &A)[0]; } while(0)
881
 
 
882
 
#define float4get(V,M)   do { float def_temp;\
883
 
                              ((uchar*) &def_temp)[0]=(M)[3];\
884
 
                              ((uchar*) &def_temp)[1]=(M)[2];\
885
 
                              ((uchar*) &def_temp)[2]=(M)[1];\
886
 
                              ((uchar*) &def_temp)[3]=(M)[0];\
887
 
                              (V)=def_temp; } while(0)
888
 
#define float8store(T,V) do { *(T)= ((uchar *) &V)[7];\
889
 
                              *((T)+1)=(char) ((uchar *) &V)[6];\
890
 
                              *((T)+2)=(char) ((uchar *) &V)[5];\
891
 
                              *((T)+3)=(char) ((uchar *) &V)[4];\
892
 
                              *((T)+4)=(char) ((uchar *) &V)[3];\
893
 
                              *((T)+5)=(char) ((uchar *) &V)[2];\
894
 
                              *((T)+6)=(char) ((uchar *) &V)[1];\
895
 
                              *((T)+7)=(char) ((uchar *) &V)[0]; } while(0)
896
 
 
897
 
#define float8get(V,M)   do { double def_temp;\
898
 
                              ((uchar*) &def_temp)[0]=(M)[7];\
899
 
                              ((uchar*) &def_temp)[1]=(M)[6];\
900
 
                              ((uchar*) &def_temp)[2]=(M)[5];\
901
 
                              ((uchar*) &def_temp)[3]=(M)[4];\
902
 
                              ((uchar*) &def_temp)[4]=(M)[3];\
903
 
                              ((uchar*) &def_temp)[5]=(M)[2];\
904
 
                              ((uchar*) &def_temp)[6]=(M)[1];\
905
 
                              ((uchar*) &def_temp)[7]=(M)[0];\
906
 
                              (V) = def_temp; } while(0)
907
 
#else
908
 
#define float4get(V,M)   memcpy(&V, (M), sizeof(float))
909
 
#define float4store(V,M) memcpy(V, (&M), sizeof(float))
910
 
 
911
 
#if defined(__FLOAT_WORD_ORDER) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN)
912
 
#define doublestore(T,V) do { *(((char*)T)+0)=(char) ((uchar *) &V)[4];\
913
 
                              *(((char*)T)+1)=(char) ((uchar *) &V)[5];\
914
 
                              *(((char*)T)+2)=(char) ((uchar *) &V)[6];\
915
 
                              *(((char*)T)+3)=(char) ((uchar *) &V)[7];\
916
 
                              *(((char*)T)+4)=(char) ((uchar *) &V)[0];\
917
 
                              *(((char*)T)+5)=(char) ((uchar *) &V)[1];\
918
 
                              *(((char*)T)+6)=(char) ((uchar *) &V)[2];\
919
 
                              *(((char*)T)+7)=(char) ((uchar *) &V)[3]; }\
920
 
                         while(0)
921
 
#define doubleget(V,M)   do { double def_temp;\
922
 
                              ((uchar*) &def_temp)[0]=(M)[4];\
923
 
                              ((uchar*) &def_temp)[1]=(M)[5];\
924
 
                              ((uchar*) &def_temp)[2]=(M)[6];\
925
 
                              ((uchar*) &def_temp)[3]=(M)[7];\
926
 
                              ((uchar*) &def_temp)[4]=(M)[0];\
927
 
                              ((uchar*) &def_temp)[5]=(M)[1];\
928
 
                              ((uchar*) &def_temp)[6]=(M)[2];\
929
 
                              ((uchar*) &def_temp)[7]=(M)[3];\
930
 
                              (V) = def_temp; } while(0)
931
 
#endif /* __FLOAT_WORD_ORDER */
932
 
 
933
 
#define float8get(V,M)   doubleget((V),(M))
934
 
#define float8store(V,M) doublestore((V),(M))
935
 
#endif /* WORDS_BIGENDIAN */
936
 
 
937
 
#endif /* __i386__ */
938
 
 
939
 
/*
940
 
  Macro for reading 32-bit integer from network byte order (big-endian)
941
 
  from unaligned memory location.
942
 
*/
943
 
#define int4net(A)        (int32_t) (((uint32_t) ((uchar) (A)[3]))        |\
944
 
                                  (((uint32_t) ((uchar) (A)[2])) << 8)  |\
945
 
                                  (((uint32_t) ((uchar) (A)[1])) << 16) |\
946
 
                                  (((uint32_t) ((uchar) (A)[0])) << 24))
947
 
/*
948
 
  Define-funktions for reading and storing in machine format from/to
949
 
  short/long to/from some place in memory V should be a (not
950
 
  register) variable, M is a pointer to byte
951
 
*/
952
 
 
953
 
#ifdef WORDS_BIGENDIAN
954
 
 
955
 
#define ushortget(V,M)  do { V = (uint16_t) (((uint16_t) ((uchar) (M)[1]))+\
956
 
                                 ((uint16_t) ((uint16_t) (M)[0]) << 8)); } while(0)
957
 
#define shortget(V,M)   do { V = (short) (((short) ((uchar) (M)[1]))+\
958
 
                                 ((short) ((short) (M)[0]) << 8)); } while(0)
959
 
#define longget(V,M)    do { int32_t def_temp;\
960
 
                             ((uchar*) &def_temp)[0]=(M)[0];\
961
 
                             ((uchar*) &def_temp)[1]=(M)[1];\
962
 
                             ((uchar*) &def_temp)[2]=(M)[2];\
963
 
                             ((uchar*) &def_temp)[3]=(M)[3];\
964
 
                             (V)=def_temp; } while(0)
965
 
#define ulongget(V,M)   do { uint32_t def_temp;\
966
 
                            ((uchar*) &def_temp)[0]=(M)[0];\
967
 
                            ((uchar*) &def_temp)[1]=(M)[1];\
968
 
                            ((uchar*) &def_temp)[2]=(M)[2];\
969
 
                            ((uchar*) &def_temp)[3]=(M)[3];\
970
 
                            (V)=def_temp; } while(0)
971
 
#define shortstore(T,A) do { uint def_temp=(uint) (A) ;\
972
 
                             *(((char*)T)+1)=(char)(def_temp); \
973
 
                             *(((char*)T)+0)=(char)(def_temp >> 8); } while(0)
974
 
#define longstore(T,A)  do { *(((char*)T)+3)=((A));\
975
 
                             *(((char*)T)+2)=(((A) >> 8));\
976
 
                             *(((char*)T)+1)=(((A) >> 16));\
977
 
                             *(((char*)T)+0)=(((A) >> 24)); } while(0)
978
 
 
979
 
#define floatget(V,M)     memcpy(&V, (M), sizeof(float))
980
 
#define floatstore(T, V)   memcpy((T), (&V), sizeof(float))
981
 
#define doubleget(V, M)   memcpy(&V, (M), sizeof(double))
982
 
#define doublestore(T, V)  memcpy((T), &V, sizeof(double))
983
 
#define int64_tget(V, M)   memcpy(&V, (M), sizeof(uint64_t))
984
 
#define int64_tstore(T, V) memcpy((T), &V, sizeof(uint64_t))
985
 
 
986
 
#else
987
 
 
988
 
#define ushortget(V,M)  do { V = uint2korr(M); } while(0)
989
 
#define shortget(V,M)   do { V = sint2korr(M); } while(0)
990
 
#define longget(V,M)    do { V = sint4korr(M); } while(0)
991
 
#define ulongget(V,M)   do { V = uint4korr(M); } while(0)
992
 
#define shortstore(T,V) int2store(T,V)
993
 
#define longstore(T,V)  int4store(T,V)
994
 
#ifndef floatstore
995
 
#define floatstore(T,V)   memcpy((T), (&V), sizeof(float))
996
 
#define floatget(V,M)     memcpy(&V, (M), sizeof(float))
997
 
#endif
998
 
#ifndef doubleget
999
 
#define doubleget(V, M)   memcpy(&V, (M), sizeof(double))
1000
 
#define doublestore(T,V)  memcpy((T), &V, sizeof(double))
1001
 
#endif /* doubleget */
1002
 
#define int64_tget(V,M)   memcpy(&V, (M), sizeof(uint64_t))
1003
 
#define int64_tstore(T,V) memcpy((T), &V, sizeof(uint64_t))
1004
 
 
1005
 
#endif /* WORDS_BIGENDIAN */
1006
694
 
1007
695
/* my_sprintf  was here. RIP */
1008
696