This repository was archived by the owner on Mar 1, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4603884
For x86, add CPUID check.
jtkukunas Sep 16, 2013
4fa77e8
zutil.h: add zlikely/zunlikely macros
jtkukunas Jun 21, 2018
63f46f5
zutil.h: add zalign macro
jtkukunas Jun 21, 2018
c4b9af6
enable 16-bit longest_match for x86
jtkukunas Nov 6, 2017
aa5fd5c
Add preprocessor define to tune Adler32 loop unrolling.
jtkukunas Jul 17, 2013
d4726de
Add preprocessor define to tune crc32 unrolling.
jtkukunas Jul 17, 2013
c0d4a12
Adds SSE2 optimized slide_hash
jtkukunas Jun 21, 2018
43a5e76
adds SSE4.2 optimized hash function
jtkukunas Jun 21, 2018
fd93c50
add PCLMULQDQ optimized CRC folding
jtkukunas Jul 11, 2013
8419145
crc_folding: Fix potential out-of-bounds access
NicolasT Mar 3, 2016
9a06dac
crc_folding: use temp buffer for partial stores
jtkukunas Dec 8, 2016
3b11552
deflate: add new deflate_quick strategy for level 1
jtkukunas Jun 21, 2018
2073486
deflate.c fix for window bits > 13
Apr 17, 2016
d6a0d5f
deflate: add new deflate_medium strategy
jtkukunas Dec 8, 2016
afa49d8
deflate: avoid use of uninitialized variable
May 22, 2014
99a86da
check whether match or orig go too far back
jtkukunas May 27, 2014
3e77468
Include wmmintrin.h in configure test and crc_folding.c aid clang com…
mp15 Jun 10, 2014
62b7616
Reorganize inflate window layout
jtkukunas Dec 1, 2016
f9716e7
in the case of overlap copy mempcy dist bytes then byte by byte for a…
Nov 21, 2013
c960eeb
Add Intel's optimized RTE memcpy
Dec 8, 2016
58b51f6
integrate Intel's RTE memcpy with zmemcpy
Dec 8, 2016
641f59e
infcover: remove OoM test for SetDictionary since we don't lazy alloc
jtkukunas Dec 5, 2016
4fcda80
update gitignore
jtkukunas Oct 5, 2018
3c6b4f7
reorganize longest_match
jtkukunas Oct 5, 2018
8311c71
add zalways_inline for msvc and gcc
jtkukunas Oct 10, 2018
cb99979
force inline std2_longest_match
jtkukunas Oct 10, 2018
4b0ef4e
inflate: fix MSVC compiler warnings
vkvenkat Nov 9, 2018
3eecf51
inflate: handle windowBits == 16
jtkukunas Feb 1, 2019
3dd73ae
deflate_medium: add dist -1 to hash even for long matches
jtkukunas Apr 9, 2019
a43a247
deflate_medium: avoid emitting a suboptimal literal in the restart case
jtkukunas Apr 9, 2019
06a9370
Bug fix: add missing source files in CMakeLists.txt
dapeng-mi Dec 9, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .gitignore
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,4 +23,14 @@
/zlib.pc
/configure.log

*.obj
*.lib
*.pdb
*.exp
*.dll
*.exe
*.res

*.swp

.DS_Store
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -103,6 +103,7 @@ set(ZLIB_PRIVATE_HDRS
inflate.h
inftrees.h
trees.h
x86.h
zutil.h
)
set(ZLIB_SRCS
Expand All@@ -120,7 +121,12 @@ set(ZLIB_SRCS
inffast.c
trees.c
uncompr.c
x86.c
zutil.c
match.c
crc_folding.c
slide_sse.c
deflate_medium.c
)

if(NOT MINGW)
Expand Down
64 changes: 50 additions & 14 deletions Makefile.in
Original file line numberDiff line numberDiff line change
Expand Up@@ -57,11 +57,11 @@ SRCDIR=
ZINC=
ZINCOUT=-I.

OBJZ = adler32.o crc32.o deflate.o infback.o inffast.o inflate.o inftrees.o trees.o zutil.o
OBJZ = adler32.o crc32.o crc_folding.o deflate_quick.o deflate_medium.o deflate.o infback.o inffast.o inflate.o inftrees.o match.o slide_sse.o trees.o x86.o zutil.o
OBJG = compress.o uncompr.o gzclose.o gzlib.o gzread.o gzwrite.o
OBJC = $(OBJZ) $(OBJG)

PIC_OBJZ = adler32.lo crc32.lo deflate.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo zutil.lo
PIC_OBJZ = adler32.lo crc32.lo crc_folding.lo deflate_quick.lo deflate_medium.lo deflate.lo infback.lo inffast.lo inflate.lo inftrees.lo match.lo slide_sse.lo trees.lo x86.lo zutil.lo
PIC_OBJG = compress.lo uncompr.lo gzclose.lo gzlib.lo gzread.lo gzwrite.lo
PIC_OBJC = $(PIC_OBJZ) $(PIC_OBJG)

Expand DownExpand Up@@ -131,18 +131,6 @@ libz.a: $(OBJS)
$(AR) $(ARFLAGS) $@ $(OBJS)
-@ ($(RANLIB) $@ || true) >/dev/null 2>&1

match.o: match.S
$(CPP) match.S > _match.s
$(CC) -c _match.s
mv _match.o match.o
rm -f _match.s

match.lo: match.S
$(CPP) match.S > _match.s
$(CC) -c -fPIC _match.s
mv _match.o match.lo
rm -f _match.s

example.o: $(SRCDIR)test/example.c $(SRCDIR)zlib.h zconf.h
$(CC) $(CFLAGS) $(ZINCOUT) -c -o $@ $(SRCDIR)test/example.c

Expand DownExpand Up@@ -201,6 +189,23 @@ gzread.o: $(SRCDIR)gzread.c
gzwrite.o: $(SRCDIR)gzwrite.c
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)gzwrite.c

x86.o: $(SRCDIR)x86.c
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)x86.c

slide_sse.o: $(SRCDIR)slide_sse.c
$(CC) $(CFLAGS) $(ZINC) -msse2 -c -o $@ $(SRCDIR)slide_sse.c

crc_folding.o: $(SRCDIR)crc_folding.c
$(CC) $(CFLAGS) $(ZINC) -mpclmul -msse4 -c -o $@ $(SRCDIR)crc_folding.c

deflate_quick.o: $(SRCDIR)deflate_quick.c
$(CC) $(CFLAGS) $(ZINC) -msse4 -c -o $@ $(SRCDIR)deflate_quick.c

deflate_medium.o: $(SRCDIR)deflate_medium.c
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)deflate_medium.c

match.o: $(SRCDIR)match.c
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)match.c

adler32.lo: $(SRCDIR)adler32.c
-@mkdir objs 2>/dev/null || test -d objs
Expand DownExpand Up@@ -277,6 +282,35 @@ gzwrite.lo: $(SRCDIR)gzwrite.c
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/gzwrite.o $(SRCDIR)gzwrite.c
-@mv objs/gzwrite.o $@

x86.lo: $(SRCDIR)x86.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/x86.o $(SRCDIR)x86.c
-@mv objs/x86.o $@

slide_sse.lo: $(SRCDIR)slide_sse.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -msse2 -DPIC -c -o objs/slide_sse.o $(SRCDIR)slide_sse.c
-@mv objs/slide_sse.o $@

crc_folding.lo: $(SRCDIR)crc_folding.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -mpclmul -msse4 -DPIC -c -o objs/crc_folding.o $(SRCDIR)crc_folding.c
-@mv objs/crc_folding.o $@

deflate_quick.lo: $(SRCDIR)deflate_quick.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -msse4 -DPIC -c -o objs/deflate_quick.o $(SRCDIR)deflate_quick.c
-@mv objs/deflate_quick.o $@

deflate_medium.lo: $(SRCDIR)deflate_medium.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/deflate_medium.o $(SRCDIR)deflate_medium.c
-@mv objs/deflate_medium.o $@

match.lo: $(SRCDIR)match.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/match.o $(SRCDIR)match.c
-@mv objs/match.o $@

placebo $(SHAREDLIBV): $(PIC_OBJS) libz.a
$(LDSHARED) $(SFLAGS) -o $@ $(PIC_OBJS) $(LDSHAREDLIBC) $(LDFLAGS)
Expand DownExpand Up@@ -398,6 +432,7 @@ infback.o inflate.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.
inffast.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h
inftrees.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h
trees.o: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)trees.h
x86.o: $(SRCDIR)x86.h

adler32.lo zutil.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h
gzclose.lo gzlib.lo gzread.lo gzwrite.lo: $(SRCDIR)zlib.h zconf.h $(SRCDIR)gzguts.h
Expand All@@ -408,3 +443,4 @@ infback.lo inflate.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftree
inffast.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h
inftrees.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h
trees.lo: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)trees.h
x86.lo: $(SRCDIR)x86.h
16 changes: 16 additions & 0 deletions adler32.c
Original file line numberDiff line numberDiff line change
Expand Up@@ -102,21 +102,37 @@ uLong ZEXPORT adler32_z(adler, buf, len)
/* do length NMAX blocks -- requires just one modulo operation */
while (len >= NMAX) {
len -= NMAX;
#ifndef ADLER32_UNROLL_LESS
n = NMAX / 16; /* NMAX is divisible by 16 */
#else
n = NMAX / 8; /* NMAX is divisible by 8 */
#endif
do {
#ifndef ADLER32_UNROLL_LESS
DO16(buf); /* 16 sums unrolled */
buf += 16;
#else
DO8(buf,0); /* 8 sums unrolled */
buf += 8;
#endif
} while (--n);
MOD(adler);
MOD(sum2);
}

