]> sigrok.org Git - libsigrok.git/blame - src/minilzo/lzoconf.h
minilzo: import content of upstream minilzo-2.10.tar.gz archive
[libsigrok.git] / src / minilzo / lzoconf.h
CommitLineData
0df44c76
GS
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-2017 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 0x20a0 /* 2.10 */
33#define LZO_VERSION_STRING "2.10"
34#define LZO_VERSION_DATE "Mar 01 2017"
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 <lzo/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# define LZO_TYPEOF_LZO_INT LZO_TYPEOF___INT64
98# else
99 typedef lzo_ullong_t lzo_uint;
100 typedef lzo_llong_t lzo_int;
101# define LZO_TYPEOF_LZO_INT LZO_TYPEOF_LONG_LONG
102# endif
103# define LZO_SIZEOF_LZO_INT 8
104# define LZO_UINT_MAX 0xffffffffffffffffull
105# define LZO_INT_MAX 9223372036854775807LL
106# define LZO_INT_MIN (-1LL - LZO_INT_MAX)
107# elif (LZO_ABI_IP32L64) /* MIPS R5900 */
108 typedef unsigned int lzo_uint;
109 typedef int lzo_int;
110# define LZO_SIZEOF_LZO_INT LZO_SIZEOF_INT
111# define LZO_TYPEOF_LZO_INT LZO_TYPEOF_INT
112# define LZO_UINT_MAX UINT_MAX
113# define LZO_INT_MAX INT_MAX
114# define LZO_INT_MIN INT_MIN
115# elif (ULONG_MAX >= LZO_0xffffffffL)
116 typedef unsigned long lzo_uint;
117 typedef long lzo_int;
118# define LZO_SIZEOF_LZO_INT LZO_SIZEOF_LONG
119# define LZO_TYPEOF_LZO_INT LZO_TYPEOF_LONG
120# define LZO_UINT_MAX ULONG_MAX
121# define LZO_INT_MAX LONG_MAX
122# define LZO_INT_MIN LONG_MIN
123# else
124# error "lzo_uint"
125# endif
126#endif
127
128/* The larger type of lzo_uint and lzo_uint32_t. */
129#if (LZO_SIZEOF_LZO_INT >= 4)
130# define lzo_xint lzo_uint
131#else
132# define lzo_xint lzo_uint32_t
133#endif
134
135typedef int lzo_bool;
136
137/* sanity checks */
138LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int) == LZO_SIZEOF_LZO_INT)
139LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == LZO_SIZEOF_LZO_INT)
140LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_xint) >= sizeof(lzo_uint))
141LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_xint) >= sizeof(lzo_uint32_t))
142
143#ifndef __LZO_MMODEL
144#define __LZO_MMODEL /*empty*/
145#endif
146
147/* no typedef here because of const-pointer issues */
148#define lzo_bytep unsigned char __LZO_MMODEL *
149#define lzo_charp char __LZO_MMODEL *
150#define lzo_voidp void __LZO_MMODEL *
151#define lzo_shortp short __LZO_MMODEL *
152#define lzo_ushortp unsigned short __LZO_MMODEL *
153#define lzo_intp lzo_int __LZO_MMODEL *
154#define lzo_uintp lzo_uint __LZO_MMODEL *
155#define lzo_xintp lzo_xint __LZO_MMODEL *
156#define lzo_voidpp lzo_voidp __LZO_MMODEL *
157#define lzo_bytepp lzo_bytep __LZO_MMODEL *
158
159#define lzo_int8_tp lzo_int8_t __LZO_MMODEL *
160#define lzo_uint8_tp lzo_uint8_t __LZO_MMODEL *
161#define lzo_int16_tp lzo_int16_t __LZO_MMODEL *
162#define lzo_uint16_tp lzo_uint16_t __LZO_MMODEL *
163#define lzo_int32_tp lzo_int32_t __LZO_MMODEL *
164#define lzo_uint32_tp lzo_uint32_t __LZO_MMODEL *
165#if defined(lzo_int64_t)
166#define lzo_int64_tp lzo_int64_t __LZO_MMODEL *
167#define lzo_uint64_tp lzo_uint64_t __LZO_MMODEL *
168#endif
169
170/* Older LZO versions used to support ancient systems and memory models
171 * such as 16-bit MSDOS with __huge pointers or Cray PVP, but these
172 * obsolete configurations are not supported any longer.
173 */
174#if defined(__LZO_MMODEL_HUGE)
175#error "__LZO_MMODEL_HUGE memory model is unsupported"
176#endif
177#if (LZO_MM_PVP)
178#error "LZO_MM_PVP memory model is unsupported"
179#endif
180#if (LZO_SIZEOF_INT < 4)
181#error "LZO_SIZEOF_INT < 4 is unsupported"
182#endif
183#if (__LZO_UINTPTR_T_IS_POINTER)
184#error "__LZO_UINTPTR_T_IS_POINTER is unsupported"
185#endif
186LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) >= 4)
187LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) >= 4)
188/* Strange configurations where sizeof(lzo_uint) != sizeof(size_t) should
189 * work but have not received much testing lately, so be strict here.
190 */
191LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(size_t))
192LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(ptrdiff_t))
193LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(lzo_uintptr_t))
194LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(void *) == sizeof(lzo_uintptr_t))
195LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(char *) == sizeof(lzo_uintptr_t))
196LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long *) == sizeof(lzo_uintptr_t))
197LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(void *) == sizeof(lzo_voidp))
198LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(char *) == sizeof(lzo_bytep))
199
200
201/***********************************************************************
202// function types
203************************************************************************/
204
205/* name mangling */
206#if !defined(__LZO_EXTERN_C)
207# ifdef __cplusplus
208# define __LZO_EXTERN_C extern "C"
209# else
210# define __LZO_EXTERN_C extern
211# endif
212#endif
213
214/* calling convention */
215#if !defined(__LZO_CDECL)
216# define __LZO_CDECL __lzo_cdecl
217#endif
218
219/* DLL export information */
220#if !defined(__LZO_EXPORT1)
221# define __LZO_EXPORT1 /*empty*/
222#endif
223#if !defined(__LZO_EXPORT2)
224# define __LZO_EXPORT2 /*empty*/
225#endif
226
227/* __cdecl calling convention for public C and assembly functions */
228#if !defined(LZO_PUBLIC)
229# define LZO_PUBLIC(r) __LZO_EXPORT1 r __LZO_EXPORT2 __LZO_CDECL
230#endif
231#if !defined(LZO_EXTERN)
232# define LZO_EXTERN(r) __LZO_EXTERN_C LZO_PUBLIC(r)
233#endif
234#if !defined(LZO_PRIVATE)
235# define LZO_PRIVATE(r) static r __LZO_CDECL
236#endif
237
238/* function types */
239typedef int
240(__LZO_CDECL *lzo_compress_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_decompress_t) ( const 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_optimize_t) ( lzo_bytep src, lzo_uint src_len,
251 lzo_bytep dst, lzo_uintp dst_len,
252 lzo_voidp wrkmem );
253
254typedef int
255(__LZO_CDECL *lzo_compress_dict_t)(const lzo_bytep src, lzo_uint src_len,
256 lzo_bytep dst, lzo_uintp dst_len,
257 lzo_voidp wrkmem,
258 const lzo_bytep dict, lzo_uint dict_len );
259
260typedef int
261(__LZO_CDECL *lzo_decompress_dict_t)(const lzo_bytep src, lzo_uint src_len,
262 lzo_bytep dst, lzo_uintp dst_len,
263 lzo_voidp wrkmem,
264 const lzo_bytep dict, lzo_uint dict_len );
265
266
267/* Callback interface. Currently only the progress indicator ("nprogress")
268 * is used, but this may change in a future release. */
269
270struct lzo_callback_t;
271typedef struct lzo_callback_t lzo_callback_t;
272#define lzo_callback_p lzo_callback_t __LZO_MMODEL *
273
274/* malloc & free function types */
275typedef lzo_voidp (__LZO_CDECL *lzo_alloc_func_t)
276 (lzo_callback_p self, lzo_uint items, lzo_uint size);
277typedef void (__LZO_CDECL *lzo_free_func_t)
278 (lzo_callback_p self, lzo_voidp ptr);
279
280/* a progress indicator callback function */
281typedef void (__LZO_CDECL *lzo_progress_func_t)
282 (lzo_callback_p, lzo_uint, lzo_uint, int);
283
284struct lzo_callback_t
285{
286 /* custom allocators (set to 0 to disable) */
287 lzo_alloc_func_t nalloc; /* [not used right now] */
288 lzo_free_func_t nfree; /* [not used right now] */
289
290 /* a progress indicator callback function (set to 0 to disable) */
291 lzo_progress_func_t nprogress;
292
293 /* INFO: the first parameter "self" of the nalloc/nfree/nprogress
294 * callbacks points back to this struct, so you are free to store
295 * some extra info in the following variables. */
296 lzo_voidp user1;
297 lzo_xint user2;
298 lzo_xint user3;
299};
300
301
302/***********************************************************************
303// error codes and prototypes
304************************************************************************/
305
306/* Error codes for the compression/decompression functions. Negative
307 * values are errors, positive values will be used for special but
308 * normal events.
309 */
310#define LZO_E_OK 0
311#define LZO_E_ERROR (-1)
312#define LZO_E_OUT_OF_MEMORY (-2) /* [lzo_alloc_func_t failure] */
313#define LZO_E_NOT_COMPRESSIBLE (-3) /* [not used right now] */
314#define LZO_E_INPUT_OVERRUN (-4)
315#define LZO_E_OUTPUT_OVERRUN (-5)
316#define LZO_E_LOOKBEHIND_OVERRUN (-6)
317#define LZO_E_EOF_NOT_FOUND (-7)
318#define LZO_E_INPUT_NOT_CONSUMED (-8)
319#define LZO_E_NOT_YET_IMPLEMENTED (-9) /* [not used right now] */
320#define LZO_E_INVALID_ARGUMENT (-10)
321#define LZO_E_INVALID_ALIGNMENT (-11) /* pointer argument is not properly aligned */
322#define LZO_E_OUTPUT_NOT_CONSUMED (-12)
323#define LZO_E_INTERNAL_ERROR (-99)
324
325
326#ifndef lzo_sizeof_dict_t
327# define lzo_sizeof_dict_t ((unsigned)sizeof(lzo_bytep))
328#endif
329
330/* lzo_init() should be the first function you call.
331 * Check the return code !
332 *
333 * lzo_init() is a macro to allow checking that the library and the
334 * compiler's view of various types are consistent.
335 */
336#define lzo_init() __lzo_init_v2(LZO_VERSION,(int)sizeof(short),(int)sizeof(int),\
337 (int)sizeof(long),(int)sizeof(lzo_uint32_t),(int)sizeof(lzo_uint),\
338 (int)lzo_sizeof_dict_t,(int)sizeof(char *),(int)sizeof(lzo_voidp),\
339 (int)sizeof(lzo_callback_t))
340LZO_EXTERN(int) __lzo_init_v2(unsigned,int,int,int,int,int,int,int,int,int);
341
342/* version functions (useful for shared libraries) */
343LZO_EXTERN(unsigned) lzo_version(void);
344LZO_EXTERN(const char *) lzo_version_string(void);
345LZO_EXTERN(const char *) lzo_version_date(void);
346LZO_EXTERN(const lzo_charp) _lzo_version_string(void);
347LZO_EXTERN(const lzo_charp) _lzo_version_date(void);
348
349/* string functions */
350LZO_EXTERN(int)
351 lzo_memcmp(const lzo_voidp a, const lzo_voidp b, lzo_uint len);
352LZO_EXTERN(lzo_voidp)
353 lzo_memcpy(lzo_voidp dst, const lzo_voidp src, lzo_uint len);
354LZO_EXTERN(lzo_voidp)
355 lzo_memmove(lzo_voidp dst, const lzo_voidp src, lzo_uint len);
356LZO_EXTERN(lzo_voidp)
357 lzo_memset(lzo_voidp buf, int c, lzo_uint len);
358
359/* checksum functions */
360LZO_EXTERN(lzo_uint32_t)
361 lzo_adler32(lzo_uint32_t c, const lzo_bytep buf, lzo_uint len);
362LZO_EXTERN(lzo_uint32_t)
363 lzo_crc32(lzo_uint32_t c, const lzo_bytep buf, lzo_uint len);
364LZO_EXTERN(const lzo_uint32_tp)
365 lzo_get_crc32_table(void);
366
367/* misc. */
368LZO_EXTERN(int) _lzo_config_check(void);
369typedef union {
370 lzo_voidp a00; lzo_bytep a01; lzo_uint a02; lzo_xint a03; lzo_uintptr_t a04;
371 void *a05; unsigned char *a06; unsigned long a07; size_t a08; ptrdiff_t a09;
372#if defined(lzo_int64_t)
373 lzo_uint64_t a10;
374#endif
375} lzo_align_t;
376
377/* align a char pointer on a boundary that is a multiple of 'size' */
378LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp p, lzo_uint size);
379#define LZO_PTR_ALIGN_UP(p,size) \
380 ((p) + (lzo_uint) __lzo_align_gap((const lzo_voidp)(p),(lzo_uint)(size)))
381
382
383/***********************************************************************
384// deprecated macros - only for backward compatibility
385************************************************************************/
386
387/* deprecated - use 'lzo_bytep' instead of 'lzo_byte *' */
388#define lzo_byte unsigned char
389/* deprecated type names */
390#define lzo_int32 lzo_int32_t
391#define lzo_uint32 lzo_uint32_t
392#define lzo_int32p lzo_int32_t __LZO_MMODEL *
393#define lzo_uint32p lzo_uint32_t __LZO_MMODEL *
394#define LZO_INT32_MAX LZO_INT32_C(2147483647)
395#define LZO_UINT32_MAX LZO_UINT32_C(4294967295)
396#if defined(lzo_int64_t)
397#define lzo_int64 lzo_int64_t
398#define lzo_uint64 lzo_uint64_t
399#define lzo_int64p lzo_int64_t __LZO_MMODEL *
400#define lzo_uint64p lzo_uint64_t __LZO_MMODEL *
401#define LZO_INT64_MAX LZO_INT64_C(9223372036854775807)
402#define LZO_UINT64_MAX LZO_UINT64_C(18446744073709551615)
403#endif
404/* deprecated types */
405typedef union { lzo_bytep a; lzo_uint b; } __lzo_pu_u;
406typedef union { lzo_bytep a; lzo_uint32_t b; } __lzo_pu32_u;
407/* deprecated defines */
408#if !defined(LZO_SIZEOF_LZO_UINT)
409# define LZO_SIZEOF_LZO_UINT LZO_SIZEOF_LZO_INT
410#endif
411
412#if defined(LZO_CFG_COMPAT)
413
414#define __LZOCONF_H 1
415
416#if defined(LZO_ARCH_I086)
417# define __LZO_i386 1
418#elif defined(LZO_ARCH_I386)
419# define __LZO_i386 1
420#endif
421
422#if defined(LZO_OS_DOS16)
423# define __LZO_DOS 1
424# define __LZO_DOS16 1
425#elif defined(LZO_OS_DOS32)
426# define __LZO_DOS 1
427#elif defined(LZO_OS_WIN16)
428# define __LZO_WIN 1
429# define __LZO_WIN16 1
430#elif defined(LZO_OS_WIN32)
431# define __LZO_WIN 1
432#endif
433
434#define __LZO_CMODEL /*empty*/
435#define __LZO_DMODEL /*empty*/
436#define __LZO_ENTRY __LZO_CDECL
437#define LZO_EXTERN_CDECL LZO_EXTERN
438#define LZO_ALIGN LZO_PTR_ALIGN_UP
439
440#define lzo_compress_asm_t lzo_compress_t
441#define lzo_decompress_asm_t lzo_decompress_t
442
443#endif /* LZO_CFG_COMPAT */
444
445
446#ifdef __cplusplus
447} /* extern "C" */
448#endif
449
450#endif /* already included */
451
452
453/* vim:set ts=4 sw=4 et: */