aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Dhillon <justin.singh.dhillon@gmail.com>2024-02-07 15:14:24 -0800
committerMark Adler <madler@alumni.caltech.edu>2024-02-07 15:35:51 -0800
commit504403f3e468bca2dc85c055d96ad392e9c7aae0 (patch)
tree42fb905a728c4b0946c810ca38cbdd798d6a813d
parent81e7c386082ccff6a6f9ba78013a79cf8e1657d2 (diff)
downloadzlib-504403f3e468bca2dc85c055d96ad392e9c7aae0.tar.gz
zlib-504403f3e468bca2dc85c055d96ad392e9c7aae0.tar.bz2
zlib-504403f3e468bca2dc85c055d96ad392e9c7aae0.zip
Fix broken links.
-rw-r--r--FAQ2
-rw-r--r--contrib/ada/readme.txt2
-rw-r--r--contrib/gcc_gvmat64/gvmat64.S1148
-rw-r--r--qnx/package.qpg2
-rw-r--r--win32/DLL_FAQ.txt2
-rw-r--r--zlib.32
6 files changed, 579 insertions, 579 deletions
diff --git a/FAQ b/FAQ
index 92f5d3e..f72cac6 100644
--- a/FAQ
+++ b/FAQ
@@ -19,7 +19,7 @@ The latest zlib FAQ is at http://zlib.net/zlib_faq.html
19 3. Where can I get a Visual Basic interface to zlib? 19 3. Where can I get a Visual Basic interface to zlib?
20 20
21 See 21 See
22 * http://marknelson.us/1997/01/01/zlib-engine/ 22 * https://marknelson.us/posts/1997/01/01/zlib-engine.html
23 * win32/DLL_FAQ.txt in the zlib distribution 23 * win32/DLL_FAQ.txt in the zlib distribution
24 24
25 4. compress() returns Z_BUF_ERROR. 25 4. compress() returns Z_BUF_ERROR.
diff --git a/contrib/ada/readme.txt b/contrib/ada/readme.txt
index efdd639..dd136c8 100644
--- a/contrib/ada/readme.txt
+++ b/contrib/ada/readme.txt
@@ -2,7 +2,7 @@
2 Release 1.3 2 Release 1.3
3 3
4ZLib.Ada is a thick binding interface to the popular ZLib data 4ZLib.Ada is a thick binding interface to the popular ZLib data
5compression library, available at http://www.gzip.org/zlib/. 5compression library, available at https://zlib.net/.
6It provides Ada-style access to the ZLib C library. 6It provides Ada-style access to the ZLib C library.
7 7
8 8
diff --git a/contrib/gcc_gvmat64/gvmat64.S b/contrib/gcc_gvmat64/gvmat64.S
index dd858dd..51a46eb 100644
--- a/contrib/gcc_gvmat64/gvmat64.S
+++ b/contrib/gcc_gvmat64/gvmat64.S
@@ -1,574 +1,574 @@
1/* 1/*
2;uInt longest_match_x64( 2;uInt longest_match_x64(
3; deflate_state *s, 3; deflate_state *s,
4; IPos cur_match); // current match 4; IPos cur_match); // current match
5 5
6; gvmat64.S -- Asm portion of the optimized longest_match for 32 bits x86_64 6; gvmat64.S -- Asm portion of the optimized longest_match for 32 bits x86_64
7; (AMD64 on Athlon 64, Opteron, Phenom 7; (AMD64 on Athlon 64, Opteron, Phenom
8; and Intel EM64T on Pentium 4 with EM64T, Pentium D, Core 2 Duo, Core I5/I7) 8; and Intel EM64T on Pentium 4 with EM64T, Pentium D, Core 2 Duo, Core I5/I7)
9; this file is translation from gvmat64.asm to GCC 4.x (for Linux, Mac XCode) 9; this file is translation from gvmat64.asm to GCC 4.x (for Linux, Mac XCode)
10; Copyright (C) 1995-2010 Jean-loup Gailly, Brian Raiter and Gilles Vollant. 10; Copyright (C) 1995-2010 Jean-loup Gailly, Brian Raiter and Gilles Vollant.
11; 11;
12; File written by Gilles Vollant, by converting to assembly the longest_match 12; File written by Gilles Vollant, by converting to assembly the longest_match
13; from Jean-loup Gailly in deflate.c of zLib and infoZip zip. 13; from Jean-loup Gailly in deflate.c of zLib and infoZip zip.
14; and by taking inspiration on asm686 with masm, optimised assembly code 14; and by taking inspiration on asm686 with masm, optimised assembly code
15; from Brian Raiter, written 1998 15; from Brian Raiter, written 1998
16; 16;
17; This software is provided 'as-is', without any express or implied 17; This software is provided 'as-is', without any express or implied
18; warranty. In no event will the authors be held liable for any damages 18; warranty. In no event will the authors be held liable for any damages
19; arising from the use of this software. 19; arising from the use of this software.
20; 20;
21; Permission is granted to anyone to use this software for any purpose, 21; Permission is granted to anyone to use this software for any purpose,
22; including commercial applications, and to alter it and redistribute it 22; including commercial applications, and to alter it and redistribute it
23; freely, subject to the following restrictions: 23; freely, subject to the following restrictions:
24; 24;
25; 1. The origin of this software must not be misrepresented; you must not 25; 1. The origin of this software must not be misrepresented; you must not
26; claim that you wrote the original software. If you use this software 26; claim that you wrote the original software. If you use this software
27; in a product, an acknowledgment in the product documentation would be 27; in a product, an acknowledgment in the product documentation would be
28; appreciated but is not required. 28; appreciated but is not required.
29; 2. Altered source versions must be plainly marked as such, and must not be 29; 2. Altered source versions must be plainly marked as such, and must not be
30; misrepresented as being the original software 30; misrepresented as being the original software
31; 3. This notice may not be removed or altered from any source distribution. 31; 3. This notice may not be removed or altered from any source distribution.
32; 32;
33; http://www.zlib.net 33; http://www.zlib.net
34; http://www.winimage.com/zLibDll 34; http://www.winimage.com/zLibDll
35; http://www.muppetlabs.com/~breadbox/software/assembly.html 35; http://www.muppetlabs.com/~breadbox/software/assembly.html
36; 36;
37; to compile this file for zLib, I use option: 37; to compile this file for zLib, I use option:
38; gcc -c -arch x86_64 gvmat64.S 38; gcc -c -arch x86_64 gvmat64.S
39 39
40 40
41;uInt longest_match(s, cur_match) 41;uInt longest_match(s, cur_match)
42; deflate_state *s; 42; deflate_state *s;
43; IPos cur_match; // current match / 43; IPos cur_match; // current match /
44; 44;
45; with XCode for Mac, I had strange error with some jump on intel syntax 45; with XCode for Mac, I had strange error with some jump on intel syntax
46; this is why BEFORE_JMP and AFTER_JMP are used 46; this is why BEFORE_JMP and AFTER_JMP are used
47 */ 47 */
48 48
49 49
50#define BEFORE_JMP .att_syntax 50#define BEFORE_JMP .att_syntax
51#define AFTER_JMP .intel_syntax noprefix 51#define AFTER_JMP .intel_syntax noprefix
52 52
53#ifndef NO_UNDERLINE 53#ifndef NO_UNDERLINE
54# define match_init _match_init 54# define match_init _match_init
55# define longest_match _longest_match 55# define longest_match _longest_match
56#endif 56#endif
57 57
58.intel_syntax noprefix 58.intel_syntax noprefix
59 59
60.globl match_init, longest_match 60.globl match_init, longest_match
61.text 61.text
62longest_match: 62longest_match:
63 63
64 64
65 65
66#define LocalVarsSize 96 66#define LocalVarsSize 96
67/* 67/*
68; register used : rax,rbx,rcx,rdx,rsi,rdi,r8,r9,r10,r11,r12 68; register used : rax,rbx,rcx,rdx,rsi,rdi,r8,r9,r10,r11,r12
69; free register : r14,r15 69; free register : r14,r15
70; register can be saved : rsp 70; register can be saved : rsp
71*/ 71*/
72 72
73#define chainlenwmask (rsp + 8 - LocalVarsSize) 73#define chainlenwmask (rsp + 8 - LocalVarsSize)
74#define nicematch (rsp + 16 - LocalVarsSize) 74#define nicematch (rsp + 16 - LocalVarsSize)
75 75
76#define save_rdi (rsp + 24 - LocalVarsSize) 76#define save_rdi (rsp + 24 - LocalVarsSize)
77#define save_rsi (rsp + 32 - LocalVarsSize) 77#define save_rsi (rsp + 32 - LocalVarsSize)
78#define save_rbx (rsp + 40 - LocalVarsSize) 78#define save_rbx (rsp + 40 - LocalVarsSize)
79#define save_rbp (rsp + 48 - LocalVarsSize) 79#define save_rbp (rsp + 48 - LocalVarsSize)
80#define save_r12 (rsp + 56 - LocalVarsSize) 80#define save_r12 (rsp + 56 - LocalVarsSize)
81#define save_r13 (rsp + 64 - LocalVarsSize) 81#define save_r13 (rsp + 64 - LocalVarsSize)
82#define save_r14 (rsp + 72 - LocalVarsSize) 82#define save_r14 (rsp + 72 - LocalVarsSize)
83#define save_r15 (rsp + 80 - LocalVarsSize) 83#define save_r15 (rsp + 80 - LocalVarsSize)
84 84
85 85
86/* 86/*
87; all the +4 offsets are due to the addition of pending_buf_size (in zlib 87; all the +4 offsets are due to the addition of pending_buf_size (in zlib
88; in the deflate_state structure since the asm code was first written 88; in the deflate_state structure since the asm code was first written
89; (if you compile with zlib 1.0.4 or older, remove the +4). 89; (if you compile with zlib 1.0.4 or older, remove the +4).
90; Note : these value are good with a 8 bytes boundary pack structure 90; Note : these value are good with a 8 bytes boundary pack structure
91*/ 91*/
92 92
93#define MAX_MATCH 258 93#define MAX_MATCH 258
94#define MIN_MATCH 3 94#define MIN_MATCH 3
95#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) 95#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
96 96
97/* 97/*
98;;; Offsets for fields in the deflate_state structure. These numbers 98;;; Offsets for fields in the deflate_state structure. These numbers
99;;; are calculated from the definition of deflate_state, with the 99;;; are calculated from the definition of deflate_state, with the
100;;; assumption that the compiler will dword-align the fields. (Thus, 100;;; assumption that the compiler will dword-align the fields. (Thus,
101;;; changing the definition of deflate_state could easily cause this 101;;; changing the definition of deflate_state could easily cause this
102;;; program to crash horribly, without so much as a warning at 102;;; program to crash horribly, without so much as a warning at
103;;; compile time. Sigh.) 103;;; compile time. Sigh.)
104 104
105; all the +zlib1222add offsets are due to the addition of fields 105; all the +zlib1222add offsets are due to the addition of fields
106; in zlib in the deflate_state structure since the asm code was first written 106; in zlib in the deflate_state structure since the asm code was first written
107; (if you compile with zlib 1.0.4 or older, use "zlib1222add equ (-4)"). 107; (if you compile with zlib 1.0.4 or older, use "zlib1222add equ (-4)").
108; (if you compile with zlib between 1.0.5 and 1.2.2.1, use "zlib1222add equ 0"). 108; (if you compile with zlib between 1.0.5 and 1.2.2.1, use "zlib1222add equ 0").
109; if you compile with zlib 1.2.2.2 or later , use "zlib1222add equ 8"). 109; if you compile with zlib 1.2.2.2 or later , use "zlib1222add equ 8").
110*/ 110*/
111 111
112 112
113 113
114/* you can check the structure offset by running 114/* you can check the structure offset by running
115 115
116#include <stdlib.h> 116#include <stdlib.h>
117#include <stdio.h> 117#include <stdio.h>
118#include "deflate.h" 118#include "deflate.h"
119 119
120void print_depl() 120void print_depl()
121{ 121{
122deflate_state ds; 122deflate_state ds;
123deflate_state *s=&ds; 123deflate_state *s=&ds;
124printf("size pointer=%u\n",(int)sizeof(void*)); 124printf("size pointer=%u\n",(int)sizeof(void*));
125 125
126printf("#define dsWSize %u\n",(int)(((char*)&(s->w_size))-((char*)s))); 126printf("#define dsWSize %u\n",(int)(((char*)&(s->w_size))-((char*)s)));
127printf("#define dsWMask %u\n",(int)(((char*)&(s->w_mask))-((char*)s))); 127printf("#define dsWMask %u\n",(int)(((char*)&(s->w_mask))-((char*)s)));
128printf("#define dsWindow %u\n",(int)(((char*)&(s->window))-((char*)s))); 128printf("#define dsWindow %u\n",(int)(((char*)&(s->window))-((char*)s)));
129printf("#define dsPrev %u\n",(int)(((char*)&(s->prev))-((char*)s))); 129printf("#define dsPrev %u\n",(int)(((char*)&(s->prev))-((char*)s)));
130printf("#define dsMatchLen %u\n",(int)(((char*)&(s->match_length))-((char*)s))); 130printf("#define dsMatchLen %u\n",(int)(((char*)&(s->match_length))-((char*)s)));
131printf("#define dsPrevMatch %u\n",(int)(((char*)&(s->prev_match))-((char*)s))); 131printf("#define dsPrevMatch %u\n",(int)(((char*)&(s->prev_match))-((char*)s)));
132printf("#define dsStrStart %u\n",(int)(((char*)&(s->strstart))-((char*)s))); 132printf("#define dsStrStart %u\n",(int)(((char*)&(s->strstart))-((char*)s)));
133printf("#define dsMatchStart %u\n",(int)(((char*)&(s->match_start))-((char*)s))); 133printf("#define dsMatchStart %u\n",(int)(((char*)&(s->match_start))-((char*)s)));
134printf("#define dsLookahead %u\n",(int)(((char*)&(s->lookahead))-((char*)s))); 134printf("#define dsLookahead %u\n",(int)(((char*)&(s->lookahead))-((char*)s)));
135printf("#define dsPrevLen %u\n",(int)(((char*)&(s->prev_length))-((char*)s))); 135printf("#define dsPrevLen %u\n",(int)(((char*)&(s->prev_length))-((char*)s)));
136printf("#define dsMaxChainLen %u\n",(int)(((char*)&(s->max_chain_length))-((char*)s))); 136printf("#define dsMaxChainLen %u\n",(int)(((char*)&(s->max_chain_length))-((char*)s)));
137printf("#define dsGoodMatch %u\n",(int)(((char*)&(s->good_match))-((char*)s))); 137printf("#define dsGoodMatch %u\n",(int)(((char*)&(s->good_match))-((char*)s)));
138printf("#define dsNiceMatch %u\n",(int)(((char*)&(s->nice_match))-((char*)s))); 138printf("#define dsNiceMatch %u\n",(int)(((char*)&(s->nice_match))-((char*)s)));
139} 139}
140*/ 140*/
141 141
142#define dsWSize 68 142#define dsWSize 68
143#define dsWMask 76 143#define dsWMask 76
144#define dsWindow 80 144#define dsWindow 80
145#define dsPrev 96 145#define dsPrev 96
146#define dsMatchLen 144 146#define dsMatchLen 144
147#define dsPrevMatch 148 147#define dsPrevMatch 148
148#define dsStrStart 156 148#define dsStrStart 156
149#define dsMatchStart 160 149#define dsMatchStart 160
150#define dsLookahead 164 150#define dsLookahead 164
151#define dsPrevLen 168 151#define dsPrevLen 168
152#define dsMaxChainLen 172 152#define dsMaxChainLen 172
153#define dsGoodMatch 188 153#define dsGoodMatch 188
154#define dsNiceMatch 192 154#define dsNiceMatch 192
155 155
156#define window_size [ rcx + dsWSize] 156#define window_size [ rcx + dsWSize]
157#define WMask [ rcx + dsWMask] 157#define WMask [ rcx + dsWMask]
158#define window_ad [ rcx + dsWindow] 158#define window_ad [ rcx + dsWindow]
159#define prev_ad [ rcx + dsPrev] 159#define prev_ad [ rcx + dsPrev]
160#define strstart [ rcx + dsStrStart] 160#define strstart [ rcx + dsStrStart]
161#define match_start [ rcx + dsMatchStart] 161#define match_start [ rcx + dsMatchStart]
162#define Lookahead [ rcx + dsLookahead] //; 0ffffffffh on infozip 162#define Lookahead [ rcx + dsLookahead] //; 0ffffffffh on infozip
163#define prev_length [ rcx + dsPrevLen] 163#define prev_length [ rcx + dsPrevLen]
164#define max_chain_length [ rcx + dsMaxChainLen] 164#define max_chain_length [ rcx + dsMaxChainLen]
165#define good_match [ rcx + dsGoodMatch] 165#define good_match [ rcx + dsGoodMatch]
166#define nice_match [ rcx + dsNiceMatch] 166#define nice_match [ rcx + dsNiceMatch]
167 167
168/* 168/*
169; windows: 169; windows:
170; parameter 1 in rcx(deflate state s), param 2 in rdx (cur match) 170; parameter 1 in rcx(deflate state s), param 2 in rdx (cur match)
171 171
172; see http://weblogs.asp.net/oldnewthing/archive/2004/01/14/58579.aspx and 172; see http://weblogs.asp.net/oldnewthing/archive/2004/01/14/58579.aspx and
173; http://msdn.microsoft.com/library/en-us/kmarch/hh/kmarch/64bitAMD_8e951dd2-ee77-4728-8702-55ce4b5dd24a.xml.asp 173; http://msdn.microsoft.com/library/en-us/kmarch/hh/kmarch/64bitAMD_8e951dd2-ee77-4728-8702-55ce4b5dd24a.xml.asp
174; 174;
175; All registers must be preserved across the call, except for 175; All registers must be preserved across the call, except for
176; rax, rcx, rdx, r8, r9, r10, and r11, which are scratch. 176; rax, rcx, rdx, r8, r9, r10, and r11, which are scratch.
177 177
178; 178;
179; gcc on macosx-linux: 179; gcc on macosx-linux:
180; see http://www.x86-64.org/documentation/abi-0.99.pdf 180; see https://refspecs.linuxbase.org/elf/x86_64-abi-0.99.pdf
181; param 1 in rdi, param 2 in rsi 181; param 1 in rdi, param 2 in rsi
182; rbx, rsp, rbp, r12 to r15 must be preserved 182; rbx, rsp, rbp, r12 to r15 must be preserved
183 183
184;;; Save registers that the compiler may be using, and adjust esp to 184;;; Save registers that the compiler may be using, and adjust esp to
185;;; make room for our stack frame. 185;;; make room for our stack frame.
186 186
187 187
188;;; Retrieve the function arguments. r8d will hold cur_match 188;;; Retrieve the function arguments. r8d will hold cur_match
189;;; throughout the entire function. edx will hold the pointer to the 189;;; throughout the entire function. edx will hold the pointer to the
190;;; deflate_state structure during the function's setup (before 190;;; deflate_state structure during the function's setup (before
191;;; entering the main loop. 191;;; entering the main loop.
192 192
193; ms: parameter 1 in rcx (deflate_state* s), param 2 in edx -> r8 (cur match) 193; ms: parameter 1 in rcx (deflate_state* s), param 2 in edx -> r8 (cur match)
194; mac: param 1 in rdi, param 2 rsi 194; mac: param 1 in rdi, param 2 rsi
195; this clear high 32 bits of r8, which can be garbage in both r8 and rdx 195; this clear high 32 bits of r8, which can be garbage in both r8 and rdx
196*/ 196*/
197 mov [save_rbx],rbx 197 mov [save_rbx],rbx
198 mov [save_rbp],rbp 198 mov [save_rbp],rbp
199 199
200 200
201 mov rcx,rdi 201 mov rcx,rdi
202 202
203 mov r8d,esi 203 mov r8d,esi
204 204
205 205
206 mov [save_r12],r12 206 mov [save_r12],r12
207 mov [save_r13],r13 207 mov [save_r13],r13
208 mov [save_r14],r14 208 mov [save_r14],r14
209 mov [save_r15],r15 209 mov [save_r15],r15
210 210
211 211
212//;;; uInt wmask = s->w_mask; 212//;;; uInt wmask = s->w_mask;
213//;;; unsigned chain_length = s->max_chain_length; 213//;;; unsigned chain_length = s->max_chain_length;
214//;;; if (s->prev_length >= s->good_match) { 214//;;; if (s->prev_length >= s->good_match) {
215//;;; chain_length >>= 2; 215//;;; chain_length >>= 2;
216//;;; } 216//;;; }
217 217
218 218
219 mov edi, prev_length 219 mov edi, prev_length
220 mov esi, good_match 220 mov esi, good_match
221 mov eax, WMask 221 mov eax, WMask
222 mov ebx, max_chain_length 222 mov ebx, max_chain_length
223 cmp edi, esi 223 cmp edi, esi
224 jl LastMatchGood 224 jl LastMatchGood
225 shr ebx, 2 225 shr ebx, 2
226LastMatchGood: 226LastMatchGood:
227 227
228//;;; chainlen is decremented once beforehand so that the function can 228//;;; chainlen is decremented once beforehand so that the function can
229//;;; use the sign flag instead of the zero flag for the exit test. 229//;;; use the sign flag instead of the zero flag for the exit test.
230//;;; It is then shifted into the high word, to make room for the wmask 230//;;; It is then shifted into the high word, to make room for the wmask
231//;;; value, which it will always accompany. 231//;;; value, which it will always accompany.
232 232
233 dec ebx 233 dec ebx
234 shl ebx, 16 234 shl ebx, 16
235 or ebx, eax 235 or ebx, eax
236 236
237//;;; on zlib only 237//;;; on zlib only
238//;;; if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; 238//;;; if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead;
239 239
240 240
241 241
242 mov eax, nice_match 242 mov eax, nice_match
243 mov [chainlenwmask], ebx 243 mov [chainlenwmask], ebx
244 mov r10d, Lookahead 244 mov r10d, Lookahead
245 cmp r10d, eax 245 cmp r10d, eax
246 cmovnl r10d, eax 246 cmovnl r10d, eax
247 mov [nicematch],r10d 247 mov [nicematch],r10d
248 248
249 249
250 250
251//;;; register Bytef *scan = s->window + s->strstart; 251//;;; register Bytef *scan = s->window + s->strstart;
252 mov r10, window_ad 252 mov r10, window_ad
253 mov ebp, strstart 253 mov ebp, strstart
254 lea r13, [r10 + rbp] 254 lea r13, [r10 + rbp]
255 255
256//;;; Determine how many bytes the scan ptr is off from being 256//;;; Determine how many bytes the scan ptr is off from being
257//;;; dword-aligned. 257//;;; dword-aligned.
258 258
259 mov r9,r13 259 mov r9,r13
260 neg r13 260 neg r13
261 and r13,3 261 and r13,3
262 262
263//;;; IPos limit = s->strstart > (IPos)MAX_DIST(s) ? 263//;;; IPos limit = s->strstart > (IPos)MAX_DIST(s) ?
264//;;; s->strstart - (IPos)MAX_DIST(s) : NIL; 264//;;; s->strstart - (IPos)MAX_DIST(s) : NIL;
265 265
266 266
267 mov eax, window_size 267 mov eax, window_size
268 sub eax, MIN_LOOKAHEAD 268 sub eax, MIN_LOOKAHEAD
269 269
270 270
271 xor edi,edi 271 xor edi,edi
272 sub ebp, eax 272 sub ebp, eax
273 273
274 mov r11d, prev_length 274 mov r11d, prev_length
275 275
276 cmovng ebp,edi 276 cmovng ebp,edi
277 277
278//;;; int best_len = s->prev_length; 278//;;; int best_len = s->prev_length;
279 279
280 280
281//;;; Store the sum of s->window + best_len in esi locally, and in esi. 281//;;; Store the sum of s->window + best_len in esi locally, and in esi.
282 282
283 lea rsi,[r10+r11] 283 lea rsi,[r10+r11]
284 284
285//;;; register ush scan_start = *(ushf*)scan; 285//;;; register ush scan_start = *(ushf*)scan;
286//;;; register ush scan_end = *(ushf*)(scan+best_len-1); 286//;;; register ush scan_end = *(ushf*)(scan+best_len-1);
287//;;; Posf *prev = s->prev; 287//;;; Posf *prev = s->prev;
288 288
289 movzx r12d,word ptr [r9] 289 movzx r12d,word ptr [r9]
290 movzx ebx, word ptr [r9 + r11 - 1] 290 movzx ebx, word ptr [r9 + r11 - 1]
291 291
292 mov rdi, prev_ad 292 mov rdi, prev_ad
293 293
294//;;; Jump into the main loop. 294//;;; Jump into the main loop.
295 295
296 mov edx, [chainlenwmask] 296 mov edx, [chainlenwmask]
297 297
298 cmp bx,word ptr [rsi + r8 - 1] 298 cmp bx,word ptr [rsi + r8 - 1]
299 jz LookupLoopIsZero 299 jz LookupLoopIsZero
300 300
301 301
302 302
303LookupLoop1: 303LookupLoop1:
304 and r8d, edx 304 and r8d, edx
305 305
306 movzx r8d, word ptr [rdi + r8*2] 306 movzx r8d, word ptr [rdi + r8*2]
307 cmp r8d, ebp 307 cmp r8d, ebp
308 jbe LeaveNow 308 jbe LeaveNow
309 309
310 310
311 311
312 sub edx, 0x00010000 312 sub edx, 0x00010000
313 BEFORE_JMP 313 BEFORE_JMP
314 js LeaveNow 314 js LeaveNow
315 AFTER_JMP 315 AFTER_JMP
316 316
317LoopEntry1: 317LoopEntry1:
318 cmp bx,word ptr [rsi + r8 - 1] 318 cmp bx,word ptr [rsi + r8 - 1]
319 BEFORE_JMP 319 BEFORE_JMP
320 jz LookupLoopIsZero 320 jz LookupLoopIsZero
321 AFTER_JMP 321 AFTER_JMP
322 322
323LookupLoop2: 323LookupLoop2:
324 and r8d, edx 324 and r8d, edx
325 325
326 movzx r8d, word ptr [rdi + r8*2] 326 movzx r8d, word ptr [rdi + r8*2]
327 cmp r8d, ebp 327 cmp r8d, ebp
328 BEFORE_JMP 328 BEFORE_JMP
329 jbe LeaveNow 329 jbe LeaveNow
330 AFTER_JMP 330 AFTER_JMP
331 sub edx, 0x00010000 331 sub edx, 0x00010000
332 BEFORE_JMP 332 BEFORE_JMP
333 js LeaveNow 333 js LeaveNow
334 AFTER_JMP 334 AFTER_JMP
335 335
336LoopEntry2: 336LoopEntry2:
337 cmp bx,word ptr [rsi + r8 - 1] 337 cmp bx,word ptr [rsi + r8 - 1]
338 BEFORE_JMP 338 BEFORE_JMP
339 jz LookupLoopIsZero 339 jz LookupLoopIsZero
340 AFTER_JMP 340 AFTER_JMP
341 341
342LookupLoop4: 342LookupLoop4:
343 and r8d, edx 343 and r8d, edx
344 344
345 movzx r8d, word ptr [rdi + r8*2] 345 movzx r8d, word ptr [rdi + r8*2]
346 cmp r8d, ebp 346 cmp r8d, ebp
347 BEFORE_JMP 347 BEFORE_JMP
348 jbe LeaveNow 348 jbe LeaveNow
349 AFTER_JMP 349 AFTER_JMP
350 sub edx, 0x00010000 350 sub edx, 0x00010000
351 BEFORE_JMP 351 BEFORE_JMP
352 js LeaveNow 352 js LeaveNow
353 AFTER_JMP 353 AFTER_JMP
354 354
355LoopEntry4: 355LoopEntry4:
356 356
357 cmp bx,word ptr [rsi + r8 - 1] 357 cmp bx,word ptr [rsi + r8 - 1]
358 BEFORE_JMP 358 BEFORE_JMP
359 jnz LookupLoop1 359 jnz LookupLoop1
360 jmp LookupLoopIsZero 360 jmp LookupLoopIsZero
361 AFTER_JMP 361 AFTER_JMP
362/* 362/*
363;;; do { 363;;; do {
364;;; match = s->window + cur_match; 364;;; match = s->window + cur_match;
365;;; if (*(ushf*)(match+best_len-1) != scan_end || 365;;; if (*(ushf*)(match+best_len-1) != scan_end ||
366;;; *(ushf*)match != scan_start) continue; 366;;; *(ushf*)match != scan_start) continue;
367;;; [...] 367;;; [...]
368;;; } while ((cur_match = prev[cur_match & wmask]) > limit 368;;; } while ((cur_match = prev[cur_match & wmask]) > limit
369;;; && --chain_length != 0); 369;;; && --chain_length != 0);
370;;; 370;;;
371;;; Here is the inner loop of the function. The function will spend the 371;;; Here is the inner loop of the function. The function will spend the
372;;; majority of its time in this loop, and majority of that time will 372;;; majority of its time in this loop, and majority of that time will
373;;; be spent in the first ten instructions. 373;;; be spent in the first ten instructions.
374;;; 374;;;
375;;; Within this loop: 375;;; Within this loop:
376;;; ebx = scanend 376;;; ebx = scanend
377;;; r8d = curmatch 377;;; r8d = curmatch
378;;; edx = chainlenwmask - i.e., ((chainlen << 16) | wmask) 378;;; edx = chainlenwmask - i.e., ((chainlen << 16) | wmask)
379;;; esi = windowbestlen - i.e., (window + bestlen) 379;;; esi = windowbestlen - i.e., (window + bestlen)
380;;; edi = prev 380;;; edi = prev
381;;; ebp = limit 381;;; ebp = limit
382*/ 382*/
383.balign 16 383.balign 16
384LookupLoop: 384LookupLoop:
385 and r8d, edx 385 and r8d, edx
386 386
387 movzx r8d, word ptr [rdi + r8*2] 387 movzx r8d, word ptr [rdi + r8*2]
388 cmp r8d, ebp 388 cmp r8d, ebp
389 BEFORE_JMP 389 BEFORE_JMP
390 jbe LeaveNow 390 jbe LeaveNow
391 AFTER_JMP 391 AFTER_JMP
392 sub edx, 0x00010000 392 sub edx, 0x00010000
393 BEFORE_JMP 393 BEFORE_JMP
394 js LeaveNow 394 js LeaveNow
395 AFTER_JMP 395 AFTER_JMP
396 396
397LoopEntry: 397LoopEntry:
398 398
399 cmp bx,word ptr [rsi + r8 - 1] 399 cmp bx,word ptr [rsi + r8 - 1]
400 BEFORE_JMP 400 BEFORE_JMP
401 jnz LookupLoop1 401 jnz LookupLoop1
402 AFTER_JMP 402 AFTER_JMP
403LookupLoopIsZero: 403LookupLoopIsZero:
404 cmp r12w, word ptr [r10 + r8] 404 cmp r12w, word ptr [r10 + r8]
405 BEFORE_JMP 405 BEFORE_JMP
406 jnz LookupLoop1 406 jnz LookupLoop1
407 AFTER_JMP 407 AFTER_JMP
408 408
409 409
410//;;; Store the current value of chainlen. 410//;;; Store the current value of chainlen.
411 mov [chainlenwmask], edx 411 mov [chainlenwmask], edx
412/* 412/*
413;;; Point edi to the string under scrutiny, and esi to the string we 413;;; Point edi to the string under scrutiny, and esi to the string we
414;;; are hoping to match it up with. In actuality, esi and edi are 414;;; are hoping to match it up with. In actuality, esi and edi are
415;;; both pointed (MAX_MATCH_8 - scanalign) bytes ahead, and edx is 415;;; both pointed (MAX_MATCH_8 - scanalign) bytes ahead, and edx is
416;;; initialized to -(MAX_MATCH_8 - scanalign). 416;;; initialized to -(MAX_MATCH_8 - scanalign).
417*/ 417*/
418 lea rsi,[r8+r10] 418 lea rsi,[r8+r10]
419 mov rdx, 0xfffffffffffffef8 //; -(MAX_MATCH_8) 419 mov rdx, 0xfffffffffffffef8 //; -(MAX_MATCH_8)
420 lea rsi, [rsi + r13 + 0x0108] //;MAX_MATCH_8] 420 lea rsi, [rsi + r13 + 0x0108] //;MAX_MATCH_8]
421 lea rdi, [r9 + r13 + 0x0108] //;MAX_MATCH_8] 421 lea rdi, [r9 + r13 + 0x0108] //;MAX_MATCH_8]
422 422
423 prefetcht1 [rsi+rdx] 423 prefetcht1 [rsi+rdx]
424 prefetcht1 [rdi+rdx] 424 prefetcht1 [rdi+rdx]
425 425
426/* 426/*
427;;; Test the strings for equality, 8 bytes at a time. At the end, 427;;; Test the strings for equality, 8 bytes at a time. At the end,
428;;; adjust rdx so that it is offset to the exact byte that mismatched. 428;;; adjust rdx so that it is offset to the exact byte that mismatched.
429;;; 429;;;
430;;; We already know at this point that the first three bytes of the 430;;; We already know at this point that the first three bytes of the
431;;; strings match each other, and they can be safely passed over before 431;;; strings match each other, and they can be safely passed over before
432;;; starting the compare loop. So what this code does is skip over 0-3 432;;; starting the compare loop. So what this code does is skip over 0-3
433;;; bytes, as much as necessary in order to dword-align the edi 433;;; bytes, as much as necessary in order to dword-align the edi
434;;; pointer. (rsi will still be misaligned three times out of four.) 434;;; pointer. (rsi will still be misaligned three times out of four.)
435;;; 435;;;
436;;; It should be confessed that this loop usually does not represent 436;;; It should be confessed that this loop usually does not represent
437;;; much of the total running time. Replacing it with a more 437;;; much of the total running time. Replacing it with a more
438;;; straightforward "rep cmpsb" would not drastically degrade 438;;; straightforward "rep cmpsb" would not drastically degrade
439;;; performance. 439;;; performance.
440*/ 440*/
441 441
442LoopCmps: 442LoopCmps:
443 mov rax, [rsi + rdx] 443 mov rax, [rsi + rdx]
444 xor rax, [rdi + rdx] 444 xor rax, [rdi + rdx]
445 jnz LeaveLoopCmps 445 jnz LeaveLoopCmps
446 446
447 mov rax, [rsi + rdx + 8] 447 mov rax, [rsi + rdx + 8]
448 xor rax, [rdi + rdx + 8] 448 xor rax, [rdi + rdx + 8]
449 jnz LeaveLoopCmps8 449 jnz LeaveLoopCmps8
450 450
451 451
452 mov rax, [rsi + rdx + 8+8] 452 mov rax, [rsi + rdx + 8+8]
453 xor rax, [rdi + rdx + 8+8] 453 xor rax, [rdi + rdx + 8+8]
454 jnz LeaveLoopCmps16 454 jnz LeaveLoopCmps16
455 455
456 add rdx,8+8+8 456 add rdx,8+8+8
457 457
458 BEFORE_JMP 458 BEFORE_JMP
459 jnz LoopCmps 459 jnz LoopCmps
460 jmp LenMaximum 460 jmp LenMaximum
461 AFTER_JMP 461 AFTER_JMP
462 462
463LeaveLoopCmps16: add rdx,8 463LeaveLoopCmps16: add rdx,8
464LeaveLoopCmps8: add rdx,8 464LeaveLoopCmps8: add rdx,8
465LeaveLoopCmps: 465LeaveLoopCmps:
466 466
467 test eax, 0x0000FFFF 467 test eax, 0x0000FFFF
468 jnz LenLower 468 jnz LenLower
469 469
470 test eax,0xffffffff 470 test eax,0xffffffff
471 471
472 jnz LenLower32 472 jnz LenLower32
473 473
474 add rdx,4 474 add rdx,4
475 shr rax,32 475 shr rax,32
476 or ax,ax 476 or ax,ax
477 BEFORE_JMP 477 BEFORE_JMP
478 jnz LenLower 478 jnz LenLower
479 AFTER_JMP 479 AFTER_JMP
480 480
481LenLower32: 481LenLower32:
482 shr eax,16 482 shr eax,16
483 add rdx,2 483 add rdx,2
484 484
485LenLower: 485LenLower:
486 sub al, 1 486 sub al, 1
487 adc rdx, 0 487 adc rdx, 0
488//;;; Calculate the length of the match. If it is longer than MAX_MATCH, 488//;;; Calculate the length of the match. If it is longer than MAX_MATCH,
489//;;; then automatically accept it as the best possible match and leave. 489//;;; then automatically accept it as the best possible match and leave.
490 490
491 lea rax, [rdi + rdx] 491 lea rax, [rdi + rdx]
492 sub rax, r9 492 sub rax, r9
493 cmp eax, MAX_MATCH 493 cmp eax, MAX_MATCH
494 BEFORE_JMP 494 BEFORE_JMP
495 jge LenMaximum 495 jge LenMaximum
496 AFTER_JMP 496 AFTER_JMP
497/* 497/*
498;;; If the length of the match is not longer than the best match we 498;;; If the length of the match is not longer than the best match we
499;;; have so far, then forget it and return to the lookup loop. 499;;; have so far, then forget it and return to the lookup loop.
500;/////////////////////////////////// 500;///////////////////////////////////
501*/ 501*/
502 cmp eax, r11d 502 cmp eax, r11d
503 jg LongerMatch 503 jg LongerMatch
504 504
505 lea rsi,[r10+r11] 505 lea rsi,[r10+r11]
506 506
507 mov rdi, prev_ad 507 mov rdi, prev_ad
508 mov edx, [chainlenwmask] 508 mov edx, [chainlenwmask]
509 BEFORE_JMP 509 BEFORE_JMP
510 jmp LookupLoop 510 jmp LookupLoop
511 AFTER_JMP 511 AFTER_JMP
512/* 512/*
513;;; s->match_start = cur_match; 513;;; s->match_start = cur_match;
514;;; best_len = len; 514;;; best_len = len;
515;;; if (len >= nice_match) break; 515;;; if (len >= nice_match) break;
516;;; scan_end = *(ushf*)(scan+best_len-1); 516;;; scan_end = *(ushf*)(scan+best_len-1);
517*/ 517*/
518LongerMatch: 518LongerMatch:
519 mov r11d, eax 519 mov r11d, eax
520 mov match_start, r8d 520 mov match_start, r8d
521 cmp eax, [nicematch] 521 cmp eax, [nicematch]
522 BEFORE_JMP 522 BEFORE_JMP
523 jge LeaveNow 523 jge LeaveNow
524 AFTER_JMP 524 AFTER_JMP
525 525
526 lea rsi,[r10+rax] 526 lea rsi,[r10+rax]
527 527
528 movzx ebx, word ptr [r9 + rax - 1] 528 movzx ebx, word ptr [r9 + rax - 1]
529 mov rdi, prev_ad 529 mov rdi, prev_ad
530 mov edx, [chainlenwmask] 530 mov edx, [chainlenwmask]
531 BEFORE_JMP 531 BEFORE_JMP
532 jmp LookupLoop 532 jmp LookupLoop
533 AFTER_JMP 533 AFTER_JMP
534 534
535//;;; Accept the current string, with the maximum possible length. 535//;;; Accept the current string, with the maximum possible length.
536 536
537LenMaximum: 537LenMaximum:
538 mov r11d,MAX_MATCH 538 mov r11d,MAX_MATCH
539 mov match_start, r8d 539 mov match_start, r8d
540 540
541//;;; if ((uInt)best_len <= s->lookahead) return (uInt)best_len; 541//;;; if ((uInt)best_len <= s->lookahead) return (uInt)best_len;
542//;;; return s->lookahead; 542//;;; return s->lookahead;
543 543
544LeaveNow: 544LeaveNow:
545 mov eax, Lookahead 545 mov eax, Lookahead
546 cmp r11d, eax 546 cmp r11d, eax
547 cmovng eax, r11d 547 cmovng eax, r11d
548 548
549 549
550 550
551//;;; Restore the stack and return from whence we came. 551//;;; Restore the stack and return from whence we came.
552 552
553 553
554// mov rsi,[save_rsi] 554// mov rsi,[save_rsi]
555// mov rdi,[save_rdi] 555// mov rdi,[save_rdi]
556 mov rbx,[save_rbx] 556 mov rbx,[save_rbx]
557 mov rbp,[save_rbp] 557 mov rbp,[save_rbp]
558 mov r12,[save_r12] 558 mov r12,[save_r12]
559 mov r13,[save_r13] 559 mov r13,[save_r13]
560 mov r14,[save_r14] 560 mov r14,[save_r14]
561 mov r15,[save_r15] 561 mov r15,[save_r15]
562 562
563 563
564 ret 0 564 ret 0
565//; please don't remove this string ! 565//; please don't remove this string !
566//; Your can freely use gvmat64 in any free or commercial app 566//; Your can freely use gvmat64 in any free or commercial app
567//; but it is far better don't remove the string in the binary! 567//; but it is far better don't remove the string in the binary!
568 // db 0dh,0ah,"asm686 with masm, optimised assembly code from Brian Raiter, written 1998, converted to amd 64 by Gilles Vollant 2005",0dh,0ah,0 568 // db 0dh,0ah,"asm686 with masm, optimised assembly code from Brian Raiter, written 1998, converted to amd 64 by Gilles Vollant 2005",0dh,0ah,0
569 569
570 570
571match_init: 571match_init:
572 ret 0 572 ret 0
573 573
574 574
diff --git a/qnx/package.qpg b/qnx/package.qpg
index 9e8e1b3..02970c2 100644
--- a/qnx/package.qpg
+++ b/qnx/package.qpg
@@ -58,7 +58,7 @@
58 <QPM:ProductIconLarge></QPM:ProductIconLarge> 58 <QPM:ProductIconLarge></QPM:ProductIconLarge>
59 <QPM:ProductDescriptionShort>A massively spiffy yet delicately unobtrusive compression library.</QPM:ProductDescriptionShort> 59 <QPM:ProductDescriptionShort>A massively spiffy yet delicately unobtrusive compression library.</QPM:ProductDescriptionShort>
60 <QPM:ProductDescriptionLong>zlib is designed to be a free, general-purpose, legally unencumbered, lossless data compression library for use on virtually any computer hardware and operating system.</QPM:ProductDescriptionLong> 60 <QPM:ProductDescriptionLong>zlib is designed to be a free, general-purpose, legally unencumbered, lossless data compression library for use on virtually any computer hardware and operating system.</QPM:ProductDescriptionLong>
61 <QPM:ProductDescriptionURL>http://www.gzip.org/zlib</QPM:ProductDescriptionURL> 61 <QPM:ProductDescriptionURL>https://zlib.net/</QPM:ProductDescriptionURL>
62 <QPM:ProductDescriptionEmbedURL></QPM:ProductDescriptionEmbedURL> 62 <QPM:ProductDescriptionEmbedURL></QPM:ProductDescriptionEmbedURL>
63 </QPM:ProductDescription> 63 </QPM:ProductDescription>
64 64
diff --git a/win32/DLL_FAQ.txt b/win32/DLL_FAQ.txt
index d8cf5f3..07760df 100644
--- a/win32/DLL_FAQ.txt
+++ b/win32/DLL_FAQ.txt
@@ -6,7 +6,7 @@ This document describes the design, the rationale, and the usage
6of the common DLL build of zlib, named ZLIB1.DLL. If you have 6of the common DLL build of zlib, named ZLIB1.DLL. If you have
7general questions about zlib, you should see the file "FAQ" found 7general questions about zlib, you should see the file "FAQ" found
8in the zlib distribution, or at the following location: 8in the zlib distribution, or at the following location:
9 http://www.gzip.org/zlib/zlib_faq.html 9 https://www.zlib.net/zlib_faq.html
10 10
11 11
12 1. What is ZLIB1.DLL, and how can I get it? 12 1. What is ZLIB1.DLL, and how can I get it?
diff --git a/zlib.3 b/zlib.3
index 7a996ad..3e24d93 100644
--- a/zlib.3
+++ b/zlib.3
@@ -86,7 +86,7 @@ Mark Nelson wrote an article about
86for the Jan. 1997 issue of Dr. Dobb's Journal; 86for the Jan. 1997 issue of Dr. Dobb's Journal;
87a copy of the article is available at: 87a copy of the article is available at:
88.IP 88.IP
89http://marknelson.us/1997/01/01/zlib-engine/ 89https://marknelson.us/posts/1997/01/01/zlib-engine.html
90.SH "REPORTING PROBLEMS" 90.SH "REPORTING PROBLEMS"
91Before reporting a problem, 91Before reporting a problem,
92please check the 92please check the