The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/lib/libz/zutil.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* $NetBSD: zutil.h,v 1.10 2002/03/12 00:42:24 fvdl Exp $ */
    2 
    3 /* zutil.h -- internal interface and configuration of the compression library
    4  * Copyright (C) 1995-2002 Jean-loup Gailly.
    5  * For conditions of distribution and use, see copyright notice in zlib.h
    6  */
    7 
    8 /* WARNING: this file should *not* be used by applications. It is
    9    part of the implementation of the compression library and is
   10    subject to change. Applications should only use zlib.h.
   11  */
   12 
   13 /* @(#) $Id: zutil.h,v 1.10 2002/03/12 00:42:24 fvdl Exp $ */
   14 
   15 #ifndef _Z_UTIL_H
   16 #define _Z_UTIL_H
   17 
   18 #include "zlib.h"
   19 
   20 #if defined(__NetBSD__) && (defined(_KERNEL) || defined(_STANDALONE))
   21 
   22 /* XXX doesn't seem to need anything at all, but this is for consistency. */
   23 #  include <lib/libkern/libkern.h>
   24 
   25 #else
   26 #ifdef STDC
   27 #  include <stddef.h>
   28 #  include <string.h>
   29 #  include <stdlib.h>
   30 #endif
   31 #ifdef NO_ERRNO_H
   32     extern int errno;
   33 #else
   34 #   include <errno.h>
   35 #endif
   36 #endif /* __NetBSD__ && _STANDALONE */
   37 
   38 #ifndef local
   39 #  define local static
   40 #endif
   41 /* compile with -Dlocal if your debugger can't find static symbols */
   42 
   43 typedef unsigned char  uch;
   44 typedef uch FAR uchf;
   45 typedef unsigned short ush;
   46 typedef ush FAR ushf;
   47 typedef unsigned long  ulg;
   48 
   49 extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
   50 /* (size given to avoid silly warnings with Visual C++) */
   51 
   52 #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
   53 
   54 #define ERR_RETURN(strm,err) \
   55   return (strm->msg = (char*)ERR_MSG(err), (err))
   56 /* To be used only when the state is known to be valid */
   57 
   58         /* common constants */
   59 
   60 #ifndef DEF_WBITS
   61 #  define DEF_WBITS MAX_WBITS
   62 #endif
   63 /* default windowBits for decompression. MAX_WBITS is for compression only */
   64 
   65 #if MAX_MEM_LEVEL >= 8
   66 #  define DEF_MEM_LEVEL 8
   67 #else
   68 #  define DEF_MEM_LEVEL  MAX_MEM_LEVEL
   69 #endif
   70 /* default memLevel */
   71 
   72 #define STORED_BLOCK 0
   73 #define STATIC_TREES 1
   74 #define DYN_TREES    2
   75 /* The three kinds of block type */
   76 
   77 #define MIN_MATCH  3
   78 #define MAX_MATCH  258
   79 /* The minimum and maximum match lengths */
   80 
   81 #define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
   82 
   83         /* target dependencies */
   84 
   85 #ifdef MSDOS
   86 #  define OS_CODE  0x00
   87 #  if defined(__TURBOC__) || defined(__BORLANDC__)
   88 #    if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
   89        /* Allow compilation with ANSI keywords only enabled */
   90        void _Cdecl farfree( void *block );
   91        void *_Cdecl farmalloc( unsigned long nbytes );
   92 #    else
   93 #     include <alloc.h>
   94 #    endif
   95 #  else /* MSC or DJGPP */
   96 #    include <malloc.h>
   97 #  endif
   98 #endif
   99 
  100 #ifdef OS2
  101 #  define OS_CODE  0x06
  102 #endif
  103 
  104 #ifdef WIN32 /* Window 95 & Windows NT */
  105 #  define OS_CODE  0x0b
  106 #endif
  107 
  108 #if defined(VAXC) || defined(VMS)
  109 #  define OS_CODE  0x02
  110 #  define F_OPEN(name, mode) \
  111      fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
  112 #endif
  113 
  114 #ifdef AMIGA
  115 #  define OS_CODE  0x01
  116 #endif
  117 
  118 #if defined(ATARI) || defined(atarist)
  119 #  define OS_CODE  0x05
  120 #endif
  121 
  122 #if defined(MACOS) || defined(TARGET_OS_MAC)
  123 #  define OS_CODE  0x07
  124 #  if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
  125 #    include <unix.h> /* for fdopen */
  126 #  else
  127 #    ifndef fdopen
  128 #      define fdopen(fd,mode) NULL /* No fdopen() */
  129 #    endif
  130 #  endif
  131 #endif
  132 
  133 #ifdef __50SERIES /* Prime/PRIMOS */
  134 #  define OS_CODE  0x0F
  135 #endif
  136 
  137 #ifdef TOPS20
  138 #  define OS_CODE  0x0a
  139 #endif
  140 
  141 #if defined(_BEOS_) || defined(RISCOS)
  142 #  define fdopen(fd,mode) NULL /* No fdopen() */
  143 #endif
  144 
  145 #if (defined(_MSC_VER) && (_MSC_VER > 600))
  146 #  define fdopen(fd,type)  _fdopen(fd,type)
  147 #endif
  148 
  149 
  150         /* Common defaults */
  151 
  152 #ifndef OS_CODE
  153 #  define OS_CODE  0x03  /* assume Unix */
  154 #endif
  155 
  156 #ifndef F_OPEN
  157 #  define F_OPEN(name, mode) fopen((name), (mode))
  158 #endif
  159 
  160          /* functions */
  161 
  162 #ifdef HAVE_STRERROR
  163    extern char *strerror __P((int));
  164 #  define zstrerror(errnum) strerror(errnum)
  165 #else
  166 #  define zstrerror(errnum) ""
  167 #endif
  168 
  169 #if defined(pyr)
  170 #  define NO_MEMCPY
  171 #endif
  172 #if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
  173  /* Use our own functions for small and medium model with MSC <= 5.0.
  174   * You may have to use the same strategy for Borland C (untested).
  175   * The __SC__ check is for Symantec.
  176   */
  177 #  define NO_MEMCPY
  178 #endif
  179 #if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
  180 #  define HAVE_MEMCPY
  181 #endif
  182 #ifdef HAVE_MEMCPY
  183 #  ifdef SMALL_MEDIUM /* MSDOS small or medium model */
  184 #    define zmemcpy _fmemcpy
  185 #    define zmemcmp _fmemcmp
  186 #    define zmemzero(dest, len) _fmemset(dest, 0, len)
  187 #  else
  188 #    define zmemcpy memcpy
  189 #    define zmemcmp memcmp
  190 #    define zmemzero(dest, len) memset(dest, 0, len)
  191 #  endif
  192 #else
  193    extern void zmemcpy  __P((Bytef* dest, const Bytef* source, uInt len));
  194    extern int  zmemcmp  __P((const Bytef* s1, const Bytef* s2, uInt len));
  195    extern void zmemzero __P((Bytef* dest, uInt len));
  196 #endif
  197 
  198 /* Diagnostic functions */
  199 #if defined(DEBUG) && !defined(_KERNEL) && !defined(_STANDALONE)
  200 #  include <stdio.h>
  201    extern int z_verbose;
  202    extern void z_error    __P((char *m));
  203 #  define Assert(cond,msg) {if(!(cond)) z_error(msg);}
  204 #  define Trace(x) {if (z_verbose>=0) fprintf x ;}
  205 #  define Tracev(x) {if (z_verbose>0) fprintf x ;}
  206 #  define Tracevv(x) {if (z_verbose>1) fprintf x ;}
  207 #  define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
  208 #  define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
  209 #else
  210 #  define Assert(cond,msg)
  211 #  define Trace(x)
  212 #  define Tracev(x)
  213 #  define Tracevv(x)
  214 #  define Tracec(c,x)
  215 #  define Tracecv(c,x)
  216 #endif
  217 
  218 
  219 typedef uLong (ZEXPORT *check_func) __P((uLong check, const Bytef *buf,
  220                                        uInt len));
  221 voidpf zcalloc __P((voidpf opaque, unsigned items, unsigned size));
  222 void   zcfree  __P((voidpf opaque, voidpf ptr));
  223 
  224 #define ZALLOC(strm, items, size) \
  225            (*((strm)->zalloc))((strm)->opaque, (items), (size))
  226 #define ZFREE(strm, addr)  (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
  227 #define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
  228 
  229 #endif /* _Z_UTIL_H */

Cache object: 56ddb7bf3ba48c2cc9a77bafe5c0766e


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.