]>
Commit | Line | Data |
---|---|---|
1 | /* lzoconf.h -- configuration for the LZO real-time data compression library | |
2 | ||
3 | This file is part of the LZO real-time data compression library. | |
4 | ||
5 | Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer | |
6 | Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer | |
7 | Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer | |
8 | Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer | |
9 | Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer | |
10 | Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer | |
11 | Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer | |
12 | All Rights Reserved. | |
13 | ||
14 | The LZO library is free software; you can redistribute it and/or | |
15 | modify it under the terms of the GNU General Public License as | |
16 | published by the Free Software Foundation; either version 2 of | |
17 | the License, or (at your option) any later version. | |
18 | ||
19 | The LZO library is distributed in the hope that it will be useful, | |
20 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
22 | GNU General Public License for more details. | |
23 | ||
24 | You should have received a copy of the GNU General Public License | |
25 | along with the LZO library; see the file COPYING. | |
26 | If not, write to the Free Software Foundation, Inc., | |
27 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
28 | ||
29 | Markus F.X.J. Oberhumer | |
30 | <markus@oberhumer.com> | |
31 | http://www.oberhumer.com/opensource/lzo/ | |
32 | */ | |
33 | ||
34 | ||
35 | #ifndef __LZOCONF_H | |
36 | #define __LZOCONF_H | |
37 | ||
38 | #define LZO_VERSION 0x1080 | |
39 | #define LZO_VERSION_STRING "1.08" | |
40 | #define LZO_VERSION_DATE "Jul 12 2002" | |
41 | ||
42 | /* internal Autoconf configuration file - only used when building LZO */ | |
43 | #if defined(LZO_HAVE_CONFIG_H) | |
44 | # include <config.h> | |
45 | #endif | |
46 | #include <limits.h> | |
47 | ||
48 | #ifdef __cplusplus | |
49 | extern "C" { | |
50 | #endif | |
51 | ||
52 | ||
53 | /*********************************************************************** | |
54 | // LZO requires a conforming <limits.h> | |
55 | ************************************************************************/ | |
56 | ||
57 | #if !defined(CHAR_BIT) || (CHAR_BIT != 8) | |
58 | # error "invalid CHAR_BIT" | |
59 | #endif | |
60 | #if !defined(UCHAR_MAX) || !defined(UINT_MAX) || !defined(ULONG_MAX) | |
61 | # error "check your compiler installation" | |
62 | #endif | |
63 | #if (USHRT_MAX < 1) || (UINT_MAX < 1) || (ULONG_MAX < 1) | |
64 | # error "your limits.h macros are broken" | |
65 | #endif | |
66 | ||
67 | /* workaround a cpp bug under hpux 10.20 */ | |
68 | #define LZO_0xffffffffL 4294967295ul | |
69 | ||
70 | #if !defined(LZO_UINT32_C) | |
71 | # if (UINT_MAX < LZO_0xffffffffL) | |
72 | # define LZO_UINT32_C(c) c ## UL | |
73 | # else | |
74 | # define LZO_UINT32_C(c) c ## U | |
75 | # endif | |
76 | #endif | |
77 | ||
78 | ||
79 | /*********************************************************************** | |
80 | // architecture defines | |
81 | ************************************************************************/ | |
82 | ||
83 | #if !defined(__LZO_WIN) && !defined(__LZO_DOS) && !defined(__LZO_OS2) | |
84 | # if defined(__WINDOWS__) || defined(_WINDOWS) || defined(_Windows) | |
85 | # define __LZO_WIN | |
86 | # elif defined(__WIN32__) || defined(_WIN32) || defined(WIN32) | |
87 | # define __LZO_WIN | |
88 | # elif defined(__NT__) || defined(__NT_DLL__) || defined(__WINDOWS_386__) | |
89 | # define __LZO_WIN | |
90 | # elif defined(__DOS__) || defined(__MSDOS__) || defined(MSDOS) | |
91 | # define __LZO_DOS | |
92 | # elif defined(__OS2__) || defined(__OS2V2__) || defined(OS2) | |
93 | # define __LZO_OS2 | |
94 | # elif defined(__palmos__) | |
95 | # define __LZO_PALMOS | |
96 | # elif defined(__TOS__) || defined(__atarist__) | |
97 | # define __LZO_TOS | |
98 | # endif | |
99 | #endif | |
100 | ||
101 | #if (UINT_MAX < LZO_0xffffffffL) | |
102 | # if defined(__LZO_WIN) | |
103 | # define __LZO_WIN16 | |
104 | # elif defined(__LZO_DOS) | |
105 | # define __LZO_DOS16 | |
106 | # elif defined(__LZO_PALMOS) | |
107 | # define __LZO_PALMOS16 | |
108 | # elif defined(__LZO_TOS) | |
109 | # define __LZO_TOS16 | |
110 | # elif defined(__C166__) | |
111 | # else | |
112 | /* porting hint: for pure 16-bit architectures try compiling | |
113 | * everything with -D__LZO_STRICT_16BIT */ | |
114 | # error "16-bit target not supported - contact me for porting hints" | |
115 | # endif | |
116 | #endif | |
117 | ||
118 | #if !defined(__LZO_i386) | |
119 | # if defined(__LZO_DOS) || defined(__LZO_WIN16) | |
120 | # define __LZO_i386 | |
121 | # elif defined(__i386__) || defined(__386__) || defined(_M_IX86) | |
122 | # define __LZO_i386 | |
123 | # endif | |
124 | #endif | |
125 | ||
126 | #if defined(__LZO_STRICT_16BIT) | |
127 | # if (UINT_MAX < LZO_0xffffffffL) | |
128 | # include <lzo16bit.h> | |
129 | # endif | |
130 | #endif | |
131 | ||
132 | /* memory checkers */ | |
133 | #if !defined(__LZO_CHECKER) | |
134 | # if defined(__BOUNDS_CHECKING_ON) | |
135 | # define __LZO_CHECKER | |
136 | # elif defined(__CHECKER__) | |
137 | # define __LZO_CHECKER | |
138 | # elif defined(__INSURE__) | |
139 | # define __LZO_CHECKER | |
140 | # elif defined(__PURIFY__) | |
141 | # define __LZO_CHECKER | |
142 | # endif | |
143 | #endif | |
144 | ||
145 | ||
146 | /*********************************************************************** | |
147 | // integral and pointer types | |
148 | ************************************************************************/ | |
149 | ||
150 | /* Integral types with 32 bits or more */ | |
151 | #if !defined(LZO_UINT32_MAX) | |
152 | # if (UINT_MAX >= LZO_0xffffffffL) | |
153 | typedef unsigned int lzo_uint32; | |
154 | typedef int lzo_int32; | |
155 | # define LZO_UINT32_MAX UINT_MAX | |
156 | # define LZO_INT32_MAX INT_MAX | |
157 | # define LZO_INT32_MIN INT_MIN | |
158 | # elif (ULONG_MAX >= LZO_0xffffffffL) | |
159 | typedef unsigned long lzo_uint32; | |
160 | typedef long lzo_int32; | |
161 | # define LZO_UINT32_MAX ULONG_MAX | |
162 | # define LZO_INT32_MAX LONG_MAX | |
163 | # define LZO_INT32_MIN LONG_MIN | |
164 | # else | |
165 | # error "lzo_uint32" | |
166 | # endif | |
167 | #endif | |
168 | ||
169 | /* lzo_uint is used like size_t */ | |
170 | #if !defined(LZO_UINT_MAX) | |
171 | # if (UINT_MAX >= LZO_0xffffffffL) | |
172 | typedef unsigned int lzo_uint; | |
173 | typedef int lzo_int; | |
174 | # define LZO_UINT_MAX UINT_MAX | |
175 | # define LZO_INT_MAX INT_MAX | |
176 | # define LZO_INT_MIN INT_MIN | |
177 | # elif (ULONG_MAX >= LZO_0xffffffffL) | |
178 | typedef unsigned long lzo_uint; | |
179 | typedef long lzo_int; | |
180 | # define LZO_UINT_MAX ULONG_MAX | |
181 | # define LZO_INT_MAX LONG_MAX | |
182 | # define LZO_INT_MIN LONG_MIN | |
183 | # else | |
184 | # error "lzo_uint" | |
185 | # endif | |
186 | #endif | |
187 | ||
188 | typedef int lzo_bool; | |
189 | ||
190 | ||
191 | /*********************************************************************** | |
192 | // memory models | |
193 | ************************************************************************/ | |
194 | ||
195 | /* Memory model for the public code segment. */ | |
196 | #if !defined(__LZO_CMODEL) | |
197 | # if defined(__LZO_DOS16) || defined(__LZO_WIN16) | |
198 | # define __LZO_CMODEL __far | |
199 | # elif defined(__LZO_i386) && defined(__WATCOMC__) | |
200 | # define __LZO_CMODEL __near | |
201 | # else | |
202 | # define __LZO_CMODEL | |
203 | # endif | |
204 | #endif | |
205 | ||
206 | /* Memory model for the public data segment. */ | |
207 | #if !defined(__LZO_DMODEL) | |
208 | # if defined(__LZO_DOS16) || defined(__LZO_WIN16) | |
209 | # define __LZO_DMODEL __far | |
210 | # elif defined(__LZO_i386) && defined(__WATCOMC__) | |
211 | # define __LZO_DMODEL __near | |
212 | # else | |
213 | # define __LZO_DMODEL | |
214 | # endif | |
215 | #endif | |
216 | ||
217 | /* Memory model that allows to access memory at offsets of lzo_uint. */ | |
218 | #if !defined(__LZO_MMODEL) | |
219 | # if (LZO_UINT_MAX <= UINT_MAX) | |
220 | # define __LZO_MMODEL | |
221 | # elif defined(__LZO_DOS16) || defined(__LZO_WIN16) | |
222 | # define __LZO_MMODEL __huge | |
223 | # define LZO_999_UNSUPPORTED | |
224 | # elif defined(__LZO_PALMOS16) || defined(__LZO_TOS16) | |
225 | # define __LZO_MMODEL | |
226 | # else | |
227 | # error "__LZO_MMODEL" | |
228 | # endif | |
229 | #endif | |
230 | ||
231 | /* no typedef here because of const-pointer issues */ | |
232 | #define lzo_byte unsigned char __LZO_MMODEL | |
233 | #define lzo_bytep unsigned char __LZO_MMODEL * | |
234 | #define lzo_charp char __LZO_MMODEL * | |
235 | #define lzo_voidp void __LZO_MMODEL * | |
236 | #define lzo_shortp short __LZO_MMODEL * | |
237 | #define lzo_ushortp unsigned short __LZO_MMODEL * | |
238 | #define lzo_uint32p lzo_uint32 __LZO_MMODEL * | |
239 | #define lzo_int32p lzo_int32 __LZO_MMODEL * | |
240 | #define lzo_uintp lzo_uint __LZO_MMODEL * | |
241 | #define lzo_intp lzo_int __LZO_MMODEL * | |
242 | #define lzo_voidpp lzo_voidp __LZO_MMODEL * | |
243 | #define lzo_bytepp lzo_bytep __LZO_MMODEL * | |
244 | ||
245 | #ifndef lzo_sizeof_dict_t | |
246 | # define lzo_sizeof_dict_t sizeof(lzo_bytep) | |
247 | #endif | |
248 | ||
249 | ||
250 | /*********************************************************************** | |
251 | // calling conventions and function types | |
252 | ************************************************************************/ | |
253 | ||
254 | /* linkage */ | |
255 | #if !defined(__LZO_EXTERN_C) | |
256 | # ifdef __cplusplus | |
257 | # define __LZO_EXTERN_C extern "C" | |
258 | # else | |
259 | # define __LZO_EXTERN_C extern | |
260 | # endif | |
261 | #endif | |
262 | ||
263 | /* calling convention */ | |
264 | #if !defined(__LZO_CDECL) | |
265 | # if defined(__LZO_DOS16) || defined(__LZO_WIN16) | |
266 | # define __LZO_CDECL __LZO_CMODEL __cdecl | |
267 | # elif defined(__LZO_i386) && defined(_MSC_VER) | |
268 | # define __LZO_CDECL __LZO_CMODEL __cdecl | |
269 | # elif defined(__LZO_i386) && defined(__WATCOMC__) | |
270 | # define __LZO_CDECL __LZO_CMODEL __cdecl | |
271 | # else | |
272 | # define __LZO_CDECL __LZO_CMODEL | |
273 | # endif | |
274 | #endif | |
275 | #if !defined(__LZO_ENTRY) | |
276 | # define __LZO_ENTRY __LZO_CDECL | |
277 | #endif | |
278 | ||
279 | /* C++ exception specification for extern "C" function types */ | |
280 | #if !defined(__cplusplus) | |
281 | # undef LZO_NOTHROW | |
282 | # define LZO_NOTHROW | |
283 | #elif !defined(LZO_NOTHROW) | |
284 | # define LZO_NOTHROW | |
285 | #endif | |
286 | ||
287 | ||
288 | typedef int | |
289 | (__LZO_ENTRY *lzo_compress_t) ( const lzo_byte *src, lzo_uint src_len, | |
290 | lzo_byte *dst, lzo_uintp dst_len, | |
291 | lzo_voidp wrkmem ); | |
292 | ||
293 | typedef int | |
294 | (__LZO_ENTRY *lzo_decompress_t) ( const lzo_byte *src, lzo_uint src_len, | |
295 | lzo_byte *dst, lzo_uintp dst_len, | |
296 | lzo_voidp wrkmem ); | |
297 | ||
298 | typedef int | |
299 | (__LZO_ENTRY *lzo_optimize_t) ( lzo_byte *src, lzo_uint src_len, | |
300 | lzo_byte *dst, lzo_uintp dst_len, | |
301 | lzo_voidp wrkmem ); | |
302 | ||
303 | typedef int | |
304 | (__LZO_ENTRY *lzo_compress_dict_t)(const lzo_byte *src, lzo_uint src_len, | |
305 | lzo_byte *dst, lzo_uintp dst_len, | |
306 | lzo_voidp wrkmem, | |
307 | const lzo_byte *dict, lzo_uint dict_len ); | |
308 | ||
309 | typedef int | |
310 | (__LZO_ENTRY *lzo_decompress_dict_t)(const lzo_byte *src, lzo_uint src_len, | |
311 | lzo_byte *dst, lzo_uintp dst_len, | |
312 | lzo_voidp wrkmem, | |
313 | const lzo_byte *dict, lzo_uint dict_len ); | |
314 | ||
315 | ||
316 | /* assembler versions always use __cdecl */ | |
317 | typedef int | |
318 | (__LZO_CDECL *lzo_compress_asm_t)( const lzo_byte *src, lzo_uint src_len, | |
319 | lzo_byte *dst, lzo_uintp dst_len, | |
320 | lzo_voidp wrkmem ); | |
321 | ||
322 | typedef int | |
323 | (__LZO_CDECL *lzo_decompress_asm_t)( const lzo_byte *src, lzo_uint src_len, | |
324 | lzo_byte *dst, lzo_uintp dst_len, | |
325 | lzo_voidp wrkmem ); | |
326 | ||
327 | ||
328 | /* a progress indicator callback function */ | |
329 | typedef void (__LZO_ENTRY *lzo_progress_callback_t) (lzo_uint, lzo_uint); | |
330 | ||
331 | ||
332 | /*********************************************************************** | |
333 | // export information | |
334 | ************************************************************************/ | |
335 | ||
336 | /* DLL export information */ | |
337 | #if !defined(__LZO_EXPORT1) | |
338 | # define __LZO_EXPORT1 | |
339 | #endif | |
340 | #if !defined(__LZO_EXPORT2) | |
341 | # define __LZO_EXPORT2 | |
342 | #endif | |
343 | ||
344 | /* exported calling convention for C functions */ | |
345 | #if !defined(LZO_PUBLIC) | |
346 | # define LZO_PUBLIC(_rettype) \ | |
347 | __LZO_EXPORT1 _rettype __LZO_EXPORT2 __LZO_ENTRY | |
348 | #endif | |
349 | #if !defined(LZO_EXTERN) | |
350 | # define LZO_EXTERN(_rettype) __LZO_EXTERN_C LZO_PUBLIC(_rettype) | |
351 | #endif | |
352 | #if !defined(LZO_PRIVATE) | |
353 | # define LZO_PRIVATE(_rettype) static _rettype __LZO_ENTRY | |
354 | #endif | |
355 | ||
356 | /* exported __cdecl calling convention for assembler functions */ | |
357 | #if !defined(LZO_PUBLIC_CDECL) | |
358 | # define LZO_PUBLIC_CDECL(_rettype) \ | |
359 | __LZO_EXPORT1 _rettype __LZO_EXPORT2 __LZO_CDECL | |
360 | #endif | |
361 | #if !defined(LZO_EXTERN_CDECL) | |
362 | # define LZO_EXTERN_CDECL(_rettype) __LZO_EXTERN_C LZO_PUBLIC_CDECL(_rettype) | |
363 | #endif | |
364 | ||
365 | /* exported global variables (LZO currently uses no static variables and | |
366 | * is fully thread safe) */ | |
367 | #if !defined(LZO_PUBLIC_VAR) | |
368 | # define LZO_PUBLIC_VAR(_type) \ | |
369 | __LZO_EXPORT1 _type __LZO_EXPORT2 __LZO_DMODEL | |
370 | #endif | |
371 | #if !defined(LZO_EXTERN_VAR) | |
372 | # define LZO_EXTERN_VAR(_type) extern LZO_PUBLIC_VAR(_type) | |
373 | #endif | |
374 | ||
375 | ||
376 | /*********************************************************************** | |
377 | // error codes and prototypes | |
378 | ************************************************************************/ | |
379 | ||
380 | /* Error codes for the compression/decompression functions. Negative | |
381 | * values are errors, positive values will be used for special but | |
382 | * normal events. | |
383 | */ | |
384 | #define LZO_E_OK 0 | |
385 | #define LZO_E_ERROR (-1) | |
386 | #define LZO_E_OUT_OF_MEMORY (-2) /* not used right now */ | |
387 | #define LZO_E_NOT_COMPRESSIBLE (-3) /* not used right now */ | |
388 | #define LZO_E_INPUT_OVERRUN (-4) | |
389 | #define LZO_E_OUTPUT_OVERRUN (-5) | |
390 | #define LZO_E_LOOKBEHIND_OVERRUN (-6) | |
391 | #define LZO_E_EOF_NOT_FOUND (-7) | |
392 | #define LZO_E_INPUT_NOT_CONSUMED (-8) | |
393 | ||
394 | ||
395 | /* lzo_init() should be the first function you call. | |
396 | * Check the return code ! | |
397 | * | |
398 | * lzo_init() is a macro to allow checking that the library and the | |
399 | * compiler's view of various types are consistent. | |
400 | */ | |
401 | #define lzo_init() __lzo_init2(LZO_VERSION,(int)sizeof(short),(int)sizeof(int),\ | |
402 | (int)sizeof(long),(int)sizeof(lzo_uint32),(int)sizeof(lzo_uint),\ | |
403 | (int)lzo_sizeof_dict_t,(int)sizeof(char *),(int)sizeof(lzo_voidp),\ | |
404 | (int)sizeof(lzo_compress_t)) | |
405 | LZO_EXTERN(int) __lzo_init2(unsigned,int,int,int,int,int,int,int,int,int); | |
406 | ||
407 | /* version functions (useful for shared libraries) */ | |
408 | LZO_EXTERN(unsigned) lzo_version(void); | |
409 | LZO_EXTERN(const char *) lzo_version_string(void); | |
410 | LZO_EXTERN(const char *) lzo_version_date(void); | |
411 | LZO_EXTERN(const lzo_charp) _lzo_version_string(void); | |
412 | LZO_EXTERN(const lzo_charp) _lzo_version_date(void); | |
413 | ||
414 | /* string functions */ | |
415 | LZO_EXTERN(int) | |
416 | lzo_memcmp(const lzo_voidp _s1, const lzo_voidp _s2, lzo_uint _len); | |
417 | LZO_EXTERN(lzo_voidp) | |
418 | lzo_memcpy(lzo_voidp _dest, const lzo_voidp _src, lzo_uint _len); | |
419 | LZO_EXTERN(lzo_voidp) | |
420 | lzo_memmove(lzo_voidp _dest, const lzo_voidp _src, lzo_uint _len); | |
421 | LZO_EXTERN(lzo_voidp) | |
422 | lzo_memset(lzo_voidp _s, int _c, lzo_uint _len); | |
423 | ||
424 | /* checksum functions */ | |
425 | LZO_EXTERN(lzo_uint32) | |
426 | lzo_adler32(lzo_uint32 _adler, const lzo_byte *_buf, lzo_uint _len); | |
427 | LZO_EXTERN(lzo_uint32) | |
428 | lzo_crc32(lzo_uint32 _c, const lzo_byte *_buf, lzo_uint _len); | |
429 | ||
430 | /* misc. */ | |
431 | LZO_EXTERN(lzo_bool) lzo_assert(int _expr); | |
432 | LZO_EXTERN(int) _lzo_config_check(void); | |
433 | typedef union { lzo_bytep p; lzo_uint u; } __lzo_pu_u; | |
434 | typedef union { lzo_bytep p; lzo_uint32 u32; } __lzo_pu32_u; | |
435 | typedef union { void *vp; lzo_bytep bp; lzo_uint32 u32; long l; } lzo_align_t; | |
436 | ||
437 | /* align a char pointer on a boundary that is a multiple of `size' */ | |
438 | LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp _ptr, lzo_uint _size); | |
439 | #define LZO_PTR_ALIGN_UP(_ptr,_size) \ | |
440 | ((_ptr) + (lzo_uint) __lzo_align_gap((const lzo_voidp)(_ptr),(lzo_uint)(_size))) | |
441 | ||
442 | /* deprecated - only for backward compatibility */ | |
443 | #define LZO_ALIGN(_ptr,_size) LZO_PTR_ALIGN_UP(_ptr,_size) | |
444 | ||
445 | ||
446 | #ifdef __cplusplus | |
447 | } /* extern "C" */ | |
448 | #endif | |
449 | ||
450 | #endif /* already included */ | |
451 |