1/* lzoconf.h -- configuration of the LZO data compression library
2
3 This file is part of the LZO real-time data compression library.
4
5 Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer
6 All Rights Reserved.
7
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.
12
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.
17
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.
22
23 Markus F.X.J. Oberhumer
24 <markus@oberhumer.com>
25 http://www.oberhumer.com/opensource/lzo/
26 */
27
28
29#ifndef __LZOCONF_H_INCLUDED
30#define __LZOCONF_H_INCLUDED 1
31
32#define LZO_VERSION 0x2080
33#define LZO_VERSION_STRING "2.08"
34#define LZO_VERSION_DATE "Jun 29 2014"
35
36/* internal Autoconf configuration file - only used when building LZO */
37#if defined(LZO_HAVE_CONFIG_H)
38# include <config.h>
39#endif
40#include <limits.h>
41#include <stddef.h>
42
43
44/***********************************************************************
45// LZO requires a conforming <limits.h>
46************************************************************************/
47
48#if !defined(CHAR_BIT) || (CHAR_BIT != 8)
49# error "invalid CHAR_BIT"
50#endif
51#if !defined(UCHAR_MAX) || !defined(USHRT_MAX) || !defined(UINT_MAX) || !defined(ULONG_MAX)
52# error "check your compiler installation"
53#endif
54#if (USHRT_MAX < 1) || (UINT_MAX < 1) || (ULONG_MAX < 1)
55# error "your limits.h macros are broken"
56#endif
57
58/* get OS and architecture defines */
59#ifndef __LZODEFS_H_INCLUDED
60#include "lzodefs.h"
61#endif
62
63
64#ifdef __cplusplus
65extern "C" {
66#endif
67
68
69/***********************************************************************
70// some core defines
71************************************************************************/
72
73/* memory checkers */
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
83# endif
84#endif
85
86
87/***********************************************************************
88// integral and pointer types
89************************************************************************/
90
91/* lzo_uint must match size_t */
92#if !defined(LZO_UINT_MAX)
93# if (LZO_ABI_LLP64)
94# if (LZO_OS_WIN64)
95 typedef unsigned __int64 lzo_uint;
96 typedef __int64 lzo_int;
97# else
98 typedef lzo_ullong_t lzo_uint;
99 typedef lzo_llong_t lzo_int;
100# endif
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;
107 typedef int lzo_int;
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
119# else
120# error "lzo_uint"
121# endif
122#endif
123
124/* The larger type of lzo_uint and lzo_uint32_t. */
125#if (LZO_SIZEOF_LZO_UINT >= 4)
126# define lzo_xint lzo_uint
127#else
128# define lzo_xint lzo_uint32_t
129#endif
130
131typedef int lzo_bool;
132
133/* sanity checks */
134LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == LZO_SIZEOF_LZO_UINT)
135LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_xint) >= sizeof(lzo_uint))
136LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_xint) >= sizeof(lzo_uint32_t))
137
138#ifndef __LZO_MMODEL
139#define __LZO_MMODEL /*empty*/
140#endif
141
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 *
153
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 *
163#endif
164
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.
168 */
169#if defined(__LZO_MMODEL_HUGE)
170#error "__LZO_MMODEL_HUGE is unsupported"
171#endif
172#if (LZO_MM_PVP)
173#error "LZO_MM_PVP is unsupported"
174#endif
175#if (LZO_SIZEOF_INT < 4)
176#error "LZO_SIZEOF_INT < 4 is unsupported"
177#endif
178#if (__LZO_UINTPTR_T_IS_POINTER)
179#error "__LZO_UINTPTR_T_IS_POINTER is unsupported"
180#endif
181LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) >= 4)
182LZO_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.
185 */
186LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(size_t))
187LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(ptrdiff_t))
188LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(lzo_uintptr_t))
189LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(void *) == sizeof(lzo_uintptr_t))
190LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(char *) == sizeof(lzo_uintptr_t))
191LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long *) == sizeof(lzo_uintptr_t))
192LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(void *) == sizeof(lzo_voidp))
193LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(char *) == sizeof(lzo_bytep))
194
195
196/***********************************************************************
197// function types
198************************************************************************/
199
200/* name mangling */
201#if !defined(__LZO_EXTERN_C)
202# ifdef __cplusplus
203# define __LZO_EXTERN_C extern "C"
204# else
205# define __LZO_EXTERN_C extern
206# endif
207#endif
208
209/* calling convention */
210#if !defined(__LZO_CDECL)
211# define __LZO_CDECL __lzo_cdecl
212#endif
213
214/* DLL export information */
215#if !defined(__LZO_EXPORT1)
216# define __LZO_EXPORT1 /*empty*/
217#endif
218#if !defined(__LZO_EXPORT2)
219# define __LZO_EXPORT2 /*empty*/
220#endif
221
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
225#endif
226#if !defined(LZO_EXTERN)
227# define LZO_EXTERN(_rettype) __LZO_EXTERN_C LZO_PUBLIC(_rettype)
228#endif
229#if !defined(LZO_PRIVATE)
230# define LZO_PRIVATE(_rettype) static _rettype __LZO_CDECL
231#endif
232
233/* function types */
234typedef int
235(__LZO_CDECL *lzo_compress_t) ( const lzo_bytep src, lzo_uint src_len,
236 lzo_bytep dst, lzo_uintp dst_len,
237 lzo_voidp wrkmem );
238
239typedef int
240(__LZO_CDECL *lzo_decompress_t) ( const lzo_bytep src, lzo_uint src_len,
241 lzo_bytep dst, lzo_uintp dst_len,
242 lzo_voidp wrkmem );
243
244typedef int
245(__LZO_CDECL *lzo_optimize_t) ( lzo_bytep src, lzo_uint src_len,
246 lzo_bytep dst, lzo_uintp dst_len,
247 lzo_voidp wrkmem );
248
249typedef int
250(__LZO_CDECL *lzo_compress_dict_t)(const lzo_bytep src, lzo_uint src_len,
251 lzo_bytep dst, lzo_uintp dst_len,
252 lzo_voidp wrkmem,
253 const lzo_bytep dict, lzo_uint dict_len );
254
255typedef int
256(__LZO_CDECL *lzo_decompress_dict_t)(const lzo_bytep src, lzo_uint src_len,
257 lzo_bytep dst, lzo_uintp dst_len,
258 lzo_voidp wrkmem,
259 const lzo_bytep dict, lzo_uint dict_len );
260
261
262/* Callback interface. Currently only the progress indicator ("nprogress")
263 * is used, but this may change in a future release. */
264
265struct lzo_callback_t;
266typedef struct lzo_callback_t lzo_callback_t;
267#define lzo_callback_p lzo_callback_t __LZO_MMODEL *
268
269/* malloc & free function types */
270typedef lzo_voidp (__LZO_CDECL *lzo_alloc_func_t)
271 (lzo_callback_p self, lzo_uint items, lzo_uint size);
272typedef void (__LZO_CDECL *lzo_free_func_t)
273 (lzo_callback_p self, lzo_voidp ptr);
274
275/* a progress indicator callback function */
276typedef void (__LZO_CDECL *lzo_progress_func_t)
277 (lzo_callback_p, lzo_uint, lzo_uint, int);
278
279struct lzo_callback_t
280{
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] */
284
285 /* a progress indicator callback function (set to 0 to disable) */
286 lzo_progress_func_t nprogress;
287
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. */
291 lzo_voidp user1;
292 lzo_xint user2;
293 lzo_xint user3;
294};
295
296
297/***********************************************************************
298// error codes and prototypes
299************************************************************************/
300
301/* Error codes for the compression/decompression functions. Negative
302 * values are errors, positive values will be used for special but
303 * normal events.
304 */
305#define LZO_E_OK 0
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)
319
320
321#ifndef lzo_sizeof_dict_t
322# define lzo_sizeof_dict_t ((unsigned)sizeof(lzo_bytep))
323#endif
324
325/* lzo_init() should be the first function you call.
326 * Check the return code !
327 *
328 * lzo_init() is a macro to allow checking that the library and the
329 * compiler's view of various types are consistent.
330 */
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))
335LZO_EXTERN(int) __lzo_init_v2(unsigned,int,int,int,int,int,int,int,int,int);
336
337/* version functions (useful for shared libraries) */
338LZO_EXTERN(unsigned) lzo_version(void);
339LZO_EXTERN(const char *) lzo_version_string(void);
340LZO_EXTERN(const char *) lzo_version_date(void);
341LZO_EXTERN(const lzo_charp) _lzo_version_string(void);
342LZO_EXTERN(const lzo_charp) _lzo_version_date(void);
343
344/* string functions */
345LZO_EXTERN(int)
346 lzo_memcmp(const lzo_voidp a, const lzo_voidp b, lzo_uint len);
347LZO_EXTERN(lzo_voidp)
348 lzo_memcpy(lzo_voidp dst, const lzo_voidp src, lzo_uint len);
349LZO_EXTERN(lzo_voidp)
350 lzo_memmove(lzo_voidp dst, const lzo_voidp src, lzo_uint len);
351LZO_EXTERN(lzo_voidp)
352 lzo_memset(lzo_voidp buf, int c, lzo_uint len);
353
354/* checksum functions */
355LZO_EXTERN(lzo_uint32_t)
356 lzo_adler32(lzo_uint32_t c, const lzo_bytep buf, lzo_uint len);
357LZO_EXTERN(lzo_uint32_t)
358 lzo_crc32(lzo_uint32_t c, const lzo_bytep buf, lzo_uint len);
359LZO_EXTERN(const lzo_uint32_tp)
360 lzo_get_crc32_table(void);
361
362/* misc. */
363LZO_EXTERN(int) _lzo_config_check(void);
364typedef union {
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)
368 lzo_uint64_t a10;
369#endif
370} lzo_align_t;
371
372/* align a char pointer on a boundary that is a multiple of 'size' */
373LZO_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)))
376
377
378/***********************************************************************
379// deprecated macros - only for backward compatibility
380************************************************************************/
381
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)
398#endif
399/* deprecated types */
400typedef union { lzo_bytep a; lzo_uint b; } __lzo_pu_u;
401typedef union { lzo_bytep a; lzo_uint32_t b; } __lzo_pu32_u;
402
403#if defined(LZO_CFG_COMPAT)
404
405#define __LZOCONF_H 1
406
407#if defined(LZO_ARCH_I086)
408# define __LZO_i386 1
409#elif defined(LZO_ARCH_I386)
410# define __LZO_i386 1
411#endif
412
413#if defined(LZO_OS_DOS16)
414# define __LZO_DOS 1
415# define __LZO_DOS16 1
416#elif defined(LZO_OS_DOS32)
417# define __LZO_DOS 1
418#elif defined(LZO_OS_WIN16)
419# define __LZO_WIN 1
420# define __LZO_WIN16 1
421#elif defined(LZO_OS_WIN32)
422# define __LZO_WIN 1
423#endif
424
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
430
431#define lzo_compress_asm_t lzo_compress_t
432#define lzo_decompress_asm_t lzo_decompress_t
433
434#endif /* LZO_CFG_COMPAT */
435
436
437#ifdef __cplusplus
438} /* extern "C" */
439#endif
440
441#endif /* already included */
442
443
444/* vim:set ts=4 sw=4 et: */
445