/* do remaining bytes (less than NMAX, still just one modulo) */
if (len) { /* avoid modulos if none remaining */
#ifndef ADLER32_UNROLL_LESS
while (len >= 16) {
len -= 16;
DO16(buf);
buf += 16;
#else
while (len >= 8) {
len -= 8;
DO8(buf, 0);
buf += 8;
#endif
}
while (len--) {
adler += *buf++;
Expand Down
15 changes: 15 additions & 0 deletions crc32.c
Original file line numberDiff line numberDiff line change
Expand Up@@ -197,6 +197,7 @@ const z_crc_t FAR * ZEXPORT get_crc_table()
/* ========================================================================= */
#define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8)
#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
#define DO4 DO1; DO1; DO1; DO1

/* ========================================================================= */
unsigned long ZEXPORT crc32_z(crc, buf, len)
Expand All@@ -223,10 +224,19 @@ unsigned long ZEXPORT crc32_z(crc, buf, len)
}
#endif /* BYFOUR */
crc = crc ^ 0xffffffffUL;

#ifdef CRC32_UNROLL_LESS
while (len >= 4) {
DO4;
len -= 4;
}
#else
while (len >= 8) {
DO8;
len -= 8;
}
#endif

if (len) do {
DO1;
} while (--len);
Expand DownExpand Up@@ -279,10 +289,14 @@ local unsigned long crc32_little(crc, buf, len)
}

buf4 = (const z_crc_t FAR *)(const void FAR *)buf;

#ifndef CRC32_UNROLL_LESS
while (len >= 32) {
DOLIT32;
len -= 32;
}
#endif

while (len >= 4) {
DOLIT4;
len -= 4;
Expand DownExpand Up@@ -440,3 +454,4 @@ uLong ZEXPORT crc32_combine64(crc1, crc2, len2)
{
return crc32_combine_(crc1, crc2, len2);
}

Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content
This repository was archived by the owner on Mar 1, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4603884
For x86, add CPUID check.
jtkukunas Sep 16, 2013
4fa77e8
zutil.h: add zlikely/zunlikely macros
jtkukunas Jun 21, 2018
63f46f5
zutil.h: add zalign macro
jtkukunas Jun 21, 2018
c4b9af6
enable 16-bit longest_match for x86
jtkukunas Nov 6, 2017
aa5fd5c
Add preprocessor define to tune Adler32 loop unrolling.
jtkukunas Jul 17, 2013
d4726de
Add preprocessor define to tune crc32 unrolling.
jtkukunas Jul 17, 2013
c0d4a12
Adds SSE2 optimized slide_hash
jtkukunas Jun 21, 2018
43a5e76
adds SSE4.2 optimized hash function
jtkukunas Jun 21, 2018
fd93c50
add PCLMULQDQ optimized CRC folding
jtkukunas Jul 11, 2013
8419145
crc_folding: Fix potential out-of-bounds access
NicolasT Mar 3, 2016
9a06dac
crc_folding: use temp buffer for partial stores
jtkukunas Dec 8, 2016
3b11552
deflate: add new deflate_quick strategy for level 1
jtkukunas Jun 21, 2018
2073486
deflate.c fix for window bits > 13
Apr 17, 2016
d6a0d5f
deflate: add new deflate_medium strategy
jtkukunas Dec 8, 2016
afa49d8
deflate: avoid use of uninitialized variable
May 22, 2014
99a86da
check whether match or orig go too far back
jtkukunas May 27, 2014
3e77468
Include wmmintrin.h in configure test and crc_folding.c aid clang com…
mp15 Jun 10, 2014
62b7616
Reorganize inflate window layout
jtkukunas Dec 1, 2016
f9716e7
in the case of overlap copy mempcy dist bytes then byte by byte for a…
Nov 21, 2013
c960eeb
Add Intel's optimized RTE memcpy
Dec 8, 2016
58b51f6
integrate Intel's RTE memcpy with zmemcpy
Dec 8, 2016
641f59e
infcover: remove OoM test for SetDictionary since we don't lazy alloc
jtkukunas Dec 5, 2016
4fcda80
update gitignore
jtkukunas Oct 5, 2018
3c6b4f7
reorganize longest_match
jtkukunas Oct 5, 2018
8311c71
add zalways_inline for msvc and gcc
jtkukunas Oct 10, 2018
cb99979
force inline std2_longest_match
jtkukunas Oct 10, 2018
4b0ef4e
inflate: fix MSVC compiler warnings
vkvenkat Nov 9, 2018
3eecf51
inflate: handle windowBits == 16
jtkukunas Feb 1, 2019
3dd73ae
deflate_medium: add dist -1 to hash even for long matches
jtkukunas Apr 9, 2019
a43a247
deflate_medium: avoid emitting a suboptimal literal in the restart case
jtkukunas Apr 9, 2019
06a9370
Bug fix: add missing source files in CMakeLists.txt
dapeng-mi Dec 9, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .gitignore
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,4 +23,14 @@
/zlib.pc
/configure.log

*.obj
*.lib
*.pdb
*.exp
*.dll
*.exe
*.res

*.swp

.DS_Store
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -103,6 +103,7 @@ set(ZLIB_PRIVATE_HDRS
inflate.h
inftrees.h
trees.h
x86.h
zutil.h
)
set(ZLIB_SRCS
Expand All@@ -120,7 +121,12 @@ set(ZLIB_SRCS
inffast.c
trees.c
uncompr.c
x86.c
zutil.c
match.c
crc_folding.c
slide_sse.c
deflate_medium.c
)

if(NOT MINGW)
Expand Down
64 changes: 50 additions & 14 deletions Makefile.in
Original file line numberDiff line numberDiff line change
Expand Up@@ -57,11 +57,11 @@ SRCDIR=
ZINC=
ZINCOUT=-I.

OBJZ = adler32.o crc32.o deflate.o infback.o inffast.o inflate.o inftrees.o trees.o zutil.o
OBJZ = adler32.o crc32.o crc_folding.o deflate_quick.o deflate_medium.o deflate.o infback.o inffast.o inflate.o inftrees.o match.o slide_sse.o trees.o x86.o zutil.o
OBJG = compress.o uncompr.o gzclose.o gzlib.o gzread.o gzwrite.o
OBJC = $(OBJZ) $(OBJG)

PIC_OBJZ = adler32.lo crc32.lo deflate.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo zutil.lo
PIC_OBJZ = adler32.lo crc32.lo crc_folding.lo deflate_quick.lo deflate_medium.lo deflate.lo infback.lo inffast.lo inflate.lo inftrees.lo match.lo slide_sse.lo trees.lo x86.lo zutil.lo
PIC_OBJG = compress.lo uncompr.lo gzclose.lo gzlib.lo gzread.lo gzwrite.lo
PIC_OBJC = $(PIC_OBJZ) $(PIC_OBJG)

Expand DownExpand Up@@ -131,18 +131,6 @@ libz.a: $(OBJS)
$(AR) $(ARFLAGS) $@ $(OBJS)
-@ ($(RANLIB) $@ || true) >/dev/null 2>&1

match.o: match.S
$(CPP) match.S > _match.s
$(CC) -c _match.s
mv _match.o match.o
rm -f _match.s

match.lo: match.S
$(CPP) match.S > _match.s
$(CC) -c -fPIC _match.s
mv _match.o match.lo
rm -f _match.s

example.o: $(SRCDIR)test/example.c $(SRCDIR)zlib.h zconf.h
$(CC) $(CFLAGS) $(ZINCOUT) -c -o $@ $(SRCDIR)test/example.c

Expand DownExpand Up@@ -201,6 +189,23 @@ gzread.o: $(SRCDIR)gzread.c
gzwrite.o: $(SRCDIR)gzwrite.c
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)gzwrite.c

x86.o: $(SRCDIR)x86.c
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)x86.c

slide_sse.o: $(SRCDIR)slide_sse.c
$(CC) $(CFLAGS) $(ZINC) -msse2 -c -o $@ $(SRCDIR)slide_sse.c

crc_folding.o: $(SRCDIR)crc_folding.c
$(CC) $(CFLAGS) $(ZINC) -mpclmul -msse4 -c -o $@ $(SRCDIR)crc_folding.c

deflate_quick.o: $(SRCDIR)deflate_quick.c
$(CC) $(CFLAGS) $(ZINC) -msse4 -c -o $@ $(SRCDIR)deflate_quick.c

deflate_medium.o: $(SRCDIR)deflate_medium.c
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)deflate_medium.c

match.o: $(SRCDIR)match.c
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)match.c

adler32.lo: $(SRCDIR)adler32.c
-@mkdir objs 2>/dev/null || test -d objs
Expand DownExpand Up@@ -277,6 +282,35 @@ gzwrite.lo: $(SRCDIR)gzwrite.c
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/gzwrite.o $(SRCDIR)gzwrite.c
-@mv objs/gzwrite.o $@

x86.lo: $(SRCDIR)x86.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/x86.o $(SRCDIR)x86.c
-@mv objs/x86.o $@

slide_sse.lo: $(SRCDIR)slide_sse.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -msse2 -DPIC -c -o objs/slide_sse.o $(SRCDIR)slide_sse.c
-@mv objs/slide_sse.o $@

crc_folding.lo: $(SRCDIR)crc_folding.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -mpclmul -msse4 -DPIC -c -o objs/crc_folding.o $(SRCDIR)crc_folding.c
-@mv objs/crc_folding.o $@

deflate_quick.lo: $(SRCDIR)deflate_quick.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -msse4 -DPIC -c -o objs/deflate_quick.o $(SRCDIR)deflate_quick.c
-@mv objs/deflate_quick.o $@

deflate_medium.lo: $(SRCDIR)deflate_medium.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/deflate_medium.o $(SRCDIR)deflate_medium.c
-@mv objs/deflate_medium.o $@

match.lo: $(SRCDIR)match.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/match.o $(SRCDIR)match.c
-@mv objs/match.o $@

placebo $(SHAREDLIBV): $(PIC_OBJS) libz.a
$(LDSHARED) $(SFLAGS) -o $@ $(PIC_OBJS) $(LDSHAREDLIBC) $(LDFLAGS)
Expand DownExpand Up@@ -398,6 +432,7 @@ infback.o inflate.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.
inffast.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h
inftrees.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h
trees.o: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)trees.h
x86.o: $(SRCDIR)x86.h

adler32.lo zutil.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h
gzclose.lo gzlib.lo gzread.lo gzwrite.lo: $(SRCDIR)zlib.h zconf.h $(SRCDIR)gzguts.h
Expand All@@ -408,3 +443,4 @@ infback.lo inflate.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftree
inffast.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h
inftrees.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h
trees.lo: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)trees.h
x86.lo: $(SRCDIR)x86.h
16 changes: 16 additions & 0 deletions adler32.c
Original file line numberDiff line numberDiff line change
Expand Up@@ -102,21 +102,37 @@ uLong ZEXPORT adler32_z(adler, buf, len)
/* do length NMAX blocks -- requires just one modulo operation */
while (len >= NMAX) {
len -= NMAX;
#ifndef ADLER32_UNROLL_LESS
n = NMAX / 16; /* NMAX is divisible by 16 */
#else
n = NMAX / 8; /* NMAX is divisible by 8 */
#endif
do {
#ifndef ADLER32_UNROLL_LESS
DO16(buf); /* 16 sums unrolled */
buf += 16;
#else
DO8(buf,0); /* 8 sums unrolled */
buf += 8;
#endif
} while (--n);
MOD(adler);
MOD(sum2);
}

