From 2acf48b246d0984016f9ee734833ffa4f7360060 Mon Sep 17 00:00:00 2001 From: hanzhelii <18221254@bjtu.edu.cn> Date: Wed, 12 May 2021 11:28:13 +0800 Subject: [PATCH 1/7] add openeuler-unzip-6.0-crc-builtin.patch this patch is only useful for openeuler of aarch64 . you can patch it to the source code of unzip6.0 by using following command: " patch -p1 < ../unzip-6.0-crc-builtin.patch " then you can compile and install the unzip software package and use it as usual with a quicker running speed. (cherry picked from commit aaaa9210ee65ac5f341a8854e5f70231987f7463) --- unzip-6.0-crc-builtin.patch | 122 ++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 unzip-6.0-crc-builtin.patch diff --git a/unzip-6.0-crc-builtin.patch b/unzip-6.0-crc-builtin.patch new file mode 100644 index 0000000..c44c6ce --- /dev/null +++ b/unzip-6.0-crc-builtin.patch @@ -0,0 +1,122 @@ +diff -Nabur unzip60/crc32.c unzip604/crc32.c +--- unzip60/crc32.c 2007-01-22 13:34:38.000000000 +0800 ++++ unzip604/crc32.c 2021-05-11 19:27:06.273953956 +0800 +@@ -675,7 +675,32 @@ + + #endif /* (IZ_CRC_BE_OPTIMIZ || IZ_CRC_LE_OPTIMIZ) */ + ++#ifdef ARCH_AARCH64 ++u_int32_t crc32(u_int32_t crc,const u_int8_t *p, unsigned int len) ++{ ++int64_t length = len; ++ ++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); ++} ++ ++if (length & sizeof(u_int16_t)) { ++ __builtin_aarch64_crc32ch(crc, *((u_int16_t *)p)); ++ p += sizeof(u_int16_t); ++} ++ ++if (length & sizeof(u_int8_t)) ++ __builtin_aarch64_crc32cb(crc, *p); ++ ++return crc; ++} ++#else + /* ========================================================================= */ + ulg crc32(crc, buf, len) + ulg crc; /* crc shift register */ +@@ -726,6 +751,9 @@ + + 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 */ +diff -Nabur unzip60/crc32.h unzip604/crc32.h +--- unzip60/crc32.h 2008-03-09 02:40:20.000000000 +0800 ++++ unzip604/crc32.h 2021-05-11 19:24:42.379717503 +0800 +@@ -36,7 +36,11 @@ + # undef IZ_CRC_BE_OPTIMIZ + # endif + #else /* !(USE_ZLIB || CRC_TABLE_ONLY) */ ++# ifdef ARCH_AARCH64 ++ u_int32_t crc32(u_int32_t crc,const u_int8_t *p, unsigned int len); ++# else + ulg crc32 OF((ulg crc, ZCONST uch *buf, extent len)); ++# endif + #endif /* ?(USE_ZLIB || CRC_TABLE_ONLY) */ + + #ifndef CRC_32_TAB +diff -Nabur unzip60/unix/Makefile unzip604/unix/Makefile +--- unzip60/unix/Makefile 2009-01-19 06:41:18.000000000 +0800 ++++ unzip604/unix/Makefile 2021-05-11 19:32:00.946534741 +0800 +@@ -40,7 +40,8 @@ + + # 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 + 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 @@ + LF = -o unzip$E $(LFLAGS1) + LF2 = -s + ++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) +@@ -77,6 +84,8 @@ + SHELL = /bin/sh + MAKEF = -f unix/Makefile + ++ ++ + # Version info for unix/unix.c + HOST_VERSINFO=-DIZ_CC_NAME='\"\$$(CC) \"' -DIZ_OS_NAME='\"`uname -a`\"' + +@@ -231,13 +240,13 @@ + # 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: +- $(CC) -c $(CF) $*.c ++ $(CC) -c $(CF) $(CFF) $*.c + + .c.obj: +- $(CC) -c $(CF) $*.c ++ $(CC) -c $(CF) $(CFF) $*.c + + .c.pic.o: +- $(CC) -c $(CF) -o $@ $*.c ++ $(CC) -c $(CF) $(CFF) -o $@ $*.c + + # this doesn't work...directories are always a pain with implicit rules + #.1.txt: man/$< +@@ -329,7 +338,7 @@ + $(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 -DARCH=$(ARCH) -march=armv8.1-a -o $@ crc32.c + + crypt_$O: crypt.c $(UNZIP_H) zip.h crypt.h crc32.h ttyio.h + $(CC) -c $(CF) -DSFX -o $@ crypt.c -- Gitee From 948bed7689ad664ea1ad23f35954dd82f80c8d56 Mon Sep 17 00:00:00 2001 From: hanzhelii <18221254@bjtu.edu.cn> Date: Wed, 12 May 2021 11:34:14 +0800 Subject: [PATCH 2/7] update unzip.spec. (cherry picked from commit 3a62f23fa6a59e20d222dec814e2bc0beb5f5a9f) --- unzip.spec | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/unzip.spec b/unzip.spec index 86ebf2e..8080749 100644 --- a/unzip.spec +++ b/unzip.spec @@ -1,6 +1,6 @@ Name: unzip Version: 6.0 -Release: 45 +Release: 46 Summary: A utility for unpacking zip files License: BSD URL: http://www.info-zip.org/UnZip.html @@ -36,6 +36,7 @@ Patch6002: CVE-2019-13232.patch Patch6003: CVE-2019-13232-fur1.patch Patch9000: CVE-2019-13232-fur2.patch +Patch12000: unzip-6.0-crc-builtin.patch BuildRequires: bzip2-devel @@ -70,6 +71,9 @@ Package help includes man pages for unzip. %{_mandir}/man1/* %changelog +* Tues May 12 2021 openEuler hanzhelii <18221254@bjtu.edu.cn> - 6.0-46 +- add unzip-6.0-crc-builtin.patch + * Mon Mar 2 2020 openEuler Buildteam - 6.0-45 - delete garbled characters -- Gitee From 59ca8e399d09db9649f8b5470e1a330341c9a15f Mon Sep 17 00:00:00 2001 From: hanzhelii <18221254@bjtu.edu.cn> Date: Wed, 12 May 2021 15:12:36 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20unzi?= =?UTF-8?q?p-6.0-crc-builtin.patch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit 8834aee77c2de92613e71500e41eecdf0da9ce30) --- unzip-6.0-crc-builtin.patch | 122 ------------------------------------ 1 file changed, 122 deletions(-) delete mode 100644 unzip-6.0-crc-builtin.patch diff --git a/unzip-6.0-crc-builtin.patch b/unzip-6.0-crc-builtin.patch deleted file mode 100644 index c44c6ce..0000000 --- a/unzip-6.0-crc-builtin.patch +++ /dev/null @@ -1,122 +0,0 @@ -diff -Nabur unzip60/crc32.c unzip604/crc32.c ---- unzip60/crc32.c 2007-01-22 13:34:38.000000000 +0800 -+++ unzip604/crc32.c 2021-05-11 19:27:06.273953956 +0800 -@@ -675,7 +675,32 @@ - - #endif /* (IZ_CRC_BE_OPTIMIZ || IZ_CRC_LE_OPTIMIZ) */ - -+#ifdef ARCH_AARCH64 -+u_int32_t crc32(u_int32_t crc,const u_int8_t *p, unsigned int len) -+{ -+int64_t length = len; -+ -+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); -+} -+ -+if (length & sizeof(u_int16_t)) { -+ __builtin_aarch64_crc32ch(crc, *((u_int16_t *)p)); -+ p += sizeof(u_int16_t); -+} -+ -+if (length & sizeof(u_int8_t)) -+ __builtin_aarch64_crc32cb(crc, *p); -+ -+return crc; -+} -+#else - /* ========================================================================= */ - ulg crc32(crc, buf, len) - ulg crc; /* crc shift register */ -@@ -726,6 +751,9 @@ - - 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 */ -diff -Nabur unzip60/crc32.h unzip604/crc32.h ---- unzip60/crc32.h 2008-03-09 02:40:20.000000000 +0800 -+++ unzip604/crc32.h 2021-05-11 19:24:42.379717503 +0800 -@@ -36,7 +36,11 @@ - # undef IZ_CRC_BE_OPTIMIZ - # endif - #else /* !(USE_ZLIB || CRC_TABLE_ONLY) */ -+# ifdef ARCH_AARCH64 -+ u_int32_t crc32(u_int32_t crc,const u_int8_t *p, unsigned int len); -+# else - ulg crc32 OF((ulg crc, ZCONST uch *buf, extent len)); -+# endif - #endif /* ?(USE_ZLIB || CRC_TABLE_ONLY) */ - - #ifndef CRC_32_TAB -diff -Nabur unzip60/unix/Makefile unzip604/unix/Makefile ---- unzip60/unix/Makefile 2009-01-19 06:41:18.000000000 +0800 -+++ unzip604/unix/Makefile 2021-05-11 19:32:00.946534741 +0800 -@@ -40,7 +40,8 @@ - - # 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 - 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 @@ - LF = -o unzip$E $(LFLAGS1) - LF2 = -s - -+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) -@@ -77,6 +84,8 @@ - SHELL = /bin/sh - MAKEF = -f unix/Makefile - -+ -+ - # Version info for unix/unix.c - HOST_VERSINFO=-DIZ_CC_NAME='\"\$$(CC) \"' -DIZ_OS_NAME='\"`uname -a`\"' - -@@ -231,13 +240,13 @@ - # 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: -- $(CC) -c $(CF) $*.c -+ $(CC) -c $(CF) $(CFF) $*.c - - .c.obj: -- $(CC) -c $(CF) $*.c -+ $(CC) -c $(CF) $(CFF) $*.c - - .c.pic.o: -- $(CC) -c $(CF) -o $@ $*.c -+ $(CC) -c $(CF) $(CFF) -o $@ $*.c - - # this doesn't work...directories are always a pain with implicit rules - #.1.txt: man/$< -@@ -329,7 +338,7 @@ - $(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 -DARCH=$(ARCH) -march=armv8.1-a -o $@ crc32.c - - crypt_$O: crypt.c $(UNZIP_H) zip.h crypt.h crc32.h ttyio.h - $(CC) -c $(CF) -DSFX -o $@ crypt.c -- Gitee From 4bbe65ec53419b4b3df2de1f249a714cad2e15de Mon Sep 17 00:00:00 2001 From: hanzhelii <18221254@bjtu.edu.cn> Date: Wed, 12 May 2021 15:15:28 +0800 Subject: [PATCH 4/7] =?UTF-8?q?add=20openeuler-unzip-6.0-crc-builtin.patch?= =?UTF-8?q?=20this=20patch=20is=20only=20useful=20for=20openeuler=20of=20A?= =?UTF-8?q?RM64=E3=80=82you=20can=20patching=20it=20to=20the=20source=20co?= =?UTF-8?q?de=20by=20following=20command=20:=20"=20patch=20-p1=20<=20../un?= =?UTF-8?q?zip-6.0-crc-builtin.patch=20"=20Then=20you=20can=20use=20it=20i?= =?UTF-8?q?n=20by=20installing=20the=20unzip=20software=20package=20and=20?= =?UTF-8?q?use=20it=20as=20usual=20while=20having=20a=20quicker=20running?= =?UTF-8?q?=20time=20than=20before=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit f6f261f84710e92b4a9de4cb1ba12e2edf547a22) --- unzip-6.0-crc-builtin.patch | 122 ++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 unzip-6.0-crc-builtin.patch diff --git a/unzip-6.0-crc-builtin.patch b/unzip-6.0-crc-builtin.patch new file mode 100644 index 0000000..c43cf29 --- /dev/null +++ b/unzip-6.0-crc-builtin.patch @@ -0,0 +1,122 @@ +diff -Nabur unzip60/crc32.c unzip604/crc32.c +--- unzip60/crc32.c 2007-01-22 13:34:38.000000000 +0800 ++++ unzip604/crc32.c 2021-05-12 15:08:34.409893493 +0800 +@@ -675,7 +675,32 @@ + + #endif /* (IZ_CRC_BE_OPTIMIZ || IZ_CRC_LE_OPTIMIZ) */ + ++#ifdef ARCH_AARCH64 ++u_int32_t crc32(u_int32_t crc,const u_int8_t *p, unsigned int len) ++{ ++int64_t length = len; ++ ++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); ++} ++ ++if (length & sizeof(u_int16_t)) { ++ __builtin_aarch64_crc32ch(crc, *((u_int16_t *)p)); ++ p += sizeof(u_int16_t); ++} ++ ++if (length & sizeof(u_int8_t)) ++ __builtin_aarch64_crc32cb(crc, *p); ++ ++return crc; ++} ++#else + /* ========================================================================= */ + ulg crc32(crc, buf, len) + ulg crc; /* crc shift register */ +@@ -726,6 +751,9 @@ + + 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 */ +diff -Nabur unzip60/crc32.h unzip604/crc32.h +--- unzip60/crc32.h 2008-03-09 02:40:20.000000000 +0800 ++++ unzip604/crc32.h 2021-05-12 15:08:34.409893493 +0800 +@@ -36,7 +36,11 @@ + # undef IZ_CRC_BE_OPTIMIZ + # endif + #else /* !(USE_ZLIB || CRC_TABLE_ONLY) */ ++# ifdef ARCH_AARCH64 ++ u_int32_t crc32(u_int32_t crc,const u_int8_t *p, unsigned int len); ++# else + ulg crc32 OF((ulg crc, ZCONST uch *buf, extent len)); ++# endif + #endif /* ?(USE_ZLIB || CRC_TABLE_ONLY) */ + + #ifndef CRC_32_TAB +diff -Nabur unzip60/unix/Makefile unzip604/unix/Makefile +--- unzip60/unix/Makefile 2009-01-19 06:41:18.000000000 +0800 ++++ unzip604/unix/Makefile 2021-05-12 15:09:05.698385219 +0800 +@@ -40,7 +40,8 @@ + + # 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 + 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 @@ + LF = -o unzip$E $(LFLAGS1) + LF2 = -s + ++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) +@@ -77,6 +84,8 @@ + SHELL = /bin/sh + MAKEF = -f unix/Makefile + ++ ++ + # Version info for unix/unix.c + HOST_VERSINFO=-DIZ_CC_NAME='\"\$$(CC) \"' -DIZ_OS_NAME='\"`uname -a`\"' + +@@ -231,13 +240,13 @@ + # 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: +- $(CC) -c $(CF) $*.c ++ $(CC) -c $(CF) $(CFF) $*.c + + .c.obj: +- $(CC) -c $(CF) $*.c ++ $(CC) -c $(CF) $(CFF) $*.c + + .c.pic.o: +- $(CC) -c $(CF) -o $@ $*.c ++ $(CC) -c $(CF) $(CFF) -o $@ $*.c + + # this doesn't work...directories are always a pain with implicit rules + #.1.txt: man/$< +@@ -329,7 +338,7 @@ + $(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 -- Gitee From 37defb1e3036f3795a3aff8e16e83470f0bd359d Mon Sep 17 00:00:00 2001 From: hanzhelii <18221254@bjtu.edu.cn> Date: Thu, 13 May 2021 11:20:13 +0800 Subject: [PATCH 5/7] update unzip.spec (cherry picked from commit 3e16471e2e51d272d9905bbae6d223ab7f86705a) --- unzip.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unzip.spec b/unzip.spec index 8080749..f7fc810 100644 --- a/unzip.spec +++ b/unzip.spec @@ -2,7 +2,7 @@ Name: unzip Version: 6.0 Release: 46 Summary: A utility for unpacking zip files -License: BSD +License: Info-ZIP URL: http://www.info-zip.org/UnZip.html Source: http://downloads.sourceforge.net/infozip/unzip60.tar.gz -- Gitee From 0c49faad0246afb32952b61d6c5b6f3f51f28626 Mon Sep 17 00:00:00 2001 From: hanzhelii <18221254@bjtu.edu.cn> Date: Thu, 13 May 2021 13:10:42 +0800 Subject: [PATCH 6/7] update unzip.spec. (cherry picked from commit 0d5dd347b4b81339ebc7fa6bc2596bff182595fa) --- unzip.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unzip.spec b/unzip.spec index f7fc810..5e193b4 100644 --- a/unzip.spec +++ b/unzip.spec @@ -2,7 +2,7 @@ Name: unzip Version: 6.0 Release: 46 Summary: A utility for unpacking zip files -License: Info-ZIP +License: Info-ZIP,Public Domain URL: http://www.info-zip.org/UnZip.html Source: http://downloads.sourceforge.net/infozip/unzip60.tar.gz -- Gitee From a89de43982d3f35c4befdc1b51c0d2495d99506a Mon Sep 17 00:00:00 2001 From: hanzhelii <18221254@bjtu.edu.cn> Date: Mon, 17 May 2021 19:48:21 +0800 Subject: [PATCH 7/7] =?UTF-8?q?update=20unzip-6.0-crc-builtin.patch.=20rea?= =?UTF-8?q?son:=20this=20patch=20is=20created=20for=20performance=20optimi?= =?UTF-8?q?zation=20in=20crc=20calculation=20only=20=20suitable=20for=20op?= =?UTF-8?q?eneuler=20of=20aarch64=20architecture=E3=80=82=20you=20can=20pa?= =?UTF-8?q?tch=20it=20to=20the=20source=20code=20of=20unzip=20software=20p?= =?UTF-8?q?ackage=20and=20install=20the=20unzip=20software=20as=20usual?= =?UTF-8?q?=E3=80=82=20effect:=20with=20this=20patch,=20the=20unzip=20soft?= =?UTF-8?q?ware=20can=20speed=20up=20nearly=20100%=20when=20running=20than?= =?UTF-8?q?=20before=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit 68a26bf6cb26ce8f0ddef72084993b75903c166e) --- unzip-6.0-crc-builtin.patch | 143 ++++++++++++++++++++---------------- 1 file changed, 81 insertions(+), 62 deletions(-) diff --git a/unzip-6.0-crc-builtin.patch b/unzip-6.0-crc-builtin.patch index c43cf29..fb7fa87 100644 --- a/unzip-6.0-crc-builtin.patch +++ b/unzip-6.0-crc-builtin.patch @@ -1,41 +1,54 @@ -diff -Nabur unzip60/crc32.c unzip604/crc32.c ---- unzip60/crc32.c 2007-01-22 13:34:38.000000000 +0800 -+++ unzip604/crc32.c 2021-05-12 15:08:34.409893493 +0800 -@@ -675,7 +675,32 @@ - +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() + #endif /* (IZ_CRC_BE_OPTIMIZ || IZ_CRC_LE_OPTIMIZ) */ - + +#ifdef ARCH_AARCH64 +u_int32_t crc32(u_int32_t crc,const u_int8_t *p, unsigned int len) +{ -+int64_t length = len; ++ int64_t length = len; + -+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); -+} ++ 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); ++ } + -+if (length & sizeof(u_int16_t)) { -+ __builtin_aarch64_crc32ch(crc, *((u_int16_t *)p)); -+ p += sizeof(u_int16_t); -+} ++ if (length & sizeof(u_int16_t)) { ++ __builtin_aarch64_crc32ch(crc, *((u_int16_t *)p)); ++ p += sizeof(u_int16_t); ++ } + -+if (length & sizeof(u_int8_t)) -+ __builtin_aarch64_crc32cb(crc, *p); ++ if (length & sizeof(u_int8_t)) ++ __builtin_aarch64_crc32cb(crc, *p); + -+return crc; ++ return crc; +} +#else /* ========================================================================= */ ulg crc32(crc, buf, len) ulg crc; /* crc shift register */ -@@ -726,6 +751,9 @@ - +@@ -726,6 +751,9 @@ ulg crc32(crc, buf, len) + return REV_BE(c) ^ 0xffffffffL; /* (instead of ~c for 64-bit machines) */ } + @@ -44,38 +57,40 @@ diff -Nabur unzip60/crc32.c unzip604/crc32.c #endif /* !ASM_CRC */ #endif /* !CRC_TABLE_ONLY */ #endif /* !USE_ZLIB */ -diff -Nabur unzip60/crc32.h unzip604/crc32.h ---- unzip60/crc32.h 2008-03-09 02:40:20.000000000 +0800 -+++ unzip604/crc32.h 2021-05-12 15:08:34.409893493 +0800 +diff --git a/unzip60/crc32.h b/unzip60/crc32.h +index 83af240..b5e386a 100644 +--- a/unzip60/crc32.h ++++ b/unzip60/crc32.h @@ -36,7 +36,11 @@ # undef IZ_CRC_BE_OPTIMIZ # endif #else /* !(USE_ZLIB || CRC_TABLE_ONLY) */ +# ifdef ARCH_AARCH64 -+ u_int32_t crc32(u_int32_t crc,const u_int8_t *p, unsigned int len); ++ u_int32_t crc32(u_int32_t crc,const u_int8_t *p, unsigned int len); +# else - ulg crc32 OF((ulg crc, ZCONST uch *buf, extent len)); + ulg crc32 OF((ulg crc, ZCONST uch *buf, extent len)); +# endif #endif /* ?(USE_ZLIB || CRC_TABLE_ONLY) */ - + #ifndef CRC_32_TAB -diff -Nabur unzip60/unix/Makefile unzip604/unix/Makefile ---- unzip60/unix/Makefile 2009-01-19 06:41:18.000000000 +0800 -+++ unzip604/unix/Makefile 2021-05-12 15:09:05.698385219 +0800 +diff --git a/unzip60/unix/Makefile b/unzip60/unix/Makefile +index ab32270..39b2263 100644 +--- a/unzip60/unix/Makefile ++++ b/unzip60/unix/Makefile @@ -40,7 +40,8 @@ - + # 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 - 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 @@ + 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 = LF = -o unzip$E $(LFLAGS1) LF2 = -s - + +ifeq ($(TARGET_ARCH),aarch64) +CFF = -DARCH=$(ARCH) -march=armv8.1-a -D ARCH_AARCH64 +else @@ -85,38 +100,42 @@ diff -Nabur unzip60/unix/Makefile unzip604/unix/Makefile # UnZipSFX flags SL = -o unzipsfx$E $(LFLAGS1) SL2 = $(LF2) -@@ -77,6 +84,8 @@ +@@ -77,6 +84,8 @@ M = unix SHELL = /bin/sh MAKEF = -f unix/Makefile - + + + # Version info for unix/unix.c HOST_VERSINFO=-DIZ_CC_NAME='\"\$$(CC) \"' -DIZ_OS_NAME='\"`uname -a`\"' - -@@ -231,13 +240,13 @@ + +@@ -231,13 +240,13 @@ generic_msg: # 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: -- $(CC) -c $(CF) $*.c -+ $(CC) -c $(CF) $(CFF) $*.c - +- $(CC) -c $(CF) $*.c ++ $(CC) -c $(CF) $(CFF) $*.c + .c.obj: -- $(CC) -c $(CF) $*.c -+ $(CC) -c $(CF) $(CFF) $*.c - +- $(CC) -c $(CF) $*.c ++ $(CC) -c $(CF) $(CFF) $*.c + .c.pic.o: -- $(CC) -c $(CF) -o $@ $*.c -+ $(CC) -c $(CF) $(CFF) -o $@ $*.c - +- $(CC) -c $(CF) -o $@ $*.c ++ $(CC) -c $(CF) $(CFF) -o $@ $*.c + # this doesn't work...directories are always a pain with implicit rules - #.1.txt: man/$< -@@ -329,7 +338,7 @@ - $(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 + #.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 + + -- Gitee