modernc.org/z@v1.7.4/internal/example_windows_arm64.go (about) 1 // Code generated by 'ccgo -lmodernc.org/z/lib -o internal\example_windows_arm64.go -trace-translation-units C:\Users\jnml\AppData\Local\Temp\go-generate-2743941486\cdb.json example.exe', DO NOT EDIT. 2 3 package main 4 5 import ( 6 "math" 7 "reflect" 8 "sync/atomic" 9 "unsafe" 10 11 "modernc.org/libc" 12 "modernc.org/libc/sys/types" 13 "modernc.org/z/lib" 14 ) 15 16 var _ = math.Pi 17 var _ reflect.Kind 18 var _ atomic.Value 19 var _ unsafe.Pointer 20 var _ *libc.TLS 21 var _ types.Size_t 22 23 func main() { libc.Start(main1) } 24 25 type ptrdiff_t = int64 /* <builtin>:3:26 */ 26 27 type size_t = uint64 /* <builtin>:9:23 */ 28 29 type wchar_t = uint16 /* <builtin>:15:24 */ 30 31 type va_list = uintptr /* <builtin>:50:27 */ 32 33 // ===---- __stddef_max_align_t.h - Definition of max_align_t for modules ---=== 34 // 35 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 36 // See https://llvm.org/LICENSE.txt for license information. 37 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 38 // 39 //===-----------------------------------------------------------------------=== 40 41 // Define 'max_align_t' to match the GCC definition. 42 type max_align_t = struct { 43 __clang_max_align_nonce1 int64 44 __clang_max_align_nonce2 float64 45 } /* __stddef_max_align_t.h:24:3 */ 46 47 // Some C libraries expect to see a wint_t here. Others (notably MinGW) will use 48 // __WINT_TYPE__ directly; accommodate both by requiring __need_wint_t 49 50 type z_size_t = size_t /* zconf.h:248:21 */ 51 52 // Maximum value for memLevel in deflateInit2 53 54 // Maximum value for windowBits in deflateInit2 and inflateInit2. 55 // WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files 56 // created by gzip. (Files created by minigzip can still be extracted by 57 // gzip.) 58 59 // The memory requirements for deflate are (in bytes): 60 // (1 << (windowBits+2)) + (1 << (memLevel+9)) 61 // that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) 62 // plus a few kilobytes for small objects. For example, if you want to reduce 63 // the default memory requirements from 256K to 128K, compile with 64 // make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" 65 // Of course this will generally degrade compression (there's no free lunch). 66 // 67 // The memory requirements for inflate are (in bytes) 1 << windowBits 68 // that is, 32K for windowBits=15 (default value) plus about 7 kilobytes 69 // for small objects. 70 71 // Type declarations 72 73 // The following definitions for FAR are needed only for MSDOS mixed 74 // model programming (small or medium model with some far allocations). 75 // This was tested only with MSC; for other MSDOS compilers you may have 76 // to define NO_MEMCPY in zutil.h. If you don't need the mixed model, 77 // just define FAR to be empty. 78 79 // If building or using zlib as a DLL, define ZLIB_DLL. 80 // This is not mandatory, but it offers a little performance increase. 81 // If building or using zlib with the WINAPI/WINAPIV calling convention, 82 // define ZLIB_WINAPI. 83 // Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. 84 85 type Byte = uint8 /* zconf.h:391:24 */ // 8 bits 86 type uInt = uint32 /* zconf.h:393:24 */ // 16 bits or more 87 type uLong = uint32 /* zconf.h:394:24 */ // 32 bits or more 88 89 type Bytef = Byte /* zconf.h:400:22 */ 90 type charf = int8 /* zconf.h:402:19 */ 91 type intf = int32 /* zconf.h:403:19 */ 92 type uIntf = uInt /* zconf.h:404:19 */ 93 type uLongf = uLong /* zconf.h:405:19 */ 94 95 type voidpc = uintptr /* zconf.h:408:23 */ 96 type voidpf = uintptr /* zconf.h:409:23 */ 97 type voidp = uintptr /* zconf.h:410:23 */ 98 99 //===---- limits.h - Standard header for integer sizes --------------------===* * 100 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 101 // See https://llvm.org/LICENSE.txt for license information. 102 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 103 // 104 // \*===----------------------------------------------------------------------=== 105 106 // The system's limits.h may, in turn, try to #include_next GCC's limits.h. 107 // Avert this #include_next madness. 108 109 // System headers include a number of constants from POSIX in <limits.h>. 110 // Include it if we're hosted. 111 112 // Many system headers try to "help us out" by defining these. No really, we 113 // know how big each datatype is. 114 115 // C90/99 5.2.4.2.1 116 117 // C2x 5.2.4.2.1 118 // FIXME: This is using the placeholder dates Clang produces for these macros 119 // in C2x mode; switch to the correct values once they've been published. 120 121 // C99 5.2.4.2.1: Added long long. 122 // C++11 18.3.3.2: same contents as the Standard C Library header <limits.h>. 123 // 124 125 // LONG_LONG_MIN/LONG_LONG_MAX/ULONG_LONG_MAX are a GNU extension. It's too bad 126 // that we don't have something like #pragma poison that could be used to 127 // deprecate a macro - the code should just use LLONG_MAX and friends. 128 // 129 130 type z_crc_t = uint32 /* zconf.h:429:17 */ 131 132 type ssize_t = int64 /* corecrt.h:45:35 */ 133 134 type rsize_t = size_t /* corecrt.h:52:16 */ 135 136 type intptr_t = int64 /* corecrt.h:62:35 */ 137 138 type uintptr_t = uint64 /* corecrt.h:75:44 */ 139 140 type wint_t = uint16 /* corecrt.h:106:24 */ 141 type wctype_t = uint16 /* corecrt.h:107:24 */ 142 143 type errno_t = int32 /* corecrt.h:113:13 */ 144 145 type time_t = int64 /* corecrt.h:138:20 */ 146 147 type threadlocaleinfostruct = struct { 148 _locale_pctype uintptr 149 _locale_mb_cur_max int32 150 _locale_lc_codepage uint32 151 } /* corecrt.h:430:1 */ 152 153 type pthreadlocinfo = uintptr /* corecrt.h:432:39 */ 154 type pthreadmbcinfo = uintptr /* corecrt.h:433:36 */ 155 156 type localeinfo_struct = struct { 157 locinfo pthreadlocinfo 158 mbcinfo pthreadmbcinfo 159 } /* corecrt.h:436:9 */ 160 161 type _locale_tstruct = localeinfo_struct /* corecrt.h:439:3 */ 162 type _locale_t = uintptr /* corecrt.h:439:19 */ 163 164 type tagLC_ID = struct { 165 wLanguage uint16 166 wCountry uint16 167 wCodePage uint16 168 } /* corecrt.h:443:9 */ 169 170 type LC_ID = tagLC_ID /* corecrt.h:447:3 */ 171 type LPLC_ID = uintptr /* corecrt.h:447:9 */ 172 173 type threadlocinfo = threadlocaleinfostruct /* corecrt.h:482:3 */ 174 175 type _ino_t = uint16 /* types.h:43:24 */ 176 type ino_t = uint16 /* types.h:45:24 */ 177 178 type _dev_t = uint32 /* types.h:51:22 */ 179 type dev_t = uint32 /* types.h:53:22 */ 180 181 type _pid_t = int64 /* types.h:63:17 */ 182 183 type pid_t = _pid_t /* types.h:68:16 */ 184 185 type _mode_t = uint16 /* types.h:74:24 */ 186 187 type mode_t = _mode_t /* types.h:77:17 */ 188 189 type _off_t = int32 /* _mingw_off_t.h:5:16 */ 190 type off32_t = int32 /* _mingw_off_t.h:7:16 */ 191 192 type _off64_t = int64 /* _mingw_off_t.h:13:39 */ 193 type off64_t = int64 /* _mingw_off_t.h:15:39 */ 194 195 type off_t = off64_t /* _mingw_off_t.h:24:17 */ 196 197 type useconds_t = uint32 /* types.h:84:22 */ 198 199 type timespec = struct { 200 tv_sec time_t 201 tv_nsec int32 202 _ [4]byte 203 } /* types.h:89:1 */ 204 205 type itimerspec = struct { 206 it_interval struct { 207 tv_sec time_t 208 tv_nsec int32 209 _ [4]byte 210 } 211 it_value struct { 212 tv_sec time_t 213 tv_nsec int32 214 _ [4]byte 215 } 216 } /* types.h:94:1 */ 217 218 type _sigset_t = uint64 /* types.h:104:28 */ 219 220 // GCC always defines __va_copy, but does not define va_copy unless in c99 mode 221 // or -ansi is not specified, since it was not part of C90. 222 223 // ===---- stddef.h - Basic type definitions --------------------------------=== 224 // 225 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 226 // See https://llvm.org/LICENSE.txt for license information. 227 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 228 // 229 //===-----------------------------------------------------------------------=== 230 231 // a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and 232 // "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even 233 // though the former does not conform to the LFS document), but considering 234 // both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as 235 // equivalently requesting no 64-bit operations 236 237 // MVS linker does not support external names larger than 8 bytes 238 239 // 240 // The 'zlib' compression library provides in-memory compression and 241 // decompression functions, including integrity checks of the uncompressed data. 242 // This version of the library supports only one compression method (deflation) 243 // but other algorithms will be added later and will have the same stream 244 // interface. 245 // 246 // Compression can be done in a single step if the buffers are large enough, 247 // or can be done by repeated calls of the compression function. In the latter 248 // case, the application must provide more input and/or consume the output 249 // (providing more output space) before each call. 250 // 251 // The compressed data format used by default by the in-memory functions is 252 // the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped 253 // around a deflate stream, which is itself documented in RFC 1951. 254 // 255 // The library also supports reading and writing files in gzip (.gz) format 256 // with an interface similar to that of stdio using the functions that start 257 // with "gz". The gzip format is different from the zlib format. gzip is a 258 // gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. 259 // 260 // This library can optionally read and write gzip and raw deflate streams in 261 // memory as well. 262 // 263 // The zlib format was designed to be compact and fast for use in memory 264 // and on communications channels. The gzip format was designed for single- 265 // file compression on file systems, has a larger header than zlib to maintain 266 // directory information, and uses a different, slower check method than zlib. 267 // 268 // The library does not install any signal handler. The decoder checks 269 // the consistency of the compressed data, so the library should never crash 270 // even in the case of corrupted input. 271 272 type alloc_func = uintptr /* zlib.h:81:16 */ 273 type free_func = uintptr /* zlib.h:82:16 */ 274 275 type z_stream_s = struct { 276 next_in uintptr 277 avail_in uInt 278 total_in uLong 279 next_out uintptr 280 avail_out uInt 281 total_out uLong 282 msg uintptr 283 state uintptr 284 zalloc alloc_func 285 zfree free_func 286 opaque voidpf 287 data_type int32 288 adler uLong 289 reserved uLong 290 _ [4]byte 291 } /* zlib.h:86:9 */ 292 293 type z_stream = z_stream_s /* zlib.h:106:3 */ 294 295 type z_streamp = uintptr /* zlib.h:108:22 */ 296 297 // 298 // gzip header information passed to and from zlib routines. See RFC 1952 299 // for more details on the meanings of these fields. 300 type gz_header_s = struct { 301 text int32 302 time uLong 303 xflags int32 304 os int32 305 extra uintptr 306 extra_len uInt 307 extra_max uInt 308 name uintptr 309 name_max uInt 310 _ [4]byte 311 comment uintptr 312 comm_max uInt 313 hcrc int32 314 done int32 315 _ [4]byte 316 } /* zlib.h:114:9 */ 317 318 // 319 // gzip header information passed to and from zlib routines. See RFC 1952 320 // for more details on the meanings of these fields. 321 type gz_header = gz_header_s /* zlib.h:129:3 */ 322 323 type gz_headerp = uintptr /* zlib.h:131:23 */ 324 // 325 // inflateGetHeader() requests that gzip header information be stored in the 326 // provided gz_header structure. inflateGetHeader() may be called after 327 // inflateInit2() or inflateReset(), and before the first call of inflate(). 328 // As inflate() processes the gzip stream, head->done is zero until the header 329 // is completed, at which time head->done is set to one. If a zlib stream is 330 // being decoded, then head->done is set to -1 to indicate that there will be 331 // no gzip header information forthcoming. Note that Z_BLOCK or Z_TREES can be 332 // used to force inflate() to return immediately after header processing is 333 // complete and before any actual data is decompressed. 334 // 335 // The text, time, xflags, and os fields are filled in with the gzip header 336 // contents. hcrc is set to true if there is a header CRC. (The header CRC 337 // was valid if done is set to one.) If extra is not Z_NULL, then extra_max 338 // contains the maximum number of bytes to write to extra. Once done is true, 339 // extra_len contains the actual extra field length, and extra contains the 340 // extra field, or that field truncated if extra_max is less than extra_len. 341 // If name is not Z_NULL, then up to name_max characters are written there, 342 // terminated with a zero unless the length is greater than name_max. If 343 // comment is not Z_NULL, then up to comm_max characters are written there, 344 // terminated with a zero unless the length is greater than comm_max. When any 345 // of extra, name, or comment are not Z_NULL and the respective field is not 346 // present in the header, then that field is set to Z_NULL to signal its 347 // absence. This allows the use of deflateSetHeader() with the returned 348 // structure to duplicate the header. However if those fields are set to 349 // allocated memory, then the application will need to save those pointers 350 // elsewhere so that they can be eventually freed. 351 // 352 // If inflateGetHeader is not used, then the header information is simply 353 // discarded. The header is always checked for validity, including the header 354 // CRC if present. inflateReset() will reset the process to discard the header 355 // information. The application would need to call inflateGetHeader() again to 356 // retrieve the header from the next gzip stream. 357 // 358 // inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source 359 // stream state was inconsistent. 360 361 // 362 // ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, 363 // unsigned char FAR *window)); 364 // 365 // Initialize the internal stream state for decompression using inflateBack() 366 // calls. The fields zalloc, zfree and opaque in strm must be initialized 367 // before the call. If zalloc and zfree are Z_NULL, then the default library- 368 // derived memory allocation routines are used. windowBits is the base two 369 // logarithm of the window size, in the range 8..15. window is a caller 370 // supplied buffer of that size. Except for special applications where it is 371 // assured that deflate was used with small window sizes, windowBits must be 15 372 // and a 32K byte window must be supplied to be able to decompress general 373 // deflate streams. 374 // 375 // See inflateBack() for the usage of these routines. 376 // 377 // inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of 378 // the parameters are invalid, Z_MEM_ERROR if the internal state could not be 379 // allocated, or Z_VERSION_ERROR if the version of the library does not match 380 // the version of the header file. 381 382 type in_func = uintptr /* zlib.h:1092:18 */ 383 type out_func = uintptr /* zlib.h:1094:13 */ 384 // 385 // Same as uncompress, except that sourceLen is a pointer, where the 386 // length of the source is *sourceLen. On return, *sourceLen is the number of 387 // source bytes consumed. 388 389 // gzip file access functions 390 391 // 392 // This library supports reading and writing files in gzip (.gz) format with 393 // an interface similar to that of stdio, using the functions that start with 394 // "gz". The gzip format is different from the zlib format. gzip is a gzip 395 // wrapper, documented in RFC 1952, wrapped around a deflate stream. 396 397 type gzFile_s = struct { 398 have uint32 399 _ [4]byte 400 next uintptr 401 pos int32 402 _ [4]byte 403 } /* zlib.h:1300:9 */ 404 405 // 406 // Same as uncompress, except that sourceLen is a pointer, where the 407 // length of the source is *sourceLen. On return, *sourceLen is the number of 408 // source bytes consumed. 409 410 // gzip file access functions 411 412 // 413 // This library supports reading and writing files in gzip (.gz) format with 414 // an interface similar to that of stdio, using the functions that start with 415 // "gz". The gzip format is different from the zlib format. gzip is a gzip 416 // wrapper, documented in RFC 1952, wrapped around a deflate stream. 417 418 type gzFile = uintptr /* zlib.h:1300:25 */ 419 420 // * 421 // This file has no copyright assigned and is placed in the Public Domain. 422 // This file is part of the mingw-w64 runtime package. 423 // No warranty is given; refer to the file DISCLAIMER.PD within this package. 424 425 // * 426 // This file has no copyright assigned and is placed in the Public Domain. 427 // This file is part of the Wine project. 428 // No warranty is given; refer to the file DISCLAIMER.PD within this package. 429 430 // * 431 // This file has no copyright assigned and is placed in the Public Domain. 432 // This file is part of the mingw-w64 runtime package. 433 // No warranty is given; refer to the file DISCLAIMER.PD within this package. 434 435 type _iobuf = struct{ _Placeholder uintptr } /* stdio.h:33:3 */ 436 437 type FILE = _iobuf /* stdio.h:47:25 */ 438 439 type fpos_t = int64 /* stdio.h:115:37 */ 440 441 func vsnwprintf(tls *libc.TLS, s uintptr, n size_t, format uintptr, arg va_list) int32 { /* stdio.h:1321:15: */ 442 var __ret int32 = libc.X__stdio_common_vswprintf(tls, 0x0004, s, n, format, uintptr(0), arg) 443 if __ret < 0 { 444 return -1 445 } 446 return __ret 447 448 } 449 450 // * 451 // This file has no copyright assigned and is placed in the Public Domain. 452 // This file is part of the mingw-w64 runtime package. 453 // No warranty is given; refer to the file DISCLAIMER.PD within this package. 454 455 // ===-------- vadefs.h ---------------------------------------------------=== 456 // 457 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 458 // See https://llvm.org/LICENSE.txt for license information. 459 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 460 // 461 //===-----------------------------------------------------------------------=== 462 463 // Only include this if we are aiming for MSVC compatibility. 464 // * 465 // This file has no copyright assigned and is placed in the Public Domain. 466 // This file is part of the mingw-w64 runtime package. 467 // No warranty is given; refer to the file DISCLAIMER.PD within this package. 468 469 func vswprintf(tls *libc.TLS, __stream uintptr, __count size_t, __format uintptr, __local_argv uintptr) int32 { /* swprintf.inl:27:5: */ 470 return vsnwprintf(tls, __stream, __count, __format, __local_argv) 471 } 472 473 func _vfscanf_s_l(tls *libc.TLS, _File uintptr, _Format uintptr, _Locale _locale_t, _ArgList va_list) int32 { /* stdio_s.h:40:27: */ 474 return libc.X__stdio_common_vfscanf(tls, 0x0001, _File, _Format, _Locale, _ArgList) 475 476 } 477 478 func _vfscanf_l(tls *libc.TLS, _File uintptr, _Format uintptr, _Locale _locale_t, _ArgList va_list) int32 { /* stdio_s.h:85:27: */ 479 return libc.X__stdio_common_vfscanf(tls, uint64(0), _File, _Format, _Locale, _ArgList) 480 481 } 482 483 func _vsscanf_s_l(tls *libc.TLS, _Src uintptr, _Format uintptr, _Locale _locale_t, _ArgList va_list) int32 { /* stdio_s.h:108:27: */ 484 return libc.X__stdio_common_vsscanf(tls, 0x0001, _Src, libc.Uint64(libc.Uint64FromInt32(-1)), _Format, _Locale, _ArgList) 485 486 } 487 488 func _vsscanf_l(tls *libc.TLS, _Src uintptr, _Format uintptr, _Locale _locale_t, _ArgList va_list) int32 { /* stdio_s.h:135:27: */ 489 return libc.X__stdio_common_vsscanf(tls, uint64(0), _Src, libc.Uint64(libc.Uint64FromInt32(-1)), _Format, _Locale, _ArgList) 490 491 } 492 493 func _vfprintf_s_l(tls *libc.TLS, _File uintptr, _Format uintptr, _Locale _locale_t, _ArgList va_list) int32 { /* stdio_s.h:181:27: */ 494 return libc.X__stdio_common_vfprintf_s(tls, uint64(0), _File, _Format, _Locale, _ArgList) 495 496 } 497 498 func _vsnprintf_c_l(tls *libc.TLS, _DstBuf uintptr, _MaxCount size_t, _Format uintptr, _Locale _locale_t, _ArgList va_list) int32 { /* stdio_s.h:234:27: */ 499 return libc.X__stdio_common_vsprintf(tls, uint64(0), _DstBuf, _MaxCount, _Format, _Locale, _ArgList) 500 501 } 502 503 func _vsnprintf_s_l(tls *libc.TLS, _DstBuf uintptr, _DstSize size_t, _MaxCount size_t, _Format uintptr, _Locale _locale_t, _ArgList va_list) int32 { /* stdio_s.h:261:27: */ 504 return libc.X__stdio_common_vsnprintf_s(tls, uint64(0), _DstBuf, _DstSize, _MaxCount, _Format, _Locale, _ArgList) 505 506 } 507 508 func _vsprintf_s_l(tls *libc.TLS, _DstBuf uintptr, _DstSize size_t, _Format uintptr, _Locale _locale_t, _ArgList va_list) int32 { /* stdio_s.h:292:27: */ 509 return libc.X__stdio_common_vsprintf_s(tls, uint64(0), _DstBuf, _DstSize, _Format, _Locale, _ArgList) 510 511 } 512 513 func _vfprintf_p_l(tls *libc.TLS, _File uintptr, _Format uintptr, _Locale _locale_t, _ArgList va_list) int32 { /* stdio_s.h:319:27: */ 514 return libc.X__stdio_common_vfprintf_p(tls, uint64(0), _File, _Format, _Locale, _ArgList) 515 516 } 517 518 func _vsprintf_p_l(tls *libc.TLS, _DstBuf uintptr, _MaxCount size_t, _Format uintptr, _Locale _locale_t, _ArgList va_list) int32 { /* stdio_s.h:372:27: */ 519 return libc.X__stdio_common_vsprintf_p(tls, uint64(0), _DstBuf, _MaxCount, _Format, _Locale, _ArgList) 520 521 } 522 523 func _vscprintf_p_l(tls *libc.TLS, _Format uintptr, _Locale _locale_t, _ArgList va_list) int32 { /* stdio_s.h:399:27: */ 524 return libc.X__stdio_common_vsprintf_p(tls, 0x0002, uintptr(0), uint64(0), _Format, _Locale, _ArgList) 525 526 } 527 528 func _vfprintf_l(tls *libc.TLS, _File uintptr, _Format uintptr, _Locale _locale_t, _ArgList va_list) int32 { /* stdio_s.h:426:27: */ 529 return libc.X__stdio_common_vfprintf(tls, uint64(0), _File, _Format, _Locale, _ArgList) 530 531 } 532 533 func _vsnprintf_l(tls *libc.TLS, _DstBuf uintptr, _MaxCount size_t, _Format uintptr, _Locale _locale_t, _ArgList va_list) int32 { /* stdio_s.h:453:27: */ 534 return libc.X__stdio_common_vsprintf(tls, 0x0001, _DstBuf, _MaxCount, _Format, _Locale, _ArgList) 535 536 } 537 538 func _vsprintf_l(tls *libc.TLS, _DstBuf uintptr, _Format uintptr, _Locale _locale_t, _ArgList va_list) int32 { /* stdio_s.h:466:27: */ 539 return _vsnprintf_l(tls, _DstBuf, libc.Uint64(libc.Uint64FromInt32(-1)), _Format, _Locale, _ArgList) 540 541 } 542 543 func _vscprintf_l(tls *libc.TLS, _Format uintptr, _Locale _locale_t, _ArgList va_list) int32 { /* stdio_s.h:480:27: */ 544 return libc.X__stdio_common_vsprintf(tls, 0x0002, uintptr(0), uint64(0), _Format, _Locale, _ArgList) 545 546 } 547 548 func _vfwscanf_s_l(tls *libc.TLS, _File uintptr, _Format uintptr, _Locale _locale_t, _ArgList va_list) int32 { /* stdio_s.h:588:27: */ 549 return libc.X__stdio_common_vfwscanf(tls, 0x0002|0x0001, _File, _Format, _Locale, _ArgList) 550 551 } 552 553 func _vswscanf_s_l(tls *libc.TLS, _Src uintptr, _Format uintptr, _Locale _locale_t, _ArgList va_list) int32 { /* stdio_s.h:633:27: */ 554 return libc.X__stdio_common_vswscanf(tls, 0x0002|0x0001, _Src, libc.Uint64(libc.Uint64FromInt32(-1)), _Format, _Locale, _ArgList) 555 556 } 557 558 func _vsnwscanf_s_l(tls *libc.TLS, _Src uintptr, _MaxCount size_t, _Format uintptr, _Locale _locale_t, _ArgList va_list) int32 { /* stdio_s.h:656:27: */ 559 return libc.X__stdio_common_vswscanf(tls, 0x0002|0x0001, _Src, _MaxCount, _Format, _Locale, _ArgList) 560 561 } 562 563 func _vfwprintf_s_l(tls *libc.TLS, _File uintptr, _Format uintptr, _Locale _locale_t, _ArgList va_list) int32 { /* stdio_s.h:679:27: */ 564 return libc.X__stdio_common_vfwprintf_s(tls, 0x0004, _File, _Format, _Locale, _ArgList) 565 566 } 567 568 func _vswprintf_s_l(tls *libc.TLS, _DstBuf uintptr, _DstSize size_t, _Format uintptr, _Locale _locale_t, _ArgList va_list) int32 { /* stdio_s.h:732:27: */ 569 return libc.X__stdio_common_vswprintf_s(tls, 0x0004, _DstBuf, _DstSize, _Format, _Locale, _ArgList) 570 571 } 572 573 func _vsnwprintf_s_l(tls *libc.TLS, _DstBuf uintptr, _DstSize size_t, _MaxCount size_t, _Format uintptr, _Locale _locale_t, _ArgList va_list) int32 { /* stdio_s.h:759:27: */ 574 return libc.X__stdio_common_vsnwprintf_s(tls, 0x0004, _DstBuf, _DstSize, _MaxCount, _Format, _Locale, _ArgList) 575 576 } 577 578 //===---- limits.h - Standard header for integer sizes --------------------===* * 579 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 580 // See https://llvm.org/LICENSE.txt for license information. 581 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 582 // 583 // \*===----------------------------------------------------------------------=== 584 585 type _onexit_t = uintptr /* stdlib.h:50:15 */ 586 587 type _div_t = struct { 588 quot int32 589 rem int32 590 } /* stdlib.h:60:11 */ 591 592 type div_t = _div_t /* stdlib.h:63:5 */ 593 594 type _ldiv_t = struct { 595 quot int32 596 rem int32 597 } /* stdlib.h:65:11 */ 598 599 type ldiv_t = _ldiv_t /* stdlib.h:68:5 */ 600 601 type _LDOUBLE = struct{ ld [10]uint8 } /* stdlib.h:77:5 */ 602 603 type _CRT_DOUBLE = struct{ x float64 } /* stdlib.h:84:5 */ 604 605 type _CRT_FLOAT = struct{ f float32 } /* stdlib.h:88:5 */ 606 607 type _LONGDOUBLE = struct{ x float64 } /* stdlib.h:95:5 */ 608 609 type _LDBL12 = struct{ ld12 [12]uint8 } /* stdlib.h:102:5 */ 610 611 type _purecall_handler = uintptr /* stdlib.h:143:16 */ 612 613 type _invalid_parameter_handler = uintptr /* stdlib.h:148:16 */ 614 615 type lldiv_t = struct { 616 quot int64 617 rem int64 618 } /* stdlib.h:724:61 */ 619 620 // * 621 // This file has no copyright assigned and is placed in the Public Domain. 622 // This file is part of the mingw-w64 runtime package. 623 // No warranty is given; refer to the file DISCLAIMER.PD within this package. 624 625 // * 626 // This file has no copyright assigned and is placed in the Public Domain. 627 // This file is part of the mingw-w64 runtime package. 628 // No warranty is given; refer to the file DISCLAIMER.PD within this package. 629 630 // Return codes for _heapwalk() 631 632 // Values for _heapinfo.useflag 633 634 // The structure used to walk through the heap with _heapwalk. 635 type _heapinfo = struct { 636 _pentry uintptr 637 _size size_t 638 _useflag int32 639 _ [4]byte 640 } /* malloc.h:46:11 */ 641 642 // * 643 // This file has no copyright assigned and is placed in the Public Domain. 644 // This file is part of the mingw-w64 runtime package. 645 // No warranty is given; refer to the file DISCLAIMER.PD within this package. 646 647 // * 648 // This file has no copyright assigned and is placed in the Public Domain. 649 // This file is part of the mingw-w64 runtime package. 650 // No warranty is given; refer to the file DISCLAIMER.PD within this package. 651 652 // Return codes for _heapwalk() 653 654 // Values for _heapinfo.useflag 655 656 // The structure used to walk through the heap with _heapwalk. 657 type _HEAPINFO = _heapinfo /* malloc.h:50:5 */ 658 659 var hello = *(*[14]int8)(unsafe.Pointer(ts)) /* example.c:29:21 */ 660 // "hello world" would be more standard, but the repeated "hello" 661 // stresses the compression code better, sorry... 662 663 var dictionary = *(*[6]int8)(unsafe.Pointer(ts + 14)) /* example.c:34:19 */ 664 var dictId uLong /* example.c:35:14: */ 665 666 var zalloc alloc_func = uintptr(0) /* example.c:77:19 */ 667 var zfree free_func = uintptr(0) /* example.c:78:18 */ 668 669 // =========================================================================== 670 // Test compress() and uncompress() 671 func test_compress(tls *libc.TLS, compr uintptr, comprLen uLong, uncompr uintptr, uncomprLen uLong) { /* example.c:88:6: */ 672 bp := tls.Alloc(48) 673 defer tls.Free(48) 674 *(*uLong)(unsafe.Pointer(bp + 40)) = comprLen 675 *(*uLong)(unsafe.Pointer(bp + 44)) = uncomprLen 676 677 var err int32 678 var len uLong = uLong(libc.Xstrlen(tls, uintptr(unsafe.Pointer(&hello)))) + uLong(1) 679 680 err = z.Xcompress(tls, compr, bp+40, uintptr(uintptr(unsafe.Pointer(&hello))), len) 681 { 682 if err != 0 { 683 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20, libc.VaList(bp, ts+34, err)) 684 libc.Xexit(tls, 1) 685 } 686 } 687 688 libc.Xstrcpy(tls, uncompr, ts+43) 689 690 err = z.Xuncompress(tls, uncompr, bp+44, compr, *(*uLong)(unsafe.Pointer(bp + 40 /* comprLen */))) 691 { 692 if err != 0 { 693 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20, libc.VaList(bp+16, ts+51, err)) 694 libc.Xexit(tls, 1) 695 } 696 } 697 698 if libc.Xstrcmp(tls, uncompr, uintptr(unsafe.Pointer(&hello))) != 0 { 699 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+62, 0) 700 libc.Xexit(tls, 1) 701 } else { 702 libc.Xprintf(tls, ts+78, libc.VaList(bp+32, uncompr)) 703 } 704 } 705 706 // =========================================================================== 707 // Test read/write of .gz files 708 func test_gzio(tls *libc.TLS, fname uintptr, uncompr uintptr, uncomprLen uLong) { /* example.c:114:6: */ 709 bp := tls.Alloc(84) 710 defer tls.Free(84) 711 712 // var err int32 at bp+80, 4 713 714 var len int32 = int32(libc.Xstrlen(tls, uintptr(unsafe.Pointer(&hello)))) + 1 715 var file gzFile 716 var pos int32 717 718 file = z.Xgzopen(tls, fname, ts+96) 719 if file == uintptr(0) { 720 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+99, 0) 721 libc.Xexit(tls, 1) 722 } 723 z.Xgzputc(tls, file, 'h') 724 if z.Xgzputs(tls, file, ts+113) != 4 { 725 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+118, libc.VaList(bp, z.Xgzerror(tls, file, bp+80))) 726 libc.Xexit(tls, 1) 727 } 728 if z.Xgzprintf(tls, file, ts+134, libc.VaList(bp+8, ts+14)) != 8 { 729 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+140, libc.VaList(bp+16, z.Xgzerror(tls, file, bp+80))) 730 libc.Xexit(tls, 1) 731 } 732 z.Xgzseek(tls, file, 1, 1) // add one zero byte 733 z.Xgzclose(tls, file) 734 735 file = z.Xgzopen(tls, fname, ts+158) 736 if file == uintptr(0) { 737 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+99, 0) 738 libc.Xexit(tls, 1) 739 } 740 libc.Xstrcpy(tls, uncompr, ts+43) 741 742 if z.Xgzread(tls, file, uncompr, uint32(uncomprLen)) != len { 743 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+161, libc.VaList(bp+24, z.Xgzerror(tls, file, bp+80))) 744 libc.Xexit(tls, 1) 745 } 746 if libc.Xstrcmp(tls, uncompr, uintptr(unsafe.Pointer(&hello))) != 0 { 747 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+177, libc.VaList(bp+32, uncompr)) 748 libc.Xexit(tls, 1) 749 } else { 750 libc.Xprintf(tls, ts+193, libc.VaList(bp+40, uncompr)) 751 } 752 753 pos = z.Xgzseek(tls, file, -8, 1) 754 if pos != 6 || z.Xgztell(tls, file) != pos { 755 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+207, 756 libc.VaList(bp+48, pos, z.Xgztell(tls, file))) 757 libc.Xexit(tls, 1) 758 } 759 760 if func() int32 { 761 if (*gzFile_s)(unsafe.Pointer(file)).have != 0 { 762 return int32(func() uint8 { 763 (*gzFile_s)(unsafe.Pointer(file)).have-- 764 (*gzFile_s)(unsafe.Pointer(file)).pos++ 765 return *(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&(*gzFile_s)(unsafe.Pointer(file)).next, 1))) 766 }()) 767 } 768 return z.Xgzgetc(tls, file) 769 }() != ' ' { 770 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+242, 0) 771 libc.Xexit(tls, 1) 772 } 773 774 if z.Xgzungetc(tls, ' ', file) != ' ' { 775 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+256, 0) 776 libc.Xexit(tls, 1) 777 } 778 779 z.Xgzgets(tls, file, uncompr, int32(uncomprLen)) 780 if libc.Xstrlen(tls, uncompr) != uint64(7) { // " hello!" 781 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+272, libc.VaList(bp+64, z.Xgzerror(tls, file, bp+80))) 782 libc.Xexit(tls, 1) 783 } 784 if libc.Xstrcmp(tls, uncompr, uintptr(unsafe.Pointer(&hello))+uintptr(6)) != 0 { 785 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+301, 0) 786 libc.Xexit(tls, 1) 787 } else { 788 libc.Xprintf(tls, ts+326, libc.VaList(bp+72, uncompr)) 789 } 790 791 z.Xgzclose(tls, file) 792 } 793 794 // =========================================================================== 795 // Test deflate() with small buffers 796 func test_deflate(tls *libc.TLS, compr uintptr, comprLen uLong) { /* example.c:200:6: */ 797 bp := tls.Alloc(152) 798 defer tls.Free(152) 799 800 // var c_stream z_stream at bp+64, 88 801 // compression stream 802 var err int32 803 var len uLong = uLong(libc.Xstrlen(tls, uintptr(unsafe.Pointer(&hello)))) + uLong(1) 804 805 (*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).zalloc = zalloc 806 (*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).zfree = zfree 807 (*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).opaque = uintptr(0) 808 809 err = z.XdeflateInit_(tls, bp+64, -1, ts+353, int32(unsafe.Sizeof(z_stream{}))) 810 { 811 if err != 0 { 812 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20, libc.VaList(bp, ts+360, err)) 813 libc.Xexit(tls, 1) 814 } 815 } 816 817 (*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).next_in = uintptr(uintptr(unsafe.Pointer(&hello))) 818 (*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).next_out = compr 819 820 for (*z_stream)(unsafe.Pointer(bp+64)).total_in != len && (*z_stream)(unsafe.Pointer(bp+64)).total_out < comprLen { 821 (*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).avail_in = libc.AssignPtrUint32(bp+64+24, uInt(1)) // force small buffers 822 err = z.Xdeflate(tls, bp+64, 0) 823 { 824 if err != 0 { 825 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20, libc.VaList(bp+16, ts+372, err)) 826 libc.Xexit(tls, 1) 827 } 828 } 829 830 } 831 // Finish the stream, still forcing small buffers: 832 for { 833 (*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).avail_out = uInt(1) 834 err = z.Xdeflate(tls, bp+64, 4) 835 if err == 1 { 836 break 837 } 838 { 839 if err != 0 { 840 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20, libc.VaList(bp+32, ts+372, err)) 841 libc.Xexit(tls, 1) 842 } 843 } 844 845 } 846 847 err = z.XdeflateEnd(tls, bp+64) 848 { 849 if err != 0 { 850 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20, libc.VaList(bp+48, ts+380, err)) 851 libc.Xexit(tls, 1) 852 } 853 } 854 855 } 856 857 // =========================================================================== 858 // Test inflate() with small buffers 859 func test_inflate(tls *libc.TLS, compr uintptr, comprLen uLong, uncompr uintptr, uncomprLen uLong) { /* example.c:238:6: */ 860 bp := tls.Alloc(144) 861 defer tls.Free(144) 862 863 var err int32 864 // var d_stream z_stream at bp+56, 88 865 // decompression stream 866 867 libc.Xstrcpy(tls, uncompr, ts+43) 868 869 (*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).zalloc = zalloc 870 (*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).zfree = zfree 871 (*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).opaque = uintptr(0) 872 873 (*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).next_in = compr 874 (*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).avail_in = uInt(0) 875 (*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).next_out = uncompr 876 877 err = z.XinflateInit_(tls, bp+56, ts+353, int32(unsafe.Sizeof(z_stream{}))) 878 { 879 if err != 0 { 880 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20, libc.VaList(bp, ts+391, err)) 881 libc.Xexit(tls, 1) 882 } 883 } 884 885 for (*z_stream)(unsafe.Pointer(bp+56)).total_out < uncomprLen && (*z_stream)(unsafe.Pointer(bp+56)).total_in < comprLen { 886 (*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).avail_in = libc.AssignPtrUint32(bp+56+24, uInt(1)) // force small buffers 887 err = z.Xinflate(tls, bp+56, 0) 888 if err == 1 { 889 break 890 } 891 { 892 if err != 0 { 893 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20, libc.VaList(bp+16, ts+403, err)) 894 libc.Xexit(tls, 1) 895 } 896 } 897 898 } 899 900 err = z.XinflateEnd(tls, bp+56) 901 { 902 if err != 0 { 903 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20, libc.VaList(bp+32, ts+411, err)) 904 libc.Xexit(tls, 1) 905 } 906 } 907 908 if libc.Xstrcmp(tls, uncompr, uintptr(unsafe.Pointer(&hello))) != 0 { 909 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+422, 0) 910 libc.Xexit(tls, 1) 911 } else { 912 libc.Xprintf(tls, ts+435, libc.VaList(bp+48, uncompr)) 913 } 914 } 915 916 // =========================================================================== 917 // Test deflate() with large buffers and dynamic change of compression level 918 func test_large_deflate(tls *libc.TLS, compr uintptr, comprLen uLong, uncompr uintptr, uncomprLen uLong) { /* example.c:279:6: */ 919 bp := tls.Alloc(168) 920 defer tls.Free(168) 921 922 // var c_stream z_stream at bp+80, 88 923 // compression stream 924 var err int32 925 926 (*z_stream)(unsafe.Pointer(bp + 80 /* &c_stream */)).zalloc = zalloc 927 (*z_stream)(unsafe.Pointer(bp + 80 /* &c_stream */)).zfree = zfree 928 (*z_stream)(unsafe.Pointer(bp + 80 /* &c_stream */)).opaque = uintptr(0) 929 930 err = z.XdeflateInit_(tls, bp+80, 1, ts+353, int32(unsafe.Sizeof(z_stream{}))) 931 { 932 if err != 0 { 933 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20, libc.VaList(bp, ts+360, err)) 934 libc.Xexit(tls, 1) 935 } 936 } 937 938 (*z_stream)(unsafe.Pointer(bp + 80 /* &c_stream */)).next_out = compr 939 (*z_stream)(unsafe.Pointer(bp + 80 /* &c_stream */)).avail_out = uInt(comprLen) 940 941 // At this point, uncompr is still mostly zeroes, so it should compress 942 // very well: 943 (*z_stream)(unsafe.Pointer(bp + 80 /* &c_stream */)).next_in = uncompr 944 (*z_stream)(unsafe.Pointer(bp + 80 /* &c_stream */)).avail_in = uInt(uncomprLen) 945 err = z.Xdeflate(tls, bp+80, 0) 946 { 947 if err != 0 { 948 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20, libc.VaList(bp+16, ts+372, err)) 949 libc.Xexit(tls, 1) 950 } 951 } 952 953 if (*z_stream)(unsafe.Pointer(bp+80)).avail_in != uInt(0) { 954 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+450, 0) 955 libc.Xexit(tls, 1) 956 } 957 958 // Feed in already compressed data and switch to no compression: 959 z.XdeflateParams(tls, bp+80, 0, 0) 960 (*z_stream)(unsafe.Pointer(bp + 80 /* &c_stream */)).next_in = compr 961 (*z_stream)(unsafe.Pointer(bp + 80 /* &c_stream */)).avail_in = uInt(comprLen) / uInt(2) 962 err = z.Xdeflate(tls, bp+80, 0) 963 { 964 if err != 0 { 965 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20, libc.VaList(bp+32, ts+372, err)) 966 libc.Xexit(tls, 1) 967 } 968 } 969 970 // Switch back to compressing mode: 971 z.XdeflateParams(tls, bp+80, 9, 1) 972 (*z_stream)(unsafe.Pointer(bp + 80 /* &c_stream */)).next_in = uncompr 973 (*z_stream)(unsafe.Pointer(bp + 80 /* &c_stream */)).avail_in = uInt(uncomprLen) 974 err = z.Xdeflate(tls, bp+80, 0) 975 { 976 if err != 0 { 977 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20, libc.VaList(bp+48, ts+372, err)) 978 libc.Xexit(tls, 1) 979 } 980 } 981 982 err = z.Xdeflate(tls, bp+80, 4) 983 if err != 1 { 984 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+470, 0) 985 libc.Xexit(tls, 1) 986 } 987 err = z.XdeflateEnd(tls, bp+80) 988 { 989 if err != 0 { 990 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20, libc.VaList(bp+64, ts+380, err)) 991 libc.Xexit(tls, 1) 992 } 993 } 994 995 } 996 997 // =========================================================================== 998 // Test inflate() with large buffers 999 func test_large_inflate(tls *libc.TLS, compr uintptr, comprLen uLong, uncompr uintptr, uncomprLen uLong) { /* example.c:334:6: */ 1000 bp := tls.Alloc(144) 1001 defer tls.Free(144) 1002 1003 var err int32 1004 // var d_stream z_stream at bp+56, 88 1005 // decompression stream 1006 1007 libc.Xstrcpy(tls, uncompr, ts+43) 1008 1009 (*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).zalloc = zalloc 1010 (*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).zfree = zfree 1011 (*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).opaque = uintptr(0) 1012 1013 (*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).next_in = compr 1014 (*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).avail_in = uInt(comprLen) 1015 1016 err = z.XinflateInit_(tls, bp+56, ts+353, int32(unsafe.Sizeof(z_stream{}))) 1017 { 1018 if err != 0 { 1019 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20, libc.VaList(bp, ts+391, err)) 1020 libc.Xexit(tls, 1) 1021 } 1022 } 1023 1024 for { 1025 (*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).next_out = uncompr // discard the output 1026 (*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).avail_out = uInt(uncomprLen) 1027 err = z.Xinflate(tls, bp+56, 0) 1028 if err == 1 { 1029 break 1030 } 1031 { 1032 if err != 0 { 1033 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20, libc.VaList(bp+16, ts+506, err)) 1034 libc.Xexit(tls, 1) 1035 } 1036 } 1037 1038 } 1039 1040 err = z.XinflateEnd(tls, bp+56) 1041 { 1042 if err != 0 { 1043 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20, libc.VaList(bp+32, ts+411, err)) 1044 libc.Xexit(tls, 1) 1045 } 1046 } 1047 1048 if (*z_stream)(unsafe.Pointer(bp+56)).total_out != uLong(2)*uncomprLen+comprLen/uLong(2) { 1049 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+520, libc.VaList(bp+48, (*z_stream)(unsafe.Pointer(bp+56 /* &d_stream */)).total_out)) 1050 libc.Xexit(tls, 1) 1051 } else { 1052 libc.Xprintf(tls, ts+544, 0) 1053 } 1054 } 1055 1056 // =========================================================================== 1057 // Test deflate() with full flush 1058 func test_flush(tls *libc.TLS, compr uintptr, comprLen uintptr) { /* example.c:375:6: */ 1059 bp := tls.Alloc(152) 1060 defer tls.Free(152) 1061 1062 // var c_stream z_stream at bp+64, 88 1063 // compression stream 1064 var err int32 1065 var len uInt = uInt(libc.Xstrlen(tls, uintptr(unsafe.Pointer(&hello)))) + uInt(1) 1066 1067 (*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).zalloc = zalloc 1068 (*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).zfree = zfree 1069 (*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).opaque = uintptr(0) 1070 1071 err = z.XdeflateInit_(tls, bp+64, -1, ts+353, int32(unsafe.Sizeof(z_stream{}))) 1072 { 1073 if err != 0 { 1074 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20, libc.VaList(bp, ts+360, err)) 1075 libc.Xexit(tls, 1) 1076 } 1077 } 1078 1079 (*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).next_in = uintptr(uintptr(unsafe.Pointer(&hello))) 1080 (*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).next_out = compr 1081 (*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).avail_in = uInt(3) 1082 (*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).avail_out = uInt(*(*uLong)(unsafe.Pointer(comprLen))) 1083 err = z.Xdeflate(tls, bp+64, 3) 1084 { 1085 if err != 0 { 1086 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20, libc.VaList(bp+16, ts+372, err)) 1087 libc.Xexit(tls, 1) 1088 } 1089 } 1090 1091 *(*Byte)(unsafe.Pointer(compr + 3))++ // force an error in first compressed block 1092 (*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).avail_in = len - uInt(3) 1093 1094 err = z.Xdeflate(tls, bp+64, 4) 1095 if err != 1 { 1096 { 1097 if err != 0 { 1098 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20, libc.VaList(bp+32, ts+372, err)) 1099 libc.Xexit(tls, 1) 1100 } 1101 } 1102 1103 } 1104 err = z.XdeflateEnd(tls, bp+64) 1105 { 1106 if err != 0 { 1107 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20, libc.VaList(bp+48, ts+380, err)) 1108 libc.Xexit(tls, 1) 1109 } 1110 } 1111 1112 *(*uLong)(unsafe.Pointer(comprLen)) = (*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).total_out 1113 } 1114 1115 // =========================================================================== 1116 // Test inflateSync() 1117 func test_sync(tls *libc.TLS, compr uintptr, comprLen uLong, uncompr uintptr, uncomprLen uLong) { /* example.c:413:6: */ 1118 bp := tls.Alloc(160) 1119 defer tls.Free(160) 1120 1121 var err int32 1122 // var d_stream z_stream at bp+72, 88 1123 // decompression stream 1124 1125 libc.Xstrcpy(tls, uncompr, ts+43) 1126 1127 (*z_stream)(unsafe.Pointer(bp + 72 /* &d_stream */)).zalloc = zalloc 1128 (*z_stream)(unsafe.Pointer(bp + 72 /* &d_stream */)).zfree = zfree 1129 (*z_stream)(unsafe.Pointer(bp + 72 /* &d_stream */)).opaque = uintptr(0) 1130 1131 (*z_stream)(unsafe.Pointer(bp + 72 /* &d_stream */)).next_in = compr 1132 (*z_stream)(unsafe.Pointer(bp + 72 /* &d_stream */)).avail_in = uInt(2) // just read the zlib header 1133 1134 err = z.XinflateInit_(tls, bp+72, ts+353, int32(unsafe.Sizeof(z_stream{}))) 1135 { 1136 if err != 0 { 1137 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20, libc.VaList(bp, ts+391, err)) 1138 libc.Xexit(tls, 1) 1139 } 1140 } 1141 1142 (*z_stream)(unsafe.Pointer(bp + 72 /* &d_stream */)).next_out = uncompr 1143 (*z_stream)(unsafe.Pointer(bp + 72 /* &d_stream */)).avail_out = uInt(uncomprLen) 1144 1145 err = z.Xinflate(tls, bp+72, 0) 1146 { 1147 if err != 0 { 1148 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20, libc.VaList(bp+16, ts+403, err)) 1149 libc.Xexit(tls, 1) 1150 } 1151 } 1152 1153 (*z_stream)(unsafe.Pointer(bp + 72 /* &d_stream */)).avail_in = uInt(comprLen) - uInt(2) // read all compressed data 1154 err = z.XinflateSync(tls, bp+72) /* but skip the damaged part */ 1155 { 1156 if err != 0 { 1157 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20, libc.VaList(bp+32, ts+565, err)) 1158 libc.Xexit(tls, 1) 1159 } 1160 } 1161 1162 err = z.Xinflate(tls, bp+72, 4) 1163 if err != -3 { 1164 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+577, 0) 1165 // Because of incorrect adler32 1166 libc.Xexit(tls, 1) 1167 } 1168 err = z.XinflateEnd(tls, bp+72) 1169 { 1170 if err != 0 { 1171 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20, libc.VaList(bp+48, ts+411, err)) 1172 libc.Xexit(tls, 1) 1173 } 1174 } 1175 1176 libc.Xprintf(tls, ts+611, libc.VaList(bp+64, uncompr)) 1177 } 1178 1179 // =========================================================================== 1180 // Test deflate() with preset dictionary 1181 func test_dict_deflate(tls *libc.TLS, compr uintptr, comprLen uLong) { /* example.c:457:6: */ 1182 bp := tls.Alloc(136) 1183 defer tls.Free(136) 1184 1185 // var c_stream z_stream at bp+48, 88 1186 // compression stream 1187 var err int32 1188 1189 (*z_stream)(unsafe.Pointer(bp + 48 /* &c_stream */)).zalloc = zalloc 1190 (*z_stream)(unsafe.Pointer(bp + 48 /* &c_stream */)).zfree = zfree 1191 (*z_stream)(unsafe.Pointer(bp + 48 /* &c_stream */)).opaque = uintptr(0) 1192 1193 err = z.XdeflateInit_(tls, bp+48, 9, ts+353, int32(unsafe.Sizeof(z_stream{}))) 1194 { 1195 if err != 0 { 1196 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20, libc.VaList(bp, ts+360, err)) 1197 libc.Xexit(tls, 1) 1198 } 1199 } 1200 1201 err = z.XdeflateSetDictionary(tls, bp+48, 1202 uintptr(uintptr(unsafe.Pointer(&dictionary))), uint32(int32(unsafe.Sizeof(dictionary)))) 1203 { 1204 if err != 0 { 1205 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20, libc.VaList(bp+16, ts+639, err)) 1206 libc.Xexit(tls, 1) 1207 } 1208 } 1209 1210 dictId = (*z_stream)(unsafe.Pointer(bp + 48 /* &c_stream */)).adler 1211 (*z_stream)(unsafe.Pointer(bp + 48 /* &c_stream */)).next_out = compr 1212 (*z_stream)(unsafe.Pointer(bp + 48 /* &c_stream */)).avail_out = uInt(comprLen) 1213 1214 (*z_stream)(unsafe.Pointer(bp + 48 /* &c_stream */)).next_in = uintptr(uintptr(unsafe.Pointer(&hello))) 1215 (*z_stream)(unsafe.Pointer(bp + 48 /* &c_stream */)).avail_in = uInt(libc.Xstrlen(tls, uintptr(unsafe.Pointer(&hello)))) + uInt(1) 1216 1217 err = z.Xdeflate(tls, bp+48, 4) 1218 if err != 1 { 1219 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+470, 0) 1220 libc.Xexit(tls, 1) 1221 } 1222 err = z.XdeflateEnd(tls, bp+48) 1223 { 1224 if err != 0 { 1225 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20, libc.VaList(bp+32, ts+380, err)) 1226 libc.Xexit(tls, 1) 1227 } 1228 } 1229 1230 } 1231 1232 // =========================================================================== 1233 // Test inflate() with a preset dictionary 1234 func test_dict_inflate(tls *libc.TLS, compr uintptr, comprLen uLong, uncompr uintptr, uncomprLen uLong) { /* example.c:494:6: */ 1235 bp := tls.Alloc(144) 1236 defer tls.Free(144) 1237 1238 var err int32 1239 // var d_stream z_stream at bp+56, 88 1240 // decompression stream 1241 1242 libc.Xstrcpy(tls, uncompr, ts+43) 1243 1244 (*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).zalloc = zalloc 1245 (*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).zfree = zfree 1246 (*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).opaque = uintptr(0) 1247 1248 (*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).next_in = compr 1249 (*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).avail_in = uInt(comprLen) 1250 1251 err = z.XinflateInit_(tls, bp+56, ts+353, int32(unsafe.Sizeof(z_stream{}))) 1252 { 1253 if err != 0 { 1254 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20, libc.VaList(bp, ts+391, err)) 1255 libc.Xexit(tls, 1) 1256 } 1257 } 1258 1259 (*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).next_out = uncompr 1260 (*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).avail_out = uInt(uncomprLen) 1261 1262 for { 1263 err = z.Xinflate(tls, bp+56, 0) 1264 if err == 1 { 1265 break 1266 } 1267 if err == 2 { 1268 if (*z_stream)(unsafe.Pointer(bp+56)).adler != dictId { 1269 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+660, 0) 1270 libc.Xexit(tls, 1) 1271 } 1272 err = z.XinflateSetDictionary(tls, bp+56, uintptr(uintptr(unsafe.Pointer(&dictionary))), 1273 uint32(int32(unsafe.Sizeof(dictionary)))) 1274 } 1275 { 1276 if err != 0 { 1277 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20, libc.VaList(bp+16, ts+682, err)) 1278 libc.Xexit(tls, 1) 1279 } 1280 } 1281 1282 } 1283 1284 err = z.XinflateEnd(tls, bp+56) 1285 { 1286 if err != 0 { 1287 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20, libc.VaList(bp+32, ts+411, err)) 1288 libc.Xexit(tls, 1) 1289 } 1290 } 1291 1292 if libc.Xstrcmp(tls, uncompr, uintptr(unsafe.Pointer(&hello))) != 0 { 1293 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+700, 0) 1294 libc.Xexit(tls, 1) 1295 } else { 1296 libc.Xprintf(tls, ts+723, libc.VaList(bp+48, uncompr)) 1297 } 1298 } 1299 1300 // =========================================================================== 1301 // Usage: example [output.gz [input.gz]] 1302 1303 func main1(tls *libc.TLS, argc int32, argv uintptr) int32 { /* example.c:545:5: */ 1304 bp := tls.Alloc(28) 1305 defer tls.Free(28) 1306 1307 var compr uintptr 1308 var uncompr uintptr 1309 *(*uLong)(unsafe.Pointer(bp + 24 /* comprLen */)) = uint32(uint64(10000) * uint64(unsafe.Sizeof(int32(0)))) // don't overflow on MSDOS 1310 var uncomprLen uLong = *(*uLong)(unsafe.Pointer(bp + 24 /* comprLen */)) 1311 1312 if int32(*(*int8)(unsafe.Pointer(z.XzlibVersion(tls)))) != int32(*(*int8)(unsafe.Pointer(myVersion))) { 1313 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+752, 0) 1314 libc.Xexit(tls, 1) 1315 1316 } else if libc.Xstrcmp(tls, z.XzlibVersion(tls), ts+353) != 0 { 1317 libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+779, 0) 1318 } 1319 1320 libc.Xprintf(tls, ts+812, 1321 libc.VaList(bp, ts+353, 0x12b0, z.XzlibCompileFlags(tls))) 1322 1323 compr = libc.Xcalloc(tls, uint64(uInt(*(*uLong)(unsafe.Pointer(bp + 24 /* comprLen */)))), uint64(1)) 1324 uncompr = libc.Xcalloc(tls, uint64(uInt(uncomprLen)), uint64(1)) 1325 // compr and uncompr are cleared to avoid reading uninitialized 1326 // data and to ensure that uncompr compresses well. 1327 if compr == uintptr(0) || uncompr == uintptr(0) { 1328 libc.Xprintf(tls, ts+861, 0) 1329 libc.Xexit(tls, 1) 1330 } 1331 1332 test_compress(tls, compr, *(*uLong)(unsafe.Pointer(bp + 24 /* comprLen */)), uncompr, uncomprLen) 1333 1334 test_gzio(tls, func() uintptr { 1335 if argc > 1 { 1336 return *(*uintptr)(unsafe.Pointer(argv + 1*8)) 1337 } 1338 return ts + 876 1339 }(), 1340 uncompr, uncomprLen) 1341 1342 test_deflate(tls, compr, *(*uLong)(unsafe.Pointer(bp + 24 /* comprLen */))) 1343 test_inflate(tls, compr, *(*uLong)(unsafe.Pointer(bp + 24 /* comprLen */)), uncompr, uncomprLen) 1344 1345 test_large_deflate(tls, compr, *(*uLong)(unsafe.Pointer(bp + 24 /* comprLen */)), uncompr, uncomprLen) 1346 test_large_inflate(tls, compr, *(*uLong)(unsafe.Pointer(bp + 24 /* comprLen */)), uncompr, uncomprLen) 1347 1348 test_flush(tls, compr, bp+24) 1349 test_sync(tls, compr, *(*uLong)(unsafe.Pointer(bp + 24 /* comprLen */)), uncompr, uncomprLen) 1350 *(*uLong)(unsafe.Pointer(bp + 24 /* comprLen */)) = uncomprLen 1351 1352 test_dict_deflate(tls, compr, *(*uLong)(unsafe.Pointer(bp + 24 /* comprLen */))) 1353 test_dict_inflate(tls, compr, *(*uLong)(unsafe.Pointer(bp + 24 /* comprLen */)), uncompr, uncomprLen) 1354 1355 libc.Xfree(tls, compr) 1356 libc.Xfree(tls, uncompr) 1357 1358 return 0 1359 } 1360 1361 var myVersion uintptr = ts + 353 /* "1.2.11" */ /* example.c:552:22 */ 1362 1363 var ts1 = "hello, hello!\x00hello\x00%s error: %d\n\x00compress\x00garbage\x00uncompress\x00bad uncompress\n\x00uncompress(): %s\n\x00wb\x00gzopen error\n\x00ello\x00gzputs err: %s\n\x00, %s!\x00gzprintf err: %s\n\x00rb\x00gzread err: %s\n\x00bad gzread: %s\n\x00gzread(): %s\n\x00gzseek error, pos=%ld, gztell=%ld\n\x00gzgetc error\n\x00gzungetc error\n\x00gzgets err after gzseek: %s\n\x00bad gzgets after gzseek\n\x00gzgets() after gzseek: %s\n\x001.2.11\x00deflateInit\x00deflate\x00deflateEnd\x00inflateInit\x00inflate\x00inflateEnd\x00bad inflate\n\x00inflate(): %s\n\x00deflate not greedy\n\x00deflate should report Z_STREAM_END\n\x00large inflate\x00bad large inflate: %ld\n\x00large_inflate(): OK\n\x00inflateSync\x00inflate should report DATA_ERROR\n\x00after inflateSync(): hel%s\n\x00deflateSetDictionary\x00unexpected dictionary\x00inflate with dict\x00bad inflate with dict\n\x00inflate with dictionary: %s\n\x00incompatible zlib version\n\x00warning: different zlib version\n\x00zlib version %s = 0x%04x, compile flags = 0x%lx\n\x00out of memory\n\x00foo.gz\x00" 1364 var ts = (*reflect.StringHeader)(unsafe.Pointer(&ts1)).Data