/* do remaining bytes (less than NMAX, still just one modulo) */
if (len) { /* avoid modulos if none remaining */
#ifndef ADLER32_UNROLL_LESS
while (len >= 16) {
len -= 16;
DO16(buf);
buf += 16;
#else
while (len >= 8) {
len -= 8;
DO8(buf, 0);
buf += 8;
#endif
}
while (len--) {
adler += *buf++;
Expand Down
15 changes: 15 additions & 0 deletions crc32.c
Original file line numberDiff line numberDiff line change
Expand Up@@ -197,6 +197,7 @@ const z_crc_t FAR * ZEXPORT get_crc_table()
/* ========================================================================= */
#define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8)
#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
#define DO4 DO1; DO1; DO1; DO1

/* ========================================================================= */
unsigned long ZEXPORT crc32_z(crc, buf, len)
Expand All@@ -223,10 +224,19 @@ unsigned long ZEXPORT crc32_z(crc, buf, len)
}
#endif /* BYFOUR */
crc = crc ^ 0xffffffffUL;

#ifdef CRC32_UNROLL_LESS
while (len >= 4) {
DO4;
len -= 4;
}
#else
while (len >= 8) {
DO8;
len -= 8;
}
#endif

if (len) do {
DO1;
} while (--len);
Expand DownExpand Up@@ -279,10 +289,14 @@ local unsigned long crc32_little(crc, buf, len)
}

buf4 = (const z_crc_t FAR *)(const void FAR *)buf;

#ifndef CRC32_UNROLL_LESS
while (len >= 32) {
DOLIT32;
len -= 32;
}
#endif

while (len >= 4) {
DOLIT4;
len -= 4;
Expand DownExpand Up@@ -440,3 +454,4 @@ uLong ZEXPORT crc32_combine64(crc1, crc2, len2)
{
return crc32_combine_(crc1, crc2, len2);
}

Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
This repository was archived by the owner on Mar 1, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4603884
For x86, add CPUID check.
jtkukunas Sep 16, 2013
4fa77e8
zutil.h: add zlikely/zunlikely macros
jtkukunas Jun 21, 2018
63f46f5
zutil.h: add zalign macro
jtkukunas Jun 21, 2018
c4b9af6
enable 16-bit longest_match for x86
jtkukunas Nov 6, 2017
aa5fd5c
Add preprocessor define to tune Adler32 loop unrolling.
jtkukunas Jul 17, 2013
d4726de
Add preprocessor define to tune crc32 unrolling.
jtkukunas Jul 17, 2013
c0d4a12
Adds SSE2 optimized slide_hash
jtkukunas Jun 21, 2018
43a5e76
adds SSE4.2 optimized hash function
jtkukunas Jun 21, 2018
fd93c50
add PCLMULQDQ optimized CRC folding
jtkukunas Jul 11, 2013
8419145
crc_folding: Fix potential out-of-bounds access
NicolasT Mar 3, 2016
9a06dac
crc_folding: use temp buffer for partial stores
jtkukunas Dec 8, 2016
3b11552
deflate: add new deflate_quick strategy for level 1
jtkukunas Jun 21, 2018
2073486
deflate.c fix for window bits > 13
Apr 17, 2016
d6a0d5f
deflate: add new deflate_medium strategy
jtkukunas Dec 8, 2016
afa49d8
deflate: avoid use of uninitialized variable
May 22, 2014
99a86da
check whether match or orig go too far back
jtkukunas May 27, 2014
3e77468
Include wmmintrin.h in configure test and crc_folding.c aid clang com…
mp15 Jun 10, 2014
62b7616
Reorganize inflate window layout
jtkukunas Dec 1, 2016
f9716e7
in the case of overlap copy mempcy dist bytes then byte by byte for a…
Nov 21, 2013
c960eeb
Add Intel's optimized RTE memcpy
Dec 8, 2016
58b51f6
integrate Intel's RTE memcpy with zmemcpy
Dec 8, 2016
641f59e
infcover: remove OoM test for SetDictionary since we don't lazy alloc
jtkukunas Dec 5, 2016
4fcda80
update gitignore
jtkukunas Oct 5, 2018
3c6b4f7
reorganize longest_match
jtkukunas Oct 5, 2018
8311c71
add zalways_inline for msvc and gcc
jtkukunas Oct 10, 2018
cb99979
force inline std2_longest_match
jtkukunas Oct 10, 2018
4b0ef4e
inflate: fix MSVC compiler warnings
vkvenkat Nov 9, 2018
3eecf51
inflate: handle windowBits == 16
jtkukunas Feb 1, 2019
3dd73ae
deflate_medium: add dist -1 to hash even for long matches
jtkukunas Apr 9, 2019
a43a247
deflate_medium: avoid emitting a suboptimal literal in the restart case
jtkukunas Apr 9, 2019
06a9370
Bug fix: add missing source files in CMakeLists.txt
dapeng-mi Dec 9, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .gitignore
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,4 +23,14 @@
/zlib.pc
/configure.log

*.obj
*.lib
*.pdb
*.exp
*.dll
*.exe
*.res

*.swp

.DS_Store
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -103,6 +103,7 @@ set(ZLIB_PRIVATE_HDRS
inflate.h
inftrees.h
trees.h
x86.h
zutil.h
)
set(ZLIB_SRCS
Expand All@@ -120,7 +121,12 @@ set(ZLIB_SRCS
inffast.c
trees.c
uncompr.c
x86.c
zutil.c
match.c
crc_folding.c
slide_sse.c
deflate_medium.c
)

if(NOT MINGW)
Expand Down
64 changes: 50 additions & 14 deletions Makefile.in
Original file line numberDiff line numberDiff line change
Expand Up@@ -57,11 +57,11 @@ SRCDIR=
ZINC=
ZINCOUT=-I.

OBJZ = adler32.o crc32.o deflate.o infback.o inffast.o inflate.o inftrees.o trees.o zutil.o
OBJZ = adler32.o crc32.o crc_folding.o deflate_quick.o deflate_medium.o deflate.o infback.o inffast.o inflate.o inftrees.o match.o slide_sse.o trees.o x86.o zutil.o
OBJG = compress.o uncompr.o gzclose.o gzlib.o gzread.o gzwrite.o
OBJC = $(OBJZ) $(OBJG)

PIC_OBJZ = adler32.lo crc32.lo deflate.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo zutil.lo
PIC_OBJZ = adler32.lo crc32.lo crc_folding.lo deflate_quick.lo deflate_medium.lo deflate.lo infback.lo inffast.lo inflate.lo inftrees.lo match.lo slide_sse.lo trees.lo x86.lo zutil.lo
PIC_OBJG = compress.lo uncompr.lo gzclose.lo gzlib.lo gzread.lo gzwrite.lo
PIC_OBJC = $(PIC_OBJZ) $(PIC_OBJG)

Expand DownExpand Up@@ -131,18 +131,6 @@ libz.a: $(OBJS)
$(AR) $(ARFLAGS) $@ $(OBJS)
-@ ($(RANLIB) $@ || true) >/dev/null 2>&1

match.o: match.S
$(CPP) match.S > _match.s
$(CC) -c _match.s
mv _match.o match.o
rm -f _match.s

match.lo: match.S
$(CPP) match.S > _match.s
$(CC) -c -fPIC _match.s
mv _match.o match.lo
rm -f _match.s

example.o: $(SRCDIR)test/example.c $(SRCDIR)zlib.h zconf.h
$(CC) $(CFLAGS) $(ZINCOUT) -c -o $@ $(SRCDIR)test/example.c

Expand DownExpand Up@@ -201,6 +189,23 @@ gzread.o: $(SRCDIR)gzread.c
gzwrite.o: $(SRCDIR)gzwrite.c
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)gzwrite.c

x86.o: $(SRCDIR)x86.c
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)x86.c

slide_sse.o: $(SRCDIR)slide_sse.c
$(CC) $(CFLAGS) $(ZINC) -msse2 -c -o $@ $(SRCDIR)slide_sse.c

crc_folding.o: $(SRCDIR)crc_folding.c
$(CC) $(CFLAGS) $(ZINC) -mpclmul -msse4 -c -o $@ $(SRCDIR)crc_folding.c

deflate_quick.o: $(SRCDIR)deflate_quick.c
$(CC) $(CFLAGS) $(ZINC) -msse4 -c -o $@ $(SRCDIR)deflate_quick.c

deflate_medium.o: $(SRCDIR)deflate_medium.c
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)deflate_medium.c

match.o: $(SRCDIR)match.c
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)match.c

adler32.lo: $(SRCDIR)adler32.c
-@mkdir objs 2>/dev/null || test -d objs
Expand DownExpand Up@@ -277,6 +282,35 @@ gzwrite.lo: $(SRCDIR)gzwrite.c
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/gzwrite.o $(SRCDIR)gzwrite.c
-@mv objs/gzwrite.o $@

x86.lo: $(SRCDIR)x86.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/x86.o $(SRCDIR)x86.c
-@mv objs/x86.o $@

slide_sse.lo: $(SRCDIR)slide_sse.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -msse2 -DPIC -c -o objs/slide_sse.o $(SRCDIR)slide_sse.c
-@mv objs/slide_sse.o $@

crc_folding.lo: $(SRCDIR)crc_folding.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -mpclmul -msse4 -DPIC -c -o objs/crc_folding.o $(SRCDIR)crc_folding.c
-@mv objs/crc_folding.o $@

deflate_quick.lo: $(SRCDIR)deflate_quick.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -msse4 -DPIC -c -o objs/deflate_quick.o $(SRCDIR)deflate_quick.c
-@mv objs/deflate_quick.o $@

deflate_medium.lo: $(SRCDIR)deflate_medium.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/deflate_medium.o $(SRCDIR)deflate_medium.c
-@mv objs/deflate_medium.o $@

match.lo: $(SRCDIR)match.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/match.o $(SRCDIR)match.c
-@mv objs/match.o $@

placebo $(SHAREDLIBV): $(PIC_OBJS) libz.a
$(LDSHARED) $(SFLAGS) -o $@ $(PIC_OBJS) $(LDSHAREDLIBC) $(LDFLAGS)
Expand DownExpand Up@@ -398,6 +432,7 @@ infback.o inflate.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.
inffast.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h
inftrees.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h
trees.o: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)trees.h
x86.o: $(SRCDIR)x86.h

adler32.lo zutil.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h
gzclose.lo gzlib.lo gzread.lo gzwrite.lo: $(SRCDIR)zlib.h zconf.h $(SRCDIR)gzguts.h
Expand All@@ -408,3 +443,4 @@ infback.lo inflate.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftree
inffast.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h
inftrees.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h
trees.lo: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)trees.h
x86.lo: $(SRCDIR)x86.h
16 changes: 16 additions & 0 deletions adler32.c
Original file line numberDiff line numberDiff line change
Expand Up@@ -102,21 +102,37 @@ uLong ZEXPORT adler32_z(adler, buf, len)
/* do length NMAX blocks -- requires just one modulo operation */
while (len >= NMAX) {
len -= NMAX;
#ifndef ADLER32_UNROLL_LESS
n = NMAX / 16; /* NMAX is divisible by 16 */
#else
n = NMAX / 8; /* NMAX is divisible by 8 */
#endif
do {
#ifndef ADLER32_UNROLL_LESS
DO16(buf); /* 16 sums unrolled */
buf += 16;
#else
DO8(buf,0); /* 8 sums unrolled */
buf += 8;
#endif
} while (--n);
MOD(adler);
MOD(sum2);
}

