5656#define POLY 0x82f63b78
5757
5858/* Block sizes for three-way parallel crc computation. LONG and SHORT must
59- both be powers of two. The associated string constants must be set
60- accordingly, for use in constructing the assembler instructions. */
59+ both be powers of two. */
6160#define LONG 8192
62- #define LONGx1 "8192"
63- #define LONGx2 "16384"
6461#define SHORT 256
65- #define SHORTx1 "256"
66- #define SHORTx2 "512"
6762
6863#ifndef GEN_CRC32C_TABLES
6964#include "crc32c-tables.c"
@@ -100,9 +95,9 @@ static uint32_t crc32c_sse42(uint32_t crc, const char *buf, size_t len)
10095 /* compute the crc for up to seven leading bytes to bring the data pointer
10196 to an eight-byte boundary */
10297 while (len && ((uintptr_t )buf & 7 ) != 0 ) {
103- __asm__("crc32b\t" "(%1) , %0"
98+ __asm__("crc32b\t" "%1 , %0"
10499 : "+r" (crc0 )
105- : "r" ( buf ), " m" (* buf ));
100+ : "m" (* buf ));
106101 buf ++ ;
107102 len -- ;
108103 }
@@ -114,14 +109,13 @@ static uint32_t crc32c_sse42(uint32_t crc, const char *buf, size_t len)
114109 uintptr_t crc2 = 0 ;
115110 const char * end = buf + LONG ;
116111 do {
117- __asm__(CRC32_PTR "\t" "(%3) , %0\n\t"
118- CRC32_PTR "\t" LONGx1 "(%3) , %1\n\t"
119- CRC32_PTR "\t" LONGx2 "(%3) , %2"
112+ __asm__(CRC32_PTR "\t%3 , %0\n\t"
113+ CRC32_PTR "\t%4 , %1\n\t"
114+ CRC32_PTR "\t%5 , %2"
120115 : "+r" (crc0 ), "+r" (crc1 ), "+r" (crc2 )
121- : "r" (buf ),
122- "m" (* (const char (* )[sizeof (void * )]) & buf [0 ]),
123- "m" (* (const char (* )[sizeof (void * )]) & buf [LONG ]),
124- "m" (* (const char (* )[sizeof (void * )]) & buf [LONG * 2 ]));
116+ : "m" (* (const uintptr_t * ) & buf [0 ]),
117+ "m" (* (const uintptr_t * ) & buf [LONG ]),
118+ "m" (* (const uintptr_t * ) & buf [LONG * 2 ]));
125119 buf += sizeof (void * );
126120 } while (buf < end );
127121 crc0 = crc32c_shift (crc32c_long , crc0 ) ^ crc1 ;
@@ -137,14 +131,13 @@ static uint32_t crc32c_sse42(uint32_t crc, const char *buf, size_t len)
137131 uintptr_t crc2 = 0 ;
138132 const char * end = buf + SHORT ;
139133 do {
140- __asm__(CRC32_PTR "\t" "(%3) , %0\n\t"
141- CRC32_PTR "\t" SHORTx1 "(%3) , %1\n\t"
142- CRC32_PTR "\t" SHORTx2 "(%3) , %2"
134+ __asm__(CRC32_PTR "\t%3 , %0\n\t"
135+ CRC32_PTR "\t%4 , %1\n\t"
136+ CRC32_PTR "\t%5 , %2"
143137 : "+r" (crc0 ), "+r" (crc1 ), "+r" (crc2 )
144- : "r" (buf ),
145- "m" (* (const char (* )[sizeof (void * )]) & buf [0 ]),
146- "m" (* (const char (* )[sizeof (void * )]) & buf [SHORT ]),
147- "m" (* (const char (* )[sizeof (void * )]) & buf [SHORT * 2 ]));
138+ : "m" (* (const uintptr_t * ) & buf [0 ]),
139+ "m" (* (const uintptr_t * ) & buf [SHORT ]),
140+ "m" (* (const uintptr_t * ) & buf [SHORT * 2 ]));
148141 buf += sizeof (void * );
149142 } while (buf < end );
150143 crc0 = crc32c_shift (crc32c_short , crc0 ) ^ crc1 ;
@@ -157,18 +150,18 @@ static uint32_t crc32c_sse42(uint32_t crc, const char *buf, size_t len)
157150 block */
158151 const char * end = buf + (len - (len & 7 ));
159152 while (buf < end ) {
160- __asm__(CRC32_PTR "\t" "(%1) , %0"
153+ __asm__(CRC32_PTR "\t" "%1 , %0"
161154 : "+r" (crc0 )
162- : "r" ( buf ), " m" (* (const char ( * )[ sizeof ( void * )] ) buf ));
155+ : "m" (* (const uintptr_t * ) buf ));
163156 buf += sizeof (void * );
164157 }
165158 len &= 7 ;
166159
167160 /* compute the crc for up to seven trailing bytes */
168161 while (len ) {
169- __asm__("crc32b\t" "(%1) , %0"
162+ __asm__("crc32b\t" "%1 , %0"
170163 : "+r" (crc0 )
171- : "r" ( buf ), " m" (* buf ));
164+ : "m" (* buf ));
172165 buf ++ ;
173166 len -- ;
174167 }
0 commit comments