1 /* lzoconf.h -- configuration of the LZO data compression library
3 This file is part of the LZO real-time data compression library.
5 Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer
8 The LZO library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2 of
11 the License, or (at your option) any later version.
13 The LZO library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with the LZO library; see the file COPYING.
20 If not, write to the Free Software Foundation, Inc.,
21 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 Markus F.X.J. Oberhumer
24 <markus@oberhumer.com>
25 http://www.oberhumer.com/opensource/lzo/
29 #ifndef __LZOCONF_H_INCLUDED
30 #define __LZOCONF_H_INCLUDED 1
32 #define LZO_VERSION 0x2080
33 #define LZO_VERSION_STRING "2.08"
34 #define LZO_VERSION_DATE "Jun 29 2014"
36 /* internal Autoconf configuration file - only used when building LZO */
37 #if defined(LZO_HAVE_CONFIG_H)
44 /***********************************************************************
45 // LZO requires a conforming <limits.h>
46 ************************************************************************/
48 #if !defined(CHAR_BIT) || (CHAR_BIT != 8)
49 # error "invalid CHAR_BIT"
51 #if !defined(UCHAR_MAX) || !defined(USHRT_MAX) || !defined(UINT_MAX) || !defined(ULONG_MAX)
52 # error "check your compiler installation"
54 #if (USHRT_MAX < 1) || (UINT_MAX < 1) || (ULONG_MAX < 1)
55 # error "your limits.h macros are broken"
58 /* get OS and architecture defines */
59 #ifndef __LZODEFS_H_INCLUDED
69 /***********************************************************************
71 ************************************************************************/
74 #if !defined(__LZO_CHECKER)
75 # if defined(__BOUNDS_CHECKING_ON)
76 # define __LZO_CHECKER 1
77 # elif defined(__CHECKER__)
78 # define __LZO_CHECKER 1
79 # elif defined(__INSURE__)
80 # define __LZO_CHECKER 1
81 # elif defined(__PURIFY__)
82 # define __LZO_CHECKER 1
87 /***********************************************************************
88 // integral and pointer types
89 ************************************************************************/
91 /* lzo_uint must match size_t */
92 #if !defined(LZO_UINT_MAX)
95 typedef unsigned __int64 lzo_uint;
96 typedef __int64 lzo_int;
98 typedef lzo_ullong_t lzo_uint;
99 typedef lzo_llong_t lzo_int;
101 # define LZO_SIZEOF_LZO_UINT 8
102 # define LZO_UINT_MAX 0xffffffffffffffffull
103 # define LZO_INT_MAX 9223372036854775807LL
104 # define LZO_INT_MIN (-1LL - LZO_INT_MAX)
105 # elif (LZO_ABI_IP32L64) /* MIPS R5900 */
106 typedef unsigned int lzo_uint;
108 # define LZO_SIZEOF_LZO_UINT LZO_SIZEOF_INT
109 # define LZO_UINT_MAX UINT_MAX
110 # define LZO_INT_MAX INT_MAX
111 # define LZO_INT_MIN INT_MIN
112 # elif (ULONG_MAX >= LZO_0xffffffffL)
113 typedef unsigned long lzo_uint;
114 typedef long lzo_int;
115 # define LZO_SIZEOF_LZO_UINT LZO_SIZEOF_LONG
116 # define LZO_UINT_MAX ULONG_MAX
117 # define LZO_INT_MAX LONG_MAX
118 # define LZO_INT_MIN LONG_MIN
124 /* The larger type of lzo_uint and lzo_uint32_t. */
125 #if (LZO_SIZEOF_LZO_UINT >= 4)
126 # define lzo_xint lzo_uint
128 # define lzo_xint lzo_uint32_t
131 typedef int lzo_bool;
134 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == LZO_SIZEOF_LZO_UINT)
135 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_xint) >= sizeof(lzo_uint))
136 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_xint) >= sizeof(lzo_uint32_t))
139 #define __LZO_MMODEL /*empty*/
142 /* no typedef here because of const-pointer issues */
143 #define lzo_bytep unsigned char __LZO_MMODEL *
144 #define lzo_charp char __LZO_MMODEL *
145 #define lzo_voidp void __LZO_MMODEL *
146 #define lzo_shortp short __LZO_MMODEL *
147 #define lzo_ushortp unsigned short __LZO_MMODEL *
148 #define lzo_intp lzo_int __LZO_MMODEL *
149 #define lzo_uintp lzo_uint __LZO_MMODEL *
150 #define lzo_xintp lzo_xint __LZO_MMODEL *
151 #define lzo_voidpp lzo_voidp __LZO_MMODEL *
152 #define lzo_bytepp lzo_bytep __LZO_MMODEL *
154 #define lzo_int8_tp lzo_int8_t __LZO_MMODEL *
155 #define lzo_uint8_tp lzo_uint8_t __LZO_MMODEL *
156 #define lzo_int16_tp lzo_int16_t __LZO_MMODEL *
157 #define lzo_uint16_tp lzo_uint16_t __LZO_MMODEL *
158 #define lzo_int32_tp lzo_int32_t __LZO_MMODEL *
159 #define lzo_uint32_tp lzo_uint32_t __LZO_MMODEL *
160 #if defined(lzo_int64_t)
161 #define lzo_int64_tp lzo_int64_t __LZO_MMODEL *
162 #define lzo_uint64_tp lzo_uint64_t __LZO_MMODEL *
165 /* Older LZO versions used to support ancient systems and memory models
166 * like 16-bit MSDOS with __huge pointers and Cray PVP, but these
167 * obsolete configurations are not supported any longer.
169 #if defined(__LZO_MMODEL_HUGE)
170 #error "__LZO_MMODEL_HUGE is unsupported"
173 #error "LZO_MM_PVP is unsupported"
175 #if (LZO_SIZEOF_INT < 4)
176 #error "LZO_SIZEOF_INT < 4 is unsupported"
178 #if (__LZO_UINTPTR_T_IS_POINTER)
179 #error "__LZO_UINTPTR_T_IS_POINTER is unsupported"
181 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) >= 4)
182 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) >= 4)
183 /* Strange configurations where sizeof(lzo_uint) != sizeof(size_t) should
184 * work but have not received much testing lately, so be strict here.
186 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(size_t))
187 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(ptrdiff_t))
188 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(lzo_uintptr_t))
189 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(void *) == sizeof(lzo_uintptr_t))
190 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(char *) == sizeof(lzo_uintptr_t))
191 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long *) == sizeof(lzo_uintptr_t))
192 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(void *) == sizeof(lzo_voidp))
193 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(char *) == sizeof(lzo_bytep))
196 /***********************************************************************
198 ************************************************************************/
201 #if !defined(__LZO_EXTERN_C)
203 # define __LZO_EXTERN_C extern "C"
205 # define __LZO_EXTERN_C extern
209 /* calling convention */
210 #if !defined(__LZO_CDECL)
211 # define __LZO_CDECL __lzo_cdecl
214 /* DLL export information */
215 #if !defined(__LZO_EXPORT1)
216 # define __LZO_EXPORT1 /*empty*/
218 #if !defined(__LZO_EXPORT2)
219 # define __LZO_EXPORT2 /*empty*/
222 /* __cdecl calling convention for public C and assembly functions */
223 #if !defined(LZO_PUBLIC)
224 # define LZO_PUBLIC(_rettype) __LZO_EXPORT1 _rettype __LZO_EXPORT2 __LZO_CDECL
226 #if !defined(LZO_EXTERN)
227 # define LZO_EXTERN(_rettype) __LZO_EXTERN_C LZO_PUBLIC(_rettype)
229 #if !defined(LZO_PRIVATE)
230 # define LZO_PRIVATE(_rettype) static _rettype __LZO_CDECL
235 (__LZO_CDECL *lzo_compress_t) ( const lzo_bytep src, lzo_uint src_len,
236 lzo_bytep dst, lzo_uintp dst_len,
240 (__LZO_CDECL *lzo_decompress_t) ( const lzo_bytep src, lzo_uint src_len,
241 lzo_bytep dst, lzo_uintp dst_len,
245 (__LZO_CDECL *lzo_optimize_t) ( lzo_bytep src, lzo_uint src_len,
246 lzo_bytep dst, lzo_uintp dst_len,
250 (__LZO_CDECL *lzo_compress_dict_t)(const lzo_bytep src, lzo_uint src_len,
251 lzo_bytep dst, lzo_uintp dst_len,
253 const lzo_bytep dict, lzo_uint dict_len );
256 (__LZO_CDECL *lzo_decompress_dict_t)(const lzo_bytep src, lzo_uint src_len,
257 lzo_bytep dst, lzo_uintp dst_len,
259 const lzo_bytep dict, lzo_uint dict_len );
262 /* Callback interface. Currently only the progress indicator ("nprogress")
263 * is used, but this may change in a future release. */
265 struct lzo_callback_t;
266 typedef struct lzo_callback_t lzo_callback_t;
267 #define lzo_callback_p lzo_callback_t __LZO_MMODEL *
269 /* malloc & free function types */
270 typedef lzo_voidp (__LZO_CDECL *lzo_alloc_func_t)
271 (lzo_callback_p self, lzo_uint items, lzo_uint size);
272 typedef void (__LZO_CDECL *lzo_free_func_t)
273 (lzo_callback_p self, lzo_voidp ptr);
275 /* a progress indicator callback function */
276 typedef void (__LZO_CDECL *lzo_progress_func_t)
277 (lzo_callback_p, lzo_uint, lzo_uint, int);
279 struct lzo_callback_t
281 /* custom allocators (set to 0 to disable) */
282 lzo_alloc_func_t nalloc; /* [not used right now] */
283 lzo_free_func_t nfree; /* [not used right now] */
285 /* a progress indicator callback function (set to 0 to disable) */
286 lzo_progress_func_t nprogress;
288 /* INFO: the first parameter "self" of the nalloc/nfree/nprogress
289 * callbacks points back to this struct, so you are free to store
290 * some extra info in the following variables. */
297 /***********************************************************************
298 // error codes and prototypes
299 ************************************************************************/
301 /* Error codes for the compression/decompression functions. Negative
302 * values are errors, positive values will be used for special but
306 #define LZO_E_ERROR (-1)
307 #define LZO_E_OUT_OF_MEMORY (-2) /* [lzo_alloc_func_t failure] */
308 #define LZO_E_NOT_COMPRESSIBLE (-3) /* [not used right now] */
309 #define LZO_E_INPUT_OVERRUN (-4)
310 #define LZO_E_OUTPUT_OVERRUN (-5)
311 #define LZO_E_LOOKBEHIND_OVERRUN (-6)
312 #define LZO_E_EOF_NOT_FOUND (-7)
313 #define LZO_E_INPUT_NOT_CONSUMED (-8)
314 #define LZO_E_NOT_YET_IMPLEMENTED (-9) /* [not used right now] */
315 #define LZO_E_INVALID_ARGUMENT (-10)
316 #define LZO_E_INVALID_ALIGNMENT (-11) /* pointer argument is not properly aligned */
317 #define LZO_E_OUTPUT_NOT_CONSUMED (-12)
318 #define LZO_E_INTERNAL_ERROR (-99)
321 #ifndef lzo_sizeof_dict_t
322 # define lzo_sizeof_dict_t ((unsigned)sizeof(lzo_bytep))
325 /* lzo_init() should be the first function you call.
326 * Check the return code !
328 * lzo_init() is a macro to allow checking that the library and the
329 * compiler's view of various types are consistent.
331 #define lzo_init() __lzo_init_v2(LZO_VERSION,(int)sizeof(short),(int)sizeof(int),\
332 (int)sizeof(long),(int)sizeof(lzo_uint32_t),(int)sizeof(lzo_uint),\
333 (int)lzo_sizeof_dict_t,(int)sizeof(char *),(int)sizeof(lzo_voidp),\
334 (int)sizeof(lzo_callback_t))
335 LZO_EXTERN(int) __lzo_init_v2(unsigned,int,int,int,int,int,int,int,int,int);
337 /* version functions (useful for shared libraries) */
338 LZO_EXTERN(unsigned) lzo_version(void);
339 LZO_EXTERN(const char *) lzo_version_string(void);
340 LZO_EXTERN(const char *) lzo_version_date(void);
341 LZO_EXTERN(const lzo_charp) _lzo_version_string(void);
342 LZO_EXTERN(const lzo_charp) _lzo_version_date(void);
344 /* string functions */
346 lzo_memcmp(const lzo_voidp a, const lzo_voidp b, lzo_uint len);
347 LZO_EXTERN(lzo_voidp)
348 lzo_memcpy(lzo_voidp dst, const lzo_voidp src, lzo_uint len);
349 LZO_EXTERN(lzo_voidp)
350 lzo_memmove(lzo_voidp dst, const lzo_voidp src, lzo_uint len);
351 LZO_EXTERN(lzo_voidp)
352 lzo_memset(lzo_voidp buf, int c, lzo_uint len);
354 /* checksum functions */
355 LZO_EXTERN(lzo_uint32_t)
356 lzo_adler32(lzo_uint32_t c, const lzo_bytep buf, lzo_uint len);
357 LZO_EXTERN(lzo_uint32_t)
358 lzo_crc32(lzo_uint32_t c, const lzo_bytep buf, lzo_uint len);
359 LZO_EXTERN(const lzo_uint32_tp)
360 lzo_get_crc32_table(void);
363 LZO_EXTERN(int) _lzo_config_check(void);
365 lzo_voidp a00; lzo_bytep a01; lzo_uint a02; lzo_xint a03; lzo_uintptr_t a04;
366 void *a05; unsigned char *a06; unsigned long a07; size_t a08; ptrdiff_t a09;
367 #if defined(lzo_int64_t)
372 /* align a char pointer on a boundary that is a multiple of 'size' */
373 LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp p, lzo_uint size);
374 #define LZO_PTR_ALIGN_UP(p,size) \
375 ((p) + (lzo_uint) __lzo_align_gap((const lzo_voidp)(p),(lzo_uint)(size)))
378 /***********************************************************************
379 // deprecated macros - only for backward compatibility
380 ************************************************************************/
382 /* deprecated - use 'lzo_bytep' instead of 'lzo_byte *' */
383 #define lzo_byte unsigned char
384 /* deprecated type names */
385 #define lzo_int32 lzo_int32_t
386 #define lzo_uint32 lzo_uint32_t
387 #define lzo_int32p lzo_int32_t __LZO_MMODEL *
388 #define lzo_uint32p lzo_uint32_t __LZO_MMODEL *
389 #define LZO_INT32_MAX LZO_INT32_C(2147483647)
390 #define LZO_UINT32_MAX LZO_UINT32_C(4294967295)
391 #if defined(lzo_int64_t)
392 #define lzo_int64 lzo_int64_t
393 #define lzo_uint64 lzo_uint64_t
394 #define lzo_int64p lzo_int64_t __LZO_MMODEL *
395 #define lzo_uint64p lzo_uint64_t __LZO_MMODEL *
396 #define LZO_INT64_MAX LZO_INT64_C(9223372036854775807)
397 #define LZO_UINT64_MAX LZO_UINT64_C(18446744073709551615)
399 /* deprecated types */
400 typedef union { lzo_bytep a; lzo_uint b; } __lzo_pu_u;
401 typedef union { lzo_bytep a; lzo_uint32_t b; } __lzo_pu32_u;
403 #if defined(LZO_CFG_COMPAT)
405 #define __LZOCONF_H 1
407 #if defined(LZO_ARCH_I086)
408 # define __LZO_i386 1
409 #elif defined(LZO_ARCH_I386)
410 # define __LZO_i386 1
413 #if defined(LZO_OS_DOS16)
415 # define __LZO_DOS16 1
416 #elif defined(LZO_OS_DOS32)
418 #elif defined(LZO_OS_WIN16)
420 # define __LZO_WIN16 1
421 #elif defined(LZO_OS_WIN32)
425 #define __LZO_CMODEL /*empty*/
426 #define __LZO_DMODEL /*empty*/
427 #define __LZO_ENTRY __LZO_CDECL
428 #define LZO_EXTERN_CDECL LZO_EXTERN
429 #define LZO_ALIGN LZO_PTR_ALIGN_UP
431 #define lzo_compress_asm_t lzo_compress_t
432 #define lzo_decompress_asm_t lzo_decompress_t
434 #endif /* LZO_CFG_COMPAT */
441 #endif /* already included */
444 /* vim:set ts=4 sw=4 et: */