/* do remaining bytes (less than NMAX, still just one modulo) */
if (len) { /* avoid modulos if none remaining */
#ifndef ADLER32_UNROLL_LESS
while (len >= 16) {
len -= 16;
DO16(buf);
buf += 16;
#else
while (len >= 8) {
len -= 8;
DO8(buf, 0);
buf += 8;
#endif
}
while (len--) {
adler += *buf++;
Expand Down
15 changes: 15 additions & 0 deletions crc32.c
Original file line numberDiff line numberDiff line change
Expand Up@@ -197,6 +197,7 @@ const z_crc_t FAR * ZEXPORT get_crc_table()
/* ========================================================================= */
#define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8)
#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
#define DO4 DO1; DO1; DO1; DO1

/* ========================================================================= */
unsigned long ZEXPORT crc32_z(crc, buf, len)
Expand All@@ -223,10 +224,19 @@ unsigned long ZEXPORT crc32_z(crc, buf, len)
}
#endif /* BYFOUR */
crc = crc ^ 0xffffffffUL;

#ifdef CRC32_UNROLL_LESS
while (len >= 4) {
DO4;
len -= 4;
}
#else
while (len >= 8) {
DO8;
len -= 8;
}
#endif

if (len) do {
DO1;
} while (--len);
Expand DownExpand Up@@ -279,10 +289,14 @@ local unsigned long crc32_little(crc, buf, len)
}

buf4 = (const z_crc_t FAR *)(const void FAR *)buf;

#ifndef CRC32_UNROLL_LESS
while (len >= 32) {
DOLIT32;
len -= 32;
}
#endif

while (len >= 4) {
DOLIT4;
len -= 4;
Expand DownExpand Up@@ -440,3 +454,4 @@ uLong ZEXPORT crc32_combine64(crc1, crc2, len2)
{
return crc32_combine_(crc1, crc2, len2);
}

Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
This repository was archived by the owner on Mar 1, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4603884
For x86, add CPUID check.
jtkukunas Sep 16, 2013
4fa77e8
zutil.h: add zlikely/zunlikely macros
jtkukunas Jun 21, 2018
63f46f5
zutil.h: add zalign macro
jtkukunas Jun 21, 2018
c4b9af6
enable 16-bit longest_match for x86
jtkukunas Nov 6, 2017
aa5fd5c
Add preprocessor define to tune Adler32 loop unrolling.
jtkukunas Jul 17, 2013
d4726de
Add preprocessor define to tune crc32 unrolling.
jtkukunas Jul 17, 2013
c0d4a12
Adds SSE2 optimized slide_hash
jtkukunas Jun 21, 2018
43a5e76
adds SSE4.2 optimized hash function
jtkukunas Jun 21, 2018
fd93c50
add PCLMULQDQ optimized CRC folding
jtkukunas Jul 11, 2013
8419145
crc_folding: Fix potential out-of-bounds access
NicolasT Mar 3, 2016
9a06dac
crc_folding: use temp buffer for partial stores
jtkukunas Dec 8, 2016
3b11552
deflate: add new deflate_quick strategy for level 1
jtkukunas Jun 21, 2018
2073486
deflate.c fix for window bits > 13
Apr 17, 2016
d6a0d5f
deflate: add new deflate_medium strategy
jtkukunas Dec 8, 2016
afa49d8
deflate: avoid use of uninitialized variable
May 22, 2014
99a86da
check whether match or orig go too far back
jtkukunas May 27, 2014
3e77468
Include wmmintrin.h in configure test and crc_folding.c aid clang com…
mp15 Jun 10, 2014
62b7616
Reorganize inflate window layout
jtkukunas Dec 1, 2016
f9716e7
in the case of overlap copy mempcy dist bytes then byte by byte for a…
Nov 21, 2013
c960eeb
Add Intel's optimized RTE memcpy
Dec 8, 2016
58b51f6
integrate Intel's RTE memcpy with zmemcpy
Dec 8, 2016
641f59e
infcover: remove OoM test for SetDictionary since we don't lazy alloc
jtkukunas Dec 5, 2016
4fcda80
update gitignore
jtkukunas Oct 5, 2018
3c6b4f7
reorganize longest_match
jtkukunas Oct 5, 2018
8311c71
add zalways_inline for msvc and gcc
jtkukunas Oct 10, 2018
cb99979
force inline std2_longest_match
jtkukunas Oct 10, 2018
4b0ef4e
inflate: fix MSVC compiler warnings
vkvenkat Nov 9, 2018
3eecf51
inflate: handle windowBits == 16
jtkukunas Feb 1, 2019
3dd73ae
deflate_medium: add dist -1 to hash even for long matches
jtkukunas Apr 9, 2019
a43a247
deflate_medium: avoid emitting a suboptimal literal in the restart case
jtkukunas Apr 9, 2019
06a9370
Bug fix: add missing source files in CMakeLists.txt
dapeng-mi Dec 9, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .gitignore
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,4 +23,14 @@
/zlib.pc
/configure.log

*.obj
*.lib
*.pdb
*.exp
*.dll
*.exe
*.res

*.swp

.DS_Store
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -103,6 +103,7 @@ set(ZLIB_PRIVATE_HDRS
inflate.h
inftrees.h
trees.h
x86.h
zutil.h
)
set(ZLIB_SRCS
Expand All@@ -120,7 +121,12 @@ set(ZLIB_SRCS
inffast.c
trees.c
uncompr.c
x86.c
zutil.c
match.c
crc_folding.c
slide_sse.c
deflate_medium.c
)

if(NOT MINGW)
Expand Down
64 changes: 50 additions & 14 deletions Makefile.in
Original file line numberDiff line numberDiff line change
Expand Up@@ -57,11 +57,11 @@ SRCDIR=
ZINC=
ZINCOUT=-I.

OBJZ = adler32.o crc32.o deflate.o infback.o inffast.o inflate.o inftrees.o trees.o zutil.o
OBJZ = adler32.o crc32.o crc_folding.o deflate_quick.o deflate_medium.o deflate.o infback.o inffast.o inflate.o inftrees.o match.o slide_sse.o trees.o x86.o zutil.o
OBJG = compress.o uncompr.o gzclose.o gzlib.o gzread.o gzwrite.o
OBJC = $(OBJZ) $(OBJG)

PIC_OBJZ = adler32.lo crc32.lo deflate.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo zutil.lo
PIC_OBJZ = adler32.lo crc32.lo crc_folding.lo deflate_quick.lo deflate_medium.lo deflate.lo infback.lo inffast.lo inflate.lo inftrees.lo match.lo slide_sse.lo trees.lo x86.lo zutil.lo
PIC_OBJG = compress.lo uncompr.lo gzclose.lo gzlib.lo gzread.lo gzwrite.lo
PIC_OBJC = $(PIC_OBJZ) $(PIC_OBJG)

Expand DownExpand Up@@ -131,18 +131,6 @@ libz.a: $(OBJS)
$(AR) $(ARFLAGS) $@ $(OBJS)
-@ ($(RANLIB) $@ || true) >/dev/null 2>&1

match.o: match.S
$(CPP) match.S > _match.s
$(CC) -c _match.s
mv _match.o match.o
rm -f _match.s

match.lo: match.S
$(CPP) match.S > _match.s
$(CC) -c -fPIC _match.s
mv _match.o match.lo
rm -f _match.s

example.o: $(SRCDIR)test/example.c $(SRCDIR)zlib.h zconf.h
$(CC) $(CFLAGS) $(ZINCOUT) -c -o $@ $(SRCDIR)test/example.c

Expand DownExpand Up@@ -201,6 +189,23 @@ gzread.o: $(SRCDIR)gzread.c
gzwrite.o: $(SRCDIR)gzwrite.c
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)gzwrite.c

x86.o: $(SRCDIR)x86.c
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)x86.c

slide_sse.o: $(SRCDIR)slide_sse.c
$(CC) $(CFLAGS) $(ZINC) -msse2 -c -o $@ $(SRCDIR)slide_sse.c

crc_folding.o: $(SRCDIR)crc_folding.c
$(CC) $(CFLAGS) $(ZINC) -mpclmul -msse4 -c -o $@ $(SRCDIR)crc_folding.c

deflate_quick.o: $(SRCDIR)deflate_quick.c
$(CC) $(CFLAGS) $(ZINC) -msse4 -c -o $@ $(SRCDIR)deflate_quick.c

deflate_medium.o: $(SRCDIR)deflate_medium.c
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)deflate_medium.c

match.o: $(SRCDIR)match.c
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)match.c

adler32.lo: $(SRCDIR)adler32.c
-@mkdir objs 2>/dev/null || test -d objs
Expand DownExpand Up@@ -277,6 +282,35 @@ gzwrite.lo: $(SRCDIR)gzwrite.c
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/gzwrite.o $(SRCDIR)gzwrite.c
-@mv objs/gzwrite.o $@

x86.lo: $(SRCDIR)x86.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/x86.o $(SRCDIR)x86.c
-@mv objs/x86.o $@

slide_sse.lo: $(SRCDIR)slide_sse.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -msse2 -DPIC -c -o objs/slide_sse.o $(SRCDIR)slide_sse.c
-@mv objs/slide_sse.o $@

crc_folding.lo: $(SRCDIR)crc_folding.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -mpclmul -msse4 -DPIC -c -o objs/crc_folding.o $(SRCDIR)crc_folding.c
-@mv objs/crc_folding.o $@

deflate_quick.lo: $(SRCDIR)deflate_quick.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -msse4 -DPIC -c -o objs/deflate_quick.o $(SRCDIR)deflate_quick.c
-@mv objs/deflate_quick.o $@

deflate_medium.lo: $(SRCDIR)deflate_medium.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/deflate_medium.o $(SRCDIR)deflate_medium.c
-@mv objs/deflate_medium.o $@

match.lo: $(SRCDIR)match.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/match.o $(SRCDIR)match.c
-@mv objs/match.o $@

placebo $(SHAREDLIBV): $(PIC_OBJS) libz.a
$(LDSHARED) $(SFLAGS) -o $@ $(PIC_OBJS) $(LDSHAREDLIBC) $(LDFLAGS)
Expand DownExpand Up@@ -398,6 +432,7 @@ infback.o inflate.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.
inffast.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h
inftrees.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h
trees.o: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)trees.h
x86.o: $(SRCDIR)x86.h

adler32.lo zutil.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h
gzclose.lo gzlib.lo gzread.lo gzwrite.lo: $(SRCDIR)zlib.h zconf.h $(SRCDIR)gzguts.h
Expand All@@ -408,3 +443,4 @@ infback.lo inflate.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftree
inffast.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h
inftrees.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h
trees.lo: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)trees.h
x86.lo: $(SRCDIR)x86.h
16 changes: 16 additions & 0 deletions adler32.c
Original file line numberDiff line numberDiff line change
Expand Up@@ -102,21 +102,37 @@ uLong ZEXPORT adler32_z(adler, buf, len)
/* do length NMAX blocks -- requires just one modulo operation */
while (len >= NMAX) {
len -= NMAX;
#ifndef ADLER32_UNROLL_LESS
n = NMAX / 16; /* NMAX is divisible by 16 */
#else
n = NMAX / 8; /* NMAX is divisible by 8 */
#endif
do {
#ifndef ADLER32_UNROLL_LESS
DO16(buf); /* 16 sums unrolled */
buf += 16;
#else
DO8(buf,0); /* 8 sums unrolled */
buf += 8;
#endif
} while (--n);
MOD(adler);
MOD(sum2);
}

