]> git.lizzy.rs Git - zlib.git/commitdiff
Use ARM crc32 instructions if the ARM architecture has them.
authorMark Adler <madler@alumni.caltech.edu>
Mon, 18 Feb 2019 04:45:53 +0000 (20:45 -0800)
committerMark Adler <madler@alumni.caltech.edu>
Mon, 18 Feb 2019 04:49:29 +0000 (20:49 -0800)
The ARM crc32 instructions will be used only if an architecture is
explicitly specified at compile time that has those instructions.
For example, -march=armv8.1-a or -march=armv8-a+crc, or if the
machine being compiled on has the instructions, -march=native.

crc32.c

diff --git a/crc32.c b/crc32.c
index 2d2082904048b1a19eaeb2bfd203245e94cfc23b..7503972b5b0c27f5a1a91d4853c376aaf5ca8a5b 100644 (file)
--- a/crc32.c
+++ b/crc32.c
@@ -618,11 +618,15 @@ const z_crc_t FAR * ZEXPORT get_crc_table()
 }
 
 /* =========================================================================
- * Use ARM machine instructions if requested. This will compute the CRC about
+ * Use ARM machine instructions if available. This will compute the CRC about
  * ten times faster than the braided calculation. This code does not check for
- * the presence of the CRC instruction. Compile with care.
+ * the presence of the CRC instruction at run time. __ARM_FEATURE_CRC32 will
+ * only be defined if the compilation specifies an ARM processor architecture
+ * that has the instructions. For example, compiling with -march=armv8.1-a or
+ * -march=armv8-a+crc, or -march=native if the compile machine has the crc32
+ * instructions.
  */
-#if defined(Z_ARM_CRC32) && defined(__aarch64__) && W == 8
+#if defined(__aarch64__) && defined(__ARM_FEATURE_CRC32) && W == 8
 
 /*
    Constants empirically determined to maximize speed. These values are from