From d10fa156ed944d1944d3cfebed3ac6104a67eb1f Mon Sep 17 00:00:00 2001 From: hanzhelii <18221254@bjtu.edu.cn> Date: Mon, 17 May 2021 17:57:41 +0800 Subject: [PATCH] =?UTF-8?q?add=20openeuler-zip-3.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=20zip=20software=20pac?= =?UTF-8?q?kage=20and=20install=20the=20zip=20software=20as=20usual?= =?UTF-8?q?=E3=80=82=20effect:=20with=20this=20patch,=20the=20zip=20softwa?= =?UTF-8?q?re=20can=20speed=20up=20nearly=2020%=20when=20running=20than=20?= =?UTF-8?q?before=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zip-3.0-crc-builtin.patch | 115 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 zip-3.0-crc-builtin.patch diff --git a/zip-3.0-crc-builtin.patch b/zip-3.0-crc-builtin.patch new file mode 100644 index 0000000..d4cb0de --- /dev/null +++ b/zip-3.0-crc-builtin.patch @@ -0,0 +1,115 @@ +From 6210c2007a430882d234d846d133d5f3799434aa Mon Sep 17 00:00:00 2001 +From: Euler Hanzh <18221254@bjtu.edu.cn> +Date: Mon, 17 May 2021 17:32:51 +0800 +Subject: [PATCH 2/2] 2 + +--- + zip30/crc32.c | 27 +++++++++++++++++++++++++++ + zip30/crc32.h | 4 ++++ + zip30/unix/Makefile | 13 +++++++++++-- + 3 files changed, 42 insertions(+), 2 deletions(-) + +diff --git a/zip30/crc32.c b/zip30/crc32.c +index 6b2403b..9e26af7 100644 +--- a/zip30/crc32.c ++++ b/zip30/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; ++ ++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,8 @@ ulg crc32(crc, buf, len) + + 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 --git a/zip30/crc32.h b/zip30/crc32.h +index 83af240..6fdaf32 100644 +--- a/zip30/crc32.h ++++ b/zip30/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); ++# else + ulg crc32 OF((ulg crc, ZCONST uch *buf, extent len)); ++# endif + #endif /* ?(USE_ZLIB || CRC_TABLE_ONLY) */ + + #ifndef CRC_32_TAB +diff --git a/zip30/unix/Makefile b/zip30/unix/Makefile +index abd0c44..065395a 100644 +--- a/zip30/unix/Makefile ++++ b/zip30/unix/Makefile +@@ -37,6 +37,9 @@ CHMOD = chmod + BINFLAGS = 755 + MANFLAGS = 644 + ++ ++TARGET_ARCH = $(shell uname -m) ++ARCH = $(shell getconf LONG_BIT) + # target directories - where to install executables and man pages to + prefix = /usr/local + BINDIR = $(prefix)/bin +@@ -59,6 +62,12 @@ IZ_OUR_BZIP2_DIR = bzip2 + # LFLAGS2 flags after obj file list (libraries, etc) + CFLAGS_NOOPT = -I. -DUNIX $(LOCAL_ZIP) + CFLAGS = -O2 $(CFLAGS_NOOPT) ++ifeq ($(TARGET_ARCH),aarch64) ++CFF = -DARCH=$(ARCH) -march=armv8.1-a -D ARCH_AARCH64 ++else ++CFF = ++endif ++ + LFLAGS1 = + LFLAGS2 = -s + +@@ -80,10 +89,10 @@ ZIP_H = zip.h ziperr.h tailor.h unix/osdep.h + .SUFFIXES: + .SUFFIXES: _.o .o .c .doc .1 + .c_.o: +- $(CC) -c $(CFLAGS) -DUTIL -o $@ $< ++ $(CC) -c $(CFLAGS) -DUTIL $(CFF) -o $@ $< + + .c.o: +- $(CC) -c $(CFLAGS) $< ++ $(CC) -c $(CFLAGS) $(CFF) $< + + .1.doc: + nroff -man $< | col -bx | uniq > $@ +-- +2.23.0 \ No newline at end of file