/* do remaining bytes (less than NMAX, still just one modulo) */
if (len) { /* avoid modulos if none remaining */
#ifndef ADLER32_UNROLL_LESS
while (len >= 16) {
len -= 16;
DO16(buf);
buf += 16;
#else
while (len >= 8) {
len -= 8;
DO8(buf, 0);
buf += 8;
#endif
}
while (len--) {
adler += *buf++;
Expand Down
15 changes: 15 additions & 0 deletions crc32.c
Original file line numberDiff line numberDiff line change
Expand Up@@ -197,6 +197,7 @@ const z_crc_t FAR * ZEXPORT get_crc_table()
/* ========================================================================= */
#define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8)
#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
#define DO4 DO1; DO1; DO1; DO1

/* ========================================================================= */
unsigned long ZEXPORT crc32_z(crc, buf, len)
Expand All@@ -223,10 +224,19 @@ unsigned long ZEXPORT crc32_z(crc, buf, len)
}
#endif /* BYFOUR */
crc = crc ^ 0xffffffffUL;

#ifdef CRC32_UNROLL_LESS
while (len >= 4) {
DO4;
len -= 4;
}
#else
while (len >= 8) {
DO8;
len -= 8;
}
#endif

if (len) do {
DO1;
} while (--len);
Expand DownExpand Up@@ -279,10 +289,14 @@ local unsigned long crc32_little(crc, buf, len)
}

buf4 = (const z_crc_t FAR *)(const void FAR *)buf;

#ifndef CRC32_UNROLL_LESS
while (len >= 32) {
DOLIT32;
len -= 32;
}
#endif

while (len >= 4) {
DOLIT4;
len -= 4;
Expand DownExpand Up@@ -440,3 +454,4 @@ uLong ZEXPORT crc32_combine64(crc1, crc2, len2)
{
return crc32_combine_(crc1, crc2, len2);
}

Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content
This repository was archived by the owner on Mar 1, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4603884
For x86, add CPUID check.
jtkukunas Sep 16, 2013
4fa77e8
zutil.h: add zlikely/zunlikely macros
jtkukunas Jun 21, 2018
63f46f5
zutil.h: add zalign macro
jtkukunas Jun 21, 2018
c4b9af6
enable 16-bit longest_match for x86
jtkukunas Nov 6, 2017
aa5fd5c
Add preprocessor define to tune Adler32 loop unrolling.
jtkukunas Jul 17, 2013
d4726de
Add preprocessor define to tune crc32 unrolling.
jtkukunas Jul 17, 2013
c0d4a12
Adds SSE2 optimized slide_hash
jtkukunas Jun 21, 2018
43a5e76
adds SSE4.2 optimized hash function
jtkukunas Jun 21, 2018
fd93c50
add PCLMULQDQ optimized CRC folding
jtkukunas Jul 11, 2013
8419145
crc_folding: Fix potential out-of-bounds access
NicolasT Mar 3, 2016
9a06dac
crc_folding: use temp buffer for partial stores
jtkukunas Dec 8, 2016
3b11552
deflate: add new deflate_quick strategy for level 1
jtkukunas Jun 21, 2018
2073486
deflate.c fix for window bits > 13
Apr 17, 2016
d6a0d5f
deflate: add new deflate_medium strategy
jtkukunas Dec 8, 2016
afa49d8
deflate: avoid use of uninitialized variable
May 22, 2014
99a86da
check whether match or orig go too far back
jtkukunas May 27, 2014
3e77468
Include wmmintrin.h in configure test and crc_folding.c aid clang com…
mp15 Jun 10, 2014
62b7616
Reorganize inflate window layout
jtkukunas Dec 1, 2016
f9716e7
in the case of overlap copy mempcy dist bytes then byte by byte for a…
Nov 21, 2013
c960eeb
Add Intel's optimized RTE memcpy
Dec 8, 2016
58b51f6
integrate Intel's RTE memcpy with zmemcpy
Dec 8, 2016
641f59e
infcover: remove OoM test for SetDictionary since we don't lazy alloc
jtkukunas Dec 5, 2016
4fcda80
update gitignore
jtkukunas Oct 5, 2018
3c6b4f7
reorganize longest_match
jtkukunas Oct 5, 2018
8311c71
add zalways_inline for msvc and gcc
jtkukunas Oct 10, 2018
cb99979
force inline std2_longest_match
jtkukunas Oct 10, 2018
4b0ef4e
inflate: fix MSVC compiler warnings
vkvenkat Nov 9, 2018
3eecf51
inflate: handle windowBits == 16
jtkukunas Feb 1, 2019
3dd73ae
deflate_medium: add dist -1 to hash even for long matches
jtkukunas Apr 9, 2019
a43a247
deflate_medium: avoid emitting a suboptimal literal in the restart case
jtkukunas Apr 9, 2019
06a9370
Bug fix: add missing source files in CMakeLists.txt
dapeng-mi Dec 9, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .gitignore
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,4 +23,14 @@
/zlib.pc
/configure.log

*.obj
*.lib
*.pdb
*.exp
*.dll
*.exe
*.res

*.swp

.DS_Store
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -103,6 +103,7 @@ set(ZLIB_PRIVATE_HDRS
inflate.h
inftrees.h
trees.h
x86.h
zutil.h
)
set(ZLIB_SRCS
Expand All@@ -120,7 +121,12 @@ set(ZLIB_SRCS
inffast.c
trees.c
uncompr.c
x86.c
zutil.c
match.c
crc_folding.c
slide_sse.c
deflate_medium.c
)

if(NOT MINGW)
Expand Down
64 changes: 50 additions & 14 deletions Makefile.in
Original file line numberDiff line numberDiff line change
Expand Up@@ -57,11 +57,11 @@ SRCDIR=
ZINC=
ZINCOUT=-I.

OBJZ = adler32.o crc32.o deflate.o infback.o inffast.o inflate.o inftrees.o trees.o zutil.o
OBJZ = adler32.o crc32.o crc_folding.o deflate_quick.o deflate_medium.o deflate.o infback.o inffast.o inflate.o inftrees.o match.o slide_sse.o trees.o x86.o zutil.o
OBJG = compress.o uncompr.o gzclose.o gzlib.o gzread.o gzwrite.o
OBJC = $(OBJZ) $(OBJG)

PIC_OBJZ = adler32.lo crc32.lo deflate.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo zutil.lo
PIC_OBJZ = adler32.lo crc32.lo crc_folding.lo deflate_quick.lo deflate_medium.lo deflate.lo infback.lo inffast.lo inflate.lo inftrees.lo match.lo slide_sse.lo trees.lo x86.lo zutil.lo
PIC_OBJG = compress.lo uncompr.lo gzclose.lo gzlib.lo gzread.lo gzwrite.lo
PIC_OBJC = $(PIC_OBJZ) $(PIC_OBJG)

Expand DownExpand Up@@ -131,18 +131,6 @@ libz.a: $(OBJS)
$(AR) $(ARFLAGS) $@ $(OBJS)
-@ ($(RANLIB) $@ || true) >/dev/null 2>&1

match.o: match.S
$(CPP) match.S > _match.s
$(CC) -c _match.s
mv _match.o match.o
rm -f _match.s

match.lo: match.S
$(CPP) match.S > _match.s
$(CC) -c -fPIC _match.s
mv _match.o match.lo
rm -f _match.s

example.o: $(SRCDIR)test/example.c $(SRCDIR)zlib.h zconf.h
$(CC) $(CFLAGS) $(ZINCOUT) -c -o $@ $(SRCDIR)test/example.c

Expand DownExpand Up@@ -201,6 +189,23 @@ gzread.o: $(SRCDIR)gzread.c
gzwrite.o: $(SRCDIR)gzwrite.c
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)gzwrite.c

x86.o: $(SRCDIR)x86.c
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)x86.c

slide_sse.o: $(SRCDIR)slide_sse.c
$(CC) $(CFLAGS) $(ZINC) -msse2 -c -o $@ $(SRCDIR)slide_sse.c

crc_folding.o: $(SRCDIR)crc_folding.c
$(CC) $(CFLAGS) $(ZINC) -mpclmul -msse4 -c -o $@ $(SRCDIR)crc_folding.c

deflate_quick.o: $(SRCDIR)deflate_quick.c
$(CC) $(CFLAGS) $(ZINC) -msse4 -c -o $@ $(SRCDIR)deflate_quick.c

deflate_medium.o: $(SRCDIR)deflate_medium.c
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)deflate_medium.c

match.o: $(SRCDIR)match.c
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)match.c

adler32.lo: $(SRCDIR)adler32.c
-@mkdir objs 2>/dev/null || test -d objs
Expand DownExpand Up@@ -277,6 +282,35 @@ gzwrite.lo: $(SRCDIR)gzwrite.c
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/gzwrite.o $(SRCDIR)gzwrite.c
-@mv objs/gzwrite.o $@

x86.lo: $(SRCDIR)x86.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/x86.o $(SRCDIR)x86.c
-@mv objs/x86.o $@

slide_sse.lo: $(SRCDIR)slide_sse.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -msse2 -DPIC -c -o objs/slide_sse.o $(SRCDIR)slide_sse.c
-@mv objs/slide_sse.o $@

crc_folding.lo: $(SRCDIR)crc_folding.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -mpclmul -msse4 -DPIC -c -o objs/crc_folding.o $(SRCDIR)crc_folding.c
-@mv objs/crc_folding.o $@

deflate_quick.lo: $(SRCDIR)deflate_quick.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -msse4 -DPIC -c -o objs/deflate_quick.o $(SRCDIR)deflate_quick.c
-@mv objs/deflate_quick.o $@

deflate_medium.lo: $(SRCDIR)deflate_medium.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/deflate_medium.o $(SRCDIR)deflate_medium.c
-@mv objs/deflate_medium.o $@

match.lo: $(SRCDIR)match.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/match.o $(SRCDIR)match.c
-@mv objs/match.o $@

placebo $(SHAREDLIBV): $(PIC_OBJS) libz.a
$(LDSHARED) $(SFLAGS) -o $@ $(PIC_OBJS) $(LDSHAREDLIBC) $(LDFLAGS)
Expand DownExpand Up@@ -398,6 +432,7 @@ infback.o inflate.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.
inffast.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h
inftrees.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h
trees.o: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)trees.h
x86.o: $(SRCDIR)x86.h

adler32.lo zutil.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h
gzclose.lo gzlib.lo gzread.lo gzwrite.lo: $(SRCDIR)zlib.h zconf.h $(SRCDIR)gzguts.h
Expand All@@ -408,3 +443,4 @@ infback.lo inflate.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftree
inffast.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h
inftrees.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h
trees.lo: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)trees.h
x86.lo: $(SRCDIR)x86.h
16 changes: 16 additions & 0 deletions adler32.c
Original file line numberDiff line numberDiff line change
Expand Up@@ -102,21 +102,37 @@ uLong ZEXPORT adler32_z(adler, buf, len)
/* do length NMAX blocks -- requires just one modulo operation */
while (len >= NMAX) {
len -= NMAX;
#ifndef ADLER32_UNROLL_LESS
n = NMAX / 16; /* NMAX is divisible by 16 */
#else
n = NMAX / 8; /* NMAX is divisible by 8 */
#endif
do {
#ifndef ADLER32_UNROLL_LESS
DO16(buf); /* 16 sums unrolled */
buf += 16;
#else
DO8(buf,0); /* 8 sums unrolled */
buf += 8;
#endif
} while (--n);
MOD(adler);
MOD(sum2);
}

