Skip to content

Commit 8aaf820

Browse files
committed
fix zlib
1 parent 3bbf364 commit 8aaf820

File tree

2 files changed

+162
-145
lines changed

2 files changed

+162
-145
lines changed

vendor/zlib/libz.lib

-522 KB
Binary file not shown.

vendor/zlib/zlib.odin

Lines changed: 162 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,32 @@ when ODIN_OS == .Windows {
1010
foreign import zlib "system:z"
1111
}
1212

13-
VERSION :: "1.2.12"
14-
VERNUM :: 0x12c0
15-
VER_MAJOR :: 1
16-
VER_MINOR :: 2
17-
VER_REVISION :: 12
13+
VERSION :: "1.3.1"
14+
VERNUM :: 0x1310
15+
VER_MAJOR :: 1
16+
VER_MINOR :: 3
17+
VER_REVISION :: 1
1818
VER_SUBREVISION :: 0
1919

20-
voidp :: rawptr
21-
voidpf :: rawptr
22-
voidpc :: rawptr
23-
Byte :: c.uchar
24-
Bytef :: c.uchar
25-
uInt :: c.uint
26-
uIntf :: c.uint
27-
uLong :: c.ulong
28-
uLongf :: c.ulong
29-
size_t :: c.size_t
30-
off_t :: c.long
31-
off64_t :: i64
32-
crc_t :: u32
20+
voidp :: rawptr
21+
voidpf :: rawptr
22+
voidpc :: rawptr
23+
Byte :: c.uchar
24+
Bytef :: c.uchar
25+
uInt :: c.uint
26+
uIntf :: c.uint
27+
uLong :: c.ulong
28+
uLongf :: c.ulong
29+
size_t :: c.size_t
30+
off_t :: c.long
31+
off64_t :: i64
32+
crc_t :: u32
3333

34-
alloc_func :: proc "c" (opaque: voidp, items: uInt, size: uInt) -> voidpf
35-
free_func :: proc "c" (opaque: voidp, address: voidpf)
34+
alloc_func :: proc "c" (opaque: voidp, items: uInt, size: uInt) -> voidpf
35+
free_func :: proc "c" (opaque: voidp, address: voidpf)
3636

37-
in_func :: proc "c" (rawptr, [^][^]c.uchar) -> c.uint
38-
out_func :: proc "c" (rawptr, [^]c.uchar, c.uint) -> c.int
37+
in_func :: proc "c" (_: rawptr, _: [^][^]c.uchar) -> c.uint
38+
out_func :: proc "c" (_: rawptr, _: [^]c.uchar, _: c.uint) -> c.int
3939

