Debian Codegraph @

ext/zlib-ng/zutil.h

raw symbols SCIP
1 #ifndef ZUTIL_H_
2 #define ZUTIL_H_
3 /* zutil.h -- internal interface and configuration of the compression library
4 * Copyright (C) 1995-2022 Jean-loup Gailly, Mark Adler
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 #include "zbuild.h"
14 #ifdef ZLIB_COMPAT
15 # include "zlib.h"
16 #else
17 # include "zlib-ng.h"
18 #endif
19
20 typedef unsigned char uch; /* Included for compatibility with external code only */
21 typedef uint16_t ush; /* Included for compatibility with external code only */
22 typedef unsigned long ulg;
23
24 extern z_const char * const PREFIX(z_errmsg)[10]; /* indexed by 2-zlib_error */
25 /* (size given to avoid silly warnings with Visual C++) */
26
27 #define ERR_MSG(err) PREFIX(z_errmsg)[Z_NEED_DICT-(err)]
28
29 #define ERR_RETURN(strm, err) return (strm->msg = ERR_MSG(err), (err))
30 /* To be used only when the state is known to be valid */
31
32 /* common constants */
33
34 #ifndef DEF_WBITS
35 # define DEF_WBITS MAX_WBITS
36 #endif
37 /* default windowBits for decompression. MAX_WBITS is for compression only */
38
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 */
45
46 #define STORED_BLOCK 0
47 #define STATIC_TREES 1
48 #define DYN_TREES 2
49 /* The three kinds of block type */
50
51 #define STD_MIN_MATCH 3
52 #define STD_MAX_MATCH 258
53 /* The minimum and maximum match lengths mandated by the deflate standard */
54
55 #define WANT_MIN_MATCH 4
56 /* The minimum wanted match length, affects deflate_quick, deflate_fast, deflate_medium and deflate_slow */
57
58 #define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
59
60 #define ADLER32_INITIAL_VALUE 1 /* initial adler-32 hash value */
61 #define CRC32_INITIAL_VALUE 0 /* initial crc-32 hash value */
62
63 #define ZLIB_WRAPLEN 6 /* zlib format overhead */
64 #define GZIP_WRAPLEN 18 /* gzip format overhead */
65
66 #define DEFLATE_HEADER_BITS 3
67 #define DEFLATE_EOBS_BITS 15
68 #define DEFLATE_PAD_BITS 6
69 #define DEFLATE_BLOCK_OVERHEAD ((DEFLATE_HEADER_BITS + DEFLATE_EOBS_BITS + DEFLATE_PAD_BITS) >> 3)
70 /* deflate block overhead: 3 bits for block start + 15 bits for block end + padding to nearest byte */
71
72 #define DEFLATE_QUICK_LIT_MAX_BITS 9
73 #define DEFLATE_QUICK_OVERHEAD(x) ((x * (DEFLATE_QUICK_LIT_MAX_BITS - 8) + 7) >> 3)
74 /* deflate_quick worst-case overhead: 9 bits per literal, round up to next byte (+7) */
75
76
77 /* target dependencies */
78
79 #ifdef AMIGA
80 # define OS_CODE 1
81 #endif
82
83 #ifdef __370__
84 # if __TARGET_LIB__ < 0x20000000
85 # define OS_CODE 4
86 # elif __TARGET_LIB__ < 0x40000000
87 # define OS_CODE 11
88 # else
89 # define OS_CODE 8
90 # endif
91 #endif
92
93 #if defined(ATARI) || defined(atarist)
94 # define OS_CODE 5
95 #endif
96
97 #ifdef OS2
98 # define OS_CODE 6
99 #endif
100
101 #if defined(MACOS) || defined(TARGET_OS_MAC)
102 # define OS_CODE 7
103 #endif
104
105 #ifdef __acorn
106 # define OS_CODE 13
107 #endif
108
109 #if defined(_WIN32) && !defined(__CYGWIN__)
110 # define OS_CODE 10
111 #endif
112
113 #ifdef __APPLE__
114 # define OS_CODE 19
115 #endif
116
117 /* common defaults */
118
119 #ifndef OS_CODE
120 # define OS_CODE 3 /* assume Unix */
121 #endif
122
123 /* macros */
124
125 #define CHECK_VER_STSIZE(_ver,_stsize) ((_ver) == NULL || (_ver)[0] != PREFIX2(VERSION)[0] || (_stsize) != (int32_t)sizeof(PREFIX3(stream)))
126
127 /* memory allocation functions */
128
129 void Z_INTERNAL *zng_calloc(void *opaque, unsigned items, unsigned size);
130 void Z_INTERNAL zng_cfree(void *opaque, void *ptr);
131
132 typedef void *zng_calloc_func(void *opaque, unsigned items, unsigned size);
133 typedef void zng_cfree_func(void *opaque, void *ptr);
134
135 void Z_INTERNAL *zng_alloc_aligned(zng_calloc_func zalloc, void *opaque, unsigned items, unsigned size, unsigned align);
136 void Z_INTERNAL zng_free_aligned(zng_cfree_func zfree, void *opaque, void *ptr);
137
138 #define ZALLOC(strm, items, size) zng_alloc_aligned((strm)->zalloc, (strm)->opaque, (items), (size), 64)
139 #define ZFREE(strm, addr) zng_free_aligned((strm)->zfree, (strm)->opaque, (void *)(addr))
140
141 #define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
142
143 #endif /* ZUTIL_H_ */