unzip/unzip-6.0-crc-builtin.patch

123 lines
3.4 KiB
Diff
Raw Normal View History

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