4040
gzFile_s :: struct {
4141
have: c.uint,
@@ -52,7 +52,7 @@ z_stream_s :: struct {
5252
next_out: ^Bytef,
5353
avail_out: uInt,
5454
total_out: uLong,
55-
msg: [^]c.char,
55+
msg: [^]c.char, //TODO: check if cstring might work
5656
state: rawptr,
5757
zalloc: alloc_func,
5858
zfree: free_func,
@@ -62,7 +62,7 @@ z_stream_s :: struct {
6262
reserved: uLong,
6363
}
6464

65-
z_stream :: z_stream_s
65+
z_stream :: z_stream_s
6666
z_streamp :: ^z_stream
6767

6868
gz_header_s :: struct {
@@ -81,173 +81,190 @@ gz_header_s :: struct {
8181
done: c.int,
8282
}
8383

84-
gz_header :: gz_header_s
84+
gz_header :: gz_header_s
8585
gz_headerp :: ^gz_header
8686

8787
// Allowed flush values; see deflate() and inflate() below for details
88-
NO_FLUSH :: 0
89-
PARTIAL_FLUSH :: 1
90-
SYNC_FLUSH :: 2
91-
FULL_FLUSH :: 3
92-
FINISH :: 4
93-
BLOCK :: 5
94-
TREES :: 6
88+
NO_FLUSH :: 0
89+
PARTIAL_FLUSH :: 1
90+
SYNC_FLUSH :: 2
91+
FULL_FLUSH :: 3
92+
FINISH :: 4
93+
BLOCK :: 5
94+
TREES :: 6
9595

9696
// Return codes for the compression/decompression functions. Negative values are
9797
// errors, positive values are used for special but normal events.
98-
OK :: 0
99-
STREAM_END :: 1
100-
NEED_DICT :: 2
101-
ERRNO :: -1
102-
STREAM_ERROR :: -2
103-
DATA_ERROR :: -3
104-
MEM_ERROR :: -4
105-
BUF_ERROR :: -5
106-
VERSION_ERROR :: -6
98+
OK :: 0
99+
STREAM_END :: 1
100+
NEED_DICT :: 2
101+
ERRNO :: -1
102+
STREAM_ERROR :: -2
103+
DATA_ERROR :: -3
104+
MEM_ERROR :: -4
105+
BUF_ERROR :: -5
106+
VERSION_ERROR :: -6
107107

108108
// compression levels
109-
NO_COMPRESSION :: 0
110-
BEST_SPEED :: 1
111-
BEST_COMPRESSION :: 9
112-
DEFAULT_COMPRESSION :: -1
109+
NO_COMPRESSION :: 0
110+
BEST_SPEED :: 1
111+
BEST_COMPRESSION :: 9
112+
DEFAULT_COMPRESSION :: -1
113113

114114
// compression strategy; see deflateInit2() below for details
115-
FILTERED :: 1
116-
HUFFMAN_ONLY :: 2
117-
RLE :: 3
118-
FIXED :: 4
119-
DEFAULT_STRATEGY :: 0
115+
FILTERED :: 1
116+
HUFFMAN_ONLY :: 2
117+
RLE :: 3
118+
FIXED :: 4
119+
DEFAULT_STRATEGY :: 0
120120

121121
// Possible values of the data_type field for deflate()
122-
BINARY :: 0
123-
TEXT :: 1
124-
ASCII :: TEXT // for compatibility with 1.2.2 and earlier
125-
UNKNOWN :: 2
122+
BINARY :: 0
123+
TEXT :: 1
124+
ASCII :: TEXT // for compatibility with 1.2.2 and earlier
125+
UNKNOWN :: 2
126126

127127
// The deflate compression method (the only one supported in this version)
128-
DEFLATED :: 8
128+
DEFLATED :: 8
129129

130-
NULL :: 0 // for initializing zalloc, zfree, opaque
131130

132-
version :: Version // for compatibility with versions < 1.0.2
131+
NULL :: 0 // Don't use this for initializing the zalloc, zfree, opaque function pointers! Use nil instead.
133132

134-
@(default_calling_convention="c")
133+
version :: Version // for compatibility with versions < 1.0.2
134+
135+
@(default_calling_convention = "c")
135136
foreign zlib {
136137
// becase zlib.zlibVersion would be silly to write
137-
@(link_prefix="zlib")
138-
Version :: proc() -> cstring ---
138+
@(link_prefix = "zlib")
139+
Version :: proc() -> cstring ---
139140

140-
deflate :: proc(strm: z_streamp, flush: c.int) -> c.int ---
141-
deflateEnd :: proc(strm: z_streamp) -> c.int ---
142-
inflate :: proc(strm: z_streamp, flush: c.int) -> c.int ---
143-
inflateEnd :: proc(strm: z_streamp) -> c.int ---
141+
deflate :: proc(strm: z_streamp, flush: c.int) -> c.int ---
142+
deflateEnd :: proc(strm: z_streamp) -> c.int ---
143+
inflate :: proc(strm: z_streamp, flush: c.int) -> c.int ---
144+
inflateEnd :: proc(strm: z_streamp) -> c.int ---
144145
deflateSetDictionary :: proc(strm: z_streamp, dictionary: [^]Bytef, dictLength: uInt) -> c.int ---
145146
deflateGetDictionary :: proc(strm: z_streamp, dictionary: [^]Bytef, dictLength: ^uInt) -> c.int ---
146-
deflateCopy :: proc(dest, source: z_streamp) -> c.int ---
147-
deflateReset :: proc(strm: z_streamp) -> c.int ---
148-
deflateParams :: proc(strm: z_streamp, level, strategy: c.int) -> c.int ---
149-
deflateTune :: proc(strm: z_streamp, good_length, max_lazy, nice_length, max_chain: c.int) -> c.int ---
150-
deflateBound :: proc(strm: z_streamp, sourceLen: uLong) -> uLong ---
151-
deflatePending :: proc(strm: z_streamp, pending: [^]c.uint, bits: [^]c.int) -> c.int ---
152-
deflatePrime :: proc(strm: z_streamp, bits, value: c.int) -> c.int ---
153-
deflateSetHeader :: proc(strm: z_streamp, head: gz_headerp) -> c.int ---
147+
deflateCopy :: proc(dest, source: z_streamp) -> c.int ---
148+
deflateReset :: proc(strm: z_streamp) -> c.int ---
149+
deflateParams :: proc(strm: z_streamp, level, strategy: c.int) -> c.int ---
150+
deflateTune :: proc(strm: z_streamp, good_length, max_lazy, nice_length, max_chain: c.int) -> c.int ---
151+
deflateBound :: proc(strm: z_streamp, sourceLen: uLong) -> uLong ---
152+
deflatePending :: proc(strm: z_streamp, pending: [^]c.uint, bits: [^]c.int) -> c.int ---
153+
deflatePrime :: proc(strm: z_streamp, bits, value: c.int) -> c.int ---
154+
deflateSetHeader :: proc(strm: z_streamp, head: gz_headerp) -> c.int ---
154155
inflateSetDictionary :: proc(strm: z_streamp, dictionary: [^]Bytef, dictLength: uInt) -> c.int ---
155156
inflateGetDictionary :: proc(strm: z_streamp, dictionary: [^]Bytef, dictLength: ^uInt) -> c.int ---
156-
inflateSync :: proc(strm: z_streamp) -> c.int ---
157-
inflateCopy :: proc(dest, source: z_streamp) -> c.int ---
158-
inflateReset :: proc(strm: z_streamp) -> c.int ---
159-
inflateReset2 :: proc(strm: z_streamp, windowBits: c.int) -> c.int ---
160-
inflatePrime :: proc(strm: z_streamp, bits, value: c.int) -> c.int ---
161-
inflateMark :: proc(strm: z_streamp) -> c.long ---
162-
inflateGetHeader :: proc(strm: z_streamp, head: gz_headerp) -> c.int ---
163-
inflateBack :: proc(strm: z_streamp, _in: in_func, in_desc: rawptr, out: out_func, out_desc: rawptr) -> c.int ---
164-
inflateBackEnd :: proc(strm: z_streamp) -> c.int ---
165-
zlibCompileFlags :: proc() -> uLong ---
166-
compress :: proc(dest: [^]Bytef, destLen: ^uLongf, source: [^]Bytef, sourceLen: uLong) -> c.int ---
167-
compress2 :: proc(dest: [^]Bytef, destLen: ^uLongf, source: [^]Bytef, sourceLen: uLong, level: c.int) -> c.int ---
168-
compressBound :: proc(sourceLen: uLong) -> uLong ---
169-
uncompress :: proc(dest: [^]Bytef, destLen: ^uLongf, source: [^]Bytef, sourceLen: uLong) -> c.int ---
170-
uncompress2 :: proc(dest: [^]Bytef, destLen: ^uLongf, source: [^]Bytef, sourceLen: ^uLong) -> c.int ---
171-
gzdopen :: proc(fd: c.int, mode: cstring) -> gzFile ---
172-
gzbuffer :: proc(file: gzFile, size: c.uint) -> c.int ---
173-
gzsetparams :: proc(file: gzFile, level, strategy: c.int) -> c.int ---
174-
gzread :: proc(file: gzFile, buf: voidp, len: c.uint) -> c.int ---
175-
gzfread :: proc(buf: voidp, size, nitems: size_t, file: gzFile) -> size_t ---
176-
gzwrite :: proc(file: gzFile, buf: voidpc, len: c.uint) -> c.int ---
177-
gzfwrite :: proc(buf: voidpc, size, nitems: size_t, file: gzFile) -> size_t ---
178-
gzprintf :: proc(file: gzFile, format: cstring, #c_vararg args: ..any) -> c.int ---
179-
gzputs :: proc(file: gzFile, s: cstring) -> c.int ---
180-
gzgets :: proc(file: gzFile, buf: [^]c.char, len: c.int) -> [^]c.char ---
181-
gzputc :: proc(file: gzFile, ch: c.int) -> c.int ---
182-
gzgetc_ :: proc(file: gzFile) -> c.int --- // backwards compat, not the same as gzget
183-
gzungetc :: proc(ch: c.int, file: gzFile) -> c.int ---
184-
gzflush :: proc(file: gzFile, flush: c.int) -> c.int ---
185-
gzrewind :: proc(file: gzFile) -> c.int ---
186-
gzeof :: proc(file: gzFile) -> c.int ---
187-
gzdirect :: proc(file: gzFile) -> c.int ---
188-
gzclose :: proc(file: gzFile) -> c.int ---
189-
gzclose_r :: proc(file: gzFile) -> c.int ---
190-
gzclose_w :: proc(file: gzFile) -> c.int ---
191-
gzerror :: proc(file: gzFile, errnum: ^c.int) -> cstring ---
192-
gzclearerr :: proc(file: gzFile) ---
193-
adler32 :: proc(adler: uLong, buf: [^]Bytef, len: uInt) -> uLong ---
194-
adler32_z :: proc(adler: uLong, buf: [^]Bytef, len: size_t) -> uLong ---
195-
crc32 :: proc(crc: uLong, buf: [^]Bytef, len: uInt) -> uLong ---
196-
crc32_z :: proc(crc: uLong, buf: [^]Bytef, len: size_t) -> uLong ---
197-
crc32_combine_op :: proc(crc1, crc2, op: uLong) -> uLong ---
198-
gzopen64 :: proc(cstring, cstring) -> gzFile ---
199-
gzseek64 :: proc(gzFile, off64_t, c.int) -> off64_t ---
200-
gztell64 :: proc(gzFile) -> off64_t ---
201-
gzoffset64 :: proc(gzFile) -> off64_t ---
202-
adler32_combine64 :: proc(uLong, uLong, off64_t) -> uLong ---
203-
crc32_combine64 :: proc(uLong, uLong, off64_t) -> uLong ---
204-
crc32_combine_gen64 :: proc(off64_t) -> uLong ---
205-
adler32_combine :: proc(uLong, uLong, off_t) -> uLong ---
206-
crc32_combine :: proc(uLong, uLong, off_t) -> uLong ---
207-
crc32_combine_gen :: proc(off_t) -> uLong ---
208-
zError :: proc(c.int) -> cstring ---
209-
inflateSyncPoint :: proc(z_streamp) -> c.int ---
210-
get_crc_table :: proc() -> [^]crc_t ---
211-
inflateUndermine :: proc(z_streamp, c.int) -> c.int ---
212-
inflateValidate :: proc(z_streamp, c.int) -> c.int ---
213-
inflateCodesUsed :: proc(z_streamp) -> c.ulong ---
214-
inflateResetKeep :: proc(z_streamp) -> c.int ---
215-
deflateResetKeep :: proc(z_streamp) -> c.int ---
157+
inflateSync :: proc(strm: z_streamp) -> c.int ---
158+
inflateCopy :: proc(dest, source: z_streamp) -> c.int ---
159+
inflateReset :: proc(strm: z_streamp) -> c.int ---
160+
inflateReset2 :: proc(strm: z_streamp, windowBits: c.int) -> c.int ---
161+
inflatePrime :: proc(strm: z_streamp, bits, value: c.int) -> c.int ---
162+
inflateMark :: proc(strm: z_streamp) -> c.long ---
163+
inflateGetHeader :: proc(strm: z_streamp, head: gz_headerp) -> c.int ---
164+
inflateBack :: proc(strm: z_streamp, _in: in_func, in_desc: rawptr, out: out_func, out_desc: rawptr) -> c.int ---
165+
inflateBackEnd :: proc(strm: z_streamp) -> c.int ---
166+
zlibCompileFlags :: proc() -> uLong ---
167+
compress :: proc(dest: [^]Bytef, destLen: ^uLongf, source: [^]Bytef, sourceLen: uLong) -> c.int ---
168+
compress2 :: proc(dest: [^]Bytef, destLen: ^uLongf, source: [^]Bytef, sourceLen: uLong, level: c.int) -> c.int ---
169+
compressBound :: proc(sourceLen: uLong) -> uLong ---
170+
uncompress :: proc(dest: [^]Bytef, destLen: ^uLongf, source: [^]Bytef, sourceLen: uLong) -> c.int ---
171+
uncompress2 :: proc(dest: [^]Bytef, destLen: ^uLongf, source: [^]Bytef, sourceLen: ^uLong) -> c.int ---
172+
gzdopen :: proc(fd: c.int, mode: cstring) -> gzFile ---
173+
gzbuffer :: proc(file: gzFile, size: c.uint) -> c.int ---
174+
gzsetparams :: proc(file: gzFile, level, strategy: c.int) -> c.int ---
175+
gzread :: proc(file: gzFile, buf: voidp, len: c.uint) -> c.int ---
176+
gzfread :: proc(buf: voidp, size, nitems: size_t, file: gzFile) -> size_t ---
177+
gzwrite :: proc(file: gzFile, buf: voidpc, len: c.uint) -> c.int ---
178+
gzfwrite :: proc(buf: voidpc, size, nitems: size_t, file: gzFile) -> size_t ---
179+
gzprintf :: proc(file: gzFile, format: cstring, #c_vararg args: ..any) -> c.int ---
180+
gzputs :: proc(file: gzFile, s: cstring) -> c.int ---
181+
gzgets :: proc(file: gzFile, buf: [^]c.char, len: c.int) -> [^]c.char ---
182+
gzputc :: proc(file: gzFile, ch: c.int) -> c.int ---
183+
gzgetc_ :: proc(file: gzFile) -> c.int --- // backwards compat, not the same as gzget
184+
gzungetc :: proc(ch: c.int, file: gzFile) -> c.int ---
185+
gzflush :: proc(file: gzFile, flush: c.int) -> c.int ---
186+
gzrewind :: proc(file: gzFile) -> c.int ---
187+
gzeof :: proc(file: gzFile) -> c.int ---
188+
gzdirect :: proc(file: gzFile) -> c.int ---
189+
gzclose :: proc(file: gzFile) -> c.int ---
190+
gzclose_r :: proc(file: gzFile) -> c.int ---
191+
gzclose_w :: proc(file: gzFile) -> c.int ---
192+
gzerror :: proc(file: gzFile, errnum: ^c.int) -> cstring ---
193+
gzclearerr :: proc(file: gzFile) ---
194+
adler32 :: proc(adler: uLong, buf: [^]Bytef, len: uInt) -> uLong ---
195+
adler32_z :: proc(adler: uLong, buf: [^]Bytef, len: size_t) -> uLong ---
196+
crc32 :: proc(crc: uLong, buf: [^]Bytef, len: uInt) -> uLong ---
197+
crc32_z :: proc(crc: uLong, buf: [^]Bytef, len: size_t) -> uLong ---
198+
crc32_combine_op :: proc(crc1, crc2, op: uLong) -> uLong ---
199+
gzopen64 :: proc(_: cstring, _: cstring) -> gzFile ---
200+
gzseek64 :: proc(_: gzFile, _: off64_t, _: c.int) -> off64_t ---
201+
gztell64 :: proc(_: gzFile) -> off64_t ---
202+
gzoffset64 :: proc(_: gzFile) -> off64_t ---
203+
adler32_combine64 :: proc(_: uLong, _: uLong, _: off64_t) -> uLong ---
204+
crc32_combine64 :: proc(_: uLong, _: uLong, _: off64_t) -> uLong ---
205+
crc32_combine_gen64 :: proc(_: off64_t) -> uLong ---
206+
adler32_combine :: proc(_: uLong, _: uLong, _: off_t) -> uLong ---
207+
crc32_combine :: proc(_: uLong, _: uLong, _: off_t) -> uLong ---
208+
crc32_combine_gen :: proc(_: off_t) -> uLong ---
209+
zError :: proc(_: c.int) -> cstring ---
210+
inflateSyncPoint :: proc(_: z_streamp) -> c.int ---
211+
get_crc_table :: proc() -> [^]crc_t ---
212+
inflateUndermine :: proc(_: z_streamp, _: c.int) -> c.int ---
213+
inflateValidate :: proc(_: z_streamp, _: c.int) -> c.int ---
214+
inflateCodesUsed :: proc(_: z_streamp) -> c.ulong ---
215+
inflateResetKeep :: proc(_: z_streamp) -> c.int ---
216+
deflateResetKeep :: proc(_: z_streamp) -> c.int ---
216217
}
217218

218219
// Make these private since we create wrappers below passing in version and size
219220
// of the stream structure like zlib.h does
220221
@(private)
221-
@(default_calling_convention="c")
222+
@(default_calling_convention = "c")
222223
foreign zlib {
223-
deflateInit_ :: proc(strm: z_streamp, level: c.int, version: cstring, stream_size: c.int) -> c.int ---
224-
inflateInit_ :: proc(strm: z_streamp, level: c.int, version: cstring, stream_size: c.int) -> c.int ---
225-
deflateInit2_ :: proc(strm: z_streamp, level, method, windowBits, memLevel, strategy: c.int, version: cstring, stream_size: c.int) -> c.int ---
226-
inflateInit2_ :: proc(strm: z_streamp, windowBits: c.int, version: cstring, stream_size: c.int) -> c.int ---
227-
inflateBackInit_ :: proc(strm: z_streamp, windowBits: c.int, window: [^]c.uchar, version: cstring, stream_size: c.int) -> c.int ---
224+
deflateInit_ :: proc(strm: z_streamp, level: c.int, version: cstring, stream_size: c.int) -> c.int ---
225+
inflateInit_ :: proc(strm: z_streamp, version: cstring, stream_size: c.int) -> c.int ---
226+
deflateInit2_ :: proc(strm: z_streamp, level, method, windowBits, memLevel, strategy: c.int, version: cstring, stream_size: c.int) -> c.int ---
227+
inflateInit2_ :: proc(strm: z_streamp, windowBits: c.int, version: cstring, stream_size: c.int) -> c.int ---
228+
inflateBackInit_ :: proc(strm: z_streamp, windowBits: c.int, window: [^]c.uchar, version: cstring, stream_size: c.int) -> c.int ---
228229

229230
// see below for explanation
230-
@(link_name="gzgetc")
231-
gzgetc_unique :: proc(file: gzFile) -> c.int ---
231+
@(link_name = "gzgetc")
232+
gzgetc_unique :: proc(file: gzFile) -> c.int ---
232233
}
233234

234235
deflateInit :: #force_inline proc "c" (strm: z_streamp, level: c.int) -> c.int {
235236
return deflateInit_(strm, level, VERSION, c.int(size_of(z_stream)))
236237
}
237238

238-
inflateInit :: #force_inline proc "c" (strm: z_streamp, level: c.int) -> c.int {
239-
return inflateInit_(strm, level, VERSION, c.int(size_of(z_stream)))
239+
inflateInit :: #force_inline proc "c" (strm: z_streamp) -> c.int {
240+
return inflateInit_(strm, VERSION, c.int(size_of(z_stream)))
240241
}
241242

242-
deflateInit2 :: #force_inline proc "c" (strm: z_streamp, level, method, windowBits, memLevel, strategy: c.int) -> c.int {
243-
return deflateInit2_(strm, level, method, windowBits, memLevel, strategy, VERSION, c.int(size_of(z_stream)))
243+
deflateInit2 :: #force_inline proc "c" (
244+
strm: z_streamp,
245+
level, method, windowBits, memLevel, strategy: c.int,
246+
) -> c.int {
247+
return deflateInit2_(
248+
strm,
249+
level,
250+
method,
251+
windowBits,
252+
memLevel,
253+
strategy,
254+
VERSION,
255+
c.int(size_of(z_stream)),
256+
)
244257
}
245258

246259
inflateInit2 :: #force_inline proc "c" (strm: z_streamp, windowBits: c.int) -> c.int {
247260
return inflateInit2_(strm, windowBits, VERSION, c.int(size_of(z_stream)))
248261
}
249262

250-
inflateBackInit :: #force_inline proc "c" (strm: z_streamp, windowBits: c.int, window: [^]c.uchar) -> c.int {
263+
inflateBackInit :: #force_inline proc "c" (
264+
strm: z_streamp,
265+
windowBits: c.int,
266+
window: [^]c.uchar,
267+
) -> c.int {
251268
return inflateBackInit_(strm, windowBits, window, VERSION, c.int(size_of(z_stream)))
252269
}
253270

0 commit comments

Comments
 (0)