/* do remaining bytes (less than NMAX, still just one modulo) */
if (len) { /* avoid modulos if none remaining */
#ifndef ADLER32_UNROLL_LESS
while (len >= 16) {
len -= 16;
DO16(buf);
buf += 16;
#else
while (len >= 8) {
len -= 8;
DO8(buf, 0);
buf += 8;
#endif
}
while (len--) {
adler += *buf++;
Expand Down
15 changes: 15 additions & 0 deletions crc32.c
Original file line numberDiff line numberDiff line change
Expand Up@@ -197,6 +197,7 @@ const z_crc_t FAR * ZEXPORT get_crc_table()
/* ========================================================================= */
#define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8)
#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
#define DO4 DO1; DO1; DO1; DO1

/* ========================================================================= */
unsigned long ZEXPORT crc32_z(crc, buf, len)
Expand All@@ -223,10 +224,19 @@ unsigned long ZEXPORT crc32_z(crc, buf, len)
}
#endif /* BYFOUR */
crc = crc ^ 0xffffffffUL;

#ifdef CRC32_UNROLL_LESS
while (len >= 4) {
DO4;
len -= 4;
}
#else
while (len >= 8) {
DO8;
len -= 8;
}
#endif

if (len) do {
DO1;
} while (--len);
Expand DownExpand Up@@ -279,10 +289,14 @@ local unsigned long crc32_little(crc, buf, len)
}

buf4 = (const z_crc_t FAR *)(const void FAR *)buf;

#ifndef CRC32_UNROLL_LESS
while (len >= 32) {
DOLIT32;
len -= 32;
}
#endif

while (len >= 4) {
DOLIT4;
len -= 4;
Expand DownExpand Up@@ -440,3 +454,4 @@ uLong ZEXPORT crc32_combine64(crc1, crc2, len2)
{
return crc32_combine_(crc1, crc2, len2);
}

Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
This repository was archived by the owner on Mar 1, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4603884
For x86, add CPUID check.
jtkukunas Sep 16, 2013
4fa77e8
zutil.h: add zlikely/zunlikely macros
jtkukunas Jun 21, 2018
63f46f5
zutil.h: add zalign macro
jtkukunas Jun 21, 2018
c4b9af6
enable 16-bit longest_match for x86
jtkukunas Nov 6, 2017
aa5fd5c
Add preprocessor define to tune Adler32 loop unrolling.
jtkukunas Jul 17, 2013
d4726de
Add preprocessor define to tune crc32 unrolling.
jtkukunas Jul 17, 2013
c0d4a12
Adds SSE2 optimized slide_hash
jtkukunas Jun 21, 2018
43a5e76
adds SSE4.2 optimized hash function
jtkukunas Jun 21, 2018
fd93c50
add PCLMULQDQ optimized CRC folding
jtkukunas Jul 11, 2013
8419145
crc_folding: Fix potential out-of-bounds access
NicolasT Mar 3, 2016
9a06dac
crc_folding: use temp buffer for partial stores
jtkukunas Dec 8, 2016
3b11552
deflate: add new deflate_quick strategy for level 1
jtkukunas Jun 21, 2018
2073486
deflate.c fix for window bits > 13
Apr 17, 2016
d6a0d5f
deflate: add new deflate_medium strategy
jtkukunas Dec 8, 2016
afa49d8
deflate: avoid use of uninitialized variable
May 22, 2014
99a86da
check whether match or orig go too far back
jtkukunas May 27, 2014
3e77468
Include wmmintrin.h in configure test and crc_folding.c aid clang com…
mp15 Jun 10, 2014
62b7616
Reorganize inflate window layout
jtkukunas Dec 1, 2016
f9716e7
in the case of overlap copy mempcy dist bytes then byte by byte for a…
Nov 21, 2013
c960eeb
Add Intel's optimized RTE memcpy
Dec 8, 2016
58b51f6
integrate Intel's RTE memcpy with zmemcpy
Dec 8, 2016
641f59e
infcover: remove OoM test for SetDictionary since we don't lazy alloc
jtkukunas Dec 5, 2016
4fcda80
update gitignore
jtkukunas Oct 5, 2018
3c6b4f7
reorganize longest_match
jtkukunas Oct 5, 2018
8311c71
add zalways_inline for msvc and gcc
jtkukunas Oct 10, 2018
cb99979
force inline std2_longest_match
jtkukunas Oct 10, 2018
4b0ef4e
inflate: fix MSVC compiler warnings
vkvenkat Nov 9, 2018
3eecf51
inflate: handle windowBits == 16
jtkukunas Feb 1, 2019
3dd73ae
deflate_medium: add dist -1 to hash even for long matches
jtkukunas Apr 9, 2019
a43a247
deflate_medium: avoid emitting a suboptimal literal in the restart case
jtkukunas Apr 9, 2019
06a9370
Bug fix: add missing source files in CMakeLists.txt
dapeng-mi Dec 9, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .gitignore
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,4 +23,14 @@
/zlib.pc
/configure.log

*.obj
*.lib
*.pdb
*.exp
*.dll
*.exe
*.res

*.swp

.DS_Store
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -103,6 +103,7 @@ set(ZLIB_PRIVATE_HDRS
inflate.h
inftrees.h
trees.h
x86.h
zutil.h
)
set(ZLIB_SRCS
Expand All@@ -120,7 +121,12 @@ set(ZLIB_SRCS
inffast.c
trees.c
uncompr.c
x86.c
zutil.c
match.c
crc_folding.c
slide_sse.c
deflate_medium.c
)

if(NOT MINGW)
Expand Down
64 changes: 50 additions & 14 deletions Makefile.in
Original file line numberDiff line numberDiff line change
Expand Up@@ -57,11 +57,11 @@ SRCDIR=
ZINC=
ZINCOUT=-I.

OBJZ = adler32.o crc32.o deflate.o infback.o inffast.o inflate.o inftrees.o trees.o zutil.o
OBJZ = adler32.o crc32.o crc_folding.o deflate_quick.o deflate_medium.o deflate.o infback.o inffast.o inflate.o inftrees.o match.o slide_sse.o trees.o x86.o zutil.o
OBJG = compress.o uncompr.o gzclose.o gzlib.o gzread.o gzwrite.o
OBJC = $(OBJZ) $(OBJG)

PIC_OBJZ = adler32.lo crc32.lo deflate.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo zutil.lo
PIC_OBJZ = adler32.lo crc32.lo crc_folding.lo deflate_quick.lo deflate_medium.lo deflate.lo infback.lo inffast.lo inflate.lo inftrees.lo match.lo slide_sse.lo trees.lo x86.lo zutil.lo
PIC_OBJG = compress.lo uncompr.lo gzclose.lo gzlib.lo gzread.lo gzwrite.lo
PIC_OBJC = $(PIC_OBJZ) $(PIC_OBJG)

Expand DownExpand Up@@ -131,18 +131,6 @@ libz.a: $(OBJS)
$(AR) $(ARFLAGS) $@ $(OBJS)
-@ ($(RANLIB) $@ || true) >/dev/null 2>&1

match.o: match.S
$(CPP) match.S > _match.s
$(CC) -c _match.s
mv _match.o match.o
rm -f _match.s

match.lo: match.S
$(CPP) match.S > _match.s
$(CC) -c -fPIC _match.s
mv _match.o match.lo
rm -f _match.s

example.o: $(SRCDIR)test/example.c $(SRCDIR)zlib.h zconf.h
$(CC) $(CFLAGS) $(ZINCOUT) -c -o $@ $(SRCDIR)test/example.c

Expand DownExpand Up@@ -201,6 +189,23 @@ gzread.o: $(SRCDIR)gzread.c
gzwrite.o: $(SRCDIR)gzwrite.c
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)gzwrite.c

x86.o: $(SRCDIR)x86.c
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)x86.c

slide_sse.o: $(SRCDIR)slide_sse.c
$(CC) $(CFLAGS) $(ZINC) -msse2 -c -o $@ $(SRCDIR)slide_sse.c

crc_folding.o: $(SRCDIR)crc_folding.c
$(CC) $(CFLAGS) $(ZINC) -mpclmul -msse4 -c -o $@ $(SRCDIR)crc_folding.c

deflate_quick.o: $(SRCDIR)deflate_quick.c
$(CC) $(CFLAGS) $(ZINC) -msse4 -c -o $@ $(SRCDIR)deflate_quick.c

deflate_medium.o: $(SRCDIR)deflate_medium.c
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)deflate_medium.c

match.o: $(SRCDIR)match.c
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)match.c

adler32.lo: $(SRCDIR)adler32.c
-@mkdir objs 2>/dev/null || test -d objs
Expand DownExpand Up@@ -277,6 +282,35 @@ gzwrite.lo: $(SRCDIR)gzwrite.c
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/gzwrite.o $(SRCDIR)gzwrite.c
-@mv objs/gzwrite.o $@

x86.lo: $(SRCDIR)x86.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/x86.o $(SRCDIR)x86.c
-@mv objs/x86.o $@

slide_sse.lo: $(SRCDIR)slide_sse.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -msse2 -DPIC -c -o objs/slide_sse.o $(SRCDIR)slide_sse.c
-@mv objs/slide_sse.o $@

crc_folding.lo: $(SRCDIR)crc_folding.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -mpclmul -msse4 -DPIC -c -o objs/crc_folding.o $(SRCDIR)crc_folding.c
-@mv objs/crc_folding.o $@

deflate_quick.lo: $(SRCDIR)deflate_quick.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -msse4 -DPIC -c -o objs/deflate_quick.o $(SRCDIR)deflate_quick.c
-@mv objs/deflate_quick.o $@

deflate_medium.lo: $(SRCDIR)deflate_medium.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/deflate_medium.o $(SRCDIR)deflate_medium.c
-@mv objs/deflate_medium.o $@

match.lo: $(SRCDIR)match.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/match.o $(SRCDIR)match.c
-@mv objs/match.o $@

placebo $(SHAREDLIBV): $(PIC_OBJS) libz.a
$(LDSHARED) $(SFLAGS) -o $@ $(PIC_OBJS) $(LDSHAREDLIBC) $(LDFLAGS)
Expand DownExpand Up@@ -398,6 +432,7 @@ infback.o inflate.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.
inffast.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h
inftrees.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h
trees.o: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)trees.h
x86.o: $(SRCDIR)x86.h

adler32.lo zutil.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h
gzclose.lo gzlib.lo gzread.lo gzwrite.lo: $(SRCDIR)zlib.h zconf.h $(SRCDIR)gzguts.h
Expand All@@ -408,3 +443,4 @@ infback.lo inflate.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftree
inffast.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h
inftrees.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h
trees.lo: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)trees.h
x86.lo: $(SRCDIR)x86.h
16 changes: 16 additions & 0 deletions adler32.c
Original file line numberDiff line numberDiff line change
Expand Up@@ -102,21 +102,37 @@ uLong ZEXPORT adler32_z(adler, buf, len)
/* do length NMAX blocks -- requires just one modulo operation */
while (len >= NMAX) {
len -= NMAX;
#ifndef ADLER32_UNROLL_LESS
n = NMAX / 16; /* NMAX is divisible by 16 */
#else
n = NMAX / 8; /* NMAX is divisible by 8 */
#endif
do {
#ifndef ADLER32_UNROLL_LESS
DO16(buf); /* 16 sums unrolled */
buf += 16;
#else
DO8(buf,0); /* 8 sums unrolled */
buf += 8;
#endif
} while (--n);
MOD(adler);
MOD(sum2);
}

