2021-05-17 19:48:21 +08:00
|
|
|
From 1ae8eea237f05a590d8da38528dceab8a7b4290b Mon Sep 17 00:00:00 2001
|
|
|
|
|
From: Euler Hanzh <18221254@bjtu.edu.cn>
|
|
|
|
|
Date: Mon, 17 May 2021 19:28:18 +0800
|
|
|
|
|
Subject: [PATCH] This patch is created for performance optimization in crc calculation only suitable for openeuler of aarch64 architecture.
|
|
|
|
|
The speed of unzip software when running can be accelerate by nearly 100% than before.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
unzip60/crc32.c | 28 ++++++++++++++++++++++++++++
|
|
|
|
|
unzip60/crc32.h | 4 ++++
|
|
|
|
|
unzip60/unix/Makefile | 19 ++++++++++++++-----
|
|
|
|
|
3 files changed, 46 insertions(+), 5 deletions(-)
|
|
|
|
|
|
|
|
|
|
diff --git a/unzip60/crc32.c b/unzip60/crc32.c
|
|
|
|
|
index 02f504d..fa73a3e 100644
|
|
|
|
|
--- a/unzip60/crc32.c
|
|
|
|
|
+++ b/unzip60/crc32.c
|
|
|
|
|
@@ -675,7 +675,32 @@ void free_crc_table()
|
|
|
|
|
|
2021-05-12 15:15:28 +08:00
|
|
|
#endif /* (IZ_CRC_BE_OPTIMIZ || IZ_CRC_LE_OPTIMIZ) */
|
2021-05-17 19:48:21 +08:00
|
|
|
|
2021-05-12 15:15:28 +08:00
|
|
|
+#ifdef ARCH_AARCH64
|
|
|
|
|
+u_int32_t crc32(u_int32_t crc,const u_int8_t *p, unsigned int len)
|
|
|
|
|
+{
|
2021-05-17 19:48:21 +08:00
|
|
|
+ int64_t length = len;
|
2021-05-12 15:15:28 +08:00
|
|
|
+
|
2021-05-17 19:48:21 +08:00
|
|
|
+ while ((length -= sizeof(u_int64_t)) >=0) {
|
|
|
|
|
+ __builtin_aarch64_crc32cx(crc, *((u_int64_t *)p));
|
|
|
|
|
+ p += sizeof(u_int64_t);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ if (length & sizeof(u_int32_t)) {
|
|
|
|
|
+ __builtin_aarch64_crc32cw(crc, *((u_int32_t *)p));
|
|
|
|
|
+ p += sizeof(u_int32_t);
|
|
|
|
|
+ }
|
2021-05-12 15:15:28 +08:00
|
|
|
+
|
2021-05-17 19:48:21 +08:00
|
|
|
+ if (length & sizeof(u_int16_t)) {
|
|
|
|
|
+ __builtin_aarch64_crc32ch(crc, *((u_int16_t *)p));
|
|
|
|
|
+ p += sizeof(u_int16_t);
|
|
|
|
|
+ }
|
2021-05-12 15:15:28 +08:00
|
|
|
+
|
2021-05-17 19:48:21 +08:00
|
|
|
+ if (length & sizeof(u_int8_t))
|
|
|
|
|
+ __builtin_aarch64_crc32cb(crc, *p);
|
2021-05-12 15:15:28 +08:00
|
|
|
+
|
2021-05-17 19:48:21 +08:00
|
|
|
+ return crc;
|
2021-05-12 15:15:28 +08:00
|
|
|
+}
|
|
|
|
|
+#else
|
|
|
|
|
/* ========================================================================= */
|
|
|
|
|
ulg crc32(crc, buf, len)
|
|
|
|
|
ulg crc; /* crc shift register */
|
2021-05-17 19:48:21 +08:00
|
|
|
@@ -726,6 +751,9 @@ ulg crc32(crc, buf, len)
|
|
|
|
|
|
2021-05-12 15:15:28 +08:00
|
|
|
return REV_BE(c) ^ 0xffffffffL; /* (instead of ~c for 64-bit machines) */
|
|
|
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+#endif /* !ARCH_AARCH64*/
|
|
|
|
|
+
|
|
|
|
|
#endif /* !ASM_CRC */
|
|
|
|
|
#endif /* !CRC_TABLE_ONLY */
|
|
|
|
|
#endif /* !USE_ZLIB */
|
2021-05-17 19:48:21 +08:00
|
|
|
diff --git a/unzip60/crc32.h b/unzip60/crc32.h
|
|
|
|
|
index 83af240..b5e386a 100644
|
|
|
|
|
--- a/unzip60/crc32.h
|
|
|
|
|
+++ b/unzip60/crc32.h
|
2021-05-12 15:15:28 +08:00
|
|
|
@@ -36,7 +36,11 @@
|
|
|
|
|
# undef IZ_CRC_BE_OPTIMIZ
|
|
|
|
|
# endif
|
|
|
|
|
#else /* !(USE_ZLIB || CRC_TABLE_ONLY) */
|
|
|
|
|
+# ifdef ARCH_AARCH64
|
2021-05-17 19:48:21 +08:00
|
|
|
+ u_int32_t crc32(u_int32_t crc,const u_int8_t *p, unsigned int len);
|
2021-05-12 15:15:28 +08:00
|
|
|
+# else
|
2021-05-17 19:48:21 +08:00
|
|
|
ulg crc32 OF((ulg crc, ZCONST uch *buf, extent len));
|
2021-05-12 15:15:28 +08:00
|
|
|
+# endif
|
|
|
|
|
#endif /* ?(USE_ZLIB || CRC_TABLE_ONLY) */
|
2021-05-17 19:48:21 +08:00
|
|
|
|
2021-05-12 15:15:28 +08:00
|
|
|
#ifndef CRC_32_TAB
|
2021-05-17 19:48:21 +08:00
|
|
|
diff --git a/unzip60/unix/Makefile b/unzip60/unix/Makefile
|
|
|
|
|
index ab32270..39b2263 100644
|
|
|
|
|
--- a/unzip60/unix/Makefile
|
|
|
|
|
+++ b/unzip60/unix/Makefile
|
2021-05-12 15:15:28 +08:00
|
|
|
@@ -40,7 +40,8 @@
|
2021-05-17 19:48:21 +08:00
|
|
|
|
2021-05-12 15:15:28 +08:00
|
|
|
# Defaults most systems use (use LOCAL_UNZIP in environment to add flags,
|
|
|
|
|
# such as -DDOSWILD).
|
|
|
|
|
-
|
|
|
|
|
+TARGET_ARCH = $(shell uname -m)
|
|
|
|
|
+ARCH = $(shell getconf LONG_BIT)
|
|
|
|
|
# UnZip flags
|
2021-05-17 19:48:21 +08:00
|
|
|
CC = cc# try using "gcc" target rather than changing this (CC and LD
|
|
|
|
|
LD = $(CC)# must match, else "unresolved symbol: ___main" is possible)
|
|
|
|
|
@@ -54,6 +55,12 @@ LFLAGS1 =
|
2021-05-12 15:15:28 +08:00
|
|
|
LF = -o unzip$E $(LFLAGS1)
|
|
|
|
|
LF2 = -s
|
2021-05-17 19:48:21 +08:00
|
|
|
|
2021-05-12 15:15:28 +08:00
|
|
|
+ifeq ($(TARGET_ARCH),aarch64)
|
|
|
|
|
+CFF = -DARCH=$(ARCH) -march=armv8.1-a -D ARCH_AARCH64
|
|
|
|
|
+else
|
|
|
|
|
+CFF =
|
|
|
|
|
+endif
|
|
|
|
|
+
|
|
|
|
|
# UnZipSFX flags
|
|
|
|
|
SL = -o unzipsfx$E $(LFLAGS1)
|
|
|
|
|
SL2 = $(LF2)
|
2021-05-17 19:48:21 +08:00
|
|
|
@@ -77,6 +84,8 @@ M = unix
|
2021-05-12 15:15:28 +08:00
|
|
|
SHELL = /bin/sh
|
|
|
|
|
MAKEF = -f unix/Makefile
|
2021-05-17 19:48:21 +08:00
|
|
|
|
2021-05-12 15:15:28 +08:00
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
# Version info for unix/unix.c
|
|
|
|
|
HOST_VERSINFO=-DIZ_CC_NAME='\"\$$(CC) \"' -DIZ_OS_NAME='\"`uname -a`\"'
|
2021-05-17 19:48:21 +08:00
|
|
|
|
|
|
|
|
@@ -231,13 +240,13 @@ generic_msg:
|
2021-05-12 15:15:28 +08:00
|
|
|
# yes, we should be able to use the $O macro to combine these two, but it
|
|
|
|
|
# fails on some brain-damaged makes (e.g., AIX's)...no big deal
|
|
|
|
|
.c.o:
|
2021-05-17 19:48:21 +08:00
|
|
|
- $(CC) -c $(CF) $*.c
|
|
|
|
|
+ $(CC) -c $(CF) $(CFF) $*.c
|
|
|
|
|
|
2021-05-12 15:15:28 +08:00
|
|
|
.c.obj:
|
2021-05-17 19:48:21 +08:00
|
|
|
- $(CC) -c $(CF) $*.c
|
|
|
|
|
+ $(CC) -c $(CF) $(CFF) $*.c
|
|
|
|
|
|
2021-05-12 15:15:28 +08:00
|
|
|
.c.pic.o:
|
2021-05-17 19:48:21 +08:00
|
|
|
- $(CC) -c $(CF) -o $@ $*.c
|
|
|
|
|
+ $(CC) -c $(CF) $(CFF) -o $@ $*.c
|
|
|
|
|
|
2021-05-12 15:15:28 +08:00
|
|
|
# this doesn't work...directories are always a pain with implicit rules
|
2021-05-17 19:48:21 +08:00
|
|
|
#.1.txt: man/$<
|
|
|
|
|
@@ -329,7 +338,7 @@ unzipsfx$O: unzip.c $(UNZIP_H) crypt.h unzvers.h consts.h
|
|
|
|
|
$(CC) -c $(CF) -DSFX -o $@ unzip.c
|
|
|
|
|
|
|
|
|
|
crc32_$O: crc32.c $(UNZIP_H) zip.h crc32.h
|
|
|
|
|
- $(CC) -c $(CF) -DSFX -o $@ crc32.c
|
|
|
|
|
+ $(CC) -c $(CF) -DSFX $(CFF) -o $@ crc32.c
|
|
|
|
|
|
|
|
|
|
crypt_$O: crypt.c $(UNZIP_H) zip.h crypt.h crc32.h ttyio.h
|
|
|
|
|
$(CC) -c $(CF) -DSFX -o $@ crypt.c
|
|
|
|
|
--
|
|
|
|
|
2.23.0
|
|
|
|
|
|
|
|
|
|
|