Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed and updated zlib #60

Merged
merged 3 commits into from
Jul 6, 2020
Merged

Fixed and updated zlib #60

merged 3 commits into from
Jul 6, 2020

Conversation

snej
Copy link
Contributor

@snej snej commented Jun 19, 2020

Three commits addressing these three issues:

snej added 3 commits June 19, 2020 16:47
Integer types in zlib.h were not properly translated into Nim. Most
seriously, `Ulong` and `Ulongf` (which are both `unsigned long`)
were translated to `int32`, which is wrong on LP64 systems like
macOS, iOS and I think 64-bit Linux too.

This causes the Nim `ZStream` struct to be much shorter than the real
`z_stream` (88 vs 120 bytes), and that causes the size comparison in
the inflate/deflateInit functions to fail with Z_VERSION_ERROR, which
is actually a good thing because if it kept going it would be smashing
memory, since Nim didn't allocate enough space for its struct.

I've fixed the types to the best of my knowledge, using the standard
C-based types like `cint` and `culong`. The only iffy one is `ZOffT`
which has a complicated conditional definition in C -- I think it's
supposed to match `off_t`, whose size depends not on the ABI but on
whether the filesystem supports 64-bit files... I made it a `clong`
since most systems handle 64-bit files nowadays.

Fixes nim-lang#23, nim-lang#39, nim-lang#53
The version parameter passed to deflateInitu etc. is supposed to be
the compile-time version string (from zlib.h), not the runtime version
returned by zlibVersion().
We didn't have a compile-time version constant, so I added one based
on the value from the zlib.h header I'm working from, i.e. "1.2.11".

Fixes nim-lang#59
Added newer zlib functions: deflateTune, deflatePending, deflatePrime,
deflateSetHeader, inflateGetDictionary, inflateCopy, inflateReset2,
inflatePrime, inflateMark, inflateGetHeader, zlibCompileFlags.

Fixes nim-lang#58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants