Skip to content

Commit

Permalink
Updated for zlib 1.2.13
Browse files Browse the repository at this point in the history
- Prepared patch for zlib in order to recover missing ASMV option
- Updated build script for work with newer Visual C compiler, it can't work with "OLDCRT" option anymore, so - using staric CRT now
- longest_match declaration in match.h should not be static ('local')
  • Loading branch information
gildor2 committed Oct 14, 2022
1 parent 8fafee1 commit 6141d21
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 9 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ is to making a file with contents looking like

and linking zlib with this file instead of deflate.c.

#### Zlib 1.2.13 or newer

Note: since zlib 1.2.13 (October 2022), ASMV option has been removed from zlib source, therefore there's no possibility to replace longest_match
function without patching the original source code. So, you'll need to apply patch to the zlib source code in order to make things buildable. You
may find the patch in Sources/zlib_1.2.13.patch.


### Building a 32-bit assembly version

Expand Down
2 changes: 1 addition & 1 deletion Sources/match.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
/* Please retain this line */
const char fast_lm_copyright[] = " Fast match finder for zlib, https://github.com/gildor2/fast_zlib ";

local uInt longest_match(s, cur_match)
uInt longest_match(s, cur_match)
deflate_state *s;
IPos cur_match; /* current match */
{
Expand Down
45 changes: 45 additions & 0 deletions Sources/zlib_1.2.13.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
diff -Nrw -U5 original/deflate.c patched/deflate.c
--- original/deflate.c 2022-10-13 08:06:55 +0300
+++ patched/deflate.c 2022-10-14 11:25:54 +0300
@@ -85,11 +85,15 @@
local block_state deflate_huff OF((deflate_state *s, int flush));
local void lm_init OF((deflate_state *s));
local void putShortMSB OF((deflate_state *s, uInt b));
local void flush_pending OF((z_streamp strm));
local unsigned read_buf OF((z_streamp strm, Bytef *buf, unsigned size));
+#ifndef ASMV
local uInt longest_match OF((deflate_state *s, IPos cur_match));
+#else
+uInt longest_match OF((deflate_state *s, IPos cur_match));
+#endif

#ifdef ZLIB_DEBUG
local void check_match OF((deflate_state *s, IPos start, IPos match,
int length));
#endif
@@ -1263,10 +1267,12 @@
s->match_length = s->prev_length = MIN_MATCH-1;
s->match_available = 0;
s->ins_h = 0;
}

+#ifndef ASMV
+
#ifndef FASTEST
/* ===========================================================================
* Set match_start to the longest match starting at the given string and
* return its length. Matches shorter or equal to prev_length are discarded,
* in which case the result is equal to prev_length and match_start is
@@ -1480,10 +1486,12 @@
return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead;
}

#endif /* FASTEST */

+#endif
+
#ifdef ZLIB_DEBUG

#define EQUAL 0
/* result of memcmp for equal strings */

2 changes: 1 addition & 1 deletion build/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ contains minizip library. To use winapi DLL you should add define ZLIB_WINAPI be
Konstantin Nosov
https://github.com/gildor2/fast_zlib
http://www.gildor.org
https://www.gildor.org/
EOF

echo "Now \"tmp\" directory contains data for zipping."
2 changes: 1 addition & 1 deletion build/zlib.rc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ BEGIN
VALUE "ProductName", "zlib\0"
VALUE "ProductVersion", ZLIB_VERSION "\0"
VALUE "Comments","Fast deflate version by Konstantin Nosov, www.gildor.org\0"
VALUE "LegalCopyright", "(C) 1995-2017 Jean-loup Gailly & Mark Adler\0"
VALUE "LegalCopyright", "(C) 1995-2022 Jean-loup Gailly & Mark Adler\0"
END
END
BLOCK "VarFileInfo"
Expand Down
4 changes: 3 additions & 1 deletion build/zlibdll.project
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ LIBC = shared
CONSOLE = 1
OPTIMIZE = speed
PDB = 2
OLDCRT = 1
OLDCRT = 0

R = .. # root directory of the project
ZLIB = $R/zlib
Expand All @@ -21,6 +21,8 @@ DLLDIR = $R/build/binaries/$PLATFORM-$CONV
DEFINES += OLDCRT vsnprintf=_vsnprintf # define vsnprintf to use underscore version of the function because non-underscore is unavailable in msvcrt
WDKCRT = $R/../Libs/msvcrt
!include $WDKCRT/msvcrt.project
!else
LIBC = static
!endif
!endif

Expand Down
8 changes: 3 additions & 5 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,7 @@ function DoTests
if [ "$dir" ]; then
DoTests "$dir"
else
DoTests C:/Projects/Epic/UnrealEngine4-latest/Engine/Source --exclude=ThirdParty
DoTests C:/3-UnrealEngine/UE_4.18/Engine/Binaries/Win64
DoTests C:/1
# DoTests C:/Data/Images
# DoTests C:/Downloads/torrent/Trollhunters
DoTests D:/EpicGames/UE_5.0/Engine/Source --exclude=ThirdParty
DoTests D:/EpicGames/UE_5.0/Engine/Binaries/Win64
DoTests D:/!unsorted/silesia
fi
2 changes: 2 additions & 0 deletions zlib/readme.txt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
Put extracted zlib sources here.

Note: starting with zlib 1.2.13 you'll need to apply patch to make code buildable, you may find it in Sources/zlib_1.2.13.patch

0 comments on commit 6141d21

Please sign in to comment.