LINT64: Fix buildkernel with WANT_HAMMER2=yes.
[dragonfly.git] / sys / vfs / hammer2 / zlib / hammer2_zlib_zutil.c
blobc5dac7eaa161d123e56a427526751605cbd25841
1 /* zutil.c -- target dependent utility functions for the compression library
2 * Copyright (C) 1995-2005, 2010, 2011, 2012 Jean-loup Gailly.
3 * For conditions of distribution and use, see copyright notice in zlib.h
4 */
6 /* @(#) $Id$ */
8 #include "hammer2_zlib_zutil.h"
10 #ifndef NO_DUMMY_DECL
11 struct internal_state {int dummy;}; /* for buggy compilers */
12 #endif
14 z_const char * const z_errmsg[10] = {
15 "need dictionary", /* Z_NEED_DICT 2 */
16 "stream end", /* Z_STREAM_END 1 */
17 "", /* Z_OK 0 */
18 "file error", /* Z_ERRNO (-1) */
19 "stream error", /* Z_STREAM_ERROR (-2) */
20 "data error", /* Z_DATA_ERROR (-3) */
21 "insufficient memory", /* Z_MEM_ERROR (-4) */
22 "buffer error", /* Z_BUF_ERROR (-5) */
23 "incompatible version",/* Z_VERSION_ERROR (-6) */
24 ""};
26 const char * zlibVersion(void);
27 uLong zlibCompileFlags(void);
28 const char * zError(int err);
30 const
31 char*
32 zlibVersion(void)
34 return ZLIB_VERSION;
37 uLong
38 zlibCompileFlags(void)
40 uLong flags;
42 flags = 0;
43 switch ((int)(sizeof(uInt))) {
44 case 2: break;
45 case 4: flags += 1; break;
46 case 8: flags += 2; break;
47 default: flags += 3;
49 switch ((int)(sizeof(uLong))) {
50 case 2: break;
51 case 4: flags += 1 << 2; break;
52 case 8: flags += 2 << 2; break;
53 default: flags += 3 << 2;
55 switch ((int)(sizeof(voidpf))) {
56 case 2: break;
57 case 4: flags += 1 << 4; break;
58 case 8: flags += 2 << 4; break;
59 default: flags += 3 << 4;
61 switch ((int)(sizeof(z_off_t))) {
62 case 2: break;
63 case 4: flags += 1 << 6; break;
64 case 8: flags += 2 << 6; break;
65 default: flags += 3 << 6;
67 #ifdef DEBUG
68 flags += 1 << 8;
69 #endif
70 #if defined(ASMV) || defined(ASMINF)
71 flags += 1 << 9;
72 #endif
73 #ifdef ZLIB_WINAPI
74 flags += 1 << 10;
75 #endif
76 #ifdef BUILDFIXED
77 flags += 1 << 12;
78 #endif
79 #ifdef DYNAMIC_CRC_TABLE
80 flags += 1 << 13;
81 #endif
82 #ifdef NO_GZCOMPRESS
83 flags += 1L << 16;
84 #endif
85 #ifdef NO_GZIP
86 flags += 1L << 17;
87 #endif
88 #ifdef PKZIP_BUG_WORKAROUND
89 flags += 1L << 20;
90 #endif
91 #ifdef FASTEST
92 flags += 1L << 21;
93 #endif
94 #if defined(STDC) || defined(Z_HAVE_STDARG_H)
95 # ifdef NO_vsnprintf
96 flags += 1L << 25;
97 # ifdef HAS_vsprintf_void
98 flags += 1L << 26;
99 # endif
100 # else
101 # ifdef HAS_vsnprintf_void
102 flags += 1L << 26;
103 # endif
104 # endif
105 #else
106 flags += 1L << 24;
107 # ifdef NO_snprintf
108 flags += 1L << 25;
109 # ifdef HAS_sprintf_void
110 flags += 1L << 26;
111 # endif
112 # else
113 # ifdef HAS_snprintf_void
114 flags += 1L << 26;
115 # endif
116 # endif
117 #endif
118 return flags;
121 #ifdef DEBUG
123 # ifndef verbose
124 # define verbose 0
125 # endif
126 int ZLIB_INTERNAL z_verbose = verbose;
128 void ZLIB_INTERNAL z_error (char *m)
130 #if defined(_KERNEL)
131 panic("h2 %s: %s", __func__, m);
132 #else
133 fprintf(stderr, "%s\n", m);
134 exit(1);
135 #endif
137 #endif
139 /* exported to allow conversion of error code to string for compress() and
140 * uncompress()
142 const
143 char*
144 zError(int err)
146 return ERR_MSG(err);
149 #ifndef HAVE_MEMCPY
151 void
152 ZLIB_INTERNAL
153 zmemcpy(Bytef* dest, const Bytef* source, uInt len)
155 if (len == 0) return;
156 do {
157 *dest++ = *source++; /* ??? to be unrolled */
158 } while (--len != 0);
162 ZLIB_INTERNAL
163 zmemcmp(const Bytef* s1, const Bytef* s2, uInt len)
165 uInt j;
167 for (j = 0; j < len; j++) {
168 if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1;
170 return 0;
173 void
174 ZLIB_INTERNAL
175 zmemzero(Bytef* dest, uInt len)
177 if (len == 0) return;
178 do {
179 *dest++ = 0; /* ??? to be unrolled */
180 } while (--len != 0);
182 #endif