Changeset 8281e06c in rtems


Ignore:
Timestamp:
Oct 27, 2005, 3:09:30 PM (15 years ago)
Author:
Ralf Corsepius <ralf.corsepius@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
6bc3001
Parents:
0819f4c
Message:

Update from FreeBSD.

Location:
cpukit/libnetworking/net
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libnetworking/net/zlib.c

    r0819f4c r8281e06c  
    1111 * - allow strm->next_out to be NULL, meaning discard the output
    1212 *
    13  * $Id$
    14  */
     13 * $FreeBSD: src/sys/net/zlib.c,v 1.20 2005/09/11 16:13:02 rodrigc Exp $
     14 */
     15
     16/* $Id$ */
    1517
    1618/*
     
    2527#define MY_ZCALLOC
    2628
    27 #if defined(__FreeBSD__) && (defined(KERNEL) || defined(_KERNEL))
     29#if defined(__FreeBSD__) && defined(_KERNEL)
    2830#define inflate inflate_ppp     /* FreeBSD already has an inflate :-( */
    2931#endif
     
    3133
    3234/* +++ zutil.h */
    33 /* zutil.h -- internal interface and configuration of the compression library
     35/*-
     36 * zutil.h -- internal interface and configuration of the compression library
    3437 * Copyright (C) 1995-1996 Jean-loup Gailly.
    3538 * For conditions of distribution and use, see copyright notice in zlib.h
     
    4649#define _Z_UTIL_H
    4750
     51#ifdef _KERNEL
     52#include <net/zlib.h>
     53#else
    4854#include "zlib.h"
    49 
    50 #if defined(KERNEL) || defined(_KERNEL)
     55#endif
     56
     57#ifdef _KERNEL
    5158/* Assume this is a *BSD or SVR4 kernel */
    5259#include <sys/types.h>
    5360#include <sys/time.h>
    5461#include <sys/systm.h>
    55 #undef u
     62#include <sys/param.h>
     63#include <sys/kernel.h>
     64#ifndef __rtems__
     65#include <sys/module.h>
     66#endif
    5667#  define HAVE_MEMCPY
    57 #  define memcpy(d, s, n)       bcopy((s), (d), (n))
    58 #  define memset(d, v, n)       bzero((d), (n))
    59 #  define memcmp                bcmp
    6068
    6169#else
     
    7886#endif
    7987#endif /* __KERNEL__ */
    80 #endif /* _KERNEL || KERNEL */
     88#endif /* _KERNEL */
    8189
    8290#ifndef local
     
    9199typedef unsigned long  ulg;
    92100
    93 extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
     101static const char *z_errmsg[10]; /* indexed by 2-zlib_error */
    94102/* (size given to avoid silly warnings with Visual C++) */
    95103
     
    97105
    98106#define ERR_RETURN(strm,err) \
    99   return (strm->msg = (char*)ERR_MSG(err), (err))
     107  return (strm->msg = (const char*)ERR_MSG(err), (err))
    100108/* To be used only when the state is known to be valid */
    101109
     
    774782    }
    775783    if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED ||
    776         windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||
     784        windowBits < 9 || windowBits > 15 || level < 0 || level > 9 ||
    777785        strategy < 0 || strategy > Z_HUFFMAN_ONLY) {
    778786        return Z_STREAM_ERROR;
     
    805813    if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
    806814        s->pending_buf == Z_NULL) {
    807         strm->msg = (char*)ERR_MSG(Z_MEM_ERROR);
     815        strm->msg = (const char*)ERR_MSG(Z_MEM_ERROR);
    808816        deflateEnd (strm);
    809817        return Z_MEM_ERROR;
     
    19841992
    19851993#ifndef DEBUG_ZLIB
    1986 #  define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len)
     1994#  define send_code(s, c, tree) send_bits(s, tree[(c)].Code, tree[(c)].Len)
    19871995   /* Send a code of the given tree. c and tree must not have side effects */
    19881996
     
    20422050
    20432051#define send_bits(s, value, length) \
    2044 { int len = length;\
    2045   if (s->bi_valid > (int)Buf_size - len) {\
    2046     int val = value;\
    2047     s->bi_buf |= (val << s->bi_valid);\
    2048     put_short(s, s->bi_buf);\
    2049     s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\
    2050     s->bi_valid += len - Buf_size;\
     2052{ int len = (length);\
     2053  if ((s)->bi_valid > (int)Buf_size - len) {\
     2054    int val = (value);\
     2055    (s)->bi_buf |= (val << (s)->bi_valid);\
     2056    put_short((s), (s)->bi_buf);\
     2057    (s)->bi_buf = (ush)val >> (Buf_size - (s)->bi_valid);\
     2058    (s)->bi_valid += len - Buf_size;\
    20512059  } else {\
    2052     s->bi_buf |= (value) << s->bi_valid;\
    2053     s->bi_valid += len;\
     2060    (s)->bi_buf |= (value) << (s)->bi_valid;\
     2061    (s)->bi_valid += len;\
    20542062  }\
    20552063}
    20562064#endif /* DEBUG_ZLIB */
    20572065
    2058 
    20592066#define MAX(a,b) (a >= b ? a : b)
     2067
    20602068/* the arguments must not have side effects */
    20612069
     
    38623870      if (t != Z_OK)
    38633871      {
     3872        r = t;
     3873        if (r == Z_DATA_ERROR) {
    38643874        ZFREE(z, s->sub.trees.blens);
    3865         r = t;
    3866         if (r == Z_DATA_ERROR)
    38673875          s->mode = BADB;
     3876        }
    38683877        LEAVE
    38693878      }
     
    39303939        t = inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f),
    39313940                                  s->sub.trees.blens, &bl, &bd, &tl, &td, z);
    3932         ZFREE(z, s->sub.trees.blens);
    39333941        if (t != Z_OK)
    39343942        {
    3935           if (t == (uInt)Z_DATA_ERROR)
     3943          if (t == (uInt)Z_DATA_ERROR) {
     3944            ZFREE(z, s->sub.trees.blens);
    39363945            s->mode = BADB;
     3946          }
    39373947          r = t;
    39383948          LEAVE
     
    39473957          LEAVE
    39483958        }
     3959        /*
     3960         * this ZFREE must occur *BEFORE* we mess with sub.decode, because
     3961         * sub.trees is union'd with sub.decode.
     3962         */
     3963        ZFREE(z, s->sub.trees.blens);
    39493964        s->sub.decode.codes = c;
    39503965        s->sub.decode.tl = tl;
     
    51295144#endif
    51305145
    5131 const char *z_errmsg[10] = {
     5146static const char *z_errmsg[10] = {
    51325147"need dictionary",     /* Z_NEED_DICT       2  */
    51335148"stream end",          /* Z_STREAM_END      1  */
     
    53395354/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
    53405355
    5341 #define DO1(buf,i)  {s1 += buf[i]; s2 += s1;}
    5342 #define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
    5343 #define DO4(buf,i)  DO2(buf,i); DO2(buf,i+2);
    5344 #define DO8(buf,i)  DO4(buf,i); DO4(buf,i+4);
     5356#define DO1(buf,i)  {s1 += buf[(i)]; s2 += s1;}
     5357#define DO2(buf,i)  DO1(buf,i); DO1(buf,(i)+1);
     5358#define DO4(buf,i)  DO2(buf,i); DO2(buf,(i)+2);
     5359#define DO8(buf,i)  DO4(buf,i); DO4(buf,(i)+4);
    53455360#define DO16(buf)   DO8(buf,0); DO8(buf,8);
    53465361
  • cpukit/libnetworking/net/zlib.h

    r0819f4c r8281e06c  
    1 /*      $Id$    */
     1/* $FreeBSD: src/sys/net/zlib.h,v 1.10 2005/01/07 01:45:35 imp Exp $    */
    22
    33/*
     
    1717
    1818/* +++ zlib.h */
    19 /* zlib.h -- interface of the 'zlib' general purpose compression library
     19/*-
     20  zlib.h -- interface of the 'zlib' general purpose compression library
    2021  version 1.0.4, Jul 24th, 1996.
    2122
     
    4041  Jean-loup Gailly        Mark Adler
    4142  gzip@prep.ai.mit.edu    madler@alumni.caltech.edu
    42 
    43 
     43*/
     44/*
    4445  The data format used by the zlib library is described by RFCs (Request for
    4546  Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt
     
    282283    uLong    total_out; /* total nb of bytes output so far */
    283284
    284     char     *msg;      /* last error message, NULL if no error */
     285    const char     *msg; /* last error message, NULL if no error */
    285286    struct internal_state FAR *state; /* not visible by applications */
    286287
     
    508509*/
    509510
     511#if defined(__FreeBSD__) && defined(_KERNEL)
     512#define inflate       inflate_ppp     /* FreeBSD already has an inflate :-( */
     513#endif
    510514
    511515extern int EXPORT inflate OF((z_streamp strm, int flush));
     
    926930     Returns the error message for the last error which occurred on the
    927931   given compressed file. errnum is set to zlib error number. If an
    928    error occurred in the file system and not in the compression library,
     932   error occurred in the filesystem and not in the compression library,
    929933   errnum is set to Z_ERRNO and the application may consult errno
    930934   to get the exact error code.
Note: See TracChangeset for help on using the changeset viewer.