/* do remaining bytes (less than NMAX, still just one modulo) */
if (len) { /* avoid modulos if none remaining */
#ifndef ADLER32_UNROLL_LESS
while (len >= 16) {
len -= 16;
DO16(buf);
buf += 16;
#else
while (len >= 8) {
len -= 8;
DO8(buf, 0);
buf += 8;
#endif
}
while (len--) {
adler += *buf++;
Expand Down
15 changes: 15 additions & 0 deletions crc32.c
Original file line numberDiff line numberDiff line change
Expand Up@@ -197,6 +197,7 @@ const z_crc_t FAR * ZEXPORT get_crc_table()
/* ========================================================================= */
#define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8)
#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
#define DO4 DO1; DO1; DO1; DO1

/* ========================================================================= */
unsigned long ZEXPORT crc32_z(crc, buf, len)
Expand All@@ -223,10 +224,19 @@ unsigned long ZEXPORT crc32_z(crc, buf, len)
}
#endif /* BYFOUR */
crc = crc ^ 0xffffffffUL;

#ifdef CRC32_UNROLL_LESS
while (len >= 4) {
DO4;
len -= 4;
}
#else
while (len >= 8) {
DO8;
len -= 8;
}
#endif

if (len) do {
DO1;
} while (--len);
Expand DownExpand Up@@ -279,10 +289,14 @@ local unsigned long crc32_little(crc, buf, len)
}

buf4 = (const z_crc_t FAR *)(const void FAR *)buf;

#ifndef CRC32_UNROLL_LESS
while (len >= 32) {
DOLIT32;
len -= 32;
}
#endif

while (len >= 4) {
DOLIT4;
len -= 4;
Expand DownExpand Up@@ -440,3 +454,4 @@ uLong ZEXPORT crc32_combine64(crc1, crc2, len2)
{
return crc32_combine_(crc1, crc2, len2);
}

Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
This repository was archived by the owner on Mar 1, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4603884
For x86, add CPUID check.
jtkukunas Sep 16, 2013
4fa77e8
zutil.h: add zlikely/zunlikely macros
jtkukunas Jun 21, 2018
63f46f5
zutil.h: add zalign macro
jtkukunas Jun 21, 2018
c4b9af6
enable 16-bit longest_match for x86
jtkukunas Nov 6, 2017
aa5fd5c
Add preprocessor define to tune Adler32 loop unrolling.
jtkukunas Jul 17, 2013
d4726de
Add preprocessor define to tune crc32 unrolling.
jtkukunas Jul 17, 2013
c0d4a12
Adds SSE2 optimized slide_hash
jtkukunas Jun 21, 2018
43a5e76
adds SSE4.2 optimized hash function
jtkukunas Jun 21, 2018
fd93c50
add PCLMULQDQ optimized CRC folding
jtkukunas Jul 11, 2013
8419145
crc_folding: Fix potential out-of-bounds access
NicolasT Mar 3, 2016
9a06dac
crc_folding: use temp buffer for partial stores
jtkukunas Dec 8, 2016
3b11552
deflate: add new deflate_quick strategy for level 1
jtkukunas Jun 21, 2018
2073486
deflate.c fix for window bits > 13
Apr 17, 2016
d6a0d5f
deflate: add new deflate_medium strategy
jtkukunas Dec 8, 2016
afa49d8
deflate: avoid use of uninitialized variable
May 22, 2014
99a86da
check whether match or orig go too far back
jtkukunas May 27, 2014
3e77468
Include wmmintrin.h in configure test and crc_folding.c aid clang com…
mp15 Jun 10, 2014
62b7616
Reorganize inflate window layout
jtkukunas Dec 1, 2016
f9716e7
in the case of overlap copy mempcy dist bytes then byte by byte for a…
Nov 21, 2013
c960eeb
Add Intel's optimized RTE memcpy
Dec 8, 2016
58b51f6
integrate Intel's RTE memcpy with zmemcpy
Dec 8, 2016
641f59e
infcover: remove OoM test for SetDictionary since we don't lazy alloc
jtkukunas Dec 5, 2016
4fcda80
update gitignore
jtkukunas Oct 5, 2018
3c6b4f7
reorganize longest_match
jtkukunas Oct 5, 2018
8311c71
add zalways_inline for msvc and gcc
jtkukunas Oct 10, 2018
cb99979
force inline std2_longest_match
jtkukunas Oct 10, 2018
4b0ef4e
inflate: fix MSVC compiler warnings
vkvenkat Nov 9, 2018
3eecf51
inflate: handle windowBits == 16
jtkukunas Feb 1, 2019
3dd73ae
deflate_medium: add dist -1 to hash even for long matches
jtkukunas Apr 9, 2019
a43a247
deflate_medium: avoid emitting a suboptimal literal in the restart case
jtkukunas Apr 9, 2019
06a9370
Bug fix: add missing source files in CMakeLists.txt
dapeng-mi Dec 9, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .gitignore
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,4 +23,14 @@
/zlib.pc
/configure.log

*.obj
*.lib
*.pdb
*.exp
*.dll
*.exe
*.res

*.swp

.DS_Store
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -103,6 +103,7 @@ set(ZLIB_PRIVATE_HDRS
inflate.h
inftrees.h
trees.h
x86.h
zutil.h
)
set(ZLIB_SRCS
Expand All@@ -120,7 +121,12 @@ set(ZLIB_SRCS
inffast.c
trees.c
uncompr.c
x86.c
zutil.c
match.c
crc_folding.c
slide_sse.c
deflate_medium.c
)

if(NOT MINGW)
Expand Down
64 changes: 50 additions & 14 deletions Makefile.in
Original file line numberDiff line numberDiff line change
Expand Up@@ -57,11 +57,11 @@ SRCDIR=
ZINC=
ZINCOUT=-I.

OBJZ = adler32.o crc32.o deflate.o infback.o inffast.o inflate.o inftrees.o trees.o zutil.o
OBJZ = adler32.o crc32.o crc_folding.o deflate_quick.o deflate_medium.o deflate.o infback.o inffast.o inflate.o inftrees.o match.o slide_sse.o trees.o x86.o zutil.o
OBJG = compress.o uncompr.o gzclose.o gzlib.o gzread.o gzwrite.o
OBJC = $(OBJZ) $(OBJG)

PIC_OBJZ = adler32.lo crc32.lo deflate.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo zutil.lo
PIC_OBJZ = adler32.lo crc32.lo crc_folding.lo deflate_quick.lo deflate_medium.lo deflate.lo infback.lo inffast.lo inflate.lo inftrees.lo match.lo slide_sse.lo trees.lo x86.lo zutil.lo
PIC_OBJG = compress.lo uncompr.lo gzclose.lo gzlib.lo gzread.lo gzwrite.lo
PIC_OBJC = $(PIC_OBJZ) $(PIC_OBJG)

Expand DownExpand Up@@ -131,18 +131,6 @@ libz.a: $(OBJS)
$(AR) $(ARFLAGS) $@ $(OBJS)
-@ ($(RANLIB) $@ || true) >/dev/null 2>&1

match.o: match.S
$(CPP) match.S > _match.s
$(CC) -c _match.s
mv _match.o match.o
rm -f _match.s

match.lo: match.S
$(CPP) match.S > _match.s
$(CC) -c -fPIC _match.s
mv _match.o match.lo
rm -f _match.s

example.o: $(SRCDIR)test/example.c $(SRCDIR)zlib.h zconf.h
$(CC) $(CFLAGS) $(ZINCOUT) -c -o $@ $(SRCDIR)test/example.c

Expand DownExpand Up@@ -201,6 +189,23 @@ gzread.o: $(SRCDIR)gzread.c
gzwrite.o: $(SRCDIR)gzwrite.c
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)gzwrite.c

x86.o: $(SRCDIR)x86.c
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)x86.c

slide_sse.o: $(SRCDIR)slide_sse.c
$(CC) $(CFLAGS) $(ZINC) -msse2 -c -o $@ $(SRCDIR)slide_sse.c

crc_folding.o: $(SRCDIR)crc_folding.c
$(CC) $(CFLAGS) $(ZINC) -mpclmul -msse4 -c -o $@ $(SRCDIR)crc_folding.c

deflate_quick.o: $(SRCDIR)deflate_quick.c
$(CC) $(CFLAGS) $(ZINC) -msse4 -c -o $@ $(SRCDIR)deflate_quick.c

deflate_medium.o: $(SRCDIR)deflate_medium.c
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)deflate_medium.c

match.o: $(SRCDIR)match.c
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)match.c

adler32.lo: $(SRCDIR)adler32.c
-@mkdir objs 2>/dev/null || test -d objs
Expand DownExpand Up@@ -277,6 +282,35 @@ gzwrite.lo: $(SRCDIR)gzwrite.c
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/gzwrite.o $(SRCDIR)gzwrite.c
-@mv objs/gzwrite.o $@

x86.lo: $(SRCDIR)x86.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/x86.o $(SRCDIR)x86.c
-@mv objs/x86.o $@

slide_sse.lo: $(SRCDIR)slide_sse.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -msse2 -DPIC -c -o objs/slide_sse.o $(SRCDIR)slide_sse.c
-@mv objs/slide_sse.o $@

crc_folding.lo: $(SRCDIR)crc_folding.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -mpclmul -msse4 -DPIC -c -o objs/crc_folding.o $(SRCDIR)crc_folding.c
-@mv objs/crc_folding.o $@

deflate_quick.lo: $(SRCDIR)deflate_quick.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -msse4 -DPIC -c -o objs/deflate_quick.o $(SRCDIR)deflate_quick.c
-@mv objs/deflate_quick.o $@

deflate_medium.lo: $(SRCDIR)deflate_medium.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/deflate_medium.o $(SRCDIR)deflate_medium.c
-@mv objs/deflate_medium.o $@

match.lo: $(SRCDIR)match.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/match.o $(SRCDIR)match.c
-@mv objs/match.o $@

placebo $(SHAREDLIBV): $(PIC_OBJS) libz.a
$(LDSHARED) $(SFLAGS) -o $@ $(PIC_OBJS) $(LDSHAREDLIBC) $(LDFLAGS)
Expand DownExpand Up@@ -398,6 +432,7 @@ infback.o inflate.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.
inffast.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h
inftrees.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h
trees.o: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)trees.h
x86.o: $(SRCDIR)x86.h

adler32.lo zutil.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h
gzclose.lo gzlib.lo gzread.lo gzwrite.lo: $(SRCDIR)zlib.h zconf.h $(SRCDIR)gzguts.h
Expand All@@ -408,3 +443,4 @@ infback.lo inflate.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftree
inffast.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h
inftrees.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h
trees.lo: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)trees.h
x86.lo: $(SRCDIR)x86.h
16 changes: 16 additions & 0 deletions adler32.c
Original file line numberDiff line numberDiff line change
Expand Up@@ -102,21 +102,37 @@ uLong ZEXPORT adler32_z(adler, buf, len)
/* do length NMAX blocks -- requires just one modulo operation */
while (len >= NMAX) {
len -= NMAX;
#ifndef ADLER32_UNROLL_LESS
n = NMAX / 16; /* NMAX is divisible by 16 */
#else
n = NMAX / 8; /* NMAX is divisible by 8 */
#endif
do {
#ifndef ADLER32_UNROLL_LESS
DO16(buf); /* 16 sums unrolled */
buf += 16;
#else
DO8(buf,0); /* 8 sums unrolled */
buf += 8;
#endif
} while (--n);
MOD(adler);
MOD(sum2);
}

