752{
753
755
756#ifdef DYNAMIC_CRC_TABLE
757 once(&made, make_crc_table);
758#endif
759
760
761 crc = (~crc) & 0xffffffff;
762
763#ifdef W
764
765
766 if (
len >=
N *
W +
W - 1) {
768 z_word_t const *words;
769 unsigned endian;
771
772
776 }
777
778
779 blks =
len / (
N *
W);
781 words = (z_word_t
const *)
buf;
782
783
784
785
786
787 endian = 1;
788 if (*(unsigned char *)&endian) {
789
790
792 z_word_t word0;
793#if N > 1
795 z_word_t word1;
796#if N > 2
798 z_word_t word2;
799#if N > 3
801 z_word_t word3;
802#if N > 4
804 z_word_t word4;
805#if N > 5
807 z_word_t word5;
808#endif
809#endif
810#endif
811#endif
812#endif
813
814
815 crc0 = crc;
816#if N > 1
817 crc1 = 0;
818#if N > 2
819 crc2 = 0;
820#if N > 3
821 crc3 = 0;
822#if N > 4
823 crc4 = 0;
824#if N > 5
825 crc5 = 0;
826#endif
827#endif
828#endif
829#endif
830#endif
831
832
833
834
835
836 while (--blks) {
837
838 word0 = crc0 ^ words[0];
839#if N > 1
840 word1 = crc1 ^ words[1];
841#if N > 2
842 word2 = crc2 ^ words[2];
843#if N > 3
844 word3 = crc3 ^ words[3];
845#if N > 4
846 word4 = crc4 ^ words[4];
847#if N > 5
848 word5 = crc5 ^ words[5];
849#endif
850#endif
851#endif
852#endif
853#endif
855
856
857
858 crc0 = crc_braid_table[0][word0 & 0xff];
859#if N > 1
860 crc1 = crc_braid_table[0][word1 & 0xff];
861#if N > 2
862 crc2 = crc_braid_table[0][word2 & 0xff];
863#if N > 3
864 crc3 = crc_braid_table[0][word3 & 0xff];
865#if N > 4
866 crc4 = crc_braid_table[0][word4 & 0xff];
867#if N > 5
868 crc5 = crc_braid_table[0][word5 & 0xff];
869#endif
870#endif
871#endif
872#endif
873#endif
874 for (
k = 1;
k <
W;
k++) {
875 crc0 ^= crc_braid_table[
k][(word0 >> (
k << 3)) & 0xff];
876#if N > 1
877 crc1 ^= crc_braid_table[
k][(word1 >> (
k << 3)) & 0xff];
878#if N > 2
879 crc2 ^= crc_braid_table[
k][(word2 >> (
k << 3)) & 0xff];
880#if N > 3
881 crc3 ^= crc_braid_table[
k][(word3 >> (
k << 3)) & 0xff];
882#if N > 4
883 crc4 ^= crc_braid_table[
k][(word4 >> (
k << 3)) & 0xff];
884#if N > 5
885 crc5 ^= crc_braid_table[
k][(word5 >> (
k << 3)) & 0xff];
886#endif
887#endif
888#endif
889#endif
890#endif
891 }
892 }
893
894
895
896
897
898 crc = crc_word(crc0 ^ words[0]);
899#if N > 1
900 crc = crc_word(crc1 ^ words[1] ^ crc);
901#if N > 2
902 crc = crc_word(crc2 ^ words[2] ^ crc);
903#if N > 3
904 crc = crc_word(crc3 ^ words[3] ^ crc);
905#if N > 4
906 crc = crc_word(crc4 ^ words[4] ^ crc);
907#if N > 5
908 crc = crc_word(crc5 ^ words[5] ^ crc);
909#endif
910#endif
911#endif
912#endif
913#endif
915 }
916 else {
917
918
919 z_word_t crc0, word0, comb;
920#if N > 1
921 z_word_t crc1, word1;
922#if N > 2
923 z_word_t crc2, word2;
924#if N > 3
925 z_word_t crc3, word3;
926#if N > 4
927 z_word_t crc4, word4;
928#if N > 5
929 z_word_t crc5, word5;
930#endif
931#endif
932#endif
933#endif
934#endif
935
936
937 crc0 = byte_swap(crc);
938#if N > 1
939 crc1 = 0;
940#if N > 2
941 crc2 = 0;
942#if N > 3
943 crc3 = 0;
944#if N > 4
945 crc4 = 0;
946#if N > 5
947 crc5 = 0;
948#endif
949#endif
950#endif
951#endif
952#endif
953
954
955
956
957
958 while (--blks) {
959
960 word0 = crc0 ^ words[0];
961#if N > 1
962 word1 = crc1 ^ words[1];
963#if N > 2
964 word2 = crc2 ^ words[2];
965#if N > 3
966 word3 = crc3 ^ words[3];
967#if N > 4
968 word4 = crc4 ^ words[4];
969#if N > 5
970 word5 = crc5 ^ words[5];
971#endif
972#endif
973#endif
974#endif
975#endif
977
978
979
980 crc0 = crc_braid_big_table[0][word0 & 0xff];
981#if N > 1
982 crc1 = crc_braid_big_table[0][word1 & 0xff];
983#if N > 2
984 crc2 = crc_braid_big_table[0][word2 & 0xff];
985#if N > 3
986 crc3 = crc_braid_big_table[0][word3 & 0xff];
987#if N > 4
988 crc4 = crc_braid_big_table[0][word4 & 0xff];
989#if N > 5
990 crc5 = crc_braid_big_table[0][word5 & 0xff];
991#endif
992#endif
993#endif
994#endif
995#endif
996 for (
k = 1;
k <
W;
k++) {
997 crc0 ^= crc_braid_big_table[
k][(word0 >> (
k << 3)) & 0xff];
998#if N > 1
999 crc1 ^= crc_braid_big_table[
k][(word1 >> (
k << 3)) & 0xff];
1000#if N > 2
1001 crc2 ^= crc_braid_big_table[
k][(word2 >> (
k << 3)) & 0xff];
1002#if N > 3
1003 crc3 ^= crc_braid_big_table[
k][(word3 >> (
k << 3)) & 0xff];
1004#if N > 4
1005 crc4 ^= crc_braid_big_table[
k][(word4 >> (
k << 3)) & 0xff];
1006#if N > 5
1007 crc5 ^= crc_braid_big_table[
k][(word5 >> (
k << 3)) & 0xff];
1008#endif
1009#endif
1010#endif
1011#endif
1012#endif
1013 }
1014 }
1015
1016
1017
1018
1019
1020 comb = crc_word_big(crc0 ^ words[0]);
1021#if N > 1
1022 comb = crc_word_big(crc1 ^ words[1] ^ comb);
1023#if N > 2
1024 comb = crc_word_big(crc2 ^ words[2] ^ comb);
1025#if N > 3
1026 comb = crc_word_big(crc3 ^ words[3] ^ comb);
1027#if N > 4
1028 comb = crc_word_big(crc4 ^ words[4] ^ comb);
1029#if N > 5
1030 comb = crc_word_big(crc5 ^ words[5] ^ comb);
1031#endif
1032#endif
1033#endif
1034#endif
1035#endif
1037 crc = byte_swap(comb);
1038 }
1039
1040
1041
1042
1043 buf = (
unsigned char const *)words;
1044 }
1045
1046#endif
1047
1048
1059 }
1063 }
1064
1065
1066 return crc ^ 0xffffffff;
1067}
const z_crc_t FAR crc_table[]