1 /* lzoconf.h -- configuration for the LZO real-time data compression library
3 This file is part of the LZO real-time data compression library.
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
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.
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.
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.
29 Markus F.X.J. Oberhumer
30 <markus@oberhumer.com>
31 http://www.oberhumer.com/opensource/lzo/
38 #define LZO_VERSION 0x1080
39 #define LZO_VERSION_STRING "1.08"
40 #define LZO_VERSION_DATE "Jul 12 2002"
42 /* internal Autoconf configuration file - only used when building LZO */
43 #if defined(LZO_HAVE_CONFIG_H)
53 /***********************************************************************
54 // LZO requires a conforming <limits.h>
55 ************************************************************************/
57 #if !defined(CHAR_BIT) || (CHAR_BIT != 8)
58 # error "invalid CHAR_BIT"
60 #if !defined(UCHAR_MAX) || !defined(UINT_MAX) || !defined(ULONG_MAX)
61 # error "check your compiler installation"
63 #if (USHRT_MAX < 1) || (UINT_MAX < 1) || (ULONG_MAX < 1)
64 # error "your limits.h macros are broken"
67 /* workaround a cpp bug under hpux 10.20 */
68 #define LZO_0xffffffffL 4294967295ul
70 #if !defined(LZO_UINT32_C)
71 # if (UINT_MAX < LZO_0xffffffffL)
72 # define LZO_UINT32_C(c) c ## UL
74 # define LZO_UINT32_C(c) c ## U
79 /***********************************************************************
80 // architecture defines
81 ************************************************************************/
83 #if !defined(__LZO_WIN) && !defined(__LZO_DOS) && !defined(__LZO_OS2)
84 # if defined(__WINDOWS__) || defined(_WINDOWS) || defined(_Windows)
86 # elif defined(__WIN32__) || defined(_WIN32) || defined(WIN32)
88 # elif defined(__NT__) || defined(__NT_DLL__) || defined(__WINDOWS_386__)
90 # elif defined(__DOS__) || defined(__MSDOS__) || defined(MSDOS)
92 # elif defined(__OS2__) || defined(__OS2V2__) || defined(OS2)
94 # elif defined(__palmos__)
96 # elif defined(__TOS__) || defined(__atarist__)
101 #if (UINT_MAX < LZO_0xffffffffL)
102 # if defined(__LZO_WIN)
104 # elif defined(__LZO_DOS)
106 # elif defined(__LZO_PALMOS)
107 # define __LZO_PALMOS16
108 # elif defined(__LZO_TOS)
110 # elif defined(__C166__)
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"
118 #if !defined(__LZO_i386)
119 # if defined(__LZO_DOS) || defined(__LZO_WIN16)
121 # elif defined(__i386__) || defined(__386__) || defined(_M_IX86)
126 #if defined(__LZO_STRICT_16BIT)
127 # if (UINT_MAX < LZO_0xffffffffL)
128 # include <lzo16bit.h>
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
146 /***********************************************************************
147 // integral and pointer types
148 ************************************************************************/
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
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;
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
188 typedef int lzo_bool;
191 /***********************************************************************
193 ************************************************************************/
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
202 # define __LZO_CMODEL
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
213 # define __LZO_DMODEL
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
227 # error "__LZO_MMODEL"
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 *
245 #ifndef lzo_sizeof_dict_t
246 # define lzo_sizeof_dict_t sizeof(lzo_bytep)
250 /***********************************************************************
251 // calling conventions and function types
252 ************************************************************************/
255 #if !defined(__LZO_EXTERN_C)
257 # define __LZO_EXTERN_C extern "C"
259 # define __LZO_EXTERN_C extern
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
272 # define __LZO_CDECL __LZO_CMODEL
275 #if !defined(__LZO_ENTRY)
276 # define __LZO_ENTRY __LZO_CDECL
279 /* C++ exception specification for extern "C" function types */
280 #if !defined(__cplusplus)
283 #elif !defined(LZO_NOTHROW)
289 (__LZO_ENTRY *lzo_compress_t) ( const lzo_byte *src, lzo_uint src_len,
290 lzo_byte *dst, lzo_uintp dst_len,
294 (__LZO_ENTRY *lzo_decompress_t) ( const lzo_byte *src, lzo_uint src_len,
295 lzo_byte *dst, lzo_uintp dst_len,
299 (__LZO_ENTRY *lzo_optimize_t) ( lzo_byte *src, lzo_uint src_len,
300 lzo_byte *dst, lzo_uintp dst_len,
304 (__LZO_ENTRY *lzo_compress_dict_t)(const lzo_byte *src, lzo_uint src_len,
305 lzo_byte *dst, lzo_uintp dst_len,
307 const lzo_byte *dict, lzo_uint dict_len );
310 (__LZO_ENTRY *lzo_decompress_dict_t)(const lzo_byte *src, lzo_uint src_len,
311 lzo_byte *dst, lzo_uintp dst_len,
313 const lzo_byte *dict, lzo_uint dict_len );
316 /* assembler versions always use __cdecl */
318 (__LZO_CDECL *lzo_compress_asm_t)( const lzo_byte *src, lzo_uint src_len,
319 lzo_byte *dst, lzo_uintp dst_len,
323 (__LZO_CDECL *lzo_decompress_asm_t)( const lzo_byte *src, lzo_uint src_len,
324 lzo_byte *dst, lzo_uintp dst_len,
328 /* a progress indicator callback function */
329 typedef void (__LZO_ENTRY *lzo_progress_callback_t) (lzo_uint, lzo_uint);
332 /***********************************************************************
333 // export information
334 ************************************************************************/
336 /* DLL export information */
337 #if !defined(__LZO_EXPORT1)
338 # define __LZO_EXPORT1
340 #if !defined(__LZO_EXPORT2)
341 # define __LZO_EXPORT2
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
349 #if !defined(LZO_EXTERN)
350 # define LZO_EXTERN(_rettype) __LZO_EXTERN_C LZO_PUBLIC(_rettype)
352 #if !defined(LZO_PRIVATE)
353 # define LZO_PRIVATE(_rettype) static _rettype __LZO_ENTRY
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
361 #if !defined(LZO_EXTERN_CDECL)
362 # define LZO_EXTERN_CDECL(_rettype) __LZO_EXTERN_C LZO_PUBLIC_CDECL(_rettype)
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
371 #if !defined(LZO_EXTERN_VAR)
372 # define LZO_EXTERN_VAR(_type) extern LZO_PUBLIC_VAR(_type)
376 /***********************************************************************
377 // error codes and prototypes
378 ************************************************************************/
380 /* Error codes for the compression/decompression functions. Negative
381 * values are errors, positive values will be used for special but
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)
395 /* lzo_init() should be the first function you call.
396 * Check the return code !
398 * lzo_init() is a macro to allow checking that the library and the
399 * compiler's view of various types are consistent.
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);
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);
414 /* string functions */
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);
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);
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;
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)))
442 /* deprecated - only for backward compatibility */
443 #define LZO_ALIGN(_ptr,_size) LZO_PTR_ALIGN_UP(_ptr,_size)
450 #endif /* already included */