]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Replace DO1/DO8 macros
authorHans Kristian Rosbach <hk-git@circlestorm.org>
Mon, 17 Feb 2025 19:37:55 +0000 (20:37 +0100)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Tue, 18 Feb 2025 22:59:16 +0000 (23:59 +0100)
adler32_p.h
arch/generic/adler32_c.c
arch/generic/crc32_braid_c.c
arch/x86/crc32_pclmulqdq_tpl.h
crc32_braid_p.h

index 38ba2ad721491a67c0bc7887beba429f30957010..7f814d20c21f71916f495616816a9108731dd6b4 100644 (file)
 #define NMAX 5552
 /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
 
-#define DO1(sum1, sum2, buf, i)  {(sum1) += buf[(i)]; (sum2) += (sum1);}
-#define DO2(sum1, sum2, buf, i)  {DO1(sum1, sum2, buf, i); DO1(sum1, sum2, buf, i+1);}
-#define DO4(sum1, sum2, buf, i)  {DO2(sum1, sum2, buf, i); DO2(sum1, sum2, buf, i+2);}
-#define DO8(sum1, sum2, buf, i)  {DO4(sum1, sum2, buf, i); DO4(sum1, sum2, buf, i+4);}
-#define DO16(sum1, sum2, buf)    {DO8(sum1, sum2, buf, 0); DO8(sum1, sum2, buf, 8);}
+#define ADLER_DO1(sum1, sum2, buf, i)  {(sum1) += buf[(i)]; (sum2) += (sum1);}
+#define ADLER_DO2(sum1, sum2, buf, i)  {ADLER_DO1(sum1, sum2, buf, i); ADLER_DO1(sum1, sum2, buf, i+1);}
+#define ADLER_DO4(sum1, sum2, buf, i)  {ADLER_DO2(sum1, sum2, buf, i); ADLER_DO2(sum1, sum2, buf, i+2);}
+#define ADLER_DO8(sum1, sum2, buf, i)  {ADLER_DO4(sum1, sum2, buf, i); ADLER_DO4(sum1, sum2, buf, i+4);}
+#define ADLER_DO16(sum1, sum2, buf)    {ADLER_DO8(sum1, sum2, buf, 0); ADLER_DO8(sum1, sum2, buf, 8);}
 
 static inline uint32_t adler32_len_1(uint32_t adler, const uint8_t *buf, uint32_t sum2) {
     adler += buf[0];
@@ -54,12 +54,12 @@ static inline uint32_t adler32_len_64(uint32_t adler, const uint8_t *buf, size_t
 #ifdef UNROLL_MORE
     while (len >= 16) {
         len -= 16;
-        DO16(adler, sum2, buf);
+        ADLER_DO16(adler, sum2, buf);
         buf += 16;
 #else
     while (len >= 8) {
         len -= 8;
-        DO8(adler, sum2, buf, 0);
+        ADLER_DO8(adler, sum2, buf, 0);
         buf += 8;
 #endif
     }
index 64258c89b4940f60382f7f1aa23383c53a3d938e..da32c95a3d4b918175d8c3d6487e7b8b1c32ee58 100644 (file)
@@ -38,10 +38,10 @@ Z_INTERNAL uint32_t adler32_c(uint32_t adler, const uint8_t *buf, size_t len) {
 #endif
         do {
 #ifdef UNROLL_MORE
-            DO16(adler, sum2, buf);          /* 16 sums unrolled */
+            ADLER_DO16(adler, sum2, buf);          /* 16 sums unrolled */
             buf += 16;
 #else
-            DO8(adler, sum2, buf, 0);         /* 8 sums unrolled */
+            ADLER_DO8(adler, sum2, buf, 0);         /* 8 sums unrolled */
             buf += 8;
 #endif
         } while (--n);
index 6947cfd8b7a55e5d122530173b1dde1d0d3a48e8..40c5610595b36f381f805ffc8be19c3d0fef5fe2 100644 (file)
@@ -72,7 +72,7 @@ Z_INTERNAL uint32_t crc32_braid_internal(uint32_t c, const uint8_t *buf, size_t
         /* Compute the CRC up to a z_word_t boundary. */
         while (len && ((uintptr_t)buf & (BRAID_W - 1)) != 0) {
             len--;
-            DO1;
+            CRC_DO1;
         }
 
         /* Compute the CRC on as many BRAID_N z_word_t blocks as are available. */
@@ -201,11 +201,11 @@ Z_INTERNAL uint32_t crc32_braid_internal(uint32_t c, const uint8_t *buf, size_t
     /* Complete the computation of the CRC on any remaining bytes. */
     while (len >= 8) {
         len -= 8;
-        DO8;
+        CRC_DO8;
     }
     while (len) {
         len--;
-        DO1;
+        CRC_DO1;
     }
 
     /* Return the CRC, post-conditioned. */
index 55b8f9aabc13fcac621a68d3f7a2f6c373152bbb..53e56ead13fbc25d729e88a3f5a2ff4324ea1c6d 100644 (file)
@@ -398,7 +398,7 @@ static inline uint32_t crc32_small(uint32_t crc, const uint8_t *buf, size_t len)
 
     while (len) {
         len--;
-        DO1;
+        CRC_DO1;
     }
 
     return c ^ 0xffffffff;
index 004cc5cced38561f6dff8a9b435f4ecc58a8d3bd..f78ef71de3949a48bcd765ddc226299bd3cef71a 100644 (file)
@@ -31,8 +31,8 @@
 #  error "No endian defined"
 #endif
 
-#define DO1 c = crc_table[(c ^ *buf++) & 0xff] ^ (c >> 8)
-#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
+#define CRC_DO1 c = crc_table[(c ^ *buf++) & 0xff] ^ (c >> 8)
+#define CRC_DO8 CRC_DO1; CRC_DO1; CRC_DO1; CRC_DO1; CRC_DO1; CRC_DO1; CRC_DO1; CRC_DO1
 
 /* CRC polynomial. */
 #define POLY 0xedb88320         /* p(x) reflected, with x^32 implied */