/* do remaining bytes (less than NMAX, still just one modulo) */
if (len) { /* avoid modulos if none remaining */
#ifndef ADLER32_UNROLL_LESS
while (len >= 16) {
len -= 16;
DO16(buf);
buf += 16;
#else
while (len >= 8) {
len -= 8;
DO8(buf, 0);
buf += 8;
#endif
}
while (len--) {
adler += *buf++;
Expand Down
15 changes: 15 additions & 0 deletions crc32.c
Original file line numberDiff line numberDiff line change
Expand Up@@ -197,6 +197,7 @@ const z_crc_t FAR * ZEXPORT get_crc_table()
/* ========================================================================= */
#define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8)
#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
#define DO4 DO1; DO1; DO1; DO1

/* ========================================================================= */
unsigned long ZEXPORT crc32_z(crc, buf, len)
Expand All@@ -223,10 +224,19 @@ unsigned long ZEXPORT crc32_z(crc, buf, len)
}
#endif /* BYFOUR */
crc = crc ^ 0xffffffffUL;

#ifdef CRC32_UNROLL_LESS
while (len >= 4) {
DO4;
len -= 4;
}
#else
while (len >= 8) {
DO8;
len -= 8;
}
#endif

if (len) do {
DO1;
} while (--len);
Expand DownExpand Up@@ -279,10 +289,14 @@ local unsigned long crc32_little(crc, buf, len)
}

buf4 = (const z_crc_t FAR *)(const void FAR *)buf;

#ifndef CRC32_UNROLL_LESS
while (len >= 32) {
DOLIT32;
len -= 32;
}
#endif

while (len >= 4) {
DOLIT4;
len -= 4;
Expand DownExpand Up@@ -440,3 +454,4 @@ uLong ZEXPORT crc32_combine64(crc1, crc2, len2)
{
return crc32_combine_(crc1, crc2, len2);
}

Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content
This repository was archived by the owner on Mar 1, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4603884
For x86, add CPUID check.
jtkukunas Sep 16, 2013
4fa77e8
zutil.h: add zlikely/zunlikely macros
jtkukunas Jun 21, 2018
63f46f5
zutil.h: add zalign macro
jtkukunas Jun 21, 2018
c4b9af6
enable 16-bit longest_match for x86
jtkukunas Nov 6, 2017
aa5fd5c
Add preprocessor define to tune Adler32 loop unrolling.
jtkukunas Jul 17, 2013
d4726de
Add preprocessor define to tune crc32 unrolling.
jtkukunas Jul 17, 2013
c0d4a12
Adds SSE2 optimized slide_hash
jtkukunas Jun 21, 2018
43a5e76
adds SSE4.2 optimized hash function
jtkukunas Jun 21, 2018
fd93c50
add PCLMULQDQ optimized CRC folding
jtkukunas Jul 11, 2013
8419145
crc_folding: Fix potential out-of-bounds access
NicolasT Mar 3, 2016
9a06dac
crc_folding: use temp buffer for partial stores
jtkukunas Dec 8, 2016
3b11552
deflate: add new deflate_quick strategy for level 1
jtkukunas Jun 21, 2018
2073486
deflate.c fix for window bits > 13
Apr 17, 2016
d6a0d5f
deflate: add new deflate_medium strategy
jtkukunas Dec 8, 2016
afa49d8
deflate: avoid use of uninitialized variable
May 22, 2014
99a86da
check whether match or orig go too far back
jtkukunas May 27, 2014
3e77468
Include wmmintrin.h in configure test and crc_folding.c aid clang com…
mp15 Jun 10, 2014
62b7616
Reorganize inflate window layout
jtkukunas Dec 1, 2016
f9716e7
in the case of overlap copy mempcy dist bytes then byte by byte for a…
Nov 21, 2013
c960eeb
Add Intel's optimized RTE memcpy
Dec 8, 2016
58b51f6
integrate Intel's RTE memcpy with zmemcpy
Dec 8, 2016
641f59e
infcover: remove OoM test for SetDictionary since we don't lazy alloc
jtkukunas Dec 5, 2016
4fcda80
update gitignore
jtkukunas Oct 5, 2018
3c6b4f7
reorganize longest_match
jtkukunas Oct 5, 2018
8311c71
add zalways_inline for msvc and gcc
jtkukunas Oct 10, 2018
cb99979
force inline std2_longest_match
jtkukunas Oct 10, 2018
4b0ef4e
inflate: fix MSVC compiler warnings
vkvenkat Nov 9, 2018
3eecf51
inflate: handle windowBits == 16
jtkukunas Feb 1, 2019
3dd73ae
deflate_medium: add dist -1 to hash even for long matches
jtkukunas Apr 9, 2019
a43a247
deflate_medium: avoid emitting a suboptimal literal in the restart case
jtkukunas Apr 9, 2019
06a9370
Bug fix: add missing source files in CMakeLists.txt
dapeng-mi Dec 9, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .gitignore
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,4 +23,14 @@
/zlib.pc
/configure.log

*.obj
*.lib
*.pdb
*.exp
*.dll
*.exe
*.res

*.swp

.DS_Store
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -103,6 +103,7 @@ set(ZLIB_PRIVATE_HDRS
inflate.h
inftrees.h
trees.h
x86.h
zutil.h
)
set(ZLIB_SRCS
Expand All@@ -120,7 +121,12 @@ set(ZLIB_SRCS
inffast.c
trees.c
uncompr.c
x86.c
zutil.c
match.c
crc_folding.c
slide_sse.c
deflate_medium.c
)

if(NOT MINGW)
Expand Down
64 changes: 50 additions & 14 deletions Makefile.in
Original file line numberDiff line numberDiff line change
Expand Up@@ -57,11 +57,11 @@ SRCDIR=
ZINC=
ZINCOUT=-I.

OBJZ = adler32.o crc32.o deflate.o infback.o inffast.o inflate.o inftrees.o trees.o zutil.o
OBJZ = adler32.o crc32.o crc_folding.o deflate_quick.o deflate_medium.o deflate.o infback.o inffast.o inflate.o inftrees.o match.o slide_sse.o trees.o x86.o zutil.o
OBJG = compress.o uncompr.o gzclose.o gzlib.o gzread.o gzwrite.o
OBJC = $(OBJZ) $(OBJG)

PIC_OBJZ = adler32.lo crc32.lo deflate.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo zutil.lo
PIC_OBJZ = adler32.lo crc32.lo crc_folding.lo deflate_quick.lo deflate_medium.lo deflate.lo infback.lo inffast.lo inflate.lo inftrees.lo match.lo slide_sse.lo trees.lo x86.lo zutil.lo
PIC_OBJG = compress.lo uncompr.lo gzclose.lo gzlib.lo gzread.lo gzwrite.lo
PIC_OBJC = $(PIC_OBJZ) $(PIC_OBJG)

Expand DownExpand Up@@ -131,18 +131,6 @@ libz.a: $(OBJS)
$(AR) $(ARFLAGS) $@ $(OBJS)
-@ ($(RANLIB) $@ || true) >/dev/null 2>&1

match.o: match.S
$(CPP) match.S > _match.s
$(CC) -c _match.s
mv _match.o match.o
rm -f _match.s

match.lo: match.S
$(CPP) match.S > _match.s
$(CC) -c -fPIC _match.s
mv _match.o match.lo
rm -f _match.s

example.o: $(SRCDIR)test/example.c $(SRCDIR)zlib.h zconf.h
$(CC) $(CFLAGS) $(ZINCOUT) -c -o $@ $(SRCDIR)test/example.c

Expand DownExpand Up@@ -201,6 +189,23 @@ gzread.o: $(SRCDIR)gzread.c
gzwrite.o: $(SRCDIR)gzwrite.c
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)gzwrite.c

x86.o: $(SRCDIR)x86.c
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)x86.c

slide_sse.o: $(SRCDIR)slide_sse.c
$(CC) $(CFLAGS) $(ZINC) -msse2 -c -o $@ $(SRCDIR)slide_sse.c

crc_folding.o: $(SRCDIR)crc_folding.c
$(CC) $(CFLAGS) $(ZINC) -mpclmul -msse4 -c -o $@ $(SRCDIR)crc_folding.c

deflate_quick.o: $(SRCDIR)deflate_quick.c
$(CC) $(CFLAGS) $(ZINC) -msse4 -c -o $@ $(SRCDIR)deflate_quick.c

deflate_medium.o: $(SRCDIR)deflate_medium.c
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)deflate_medium.c

match.o: $(SRCDIR)match.c
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)match.c

adler32.lo: $(SRCDIR)adler32.c
-@mkdir objs 2>/dev/null || test -d objs
Expand DownExpand Up@@ -277,6 +282,35 @@ gzwrite.lo: $(SRCDIR)gzwrite.c
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/gzwrite.o $(SRCDIR)gzwrite.c
-@mv objs/gzwrite.o $@

x86.lo: $(SRCDIR)x86.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/x86.o $(SRCDIR)x86.c
-@mv objs/x86.o $@

slide_sse.lo: $(SRCDIR)slide_sse.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -msse2 -DPIC -c -o objs/slide_sse.o $(SRCDIR)slide_sse.c
-@mv objs/slide_sse.o $@

crc_folding.lo: $(SRCDIR)crc_folding.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -mpclmul -msse4 -DPIC -c -o objs/crc_folding.o $(SRCDIR)crc_folding.c
-@mv objs/crc_folding.o $@

deflate_quick.lo: $(SRCDIR)deflate_quick.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -msse4 -DPIC -c -o objs/deflate_quick.o $(SRCDIR)deflate_quick.c
-@mv objs/deflate_quick.o $@

deflate_medium.lo: $(SRCDIR)deflate_medium.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/deflate_medium.o $(SRCDIR)deflate_medium.c
-@mv objs/deflate_medium.o $@

match.lo: $(SRCDIR)match.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/match.o $(SRCDIR)match.c
-@mv objs/match.o $@

placebo $(SHAREDLIBV): $(PIC_OBJS) libz.a
$(LDSHARED) $(SFLAGS) -o $@ $(PIC_OBJS) $(LDSHAREDLIBC) $(LDFLAGS)
Expand DownExpand Up@@ -398,6 +432,7 @@ infback.o inflate.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.
inffast.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h
inftrees.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h
trees.o: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)trees.h
x86.o: $(SRCDIR)x86.h

adler32.lo zutil.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h
gzclose.lo gzlib.lo gzread.lo gzwrite.lo: $(SRCDIR)zlib.h zconf.h $(SRCDIR)gzguts.h
Expand All@@ -408,3 +443,4 @@ infback.lo inflate.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftree
inffast.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h
inftrees.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h
trees.lo: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)trees.h
x86.lo: $(SRCDIR)x86.h
16 changes: 16 additions & 0 deletions adler32.c
Original file line numberDiff line numberDiff line change
Expand Up@@ -102,21 +102,37 @@ uLong ZEXPORT adler32_z(adler, buf, len)
/* do length NMAX blocks -- requires just one modulo operation */
while (len >= NMAX) {
len -= NMAX;
#ifndef ADLER32_UNROLL_LESS
n = NMAX / 16; /* NMAX is divisible by 16 */
#else
n = NMAX / 8; /* NMAX is divisible by 8 */
#endif
do {
#ifndef ADLER32_UNROLL_LESS
DO16(buf); /* 16 sums unrolled */
buf += 16;
#else
DO8(buf,0); /* 8 sums unrolled */
buf += 8;
#endif
} while (--n);
MOD(adler);
MOD(sum2);
}

/* do remaining bytes (less than NMAX, still just one modulo) */
if (len) { /* avoid modulos if none remaining */
#ifndef ADLER32_UNROLL_LESS
while (len >= 16) {
len -= 16;
DO16(buf);
buf += 16;
#else
while (len >= 8) {
len -= 8;
DO8(buf, 0);
buf += 8;
#endif
}
while (len--) {
adler += *buf++;
Expand Down
15 changes: 15 additions & 0 deletions crc32.c
Original file line numberDiff line numberDiff line change
Expand Up@@ -197,6 +197,7 @@ const z_crc_t FAR * ZEXPORT get_crc_table()
/* ========================================================================= */
#define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8)
#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
#define DO4 DO1; DO1; DO1; DO1

/* ========================================================================= */
unsigned long ZEXPORT crc32_z(crc, buf, len)
Expand All@@ -223,10 +224,19 @@ unsigned long ZEXPORT crc32_z(crc, buf, len)
}
#endif /* BYFOUR */
crc = crc ^ 0xffffffffUL;

#ifdef CRC32_UNROLL_LESS
while (len >= 4) {
DO4;
len -= 4;
}
#else
while (len >= 8) {
DO8;
len -= 8;
}
#endif

if (len) do {
DO1;
} while (--len);
Expand DownExpand Up@@ -279,10 +289,14 @@ local unsigned long crc32_little(crc, buf, len)
}

buf4 = (const z_crc_t FAR *)(const void FAR *)buf;

#ifndef CRC32_UNROLL_LESS
while (len >= 32) {
DOLIT32;
len -= 32;
}
#endif

while (len >= 4) {
DOLIT4;
len -= 4;
Expand DownExpand Up@@ -440,3 +454,4 @@ uLong ZEXPORT crc32_combine64(crc1, crc2, len2)
{
return crc32_combine_(crc1, crc2, len2);
}

Loading