modernc.org/z@v1.7.4/internal/example_freebsd_arm.go (about)

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