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))
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)
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))) <<\
817
779
#define int2store(T,A) do { uint def_temp= (uint) (A) ;\
818
780
*((uchar*) (T))= (uchar)(def_temp); \
923
885
#ifdef WORDS_BIGENDIAN
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];\