toolchain: switch kernel 2.4 builds to gcc 4.2.4
[tomato.git] / tools / brcm / K24 / hndtools-mipsel-uclibc-4.1.2 / include / linux / zutil.h
bloba4a4d8d75f1e2268467082554e54ae2c349a87ed
1 /* zutil.h -- internal interface and configuration of the compression library
2 * Copyright (C) 1995-1998 Jean-loup Gailly.
3 * For conditions of distribution and use, see copyright notice in zlib.h
4 */
6 /* WARNING: this file should *not* be used by applications. It is
7 part of the implementation of the compression library and is
8 subject to change. Applications should only use zlib.h.
9 */
11 /* @(#) $Id: zutil.h,v 1.1 2000/01/01 03:32:23 davem Exp $ */
13 #ifndef _Z_UTIL_H
14 #define _Z_UTIL_H
16 #include <linux/zlib.h>
17 #include <linux/string.h>
18 #include <linux/errno.h>
19 #include <linux/kernel.h>
21 #ifndef local
22 # define local static
23 #endif
24 /* compile with -Dlocal if your debugger can't find static symbols */
26 typedef unsigned char uch;
27 typedef uch FAR uchf;
28 typedef unsigned short ush;
29 typedef ush FAR ushf;
30 typedef unsigned long ulg;
32 /* common constants */
34 #ifndef DEF_WBITS
35 # define DEF_WBITS MAX_WBITS
36 #endif
37 /* default windowBits for decompression. MAX_WBITS is for compression only */
39 #if MAX_MEM_LEVEL >= 8
40 # define DEF_MEM_LEVEL 8
41 #else
42 # define DEF_MEM_LEVEL MAX_MEM_LEVEL
43 #endif
44 /* default memLevel */
46 #define STORED_BLOCK 0
47 #define STATIC_TREES 1
48 #define DYN_TREES 2
49 /* The three kinds of block type */
51 #define MIN_MATCH 3
52 #define MAX_MATCH 258
53 /* The minimum and maximum match lengths */
55 #define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
57 /* target dependencies */
59 /* Common defaults */
61 #ifndef OS_CODE
62 # define OS_CODE 0x03 /* assume Unix */
63 #endif
65 /* functions */
67 typedef uLong (ZEXPORT *check_func) OF((uLong check, const Bytef *buf,
68 uInt len));
71 /* checksum functions */
73 #define BASE 65521L /* largest prime smaller than 65536 */
74 #define NMAX 5552
75 /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
77 #define DO1(buf,i) {s1 += buf[i]; s2 += s1;}
78 #define DO2(buf,i) DO1(buf,i); DO1(buf,i+1);
79 #define DO4(buf,i) DO2(buf,i); DO2(buf,i+2);
80 #define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
81 #define DO16(buf) DO8(buf,0); DO8(buf,8);
83 /* ========================================================================= */
85 Update a running Adler-32 checksum with the bytes buf[0..len-1] and
86 return the updated checksum. If buf is NULL, this function returns
87 the required initial value for the checksum.
88 An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
89 much faster. Usage example:
91 uLong adler = adler32(0L, Z_NULL, 0);
93 while (read_buffer(buffer, length) != EOF) {
94 adler = adler32(adler, buffer, length);
96 if (adler != original_adler) error();
98 static inline uLong zlib_adler32(uLong adler,
99 const Bytef *buf,
100 uInt len)
102 unsigned long s1 = adler & 0xffff;
103 unsigned long s2 = (adler >> 16) & 0xffff;
104 int k;
106 if (buf == Z_NULL) return 1L;
108 while (len > 0) {
109 k = len < NMAX ? len : NMAX;
110 len -= k;
111 while (k >= 16) {
112 DO16(buf);
113 buf += 16;
114 k -= 16;
116 if (k != 0) do {
117 s1 += *buf++;
118 s2 += s1;
119 } while (--k);
120 s1 %= BASE;
121 s2 %= BASE;
123 return (s2 << 16) | s1;
126 #endif /* _Z_UTIL_H */