98
98
# endif
99
99
#endif
100
100
101
+ /* If available, use the ARM processor CRC32 instruction. */
102
+ #if defined(__aarch64__ ) && defined(__ARM_FEATURE_CRC32 ) && W == 8
103
+ # define ARMCRC32
104
+ #endif
105
+
101
106
/* Local functions. */
102
107
local z_crc_t multmodp OF ( (z_crc_t a , z_crc_t b ));
103
108
local z_crc_t x2nmodp OF ( (z_off64_t n , unsigned k ));
104
109
105
- /* If available, use the ARM processor CRC32 instruction. */
106
- #if defined(__aarch64__ ) && defined(__ARM_FEATURE_CRC32 ) && W == 8
107
- # define ARMCRC32
110
+ #if defined(W ) && (!defined(ARMCRC32 ) || defined(DYNAMIC_CRC_TABLE ))
111
+ local z_word_t byte_swap OF ( (z_word_t word ));
112
+ #endif
113
+
114
+ #if defined(W ) && !defined(ARMCRC32 )
115
+ local z_crc_t crc_word OF ( (z_word_t data ));
116
+ local z_word_t crc_word_big OF ( (z_word_t data ));
108
117
#endif
109
118
110
119
#if defined(W ) && (!defined(ARMCRC32 ) || defined(DYNAMIC_CRC_TABLE ))
@@ -630,7 +639,7 @@ unsigned long ZEXPORT crc32_z(crc, buf, len)
630
639
#endif /* DYNAMIC_CRC_TABLE */
631
640
632
641
/* Pre-condition the CRC */
633
- crc ^= 0xffffffff ;
642
+ crc = (~ crc ) & 0xffffffff ;
634
643
635
644
/* Compute the CRC up to a word boundary. */
636
645
while (len && ((z_size_t )buf & 7 ) != 0 ) {
@@ -645,8 +654,8 @@ unsigned long ZEXPORT crc32_z(crc, buf, len)
645
654
len &= 7 ;
646
655
647
656
/* Do three interleaved CRCs to realize the throughput of one crc32x
648
- instruction per cycle. Each CRC is calcuated on Z_BATCH words. The three
649
- CRCs are combined into a single CRC after each set of batches. */
657
+ instruction per cycle. Each CRC is calculated on Z_BATCH words. The
658
+ three CRCs are combined into a single CRC after each set of batches. */
650
659
while (num >= 3 * Z_BATCH ) {
651
660
crc1 = 0 ;
652
661
crc2 = 0 ;
@@ -749,7 +758,7 @@ unsigned long ZEXPORT crc32_z(crc, buf, len)
749
758
#endif /* DYNAMIC_CRC_TABLE */
750
759
751
760
/* Pre-condition the CRC */
752
- crc ^= 0xffffffff ;
761
+ crc = (~ crc ) & 0xffffffff ;
753
762
754
763
#ifdef W
755
764
@@ -1077,7 +1086,7 @@ uLong ZEXPORT crc32_combine64(crc1, crc2, len2)
1077
1086
#ifdef DYNAMIC_CRC_TABLE
1078
1087
once (& made , make_crc_table );
1079
1088
#endif /* DYNAMIC_CRC_TABLE */
1080
- return multmodp (x2nmodp (len2 , 3 ), crc1 ) ^ crc2 ;
1089
+ return multmodp (x2nmodp (len2 , 3 ), crc1 ) ^ ( crc2 & 0xffffffff ) ;
1081
1090
}
1082
1091
1083
1092
/* ========================================================================= */
@@ -1086,7 +1095,7 @@ uLong ZEXPORT crc32_combine(crc1, crc2, len2)
1086
1095
uLong crc2 ;
1087
1096
z_off_t len2 ;
1088
1097
{
1089
- return crc32_combine64 (crc1 , crc2 , len2 );
1098
+ return crc32_combine64 (crc1 , crc2 , ( z_off64_t ) len2 );
1090
1099
}
1091
1100
1092
1101
/* ========================================================================= */
@@ -1103,14 +1112,14 @@ uLong ZEXPORT crc32_combine_gen64(len2)
1103
1112
uLong ZEXPORT crc32_combine_gen (len2 )
1104
1113
z_off_t len2 ;
1105
1114
{
1106
- return crc32_combine_gen64 (len2 );
1115
+ return crc32_combine_gen64 (( z_off64_t ) len2 );
1107
1116
}
1108
1117
1109
1118
/* ========================================================================= */
1110
- uLong crc32_combine_op (crc1 , crc2 , op )
1119
+ uLong ZEXPORT crc32_combine_op (crc1 , crc2 , op )
1111
1120
uLong crc1 ;
1112
1121
uLong crc2 ;
1113
1122
uLong op ;
1114
1123
{
1115
- return multmodp (op , crc1 ) ^ crc2 ;
1124
+ return multmodp (op , crc1 ) ^ ( crc2 & 0xffffffff ) ;
1116
1125
}
0 commit comments