modernc.org/z@v1.7.4/internal/example_freebsd_amd64.go (about) 1 // Code generated by 'ccgo -lmodernc.org/z/lib -o internal/example_freebsd_amd64.go -trace-translation-units /tmp/go-generate-3340550282/cdb.json example64', 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 _ types.Size_t 21 22 func main() { libc.Start(main1) } 23 24 type ptrdiff_t = int64 /* <builtin>:3:26 */ 25 26 type size_t = uint64 /* <builtin>:9:23 */ 27 28 type wchar_t = int32 /* <builtin>:15:24 */ 29 30 type rune_t = int32 /* stddef.h:50:18 */ 31 32 type max_align_t = struct { 33 __max_align1 int64 34 __max_align2 float64 35 } /* stddef.h:69:23 */ 36 37 // ISO/IEC 9899:2011 K.3.3.2 38 type rsize_t = size_t /* stddef.h:81:16 */ 39 40 type z_size_t = size_t /* zconf.h:248:21 */ 41 42 // Maximum value for memLevel in deflateInit2 43 44 // Maximum value for windowBits in deflateInit2 and inflateInit2. 45 // WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files 46 // created by gzip. (Files created by minigzip can still be extracted by 47 // gzip.) 48 49 // The memory requirements for deflate are (in bytes): 50 // (1 << (windowBits+2)) + (1 << (memLevel+9)) 51 // that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) 52 // plus a few kilobytes for small objects. For example, if you want to reduce 53 // the default memory requirements from 256K to 128K, compile with 54 // make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" 55 // Of course this will generally degrade compression (there's no free lunch). 56 // 57 // The memory requirements for inflate are (in bytes) 1 << windowBits 58 // that is, 32K for windowBits=15 (default value) plus about 7 kilobytes 59 // for small objects. 60 61 // Type declarations 62 63 // The following definitions for FAR are needed only for MSDOS mixed 64 // model programming (small or medium model with some far allocations). 65 // This was tested only with MSC; for other MSDOS compilers you may have 66 // to define NO_MEMCPY in zutil.h. If you don't need the mixed model, 67 // just define FAR to be empty. 68 69 type Byte = uint8 /* zconf.h:391:24 */ // 8 bits 70 type uInt = uint32 /* zconf.h:393:24 */ // 16 bits or more 71 type uLong = uint64 /* zconf.h:394:24 */ // 32 bits or more 72 73 type Bytef = Byte /* zconf.h:400:22 */ 74 type charf = int8 /* zconf.h:402:19 */ 75 type intf = int32 /* zconf.h:403:19 */ 76 type uIntf = uInt /* zconf.h:404:19 */ 77 type uLongf = uLong /* zconf.h:405:19 */ 78 79 type voidpc = uintptr /* zconf.h:408:23 */ 80 type voidpf = uintptr /* zconf.h:409:23 */ 81 type voidp = uintptr /* zconf.h:410:23 */ 82 83 // - 84 // SPDX-License-Identifier: BSD-3-Clause 85 // 86 // Copyright (c) 1988, 1993 87 // The Regents of the University of California. All rights reserved. 88 // 89 // Redistribution and use in source and binary forms, with or without 90 // modification, are permitted provided that the following conditions 91 // are met: 92 // 1. Redistributions of source code must retain the above copyright 93 // notice, this list of conditions and the following disclaimer. 94 // 2. Redistributions in binary form must reproduce the above copyright 95 // notice, this list of conditions and the following disclaimer in the 96 // documentation and/or other materials provided with the distribution. 97 // 3. Neither the name of the University nor the names of its contributors 98 // may be used to endorse or promote products derived from this software 99 // without specific prior written permission. 100 // 101 // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 102 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 103 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 104 // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 105 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 106 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 107 // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 108 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 109 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 110 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 111 // SUCH DAMAGE. 112 // 113 // @(#)limits.h 8.2 (Berkeley) 1/4/94 114 // $FreeBSD$ 115 116 // - 117 // SPDX-License-Identifier: BSD-3-Clause 118 // 119 // Copyright (c) 1991, 1993 120 // The Regents of the University of California. All rights reserved. 121 // 122 // This code is derived from software contributed to Berkeley by 123 // Berkeley Software Design, Inc. 124 // 125 // Redistribution and use in source and binary forms, with or without 126 // modification, are permitted provided that the following conditions 127 // are met: 128 // 1. Redistributions of source code must retain the above copyright 129 // notice, this list of conditions and the following disclaimer. 130 // 2. Redistributions in binary form must reproduce the above copyright 131 // notice, this list of conditions and the following disclaimer in the 132 // documentation and/or other materials provided with the distribution. 133 // 3. Neither the name of the University nor the names of its contributors 134 // may be used to endorse or promote products derived from this software 135 // without specific prior written permission. 136 // 137 // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 138 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 139 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 140 // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 141 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 142 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 143 // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 144 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 145 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 146 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 147 // SUCH DAMAGE. 148 // 149 // @(#)cdefs.h 8.8 (Berkeley) 1/9/95 150 // $FreeBSD$ 151 152 // - 153 // SPDX-License-Identifier: BSD-3-Clause 154 // 155 // Copyright (c) 1988, 1993 156 // The Regents of the University of California. All rights reserved. 157 // 158 // Redistribution and use in source and binary forms, with or without 159 // modification, are permitted provided that the following conditions 160 // are met: 161 // 1. Redistributions of source code must retain the above copyright 162 // notice, this list of conditions and the following disclaimer. 163 // 2. Redistributions in binary form must reproduce the above copyright 164 // notice, this list of conditions and the following disclaimer in the 165 // documentation and/or other materials provided with the distribution. 166 // 3. Neither the name of the University nor the names of its contributors 167 // may be used to endorse or promote products derived from this software 168 // without specific prior written permission. 169 // 170 // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 171 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 172 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 173 // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 174 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 175 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 176 // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 177 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 178 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 179 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 180 // SUCH DAMAGE. 181 // 182 // $FreeBSD$ 183 184 // - 185 // SPDX-License-Identifier: BSD-3-Clause 186 // 187 // Copyright (c) 1991, 1993 188 // The Regents of the University of California. All rights reserved. 189 // 190 // This code is derived from software contributed to Berkeley by 191 // Berkeley Software Design, Inc. 192 // 193 // Redistribution and use in source and binary forms, with or without 194 // modification, are permitted provided that the following conditions 195 // are met: 196 // 1. Redistributions of source code must retain the above copyright 197 // notice, this list of conditions and the following disclaimer. 198 // 2. Redistributions in binary form must reproduce the above copyright 199 // notice, this list of conditions and the following disclaimer in the 200 // documentation and/or other materials provided with the distribution. 201 // 3. Neither the name of the University nor the names of its contributors 202 // may be used to endorse or promote products derived from this software 203 // without specific prior written permission. 204 // 205 // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 206 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 207 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 208 // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 209 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 210 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 211 // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 212 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 213 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 214 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 215 // SUCH DAMAGE. 216 // 217 // @(#)cdefs.h 8.8 (Berkeley) 1/9/95 218 // $FreeBSD$ 219 220 // - 221 // This file is in the public domain. 222 // $FreeBSD$ 223 224 // - 225 // SPDX-License-Identifier: BSD-3-Clause 226 // 227 // Copyright (c) 1988, 1993 228 // The Regents of the University of California. All rights reserved. 229 // 230 // Redistribution and use in source and binary forms, with or without 231 // modification, are permitted provided that the following conditions 232 // are met: 233 // 1. Redistributions of source code must retain the above copyright 234 // notice, this list of conditions and the following disclaimer. 235 // 2. Redistributions in binary form must reproduce the above copyright 236 // notice, this list of conditions and the following disclaimer in the 237 // documentation and/or other materials provided with the distribution. 238 // 3. Neither the name of the University nor the names of its contributors 239 // may be used to endorse or promote products derived from this software 240 // without specific prior written permission. 241 // 242 // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 243 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 244 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 245 // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 246 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 247 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 248 // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 249 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 250 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 251 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 252 // SUCH DAMAGE. 253 // 254 // @(#)limits.h 8.3 (Berkeley) 1/4/94 255 // $FreeBSD$ 256 257 // - 258 // SPDX-License-Identifier: BSD-3-Clause 259 // 260 // Copyright (c) 1988, 1993 261 // The Regents of the University of California. All rights reserved. 262 // 263 // Redistribution and use in source and binary forms, with or without 264 // modification, are permitted provided that the following conditions 265 // are met: 266 // 1. Redistributions of source code must retain the above copyright 267 // notice, this list of conditions and the following disclaimer. 268 // 2. Redistributions in binary form must reproduce the above copyright 269 // notice, this list of conditions and the following disclaimer in the 270 // documentation and/or other materials provided with the distribution. 271 // 3. Neither the name of the University nor the names of its contributors 272 // may be used to endorse or promote products derived from this software 273 // without specific prior written permission. 274 // 275 // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 276 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 277 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 278 // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 279 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 280 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 281 // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 282 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 283 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 284 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 285 // SUCH DAMAGE. 286 // 287 // @(#)syslimits.h 8.1 (Berkeley) 6/2/93 288 // $FreeBSD$ 289 290 // Do not add any new variables here. (See the comment at the end of 291 // the file for why.) 292 293 // We leave the following values undefined to force applications to either 294 // assume conservative values or call sysconf() to get the current value. 295 // 296 // HOST_NAME_MAX 297 // 298 // (We should do this for most of the values currently defined here, 299 // but many programs are not prepared to deal with this yet.) 300 301 type z_crc_t = uint32 /* zconf.h:429:17 */ 302 type pthread_once = struct { 303 state int32 304 _ [4]byte 305 mutex pthread_mutex_t 306 } /* _pthreadtypes.h:52:1 */ 307 308 // Primitive system data type definitions required by P1003.1c. 309 // 310 // Note that P1003.1c specifies that there are no defined comparison 311 // or assignment operators for the types pthread_attr_t, pthread_cond_t, 312 // pthread_condattr_t, pthread_mutex_t, pthread_mutexattr_t. 313 type pthread_t = uintptr /* _pthreadtypes.h:67:26 */ 314 type pthread_attr_t = uintptr /* _pthreadtypes.h:70:30 */ 315 type pthread_mutex_t = uintptr /* _pthreadtypes.h:71:31 */ 316 type pthread_mutexattr_t = uintptr /* _pthreadtypes.h:72:35 */ 317 type pthread_cond_t = uintptr /* _pthreadtypes.h:73:30 */ 318 type pthread_condattr_t = uintptr /* _pthreadtypes.h:74:34 */ 319 type pthread_key_t = int32 /* _pthreadtypes.h:75:20 */ 320 type pthread_once_t = pthread_once /* _pthreadtypes.h:76:30 */ 321 type pthread_rwlock_t = uintptr /* _pthreadtypes.h:77:32 */ 322 type pthread_rwlockattr_t = uintptr /* _pthreadtypes.h:78:35 */ 323 type pthread_barrier_t = uintptr /* _pthreadtypes.h:79:33 */ 324 type pthread_barrierattr_t = uintptr /* _pthreadtypes.h:80:36 */ 325 type pthread_spinlock_t = uintptr /* _pthreadtypes.h:81:33 */ 326 327 // Additional type definitions: 328 // 329 // Note that P1003.1c reserves the prefixes pthread_ and PTHREAD_ for 330 // use in header symbols. 331 type pthread_addr_t = uintptr /* _pthreadtypes.h:89:14 */ 332 type pthread_startroutine_t = uintptr /* _pthreadtypes.h:90:14 */ 333 334 type u_char = uint8 /* types.h:52:23 */ 335 type u_short = uint16 /* types.h:53:24 */ 336 type u_int = uint32 /* types.h:54:22 */ 337 type u_long = uint64 /* types.h:55:23 */ 338 type ushort = uint16 /* types.h:57:24 */ // Sys V compatibility 339 type uint = uint32 /* types.h:58:22 */ // Sys V compatibility 340 341 // XXX POSIX sized integrals that should appear only in <sys/stdint.h>. 342 // - 343 // SPDX-License-Identifier: BSD-2-Clause-FreeBSD 344 // 345 // Copyright (c) 2011 David E. O'Brien <obrien@FreeBSD.org> 346 // Copyright (c) 2001 Mike Barcroft <mike@FreeBSD.org> 347 // All rights reserved. 348 // 349 // Redistribution and use in source and binary forms, with or without 350 // modification, are permitted provided that the following conditions 351 // are met: 352 // 1. Redistributions of source code must retain the above copyright 353 // notice, this list of conditions and the following disclaimer. 354 // 2. Redistributions in binary form must reproduce the above copyright 355 // notice, this list of conditions and the following disclaimer in the 356 // documentation and/or other materials provided with the distribution. 357 // 358 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 359 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 360 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 361 // ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 362 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 363 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 364 // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 365 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 366 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 367 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 368 // SUCH DAMAGE. 369 // 370 // $FreeBSD$ 371 372 type int8_t = int8 /* _stdint.h:36:19 */ 373 374 type int16_t = int16 /* _stdint.h:41:20 */ 375 376 type int32_t = int32 /* _stdint.h:46:20 */ 377 378 type int64_t = int64 /* _stdint.h:51:20 */ 379 380 type uint8_t = uint8 /* _stdint.h:56:20 */ 381 382 type uint16_t = uint16 /* _stdint.h:61:21 */ 383 384 type uint32_t = uint32 /* _stdint.h:66:21 */ 385 386 type uint64_t = uint64 /* _stdint.h:71:21 */ 387 388 type intptr_t = int64 /* _stdint.h:76:21 */ 389 type uintptr_t = uint64 /* _stdint.h:80:22 */ 390 type intmax_t = int64 /* _stdint.h:84:21 */ 391 type uintmax_t = uint64 /* _stdint.h:88:22 */ 392 393 type u_int8_t = uint8 /* types.h:67:19 */ // unsigned integrals (deprecated) 394 type u_int16_t = uint16 /* types.h:68:20 */ 395 type u_int32_t = uint32 /* types.h:69:20 */ 396 type u_int64_t = uint64 /* types.h:70:20 */ 397 398 type u_quad_t = uint64 /* types.h:72:20 */ // quads (deprecated) 399 type quad_t = int64 /* types.h:73:19 */ 400 type qaddr_t = uintptr /* types.h:74:16 */ 401 402 type caddr_t = uintptr /* types.h:76:14 */ // core address 403 type c_caddr_t = uintptr /* types.h:77:20 */ // core address, pointer to const 404 405 type blksize_t = int32 /* types.h:80:21 */ 406 407 type cpuwhich_t = int32 /* types.h:84:22 */ 408 type cpulevel_t = int32 /* types.h:85:22 */ 409 type cpusetid_t = int32 /* types.h:86:22 */ 410 411 type blkcnt_t = int64 /* types.h:89:20 */ 412 413 type clock_t = int32 /* types.h:94:19 */ 414 415 type clockid_t = int32 /* types.h:99:21 */ 416 417 type critical_t = int64 /* types.h:103:22 */ // Critical section value 418 type daddr_t = int64 /* types.h:104:19 */ // disk address 419 420 type dev_t = uint64 /* types.h:107:18 */ // device number or struct cdev 421 422 type fflags_t = uint32 /* types.h:112:20 */ // file flags 423 424 type fixpt_t = uint32 /* types.h:116:19 */ // fixed point number 425 426 type fsblkcnt_t = uint64 /* types.h:119:22 */ 427 type fsfilcnt_t = uint64 /* types.h:120:22 */ 428 429 type gid_t = uint32 /* types.h:125:18 */ // group id 430 431 type in_addr_t = uint32 /* types.h:130:20 */ // base type for internet address 432 433 type in_port_t = uint16 /* types.h:135:20 */ 434 435 type id_t = int64 /* types.h:140:17 */ // can hold a uid_t or pid_t 436 437 type ino_t = uint64 /* types.h:145:18 */ // inode number 438 439 type key_t = int64 /* types.h:150:18 */ // IPC key (for Sys V IPC) 440 441 type lwpid_t = int32 /* types.h:155:19 */ // Thread ID (a.k.a. LWP) 442 443 type mode_t = uint16 /* types.h:160:18 */ // permissions 444 445 type accmode_t = int32 /* types.h:165:21 */ // access permissions 446 447 type nlink_t = uint64 /* types.h:170:19 */ // link count 448 449 type off_t = int64 /* types.h:175:18 */ // file offset 450 451 type off64_t = int64 /* types.h:180:19 */ // file offset (alias) 452 453 type pid_t = int32 /* types.h:185:18 */ // process id 454 455 type register_t = int64 /* types.h:189:22 */ 456 457 type rlim_t = int64 /* types.h:192:18 */ // resource limit 458 459 type sbintime_t = int64 /* types.h:196:19 */ 460 461 type segsz_t = int64 /* types.h:198:19 */ // segment size (in pages) 462 463 type ssize_t = int64 /* types.h:206:19 */ 464 465 type suseconds_t = int64 /* types.h:211:23 */ // microseconds (signed) 466 467 type time_t = int64 /* types.h:216:18 */ 468 469 type timer_t = uintptr /* types.h:221:19 */ 470 471 type mqd_t = uintptr /* types.h:226:17 */ 472 473 type u_register_t = uint64 /* types.h:230:24 */ 474 475 type uid_t = uint32 /* types.h:233:18 */ // user id 476 477 type useconds_t = uint32 /* types.h:238:22 */ // microseconds (unsigned) 478 479 type cap_ioctl_t = uint64 /* types.h:244:23 */ 480 481 // Types suitable for exporting physical addresses, virtual addresses 482 // (pointers), and memory object sizes from the kernel independent of native 483 // word size. These should be used in place of vm_paddr_t, (u)intptr_t, and 484 // size_t in structs which contain such types that are shared with userspace. 485 type kpaddr_t = uint64 /* types.h:260:20 */ 486 type kvaddr_t = uint64 /* types.h:261:20 */ 487 type ksize_t = uint64 /* types.h:262:20 */ 488 type kssize_t = int64 /* types.h:263:19 */ 489 490 type vm_offset_t = uint64 /* types.h:265:23 */ 491 type vm_ooffset_t = uint64 /* types.h:266:20 */ 492 type vm_paddr_t = uint64 /* types.h:267:22 */ 493 type vm_pindex_t = uint64 /* types.h:268:20 */ 494 type vm_size_t = uint64 /* types.h:269:21 */ 495 496 type rman_res_t = uint64 /* types.h:271:25 */ 497 498 // - 499 // SPDX-License-Identifier: BSD-3-Clause 500 // 501 // Copyright (c) 1992, 1993 502 // The Regents of the University of California. All rights reserved. 503 // 504 // Redistribution and use in source and binary forms, with or without 505 // modification, are permitted provided that the following conditions 506 // are met: 507 // 1. Redistributions of source code must retain the above copyright 508 // notice, this list of conditions and the following disclaimer. 509 // 2. Redistributions in binary form must reproduce the above copyright 510 // notice, this list of conditions and the following disclaimer in the 511 // documentation and/or other materials provided with the distribution. 512 // 3. Neither the name of the University nor the names of its contributors 513 // may be used to endorse or promote products derived from this software 514 // without specific prior written permission. 515 // 516 // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 517 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 518 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 519 // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 520 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 521 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 522 // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 523 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 524 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 525 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 526 // SUCH DAMAGE. 527 // 528 // $FreeBSD$ 529 530 // - 531 // SPDX-License-Identifier: BSD-3-Clause 532 // 533 // Copyright (c) 1991, 1993 534 // The Regents of the University of California. All rights reserved. 535 // 536 // This code is derived from software contributed to Berkeley by 537 // Berkeley Software Design, Inc. 538 // 539 // Redistribution and use in source and binary forms, with or without 540 // modification, are permitted provided that the following conditions 541 // are met: 542 // 1. Redistributions of source code must retain the above copyright 543 // notice, this list of conditions and the following disclaimer. 544 // 2. Redistributions in binary form must reproduce the above copyright 545 // notice, this list of conditions and the following disclaimer in the 546 // documentation and/or other materials provided with the distribution. 547 // 3. Neither the name of the University nor the names of its contributors 548 // may be used to endorse or promote products derived from this software 549 // without specific prior written permission. 550 // 551 // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 552 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 553 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 554 // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 555 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 556 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 557 // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 558 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 559 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 560 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 561 // SUCH DAMAGE. 562 // 563 // @(#)cdefs.h 8.8 (Berkeley) 1/9/95 564 // $FreeBSD$ 565 566 // - 567 // SPDX-License-Identifier: BSD-2-Clause-FreeBSD 568 // 569 // Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org> 570 // All rights reserved. 571 // 572 // Redistribution and use in source and binary forms, with or without 573 // modification, are permitted provided that the following conditions 574 // are met: 575 // 1. Redistributions of source code must retain the above copyright 576 // notice, this list of conditions and the following disclaimer. 577 // 2. Redistributions in binary form must reproduce the above copyright 578 // notice, this list of conditions and the following disclaimer in the 579 // documentation and/or other materials provided with the distribution. 580 // 581 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 582 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 583 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 584 // ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 585 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 586 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 587 // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 588 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 589 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 590 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 591 // SUCH DAMAGE. 592 // 593 // $FreeBSD$ 594 595 // - 596 // SPDX-License-Identifier: BSD-3-Clause 597 // 598 // Copyright (c) 1982, 1986, 1989, 1991, 1993 599 // The Regents of the University of California. All rights reserved. 600 // (c) UNIX System Laboratories, Inc. 601 // All or some portions of this file are derived from material licensed 602 // to the University of California by American Telephone and Telegraph 603 // Co. or Unix System Laboratories, Inc. and are reproduced herein with 604 // the permission of UNIX System Laboratories, Inc. 605 // 606 // Redistribution and use in source and binary forms, with or without 607 // modification, are permitted provided that the following conditions 608 // are met: 609 // 1. Redistributions of source code must retain the above copyright 610 // notice, this list of conditions and the following disclaimer. 611 // 2. Redistributions in binary form must reproduce the above copyright 612 // notice, this list of conditions and the following disclaimer in the 613 // documentation and/or other materials provided with the distribution. 614 // 3. Neither the name of the University nor the names of its contributors 615 // may be used to endorse or promote products derived from this software 616 // without specific prior written permission. 617 // 618 // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 619 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 620 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 621 // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 622 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 623 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 624 // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 625 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 626 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 627 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 628 // SUCH DAMAGE. 629 // 630 // @(#)signal.h 8.4 (Berkeley) 5/4/95 631 // $FreeBSD$ 632 633 // sigset_t macros. 634 635 type __sigset = struct{ __bits [4]uint32 } /* _sigset.h:53:9 */ 636 637 // - 638 // SPDX-License-Identifier: BSD-2-Clause-FreeBSD 639 // 640 // Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org> 641 // All rights reserved. 642 // 643 // Redistribution and use in source and binary forms, with or without 644 // modification, are permitted provided that the following conditions 645 // are met: 646 // 1. Redistributions of source code must retain the above copyright 647 // notice, this list of conditions and the following disclaimer. 648 // 2. Redistributions in binary form must reproduce the above copyright 649 // notice, this list of conditions and the following disclaimer in the 650 // documentation and/or other materials provided with the distribution. 651 // 652 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 653 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 654 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 655 // ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 656 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 657 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 658 // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 659 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 660 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 661 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 662 // SUCH DAMAGE. 663 // 664 // $FreeBSD$ 665 666 // - 667 // SPDX-License-Identifier: BSD-2-Clause-FreeBSD 668 // 669 // Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org> 670 // All rights reserved. 671 // 672 // Redistribution and use in source and binary forms, with or without 673 // modification, are permitted provided that the following conditions 674 // are met: 675 // 1. Redistributions of source code must retain the above copyright 676 // notice, this list of conditions and the following disclaimer. 677 // 2. Redistributions in binary form must reproduce the above copyright 678 // notice, this list of conditions and the following disclaimer in the 679 // documentation and/or other materials provided with the distribution. 680 // 681 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 682 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 683 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 684 // ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 685 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 686 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 687 // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 688 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 689 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 690 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 691 // SUCH DAMAGE. 692 // 693 // $FreeBSD$ 694 695 // Structure returned by gettimeofday(2) system call, and used in other calls. 696 type timeval = struct { 697 tv_sec time_t 698 tv_usec suseconds_t 699 } /* _timeval.h:49:1 */ 700 701 // - 702 // SPDX-License-Identifier: BSD-3-Clause 703 // 704 // Copyright (c) 1982, 1986, 1993 705 // The Regents of the University of California. All rights reserved. 706 // 707 // Redistribution and use in source and binary forms, with or without 708 // modification, are permitted provided that the following conditions 709 // are met: 710 // 1. Redistributions of source code must retain the above copyright 711 // notice, this list of conditions and the following disclaimer. 712 // 2. Redistributions in binary form must reproduce the above copyright 713 // notice, this list of conditions and the following disclaimer in the 714 // documentation and/or other materials provided with the distribution. 715 // 3. Neither the name of the University nor the names of its contributors 716 // may be used to endorse or promote products derived from this software 717 // without specific prior written permission. 718 // 719 // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 720 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 721 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 722 // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 723 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 724 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 725 // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 726 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 727 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 728 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 729 // SUCH DAMAGE. 730 // 731 // @(#)time.h 8.5 (Berkeley) 5/4/95 732 // from: FreeBSD: src/sys/sys/time.h,v 1.43 2000/03/20 14:09:05 phk Exp 733 // $FreeBSD$ 734 735 // - 736 // SPDX-License-Identifier: BSD-3-Clause 737 // 738 // Copyright (c) 1991, 1993 739 // The Regents of the University of California. All rights reserved. 740 // 741 // This code is derived from software contributed to Berkeley by 742 // Berkeley Software Design, Inc. 743 // 744 // Redistribution and use in source and binary forms, with or without 745 // modification, are permitted provided that the following conditions 746 // are met: 747 // 1. Redistributions of source code must retain the above copyright 748 // notice, this list of conditions and the following disclaimer. 749 // 2. Redistributions in binary form must reproduce the above copyright 750 // notice, this list of conditions and the following disclaimer in the 751 // documentation and/or other materials provided with the distribution. 752 // 3. Neither the name of the University nor the names of its contributors 753 // may be used to endorse or promote products derived from this software 754 // without specific prior written permission. 755 // 756 // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 757 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 758 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 759 // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 760 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 761 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 762 // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 763 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 764 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 765 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 766 // SUCH DAMAGE. 767 // 768 // @(#)cdefs.h 8.8 (Berkeley) 1/9/95 769 // $FreeBSD$ 770 771 // - 772 // SPDX-License-Identifier: BSD-3-Clause 773 // 774 // Copyright (c) 1982, 1986, 1993 775 // The Regents of the University of California. All rights reserved. 776 // 777 // Redistribution and use in source and binary forms, with or without 778 // modification, are permitted provided that the following conditions 779 // are met: 780 // 1. Redistributions of source code must retain the above copyright 781 // notice, this list of conditions and the following disclaimer. 782 // 2. Redistributions in binary form must reproduce the above copyright 783 // notice, this list of conditions and the following disclaimer in the 784 // documentation and/or other materials provided with the distribution. 785 // 3. Neither the name of the University nor the names of its contributors 786 // may be used to endorse or promote products derived from this software 787 // without specific prior written permission. 788 // 789 // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 790 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 791 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 792 // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 793 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 794 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 795 // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 796 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 797 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 798 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 799 // SUCH DAMAGE. 800 // 801 // @(#)time.h 8.5 (Berkeley) 5/4/95 802 // from: FreeBSD: src/sys/sys/time.h,v 1.43 2000/03/20 14:09:05 phk Exp 803 // $FreeBSD$ 804 805 // - 806 // SPDX-License-Identifier: BSD-2-Clause-FreeBSD 807 // 808 // Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org> 809 // All rights reserved. 810 // 811 // Redistribution and use in source and binary forms, with or without 812 // modification, are permitted provided that the following conditions 813 // are met: 814 // 1. Redistributions of source code must retain the above copyright 815 // notice, this list of conditions and the following disclaimer. 816 // 2. Redistributions in binary form must reproduce the above copyright 817 // notice, this list of conditions and the following disclaimer in the 818 // documentation and/or other materials provided with the distribution. 819 // 820 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 821 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 822 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 823 // ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 824 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 825 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 826 // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 827 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 828 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 829 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 830 // SUCH DAMAGE. 831 // 832 // $FreeBSD$ 833 834 type timespec = struct { 835 tv_sec time_t 836 tv_nsec int64 837 } /* _timespec.h:46:1 */ 838 839 // Structure defined by POSIX.1b to be like a itimerval, but with 840 // timespecs. Used in the timer_*() system calls. 841 type itimerspec = struct { 842 it_interval struct { 843 tv_sec time_t 844 tv_nsec int64 845 } 846 it_value struct { 847 tv_sec time_t 848 tv_nsec int64 849 } 850 } /* timespec.h:60:1 */ 851 852 type fd_mask = uint64 /* select.h:46:19 */ 853 854 type sigset_t = __sigset /* select.h:51:20 */ 855 856 // Select uses bit masks of file descriptors in longs. These macros 857 // manipulate such bit fields (the filesystem macros use chars). 858 // FD_SETSIZE may be defined by the user, but the default here should 859 // be enough for most uses. 860 861 type fd_set1 = struct{ __fds_bits [16]uint64 } /* select.h:73:9 */ 862 863 // Select uses bit masks of file descriptors in longs. These macros 864 // manipulate such bit fields (the filesystem macros use chars). 865 // FD_SETSIZE may be defined by the user, but the default here should 866 // be enough for most uses. 867 868 type fd_set = fd_set1 /* select.h:75:3 */ 869 870 // - 871 // This file is in the public domain. 872 // $FreeBSD$ 873 874 // - 875 // SPDX-License-Identifier: BSD-2-Clause 876 // 877 // Copyright (c) 2017 Poul-Henning Kamp. All rights reserved. 878 // 879 // Redistribution and use in source and binary forms, with or without 880 // modification, are permitted provided that the following conditions 881 // are met: 882 // 1. Redistributions of source code must retain the above copyright 883 // notice, this list of conditions and the following disclaimer. 884 // 2. Redistributions in binary form must reproduce the above copyright 885 // notice, this list of conditions and the following disclaimer in the 886 // documentation and/or other materials provided with the distribution. 887 // 888 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 889 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 890 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 891 // ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 892 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 893 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 894 // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 895 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 896 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 897 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 898 // SUCH DAMAGE. 899 // 900 // $FreeBSD$ 901 902 // - 903 // SPDX-License-Identifier: BSD-3-Clause 904 // 905 // Copyright (c) 2002 David E. O'Brien. All rights reserved. 906 // 907 // Redistribution and use in source and binary forms, with or without 908 // modification, are permitted provided that the following conditions 909 // are met: 910 // 1. Redistributions of source code must retain the above copyright 911 // notice, this list of conditions and the following disclaimer. 912 // 2. Redistributions in binary form must reproduce the above copyright 913 // notice, this list of conditions and the following disclaimer in the 914 // documentation and/or other materials provided with the distribution. 915 // 3. Neither the name of the University nor the names of its contributors 916 // may be used to endorse or promote products derived from this software 917 // without specific prior written permission. 918 // 919 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 920 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 921 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 922 // ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 923 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 924 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 925 // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 926 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 927 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 928 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 929 // SUCH DAMAGE. 930 // 931 // $FreeBSD$ 932 933 // - 934 // SPDX-License-Identifier: BSD-3-Clause 935 // 936 // Copyright (c) 1991, 1993 937 // The Regents of the University of California. All rights reserved. 938 // 939 // This code is derived from software contributed to Berkeley by 940 // Berkeley Software Design, Inc. 941 // 942 // Redistribution and use in source and binary forms, with or without 943 // modification, are permitted provided that the following conditions 944 // are met: 945 // 1. Redistributions of source code must retain the above copyright 946 // notice, this list of conditions and the following disclaimer. 947 // 2. Redistributions in binary form must reproduce the above copyright 948 // notice, this list of conditions and the following disclaimer in the 949 // documentation and/or other materials provided with the distribution. 950 // 3. Neither the name of the University nor the names of its contributors 951 // may be used to endorse or promote products derived from this software 952 // without specific prior written permission. 953 // 954 // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 955 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 956 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 957 // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 958 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 959 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 960 // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 961 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 962 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 963 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 964 // SUCH DAMAGE. 965 // 966 // @(#)cdefs.h 8.8 (Berkeley) 1/9/95 967 // $FreeBSD$ 968 969 // - 970 // SPDX-License-Identifier: BSD-2-Clause-FreeBSD 971 // 972 // Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org> 973 // All rights reserved. 974 // 975 // Redistribution and use in source and binary forms, with or without 976 // modification, are permitted provided that the following conditions 977 // are met: 978 // 1. Redistributions of source code must retain the above copyright 979 // notice, this list of conditions and the following disclaimer. 980 // 2. Redistributions in binary form must reproduce the above copyright 981 // notice, this list of conditions and the following disclaimer in the 982 // documentation and/or other materials provided with the distribution. 983 // 984 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 985 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 986 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 987 // ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 988 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 989 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 990 // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 991 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 992 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 993 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 994 // SUCH DAMAGE. 995 // 996 // $FreeBSD$ 997 998 type va_list = uintptr /* _stdarg.h:41:27 */ // select(2) 999 1000 type crypt_data = struct { 1001 initialized int32 1002 __buf [256]int8 1003 } /* unistd.h:489:1 */ 1004 1005 // getopt(3) external variable 1006 1007 // MVS linker does not support external names larger than 8 bytes 1008 1009 // 1010 // The 'zlib' compression library provides in-memory compression and 1011 // decompression functions, including integrity checks of the uncompressed data. 1012 // This version of the library supports only one compression method (deflation) 1013 // but other algorithms will be added later and will have the same stream 1014 // interface. 1015 // 1016 // Compression can be done in a single step if the buffers are large enough, 1017 // or can be done by repeated calls of the compression function. In the latter 1018 // case, the application must provide more input and/or consume the output 1019 // (providing more output space) before each call. 1020 // 1021 // The compressed data format used by default by the in-memory functions is 1022 // the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped 1023 // around a deflate stream, which is itself documented in RFC 1951. 1024 // 1025 // The library also supports reading and writing files in gzip (.gz) format 1026 // with an interface similar to that of stdio using the functions that start 1027 // with "gz". The gzip format is different from the zlib format. gzip is a 1028 // gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. 1029 // 1030 // This library can optionally read and write gzip and raw deflate streams in 1031 // memory as well. 1032 // 1033 // The zlib format was designed to be compact and fast for use in memory 1034 // and on communications channels. The gzip format was designed for single- 1035 // file compression on file systems, has a larger header than zlib to maintain 1036 // directory information, and uses a different, slower check method than zlib. 1037 // 1038 // The library does not install any signal handler. The decoder checks 1039 // the consistency of the compressed data, so the library should never crash 1040 // even in the case of corrupted input. 1041 1042 type alloc_func = uintptr /* zlib.h:81:16 */ 1043 type free_func = uintptr /* zlib.h:82:16 */ 1044 1045 type z_stream_s = struct { 1046 next_in uintptr 1047 avail_in uInt 1048 _ [4]byte 1049 total_in uLong 1050 next_out uintptr 1051 avail_out uInt 1052 _ [4]byte 1053 total_out uLong 1054 msg uintptr 1055 state uintptr 1056 zalloc alloc_func 1057 zfree free_func 1058 opaque voidpf 1059 data_type int32 1060 _ [4]byte 1061 adler uLong 1062 reserved uLong 1063 } /* zlib.h:86:9 */ 1064 1065 type z_stream = z_stream_s /* zlib.h:106:3 */ 1066 1067 type z_streamp = uintptr /* zlib.h:108:22 */ 1068 1069 // 1070 // gzip header information passed to and from zlib routines. See RFC 1952 1071 // for more details on the meanings of these fields. 1072 type gz_header_s = struct { 1073 text int32 1074 _ [4]byte 1075 time uLong 1076 xflags int32 1077 os int32 1078 extra uintptr 1079 extra_len uInt 1080 extra_max uInt 1081 name uintptr 1082 name_max uInt 1083 _ [4]byte 1084 comment uintptr 1085 comm_max uInt 1086 hcrc int32 1087 done int32 1088 _ [4]byte 1089 } /* zlib.h:114:9 */ 1090 1091 // 1092 // gzip header information passed to and from zlib routines. See RFC 1952 1093 // for more details on the meanings of these fields. 1094 type gz_header = gz_header_s /* zlib.h:129:3 */ 1095 1096 type gz_headerp = uintptr /* zlib.h:131:23 */ 1097 // 1098 // inflateGetHeader() requests that gzip header information be stored in the 1099 // provided gz_header structure. inflateGetHeader() may be called after 1100 // inflateInit2() or inflateReset(), and before the first call of inflate(). 1101 // As inflate() processes the gzip stream, head->done is zero until the header 1102 // is completed, at which time head->done is set to one. If a zlib stream is 1103 // being decoded, then head->done is set to -1 to indicate that there will be 1104 // no gzip header information forthcoming. Note that Z_BLOCK or Z_TREES can be 1105 // used to force inflate() to return immediately after header processing is 1106 // complete and before any actual data is decompressed. 1107 // 1108 // The text, time, xflags, and os fields are filled in with the gzip header 1109 // contents. hcrc is set to true if there is a header CRC. (The header CRC 1110 // was valid if done is set to one.) If extra is not Z_NULL, then extra_max 1111 // contains the maximum number of bytes to write to extra. Once done is true, 1112 // extra_len contains the actual extra field length, and extra contains the 1113 // extra field, or that field truncated if extra_max is less than extra_len. 1114 // If name is not Z_NULL, then up to name_max characters are written there, 1115 // terminated with a zero unless the length is greater than name_max. If 1116 // comment is not Z_NULL, then up to comm_max characters are written there, 1117 // terminated with a zero unless the length is greater than comm_max. When any 1118 // of extra, name, or comment are not Z_NULL and the respective field is not 1119 // present in the header, then that field is set to Z_NULL to signal its 1120 // absence. This allows the use of deflateSetHeader() with the returned 1121 // structure to duplicate the header. However if those fields are set to 1122 // allocated memory, then the application will need to save those pointers 1123 // elsewhere so that they can be eventually freed. 1124 // 1125 // If inflateGetHeader is not used, then the header information is simply 1126 // discarded. The header is always checked for validity, including the header 1127 // CRC if present. inflateReset() will reset the process to discard the header 1128 // information. The application would need to call inflateGetHeader() again to 1129 // retrieve the header from the next gzip stream. 1130 // 1131 // inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source 1132 // stream state was inconsistent. 1133 1134 // 1135 // ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, 1136 // unsigned char FAR *window)); 1137 // 1138 // Initialize the internal stream state for decompression using inflateBack() 1139 // calls. The fields zalloc, zfree and opaque in strm must be initialized 1140 // before the call. If zalloc and zfree are Z_NULL, then the default library- 1141 // derived memory allocation routines are used. windowBits is the base two 1142 // logarithm of the window size, in the range 8..15. window is a caller 1143 // supplied buffer of that size. Except for special applications where it is 1144 // assured that deflate was used with small window sizes, windowBits must be 15 1145 // and a 32K byte window must be supplied to be able to decompress general 1146 // deflate streams. 1147 // 1148 // See inflateBack() for the usage of these routines. 1149 // 1150 // inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of 1151 // the parameters are invalid, Z_MEM_ERROR if the internal state could not be 1152 // allocated, or Z_VERSION_ERROR if the version of the library does not match 1153 // the version of the header file. 1154 1155 type in_func = uintptr /* zlib.h:1092:18 */ 1156 type out_func = uintptr /* zlib.h:1094:13 */ 1157 // 1158 // Same as uncompress, except that sourceLen is a pointer, where the 1159 // length of the source is *sourceLen. On return, *sourceLen is the number of 1160 // source bytes consumed. 1161 1162 // gzip file access functions 1163 1164 // 1165 // This library supports reading and writing files in gzip (.gz) format with 1166 // an interface similar to that of stdio, using the functions that start with 1167 // "gz". The gzip format is different from the zlib format. gzip is a gzip 1168 // wrapper, documented in RFC 1952, wrapped around a deflate stream. 1169 1170 type gzFile_s = struct { 1171 have uint32 1172 _ [4]byte 1173 next uintptr 1174 pos off_t 1175 } /* zlib.h:1300:9 */ 1176 1177 // 1178 // Same as uncompress, except that sourceLen is a pointer, where the 1179 // length of the source is *sourceLen. On return, *sourceLen is the number of 1180 // source bytes consumed. 1181 1182 // gzip file access functions 1183 1184 // 1185 // This library supports reading and writing files in gzip (.gz) format with 1186 // an interface similar to that of stdio, using the functions that start with 1187 // "gz". The gzip format is different from the zlib format. gzip is a gzip 1188 // wrapper, documented in RFC 1952, wrapped around a deflate stream. 1189 1190 type gzFile = uintptr /* zlib.h:1300:25 */ 1191 1192 // - 1193 // SPDX-License-Identifier: BSD-3-Clause 1194 // 1195 // Copyright (c) 1990, 1993 1196 // The Regents of the University of California. All rights reserved. 1197 // 1198 // This code is derived from software contributed to Berkeley by 1199 // Chris Torek. 1200 // 1201 // Redistribution and use in source and binary forms, with or without 1202 // modification, are permitted provided that the following conditions 1203 // are met: 1204 // 1. Redistributions of source code must retain the above copyright 1205 // notice, this list of conditions and the following disclaimer. 1206 // 2. Redistributions in binary form must reproduce the above copyright 1207 // notice, this list of conditions and the following disclaimer in the 1208 // documentation and/or other materials provided with the distribution. 1209 // 3. Neither the name of the University nor the names of its contributors 1210 // may be used to endorse or promote products derived from this software 1211 // without specific prior written permission. 1212 // 1213 // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 1214 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1215 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1216 // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 1217 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1218 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 1219 // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 1220 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 1221 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 1222 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 1223 // SUCH DAMAGE. 1224 // 1225 // @(#)stdio.h 8.5 (Berkeley) 4/29/95 1226 // $FreeBSD$ 1227 1228 // - 1229 // SPDX-License-Identifier: BSD-3-Clause 1230 // 1231 // Copyright (c) 1991, 1993 1232 // The Regents of the University of California. All rights reserved. 1233 // 1234 // This code is derived from software contributed to Berkeley by 1235 // Berkeley Software Design, Inc. 1236 // 1237 // Redistribution and use in source and binary forms, with or without 1238 // modification, are permitted provided that the following conditions 1239 // are met: 1240 // 1. Redistributions of source code must retain the above copyright 1241 // notice, this list of conditions and the following disclaimer. 1242 // 2. Redistributions in binary form must reproduce the above copyright 1243 // notice, this list of conditions and the following disclaimer in the 1244 // documentation and/or other materials provided with the distribution. 1245 // 3. Neither the name of the University nor the names of its contributors 1246 // may be used to endorse or promote products derived from this software 1247 // without specific prior written permission. 1248 // 1249 // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 1250 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1251 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1252 // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 1253 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1254 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 1255 // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 1256 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 1257 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 1258 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 1259 // SUCH DAMAGE. 1260 // 1261 // @(#)cdefs.h 8.8 (Berkeley) 1/9/95 1262 // $FreeBSD$ 1263 1264 // - 1265 // SPDX-License-Identifier: BSD-2-Clause-FreeBSD 1266 // 1267 // Copyright (c) 2003 Marcel Moolenaar 1268 // All rights reserved. 1269 // 1270 // Redistribution and use in source and binary forms, with or without 1271 // modification, are permitted provided that the following conditions 1272 // are met: 1273 // 1274 // 1. Redistributions of source code must retain the above copyright 1275 // notice, this list of conditions and the following disclaimer. 1276 // 2. Redistributions in binary form must reproduce the above copyright 1277 // notice, this list of conditions and the following disclaimer in the 1278 // documentation and/or other materials provided with the distribution. 1279 // 1280 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1281 // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1282 // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1283 // IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 1284 // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 1285 // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 1286 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 1287 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 1288 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 1289 // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 1290 // 1291 // $FreeBSD$ 1292 1293 // - 1294 // SPDX-License-Identifier: BSD-2-Clause-FreeBSD 1295 // 1296 // Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org> 1297 // All rights reserved. 1298 // 1299 // Redistribution and use in source and binary forms, with or without 1300 // modification, are permitted provided that the following conditions 1301 // are met: 1302 // 1. Redistributions of source code must retain the above copyright 1303 // notice, this list of conditions and the following disclaimer. 1304 // 2. Redistributions in binary form must reproduce the above copyright 1305 // notice, this list of conditions and the following disclaimer in the 1306 // documentation and/or other materials provided with the distribution. 1307 // 1308 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1309 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1310 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1311 // ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1312 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1313 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 1314 // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 1315 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 1316 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 1317 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 1318 // SUCH DAMAGE. 1319 // 1320 // $FreeBSD$ 1321 1322 type fpos_t = int64 /* stdio.h:47:18 */ 1323 1324 // NB: to fit things in six character monocase externals, the stdio 1325 // code uses the prefix `__s' for stdio objects, typically followed 1326 // by a three-character attempt at a mnemonic. 1327 1328 // stdio buffers 1329 type __sbuf = struct { 1330 _base uintptr 1331 _size int32 1332 _ [4]byte 1333 } /* stdio.h:91:1 */ 1334 1335 // stdio state variables. 1336 // 1337 // The following always hold: 1338 // 1339 // if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR), 1340 // _lbfsize is -_bf._size, else _lbfsize is 0 1341 // if _flags&__SRD, _w is 0 1342 // if _flags&__SWR, _r is 0 1343 // 1344 // This ensures that the getc and putc macros (or inline functions) never 1345 // try to write or read from a file that is in `read' or `write' mode. 1346 // (Moreover, they can, and do, automatically switch from read mode to 1347 // write mode, and back, on "r+" and "w+" files.) 1348 // 1349 // _lbfsize is used only to make the inline line-buffered output stream 1350 // code as compact as possible. 1351 // 1352 // _ub, _up, and _ur are used when ungetc() pushes back more characters 1353 // than fit in the current _bf, or when ungetc() pushes back a character 1354 // that does not match the previous one in _bf. When this happens, 1355 // _ub._base becomes non-nil (i.e., a stream has ungetc() data iff 1356 // _ub._base!=NULL) and _up and _ur save the current values of _p and _r. 1357 // 1358 // Certain members of __sFILE are accessed directly via macros or 1359 // inline functions. To preserve ABI compat, these members must not 1360 // be disturbed. These members are marked below with (*). 1361 type __sFILE = struct { 1362 _p uintptr 1363 _r int32 1364 _w int32 1365 _flags int16 1366 _file int16 1367 _ [4]byte 1368 _bf struct { 1369 _base uintptr 1370 _size int32 1371 _ [4]byte 1372 } 1373 _lbfsize int32 1374 _ [4]byte 1375 _cookie uintptr 1376 _close uintptr 1377 _read uintptr 1378 _seek uintptr 1379 _write uintptr 1380 _ub struct { 1381 _base uintptr 1382 _size int32 1383 _ [4]byte 1384 } 1385 _up uintptr 1386 _ur int32 1387 _ubuf [3]uint8 1388 _nbuf [1]uint8 1389 _lb struct { 1390 _base uintptr 1391 _size int32 1392 _ [4]byte 1393 } 1394 _blksize int32 1395 _ [4]byte 1396 _offset fpos_t 1397 _fl_mutex uintptr 1398 _fl_owner uintptr 1399 _fl_count int32 1400 _orientation int32 1401 _mbstate struct { 1402 _ [0]uint64 1403 __mbstate8 [128]int8 1404 } 1405 _flags2 int32 1406 _ [4]byte 1407 } /* stdio.h:124:1 */ 1408 1409 type FILE = __sFILE /* stdio.h:165:24 */ 1410 type cookie_io_functions_t = struct { 1411 read uintptr 1412 write uintptr 1413 seek uintptr 1414 close uintptr 1415 } /* stdio.h:428:3 */ 1416 1417 // - 1418 // Copyright (c) 2011, 2012 The FreeBSD Foundation 1419 // All rights reserved. 1420 // 1421 // Redistribution and use in source and binary forms, with or without 1422 // modification, are permitted provided that the following conditions 1423 // are met: 1424 // 1. Redistributions of source code must retain the above copyright 1425 // notice, this list of conditions and the following disclaimer. 1426 // 2. Redistributions in binary form must reproduce the above copyright 1427 // notice, this list of conditions and the following disclaimer in the 1428 // documentation and/or other materials provided with the distribution. 1429 // 1430 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1431 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1432 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1433 // ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1434 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1435 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 1436 // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 1437 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 1438 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 1439 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 1440 // SUCH DAMAGE. 1441 // 1442 // $FreeBSD$ 1443 1444 type locale_t = uintptr /* _strings.h:31:25 */ 1445 1446 // xlocale extensions 1447 1448 type errno_t = int32 /* string.h:156:13 */ 1449 1450 // - 1451 // SPDX-License-Identifier: BSD-3-Clause 1452 // 1453 // Copyright (c) 1990, 1993 1454 // The Regents of the University of California. All rights reserved. 1455 // 1456 // Redistribution and use in source and binary forms, with or without 1457 // modification, are permitted provided that the following conditions 1458 // are met: 1459 // 1. Redistributions of source code must retain the above copyright 1460 // notice, this list of conditions and the following disclaimer. 1461 // 2. Redistributions in binary form must reproduce the above copyright 1462 // notice, this list of conditions and the following disclaimer in the 1463 // documentation and/or other materials provided with the distribution. 1464 // 3. Neither the name of the University nor the names of its contributors 1465 // may be used to endorse or promote products derived from this software 1466 // without specific prior written permission. 1467 // 1468 // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 1469 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1470 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1471 // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 1472 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1473 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 1474 // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 1475 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 1476 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 1477 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 1478 // SUCH DAMAGE. 1479 // 1480 // @(#)stdlib.h 8.5 (Berkeley) 5/19/95 1481 // $FreeBSD$ 1482 1483 // - 1484 // SPDX-License-Identifier: BSD-3-Clause 1485 // 1486 // Copyright (c) 1991, 1993 1487 // The Regents of the University of California. All rights reserved. 1488 // 1489 // This code is derived from software contributed to Berkeley by 1490 // Berkeley Software Design, Inc. 1491 // 1492 // Redistribution and use in source and binary forms, with or without 1493 // modification, are permitted provided that the following conditions 1494 // are met: 1495 // 1. Redistributions of source code must retain the above copyright 1496 // notice, this list of conditions and the following disclaimer. 1497 // 2. Redistributions in binary form must reproduce the above copyright 1498 // notice, this list of conditions and the following disclaimer in the 1499 // documentation and/or other materials provided with the distribution. 1500 // 3. Neither the name of the University nor the names of its contributors 1501 // may be used to endorse or promote products derived from this software 1502 // without specific prior written permission. 1503 // 1504 // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 1505 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1506 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1507 // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 1508 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1509 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 1510 // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 1511 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 1512 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 1513 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 1514 // SUCH DAMAGE. 1515 // 1516 // @(#)cdefs.h 8.8 (Berkeley) 1/9/95 1517 // $FreeBSD$ 1518 1519 // - 1520 // SPDX-License-Identifier: BSD-2-Clause-FreeBSD 1521 // 1522 // Copyright (c) 2003 Marcel Moolenaar 1523 // All rights reserved. 1524 // 1525 // Redistribution and use in source and binary forms, with or without 1526 // modification, are permitted provided that the following conditions 1527 // are met: 1528 // 1529 // 1. Redistributions of source code must retain the above copyright 1530 // notice, this list of conditions and the following disclaimer. 1531 // 2. Redistributions in binary form must reproduce the above copyright 1532 // notice, this list of conditions and the following disclaimer in the 1533 // documentation and/or other materials provided with the distribution. 1534 // 1535 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1536 // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1537 // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1538 // IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 1539 // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 1540 // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 1541 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 1542 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 1543 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 1544 // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 1545 // 1546 // $FreeBSD$ 1547 1548 // - 1549 // SPDX-License-Identifier: BSD-2-Clause-FreeBSD 1550 // 1551 // Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org> 1552 // All rights reserved. 1553 // 1554 // Redistribution and use in source and binary forms, with or without 1555 // modification, are permitted provided that the following conditions 1556 // are met: 1557 // 1. Redistributions of source code must retain the above copyright 1558 // notice, this list of conditions and the following disclaimer. 1559 // 2. Redistributions in binary form must reproduce the above copyright 1560 // notice, this list of conditions and the following disclaimer in the 1561 // documentation and/or other materials provided with the distribution. 1562 // 1563 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1564 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1565 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1566 // ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1567 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1568 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 1569 // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 1570 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 1571 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 1572 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 1573 // SUCH DAMAGE. 1574 // 1575 // $FreeBSD$ 1576 1577 type div_t = struct { 1578 quot int32 1579 rem int32 1580 } /* stdlib.h:66:3 */ 1581 1582 type ldiv_t = struct { 1583 quot int64 1584 rem int64 1585 } /* stdlib.h:71:3 */ 1586 1587 // Functions added in C99 which we make conditionally available in the 1588 // BSD^C89 namespace if the compiler supports `long long'. 1589 // The #if test is more complicated than it ought to be because 1590 // __BSD_VISIBLE implies __ISO_C_VISIBLE == 1999 *even if* `long long' 1591 // is not supported in the compilation environment (which therefore means 1592 // that it can't really be ISO C99). 1593 // 1594 // (The only other extension made by C99 in thie header is _Exit().) 1595 // LONGLONG 1596 type lldiv_t = struct { 1597 quot int64 1598 rem int64 1599 } /* stdlib.h:142:3 */ // getsubopt(3) external variable 1600 1601 // K.3.6 1602 type constraint_handler_t = uintptr /* stdlib.h:349:14 */ 1603 1604 var hello = *(*[14]int8)(unsafe.Pointer(ts /* "hello, hello!" */)) /* example.c:29:21 */ 1605 // "hello world" would be more standard, but the repeated "hello" 1606 // stresses the compression code better, sorry... 1607 1608 var dictionary = *(*[6]int8)(unsafe.Pointer(ts + 14 /* "hello" */)) /* example.c:34:19 */ 1609 var dictId uLong /* example.c:35:14: */ 1610 1611 var zalloc alloc_func = uintptr(0) /* example.c:77:19 */ 1612 var zfree free_func = uintptr(0) /* example.c:78:18 */ 1613 1614 // =========================================================================== 1615 // Test compress() and uncompress() 1616 func test_compress(tls *libc.TLS, compr uintptr, comprLen uLong, uncompr uintptr, uncomprLen uLong) { /* example.c:88:6: */ 1617 bp := tls.Alloc(56) 1618 defer tls.Free(56) 1619 *(*uLong)(unsafe.Pointer(bp + 40)) = comprLen 1620 *(*uLong)(unsafe.Pointer(bp + 48)) = uncomprLen 1621 1622 var err int32 1623 var len uLong = (libc.Xstrlen(tls, uintptr(unsafe.Pointer(&hello))) + uint64(1)) 1624 1625 err = z.Xcompress(tls, compr, bp+40 /* &comprLen */, uintptr(uintptr(unsafe.Pointer(&hello))), len) 1626 { 1627 if err != 0 { 1628 libc.Xfprintf(tls, libc.X__stderrp, ts+20 /* "%s error: %d\n" */, libc.VaList(bp, ts+34 /* "compress" */, err)) 1629 libc.Xexit(tls, 1) 1630 } 1631 } 1632 1633 libc.Xstrcpy(tls, uncompr, ts+43 /* "garbage" */) 1634 1635 err = z.Xuncompress(tls, uncompr, bp+48 /* &uncomprLen */, compr, *(*uLong)(unsafe.Pointer(bp + 40 /* comprLen */))) 1636 { 1637 if err != 0 { 1638 libc.Xfprintf(tls, libc.X__stderrp, ts+20 /* "%s error: %d\n" */, libc.VaList(bp+16, ts+51 /* "uncompress" */, err)) 1639 libc.Xexit(tls, 1) 1640 } 1641 } 1642 1643 if libc.Xstrcmp(tls, uncompr, uintptr(unsafe.Pointer(&hello))) != 0 { 1644 libc.Xfprintf(tls, libc.X__stderrp, ts+62 /* "bad uncompress\n" */, 0) 1645 libc.Xexit(tls, 1) 1646 } else { 1647 libc.Xprintf(tls, ts+78 /* "uncompress(): %s..." */, libc.VaList(bp+32, uncompr)) 1648 } 1649 } 1650 1651 // =========================================================================== 1652 // Test read/write of .gz files 1653 func test_gzio(tls *libc.TLS, fname uintptr, uncompr uintptr, uncomprLen uLong) { /* example.c:114:6: */ 1654 bp := tls.Alloc(84) 1655 defer tls.Free(84) 1656 1657 // var err int32 at bp+80, 4 1658 1659 var len int32 = (int32(libc.Xstrlen(tls, uintptr(unsafe.Pointer(&hello)))) + 1) 1660 var file gzFile 1661 var pos off_t 1662 1663 file = z.Xgzopen(tls, fname, ts+96 /* "wb" */) 1664 if file == (uintptr(0)) { 1665 libc.Xfprintf(tls, libc.X__stderrp, ts+99 /* "gzopen error\n" */, 0) 1666 libc.Xexit(tls, 1) 1667 } 1668 z.Xgzputc(tls, file, 'h') 1669 if z.Xgzputs(tls, file, ts+113 /* "ello" */) != 4 { 1670 libc.Xfprintf(tls, libc.X__stderrp, ts+118 /* "gzputs err: %s\n" */, libc.VaList(bp, z.Xgzerror(tls, file, bp+80 /* &err */))) 1671 libc.Xexit(tls, 1) 1672 } 1673 if z.Xgzprintf(tls, file, ts+134 /* ", %s!" */, libc.VaList(bp+8, ts+14 /* "hello" */)) != 8 { 1674 libc.Xfprintf(tls, libc.X__stderrp, ts+140 /* "gzprintf err: %s..." */, libc.VaList(bp+16, z.Xgzerror(tls, file, bp+80 /* &err */))) 1675 libc.Xexit(tls, 1) 1676 } 1677 z.Xgzseek(tls, file, 1, 1) // add one zero byte 1678 z.Xgzclose(tls, file) 1679 1680 file = z.Xgzopen(tls, fname, ts+158 /* "rb" */) 1681 if file == (uintptr(0)) { 1682 libc.Xfprintf(tls, libc.X__stderrp, ts+99 /* "gzopen error\n" */, 0) 1683 libc.Xexit(tls, 1) 1684 } 1685 libc.Xstrcpy(tls, uncompr, ts+43 /* "garbage" */) 1686 1687 if z.Xgzread(tls, file, uncompr, uint32(uncomprLen)) != len { 1688 libc.Xfprintf(tls, libc.X__stderrp, ts+161 /* "gzread err: %s\n" */, libc.VaList(bp+24, z.Xgzerror(tls, file, bp+80 /* &err */))) 1689 libc.Xexit(tls, 1) 1690 } 1691 if libc.Xstrcmp(tls, uncompr, uintptr(unsafe.Pointer(&hello))) != 0 { 1692 libc.Xfprintf(tls, libc.X__stderrp, ts+177 /* "bad gzread: %s\n" */, libc.VaList(bp+32, uncompr)) 1693 libc.Xexit(tls, 1) 1694 } else { 1695 libc.Xprintf(tls, ts+193 /* "gzread(): %s\n" */, libc.VaList(bp+40, uncompr)) 1696 } 1697 1698 pos = z.Xgzseek(tls, file, -8, 1) 1699 if (pos != int64(6)) || (z.Xgztell(tls, file) != pos) { 1700 libc.Xfprintf(tls, libc.X__stderrp, ts+207, /* "gzseek error, po..." */ 1701 libc.VaList(bp+48, pos, z.Xgztell(tls, file))) 1702 libc.Xexit(tls, 1) 1703 } 1704 1705 if (func() int32 { 1706 if (*gzFile_s)(unsafe.Pointer(file)).have != 0 { 1707 return int32(func() uint8 { 1708 (*gzFile_s)(unsafe.Pointer(file)).have-- 1709 (*gzFile_s)(unsafe.Pointer(file)).pos++ 1710 return *(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&((*gzFile_s)(unsafe.Pointer(file)).next), 1))) 1711 }()) 1712 } 1713 return z.Xgzgetc(tls, file) 1714 }()) != ' ' { 1715 libc.Xfprintf(tls, libc.X__stderrp, ts+242 /* "gzgetc error\n" */, 0) 1716 libc.Xexit(tls, 1) 1717 } 1718 1719 if z.Xgzungetc(tls, ' ', file) != ' ' { 1720 libc.Xfprintf(tls, libc.X__stderrp, ts+256 /* "gzungetc error\n" */, 0) 1721 libc.Xexit(tls, 1) 1722 } 1723 1724 z.Xgzgets(tls, file, uncompr, int32(uncomprLen)) 1725 if libc.Xstrlen(tls, uncompr) != uint64(7) { // " hello!" 1726 libc.Xfprintf(tls, libc.X__stderrp, ts+272 /* "gzgets err after..." */, libc.VaList(bp+64, z.Xgzerror(tls, file, bp+80 /* &err */))) 1727 libc.Xexit(tls, 1) 1728 } 1729 if libc.Xstrcmp(tls, uncompr, (uintptr(unsafe.Pointer(&hello))+uintptr(6))) != 0 { 1730 libc.Xfprintf(tls, libc.X__stderrp, ts+301 /* "bad gzgets after..." */, 0) 1731 libc.Xexit(tls, 1) 1732 } else { 1733 libc.Xprintf(tls, ts+326 /* "gzgets() after g..." */, libc.VaList(bp+72, uncompr)) 1734 } 1735 1736 z.Xgzclose(tls, file) 1737 } 1738 1739 // =========================================================================== 1740 // Test deflate() with small buffers 1741 func test_deflate(tls *libc.TLS, compr uintptr, comprLen uLong) { /* example.c:200:6: */ 1742 bp := tls.Alloc(176) 1743 defer tls.Free(176) 1744 1745 // var c_stream z_stream at bp+64, 112 1746 // compression stream 1747 var err int32 1748 var len uLong = (libc.Xstrlen(tls, uintptr(unsafe.Pointer(&hello))) + uint64(1)) 1749 1750 (*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).zalloc = zalloc 1751 (*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).zfree = zfree 1752 (*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).opaque = uintptr(0) 1753 1754 err = z.XdeflateInit_(tls, bp+64 /* &c_stream */, -1, ts+353 /* "1.2.11" */, int32(unsafe.Sizeof(z_stream{}))) 1755 { 1756 if err != 0 { 1757 libc.Xfprintf(tls, libc.X__stderrp, ts+20 /* "%s error: %d\n" */, libc.VaList(bp, ts+360 /* "deflateInit" */, err)) 1758 libc.Xexit(tls, 1) 1759 } 1760 } 1761 1762 (*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).next_in = uintptr(uintptr(unsafe.Pointer(&hello))) 1763 (*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).next_out = compr 1764 1765 for ((*z_stream)(unsafe.Pointer(bp+64 /* &c_stream */)).total_in != len) && ((*z_stream)(unsafe.Pointer(bp+64 /* &c_stream */)).total_out < comprLen) { 1766 (*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).avail_in = libc.AssignPtrUint32(bp+64 /* &c_stream */ +32 /* &.avail_out */, uInt(1)) // force small buffers 1767 err = z.Xdeflate(tls, bp+64 /* &c_stream */, 0) 1768 { 1769 if err != 0 { 1770 libc.Xfprintf(tls, libc.X__stderrp, ts+20 /* "%s error: %d\n" */, libc.VaList(bp+16, ts+372 /* "deflate" */, err)) 1771 libc.Xexit(tls, 1) 1772 } 1773 } 1774 1775 } 1776 // Finish the stream, still forcing small buffers: 1777 for { 1778 (*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).avail_out = uInt(1) 1779 err = z.Xdeflate(tls, bp+64 /* &c_stream */, 4) 1780 if err == 1 { 1781 break 1782 } 1783 { 1784 if err != 0 { 1785 libc.Xfprintf(tls, libc.X__stderrp, ts+20 /* "%s error: %d\n" */, libc.VaList(bp+32, ts+372 /* "deflate" */, err)) 1786 libc.Xexit(tls, 1) 1787 } 1788 } 1789 1790 } 1791 1792 err = z.XdeflateEnd(tls, bp+64 /* &c_stream */) 1793 { 1794 if err != 0 { 1795 libc.Xfprintf(tls, libc.X__stderrp, ts+20 /* "%s error: %d\n" */, libc.VaList(bp+48, ts+380 /* "deflateEnd" */, err)) 1796 libc.Xexit(tls, 1) 1797 } 1798 } 1799 1800 } 1801 1802 // =========================================================================== 1803 // Test inflate() with small buffers 1804 func test_inflate(tls *libc.TLS, compr uintptr, comprLen uLong, uncompr uintptr, uncomprLen uLong) { /* example.c:238:6: */ 1805 bp := tls.Alloc(168) 1806 defer tls.Free(168) 1807 1808 var err int32 1809 // var d_stream z_stream at bp+56, 112 1810 // decompression stream 1811 1812 libc.Xstrcpy(tls, uncompr, ts+43 /* "garbage" */) 1813 1814 (*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).zalloc = zalloc 1815 (*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).zfree = zfree 1816 (*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).opaque = uintptr(0) 1817 1818 (*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).next_in = compr 1819 (*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).avail_in = uInt(0) 1820 (*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).next_out = uncompr 1821 1822 err = z.XinflateInit_(tls, bp+56 /* &d_stream */, ts+353 /* "1.2.11" */, int32(unsafe.Sizeof(z_stream{}))) 1823 { 1824 if err != 0 { 1825 libc.Xfprintf(tls, libc.X__stderrp, ts+20 /* "%s error: %d\n" */, libc.VaList(bp, ts+391 /* "inflateInit" */, err)) 1826 libc.Xexit(tls, 1) 1827 } 1828 } 1829 1830 for ((*z_stream)(unsafe.Pointer(bp+56 /* &d_stream */)).total_out < uncomprLen) && ((*z_stream)(unsafe.Pointer(bp+56 /* &d_stream */)).total_in < comprLen) { 1831 (*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).avail_in = libc.AssignPtrUint32(bp+56 /* &d_stream */ +32 /* &.avail_out */, uInt(1)) // force small buffers 1832 err = z.Xinflate(tls, bp+56 /* &d_stream */, 0) 1833 if err == 1 { 1834 break 1835 } 1836 { 1837 if err != 0 { 1838 libc.Xfprintf(tls, libc.X__stderrp, ts+20 /* "%s error: %d\n" */, libc.VaList(bp+16, ts+403 /* "inflate" */, err)) 1839 libc.Xexit(tls, 1) 1840 } 1841 } 1842 1843 } 1844 1845 err = z.XinflateEnd(tls, bp+56 /* &d_stream */) 1846 { 1847 if err != 0 { 1848 libc.Xfprintf(tls, libc.X__stderrp, ts+20 /* "%s error: %d\n" */, libc.VaList(bp+32, ts+411 /* "inflateEnd" */, err)) 1849 libc.Xexit(tls, 1) 1850 } 1851 } 1852 1853 if libc.Xstrcmp(tls, uncompr, uintptr(unsafe.Pointer(&hello))) != 0 { 1854 libc.Xfprintf(tls, libc.X__stderrp, ts+422 /* "bad inflate\n" */, 0) 1855 libc.Xexit(tls, 1) 1856 } else { 1857 libc.Xprintf(tls, ts+435 /* "inflate(): %s\n" */, libc.VaList(bp+48, uncompr)) 1858 } 1859 } 1860 1861 // =========================================================================== 1862 // Test deflate() with large buffers and dynamic change of compression level 1863 func test_large_deflate(tls *libc.TLS, compr uintptr, comprLen uLong, uncompr uintptr, uncomprLen uLong) { /* example.c:279:6: */ 1864 bp := tls.Alloc(192) 1865 defer tls.Free(192) 1866 1867 // var c_stream z_stream at bp+80, 112 1868 // compression stream 1869 var err int32 1870 1871 (*z_stream)(unsafe.Pointer(bp + 80 /* &c_stream */)).zalloc = zalloc 1872 (*z_stream)(unsafe.Pointer(bp + 80 /* &c_stream */)).zfree = zfree 1873 (*z_stream)(unsafe.Pointer(bp + 80 /* &c_stream */)).opaque = uintptr(0) 1874 1875 err = z.XdeflateInit_(tls, bp+80 /* &c_stream */, 1, ts+353 /* "1.2.11" */, int32(unsafe.Sizeof(z_stream{}))) 1876 { 1877 if err != 0 { 1878 libc.Xfprintf(tls, libc.X__stderrp, ts+20 /* "%s error: %d\n" */, libc.VaList(bp, ts+360 /* "deflateInit" */, err)) 1879 libc.Xexit(tls, 1) 1880 } 1881 } 1882 1883 (*z_stream)(unsafe.Pointer(bp + 80 /* &c_stream */)).next_out = compr 1884 (*z_stream)(unsafe.Pointer(bp + 80 /* &c_stream */)).avail_out = uInt(comprLen) 1885 1886 // At this point, uncompr is still mostly zeroes, so it should compress 1887 // very well: 1888 (*z_stream)(unsafe.Pointer(bp + 80 /* &c_stream */)).next_in = uncompr 1889 (*z_stream)(unsafe.Pointer(bp + 80 /* &c_stream */)).avail_in = uInt(uncomprLen) 1890 err = z.Xdeflate(tls, bp+80 /* &c_stream */, 0) 1891 { 1892 if err != 0 { 1893 libc.Xfprintf(tls, libc.X__stderrp, ts+20 /* "%s error: %d\n" */, libc.VaList(bp+16, ts+372 /* "deflate" */, err)) 1894 libc.Xexit(tls, 1) 1895 } 1896 } 1897 1898 if (*z_stream)(unsafe.Pointer(bp+80 /* &c_stream */)).avail_in != uInt(0) { 1899 libc.Xfprintf(tls, libc.X__stderrp, ts+450 /* "deflate not gree..." */, 0) 1900 libc.Xexit(tls, 1) 1901 } 1902 1903 // Feed in already compressed data and switch to no compression: 1904 z.XdeflateParams(tls, bp+80 /* &c_stream */, 0, 0) 1905 (*z_stream)(unsafe.Pointer(bp + 80 /* &c_stream */)).next_in = compr 1906 (*z_stream)(unsafe.Pointer(bp + 80 /* &c_stream */)).avail_in = (uInt(comprLen) / uInt(2)) 1907 err = z.Xdeflate(tls, bp+80 /* &c_stream */, 0) 1908 { 1909 if err != 0 { 1910 libc.Xfprintf(tls, libc.X__stderrp, ts+20 /* "%s error: %d\n" */, libc.VaList(bp+32, ts+372 /* "deflate" */, err)) 1911 libc.Xexit(tls, 1) 1912 } 1913 } 1914 1915 // Switch back to compressing mode: 1916 z.XdeflateParams(tls, bp+80 /* &c_stream */, 9, 1) 1917 (*z_stream)(unsafe.Pointer(bp + 80 /* &c_stream */)).next_in = uncompr 1918 (*z_stream)(unsafe.Pointer(bp + 80 /* &c_stream */)).avail_in = uInt(uncomprLen) 1919 err = z.Xdeflate(tls, bp+80 /* &c_stream */, 0) 1920 { 1921 if err != 0 { 1922 libc.Xfprintf(tls, libc.X__stderrp, ts+20 /* "%s error: %d\n" */, libc.VaList(bp+48, ts+372 /* "deflate" */, err)) 1923 libc.Xexit(tls, 1) 1924 } 1925 } 1926 1927 err = z.Xdeflate(tls, bp+80 /* &c_stream */, 4) 1928 if err != 1 { 1929 libc.Xfprintf(tls, libc.X__stderrp, ts+470 /* "deflate should r..." */, 0) 1930 libc.Xexit(tls, 1) 1931 } 1932 err = z.XdeflateEnd(tls, bp+80 /* &c_stream */) 1933 { 1934 if err != 0 { 1935 libc.Xfprintf(tls, libc.X__stderrp, ts+20 /* "%s error: %d\n" */, libc.VaList(bp+64, ts+380 /* "deflateEnd" */, err)) 1936 libc.Xexit(tls, 1) 1937 } 1938 } 1939 1940 } 1941 1942 // =========================================================================== 1943 // Test inflate() with large buffers 1944 func test_large_inflate(tls *libc.TLS, compr uintptr, comprLen uLong, uncompr uintptr, uncomprLen uLong) { /* example.c:334:6: */ 1945 bp := tls.Alloc(168) 1946 defer tls.Free(168) 1947 1948 var err int32 1949 // var d_stream z_stream at bp+56, 112 1950 // decompression stream 1951 1952 libc.Xstrcpy(tls, uncompr, ts+43 /* "garbage" */) 1953 1954 (*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).zalloc = zalloc 1955 (*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).zfree = zfree 1956 (*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).opaque = uintptr(0) 1957 1958 (*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).next_in = compr 1959 (*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).avail_in = uInt(comprLen) 1960 1961 err = z.XinflateInit_(tls, bp+56 /* &d_stream */, ts+353 /* "1.2.11" */, int32(unsafe.Sizeof(z_stream{}))) 1962 { 1963 if err != 0 { 1964 libc.Xfprintf(tls, libc.X__stderrp, ts+20 /* "%s error: %d\n" */, libc.VaList(bp, ts+391 /* "inflateInit" */, err)) 1965 libc.Xexit(tls, 1) 1966 } 1967 } 1968 1969 for { 1970 (*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).next_out = uncompr // discard the output 1971 (*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).avail_out = uInt(uncomprLen) 1972 err = z.Xinflate(tls, bp+56 /* &d_stream */, 0) 1973 if err == 1 { 1974 break 1975 } 1976 { 1977 if err != 0 { 1978 libc.Xfprintf(tls, libc.X__stderrp, ts+20 /* "%s error: %d\n" */, libc.VaList(bp+16, ts+506 /* "large inflate" */, err)) 1979 libc.Xexit(tls, 1) 1980 } 1981 } 1982 1983 } 1984 1985 err = z.XinflateEnd(tls, bp+56 /* &d_stream */) 1986 { 1987 if err != 0 { 1988 libc.Xfprintf(tls, libc.X__stderrp, ts+20 /* "%s error: %d\n" */, libc.VaList(bp+32, ts+411 /* "inflateEnd" */, err)) 1989 libc.Xexit(tls, 1) 1990 } 1991 } 1992 1993 if (*z_stream)(unsafe.Pointer(bp+56 /* &d_stream */)).total_out != ((uint64(2) * uncomprLen) + (comprLen / uint64(2))) { 1994 libc.Xfprintf(tls, libc.X__stderrp, ts+520 /* "bad large inflat..." */, libc.VaList(bp+48, (*z_stream)(unsafe.Pointer(bp+56 /* &d_stream */)).total_out)) 1995 libc.Xexit(tls, 1) 1996 } else { 1997 libc.Xprintf(tls, ts+544 /* "large_inflate():..." */, 0) 1998 } 1999 } 2000 2001 // =========================================================================== 2002 // Test deflate() with full flush 2003 func test_flush(tls *libc.TLS, compr uintptr, comprLen uintptr) { /* example.c:375:6: */ 2004 bp := tls.Alloc(176) 2005 defer tls.Free(176) 2006 2007 // var c_stream z_stream at bp+64, 112 2008 // compression stream 2009 var err int32 2010 var len uInt = (uInt(libc.Xstrlen(tls, uintptr(unsafe.Pointer(&hello)))) + uInt(1)) 2011 2012 (*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).zalloc = zalloc 2013 (*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).zfree = zfree 2014 (*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).opaque = uintptr(0) 2015 2016 err = z.XdeflateInit_(tls, bp+64 /* &c_stream */, -1, ts+353 /* "1.2.11" */, int32(unsafe.Sizeof(z_stream{}))) 2017 { 2018 if err != 0 { 2019 libc.Xfprintf(tls, libc.X__stderrp, ts+20 /* "%s error: %d\n" */, libc.VaList(bp, ts+360 /* "deflateInit" */, err)) 2020 libc.Xexit(tls, 1) 2021 } 2022 } 2023 2024 (*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).next_in = uintptr(uintptr(unsafe.Pointer(&hello))) 2025 (*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).next_out = compr 2026 (*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).avail_in = uInt(3) 2027 (*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).avail_out = uInt(*(*uLong)(unsafe.Pointer(comprLen))) 2028 err = z.Xdeflate(tls, bp+64 /* &c_stream */, 3) 2029 { 2030 if err != 0 { 2031 libc.Xfprintf(tls, libc.X__stderrp, ts+20 /* "%s error: %d\n" */, libc.VaList(bp+16, ts+372 /* "deflate" */, err)) 2032 libc.Xexit(tls, 1) 2033 } 2034 } 2035 2036 *(*Byte)(unsafe.Pointer(compr + 3))++ // force an error in first compressed block 2037 (*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).avail_in = (len - uInt(3)) 2038 2039 err = z.Xdeflate(tls, bp+64 /* &c_stream */, 4) 2040 if err != 1 { 2041 { 2042 if err != 0 { 2043 libc.Xfprintf(tls, libc.X__stderrp, ts+20 /* "%s error: %d\n" */, libc.VaList(bp+32, ts+372 /* "deflate" */, err)) 2044 libc.Xexit(tls, 1) 2045 } 2046 } 2047 2048 } 2049 err = z.XdeflateEnd(tls, bp+64 /* &c_stream */) 2050 { 2051 if err != 0 { 2052 libc.Xfprintf(tls, libc.X__stderrp, ts+20 /* "%s error: %d\n" */, libc.VaList(bp+48, ts+380 /* "deflateEnd" */, err)) 2053 libc.Xexit(tls, 1) 2054 } 2055 } 2056 2057 *(*uLong)(unsafe.Pointer(comprLen)) = (*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).total_out 2058 } 2059 2060 // =========================================================================== 2061 // Test inflateSync() 2062 func test_sync(tls *libc.TLS, compr uintptr, comprLen uLong, uncompr uintptr, uncomprLen uLong) { /* example.c:413:6: */ 2063 bp := tls.Alloc(184) 2064 defer tls.Free(184) 2065 2066 var err int32 2067 // var d_stream z_stream at bp+72, 112 2068 // decompression stream 2069 2070 libc.Xstrcpy(tls, uncompr, ts+43 /* "garbage" */) 2071 2072 (*z_stream)(unsafe.Pointer(bp + 72 /* &d_stream */)).zalloc = zalloc 2073 (*z_stream)(unsafe.Pointer(bp + 72 /* &d_stream */)).zfree = zfree 2074 (*z_stream)(unsafe.Pointer(bp + 72 /* &d_stream */)).opaque = uintptr(0) 2075 2076 (*z_stream)(unsafe.Pointer(bp + 72 /* &d_stream */)).next_in = compr 2077 (*z_stream)(unsafe.Pointer(bp + 72 /* &d_stream */)).avail_in = uInt(2) // just read the zlib header 2078 2079 err = z.XinflateInit_(tls, bp+72 /* &d_stream */, ts+353 /* "1.2.11" */, int32(unsafe.Sizeof(z_stream{}))) 2080 { 2081 if err != 0 { 2082 libc.Xfprintf(tls, libc.X__stderrp, ts+20 /* "%s error: %d\n" */, libc.VaList(bp, ts+391 /* "inflateInit" */, err)) 2083 libc.Xexit(tls, 1) 2084 } 2085 } 2086 2087 (*z_stream)(unsafe.Pointer(bp + 72 /* &d_stream */)).next_out = uncompr 2088 (*z_stream)(unsafe.Pointer(bp + 72 /* &d_stream */)).avail_out = uInt(uncomprLen) 2089 2090 err = z.Xinflate(tls, bp+72 /* &d_stream */, 0) 2091 { 2092 if err != 0 { 2093 libc.Xfprintf(tls, libc.X__stderrp, ts+20 /* "%s error: %d\n" */, libc.VaList(bp+16, ts+403 /* "inflate" */, err)) 2094 libc.Xexit(tls, 1) 2095 } 2096 } 2097 2098 (*z_stream)(unsafe.Pointer(bp + 72 /* &d_stream */)).avail_in = (uInt(comprLen) - uInt(2)) // read all compressed data 2099 err = z.XinflateSync(tls, bp+72 /* &d_stream */) /* but skip the damaged part */ 2100 { 2101 if err != 0 { 2102 libc.Xfprintf(tls, libc.X__stderrp, ts+20 /* "%s error: %d\n" */, libc.VaList(bp+32, ts+565 /* "inflateSync" */, err)) 2103 libc.Xexit(tls, 1) 2104 } 2105 } 2106 2107 err = z.Xinflate(tls, bp+72 /* &d_stream */, 4) 2108 if err != (-3) { 2109 libc.Xfprintf(tls, libc.X__stderrp, ts+577 /* "inflate should r..." */, 0) 2110 // Because of incorrect adler32 2111 libc.Xexit(tls, 1) 2112 } 2113 err = z.XinflateEnd(tls, bp+72 /* &d_stream */) 2114 { 2115 if err != 0 { 2116 libc.Xfprintf(tls, libc.X__stderrp, ts+20 /* "%s error: %d\n" */, libc.VaList(bp+48, ts+411 /* "inflateEnd" */, err)) 2117 libc.Xexit(tls, 1) 2118 } 2119 } 2120 2121 libc.Xprintf(tls, ts+611 /* "after inflateSyn..." */, libc.VaList(bp+64, uncompr)) 2122 } 2123 2124 // =========================================================================== 2125 // Test deflate() with preset dictionary 2126 func test_dict_deflate(tls *libc.TLS, compr uintptr, comprLen uLong) { /* example.c:457:6: */ 2127 bp := tls.Alloc(160) 2128 defer tls.Free(160) 2129 2130 // var c_stream z_stream at bp+48, 112 2131 // compression stream 2132 var err int32 2133 2134 (*z_stream)(unsafe.Pointer(bp + 48 /* &c_stream */)).zalloc = zalloc 2135 (*z_stream)(unsafe.Pointer(bp + 48 /* &c_stream */)).zfree = zfree 2136 (*z_stream)(unsafe.Pointer(bp + 48 /* &c_stream */)).opaque = uintptr(0) 2137 2138 err = z.XdeflateInit_(tls, bp+48 /* &c_stream */, 9, ts+353 /* "1.2.11" */, int32(unsafe.Sizeof(z_stream{}))) 2139 { 2140 if err != 0 { 2141 libc.Xfprintf(tls, libc.X__stderrp, ts+20 /* "%s error: %d\n" */, libc.VaList(bp, ts+360 /* "deflateInit" */, err)) 2142 libc.Xexit(tls, 1) 2143 } 2144 } 2145 2146 err = z.XdeflateSetDictionary(tls, bp+48, /* &c_stream */ 2147 uintptr(uintptr(unsafe.Pointer(&dictionary))), uint32(int32(unsafe.Sizeof(dictionary)))) 2148 { 2149 if err != 0 { 2150 libc.Xfprintf(tls, libc.X__stderrp, ts+20 /* "%s error: %d\n" */, libc.VaList(bp+16, ts+639 /* "deflateSetDictio..." */, err)) 2151 libc.Xexit(tls, 1) 2152 } 2153 } 2154 2155 dictId = (*z_stream)(unsafe.Pointer(bp + 48 /* &c_stream */)).adler 2156 (*z_stream)(unsafe.Pointer(bp + 48 /* &c_stream */)).next_out = compr 2157 (*z_stream)(unsafe.Pointer(bp + 48 /* &c_stream */)).avail_out = uInt(comprLen) 2158 2159 (*z_stream)(unsafe.Pointer(bp + 48 /* &c_stream */)).next_in = uintptr(uintptr(unsafe.Pointer(&hello))) 2160 (*z_stream)(unsafe.Pointer(bp + 48 /* &c_stream */)).avail_in = (uInt(libc.Xstrlen(tls, uintptr(unsafe.Pointer(&hello)))) + uInt(1)) 2161 2162 err = z.Xdeflate(tls, bp+48 /* &c_stream */, 4) 2163 if err != 1 { 2164 libc.Xfprintf(tls, libc.X__stderrp, ts+470 /* "deflate should r..." */, 0) 2165 libc.Xexit(tls, 1) 2166 } 2167 err = z.XdeflateEnd(tls, bp+48 /* &c_stream */) 2168 { 2169 if err != 0 { 2170 libc.Xfprintf(tls, libc.X__stderrp, ts+20 /* "%s error: %d\n" */, libc.VaList(bp+32, ts+380 /* "deflateEnd" */, err)) 2171 libc.Xexit(tls, 1) 2172 } 2173 } 2174 2175 } 2176 2177 // =========================================================================== 2178 // Test inflate() with a preset dictionary 2179 func test_dict_inflate(tls *libc.TLS, compr uintptr, comprLen uLong, uncompr uintptr, uncomprLen uLong) { /* example.c:494:6: */ 2180 bp := tls.Alloc(168) 2181 defer tls.Free(168) 2182 2183 var err int32 2184 // var d_stream z_stream at bp+56, 112 2185 // decompression stream 2186 2187 libc.Xstrcpy(tls, uncompr, ts+43 /* "garbage" */) 2188 2189 (*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).zalloc = zalloc 2190 (*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).zfree = zfree 2191 (*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).opaque = uintptr(0) 2192 2193 (*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).next_in = compr 2194 (*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).avail_in = uInt(comprLen) 2195 2196 err = z.XinflateInit_(tls, bp+56 /* &d_stream */, ts+353 /* "1.2.11" */, int32(unsafe.Sizeof(z_stream{}))) 2197 { 2198 if err != 0 { 2199 libc.Xfprintf(tls, libc.X__stderrp, ts+20 /* "%s error: %d\n" */, libc.VaList(bp, ts+391 /* "inflateInit" */, err)) 2200 libc.Xexit(tls, 1) 2201 } 2202 } 2203 2204 (*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).next_out = uncompr 2205 (*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).avail_out = uInt(uncomprLen) 2206 2207 for { 2208 err = z.Xinflate(tls, bp+56 /* &d_stream */, 0) 2209 if err == 1 { 2210 break 2211 } 2212 if err == 2 { 2213 if (*z_stream)(unsafe.Pointer(bp+56 /* &d_stream */)).adler != dictId { 2214 libc.Xfprintf(tls, libc.X__stderrp, ts+660 /* "unexpected dicti..." */, 0) 2215 libc.Xexit(tls, 1) 2216 } 2217 err = z.XinflateSetDictionary(tls, bp+56 /* &d_stream */, uintptr(uintptr(unsafe.Pointer(&dictionary))), 2218 uint32(int32(unsafe.Sizeof(dictionary)))) 2219 } 2220 { 2221 if err != 0 { 2222 libc.Xfprintf(tls, libc.X__stderrp, ts+20 /* "%s error: %d\n" */, libc.VaList(bp+16, ts+682 /* "inflate with dic..." */, err)) 2223 libc.Xexit(tls, 1) 2224 } 2225 } 2226 2227 } 2228 2229 err = z.XinflateEnd(tls, bp+56 /* &d_stream */) 2230 { 2231 if err != 0 { 2232 libc.Xfprintf(tls, libc.X__stderrp, ts+20 /* "%s error: %d\n" */, libc.VaList(bp+32, ts+411 /* "inflateEnd" */, err)) 2233 libc.Xexit(tls, 1) 2234 } 2235 } 2236 2237 if libc.Xstrcmp(tls, uncompr, uintptr(unsafe.Pointer(&hello))) != 0 { 2238 libc.Xfprintf(tls, libc.X__stderrp, ts+700 /* "bad inflate with..." */, 0) 2239 libc.Xexit(tls, 1) 2240 } else { 2241 libc.Xprintf(tls, ts+723 /* "inflate with dic..." */, libc.VaList(bp+48, uncompr)) 2242 } 2243 } 2244 2245 // =========================================================================== 2246 // Usage: example [output.gz [input.gz]] 2247 2248 func main1(tls *libc.TLS, argc int32, argv uintptr) int32 { /* example.c:545:5: */ 2249 bp := tls.Alloc(32) 2250 defer tls.Free(32) 2251 2252 var compr uintptr 2253 var uncompr uintptr 2254 *(*uLong)(unsafe.Pointer(bp + 24 /* comprLen */)) = (uint64(10000) * uint64(unsafe.Sizeof(int32(0)))) // don't overflow on MSDOS 2255 var uncomprLen uLong = *(*uLong)(unsafe.Pointer(bp + 24 /* comprLen */)) 2256 2257 if int32(*(*int8)(unsafe.Pointer(z.XzlibVersion(tls)))) != int32(*(*int8)(unsafe.Pointer(myVersion))) { 2258 libc.Xfprintf(tls, libc.X__stderrp, ts+752 /* "incompatible zli..." */, 0) 2259 libc.Xexit(tls, 1) 2260 2261 } else if libc.Xstrcmp(tls, z.XzlibVersion(tls), ts+353 /* "1.2.11" */) != 0 { 2262 libc.Xfprintf(tls, libc.X__stderrp, ts+779 /* "warning: differe..." */, 0) 2263 } 2264 2265 libc.Xprintf(tls, ts+812, /* "zlib version %s ..." */ 2266 libc.VaList(bp, ts+353 /* "1.2.11" */, 0x12b0, z.XzlibCompileFlags(tls))) 2267 2268 compr = libc.Xcalloc(tls, uint64(uInt(*(*uLong)(unsafe.Pointer(bp + 24 /* comprLen */)))), uint64(1)) 2269 uncompr = libc.Xcalloc(tls, uint64(uInt(uncomprLen)), uint64(1)) 2270 // compr and uncompr are cleared to avoid reading uninitialized 2271 // data and to ensure that uncompr compresses well. 2272 if (compr == uintptr(0)) || (uncompr == uintptr(0)) { 2273 libc.Xprintf(tls, ts+861 /* "out of memory\n" */, 0) 2274 libc.Xexit(tls, 1) 2275 } 2276 2277 test_compress(tls, compr, *(*uLong)(unsafe.Pointer(bp + 24 /* comprLen */)), uncompr, uncomprLen) 2278 2279 test_gzio(tls, func() uintptr { 2280 if argc > 1 { 2281 return *(*uintptr)(unsafe.Pointer(argv + 1*8)) 2282 } 2283 return ts + 876 /* "foo.gz" */ 2284 }(), 2285 uncompr, uncomprLen) 2286 2287 test_deflate(tls, compr, *(*uLong)(unsafe.Pointer(bp + 24 /* comprLen */))) 2288 test_inflate(tls, compr, *(*uLong)(unsafe.Pointer(bp + 24 /* comprLen */)), uncompr, uncomprLen) 2289 2290 test_large_deflate(tls, compr, *(*uLong)(unsafe.Pointer(bp + 24 /* comprLen */)), uncompr, uncomprLen) 2291 test_large_inflate(tls, compr, *(*uLong)(unsafe.Pointer(bp + 24 /* comprLen */)), uncompr, uncomprLen) 2292 2293 test_flush(tls, compr, bp+24 /* &comprLen */) 2294 test_sync(tls, compr, *(*uLong)(unsafe.Pointer(bp + 24 /* comprLen */)), uncompr, uncomprLen) 2295 *(*uLong)(unsafe.Pointer(bp + 24 /* comprLen */)) = uncomprLen 2296 2297 test_dict_deflate(tls, compr, *(*uLong)(unsafe.Pointer(bp + 24 /* comprLen */))) 2298 test_dict_inflate(tls, compr, *(*uLong)(unsafe.Pointer(bp + 24 /* comprLen */)), uncompr, uncomprLen) 2299 2300 libc.Xfree(tls, compr) 2301 libc.Xfree(tls, uncompr) 2302 2303 return 0 2304 } 2305 2306 var myVersion uintptr = ts + 353 /* "1.2.11" */ /* example.c:552:22 */ 2307 2308 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" 2309 var ts = (*reflect.StringHeader)(unsafe.Pointer(&ts1)).Data