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) 2010 Markus Franz Xaver Johannes Oberhumer
6   Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer
7   Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer
8   Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer
9   Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer
10   Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer
11   Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer
12   Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer
13   Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
14   Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
15   Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
16   Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
17   Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
18   Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
19   Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
20   All Rights Reserved.
21
22   The LZO library is free software; you can redistribute it and/or
23   modify it under the terms of the GNU General Public License as
24   published by the Free Software Foundation; either version 2 of
25   the License, or (at your option) any later version.
26
27   The LZO library is distributed in the hope that it will be useful,
28   but WITHOUT ANY WARRANTY; without even the implied warranty of
29   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
30   GNU General Public License for more details.
31
32   You should have received a copy of the GNU General Public License
33   along with the LZO library; see the file COPYING.
34   If not, write to the Free Software Foundation, Inc.,
35   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
36
37   Markus F.X.J. Oberhumer
38   <markus@oberhumer.com>
39   http://www.oberhumer.com/opensource/lzo/
40 */
41
42
43#ifndef __LZOCONF_H_INCLUDED
44#define __LZOCONF_H_INCLUDED 1
45
46#define LZO_VERSION             0x2040
47#define LZO_VERSION_STRING      "2.04"
48#define LZO_VERSION_DATE        "Oct 31 2010"
49
50/* internal Autoconf configuration file - only used when building LZO */
51#if defined(LZO_HAVE_CONFIG_H)
52#  include <config.h>
53#endif
54#include <limits.h>
55#include <stddef.h>
56
57
58/***********************************************************************
59// LZO requires a conforming <limits.h>
60************************************************************************/
61
62#if !defined(CHAR_BIT) || (CHAR_BIT != 8)
63#  error "invalid CHAR_BIT"
64#endif
65#if !defined(UCHAR_MAX) || !defined(UINT_MAX) || !defined(ULONG_MAX)
66#  error "check your compiler installation"
67#endif
68#if (USHRT_MAX < 1) || (UINT_MAX < 1) || (ULONG_MAX < 1)
69#  error "your limits.h macros are broken"
70#endif
71
72/* get OS and architecture defines */
73#ifndef __LZODEFS_H_INCLUDED
74#include "lzodefs.h"
75#endif
76
77
78#ifdef __cplusplus
79extern "C" {
80#endif
81
82
83/***********************************************************************
84// some core defines
85************************************************************************/
86
87#if !defined(LZO_UINT32_C)
88#  if (UINT_MAX < LZO_0xffffffffL)
89#    define LZO_UINT32_C(c)     c ## UL
90#  else
91#    define LZO_UINT32_C(c)     ((c) + 0U)
92#  endif
93#endif
94
95/* memory checkers */
96#if !defined(__LZO_CHECKER)
97#  if defined(__BOUNDS_CHECKING_ON)
98#    define __LZO_CHECKER       1
99#  elif defined(__CHECKER__)
100#    define __LZO_CHECKER       1
101#  elif defined(__INSURE__)
102#    define __LZO_CHECKER       1
103#  elif defined(__PURIFY__)
104#    define __LZO_CHECKER       1
105#  endif
106#endif
107
108
109/***********************************************************************
110// integral and pointer types
111************************************************************************/
112
113/* lzo_uint should match size_t */
114#if !defined(LZO_UINT_MAX)
115#  if defined(LZO_ABI_LLP64) /* WIN64 */
116#    if defined(LZO_OS_WIN64)
117     typedef unsigned __int64   lzo_uint;
118     typedef __int64            lzo_int;
119#    else
120     typedef unsigned long long lzo_uint;
121     typedef long long          lzo_int;
122#    endif
123#    define LZO_UINT_MAX        0xffffffffffffffffull
124#    define LZO_INT_MAX         9223372036854775807LL
125#    define LZO_INT_MIN         (-1LL - LZO_INT_MAX)
126#  elif defined(LZO_ABI_IP32L64) /* MIPS R5900 */
127     typedef unsigned int       lzo_uint;
128     typedef int                lzo_int;
129#    define LZO_UINT_MAX        UINT_MAX
130#    define LZO_INT_MAX         INT_MAX
131#    define LZO_INT_MIN         INT_MIN
132#  elif (ULONG_MAX >= LZO_0xffffffffL)
133     typedef unsigned long      lzo_uint;
134     typedef long               lzo_int;
135#    define LZO_UINT_MAX        ULONG_MAX
136#    define LZO_INT_MAX         LONG_MAX
137#    define LZO_INT_MIN         LONG_MIN
138#  else
139#    error "lzo_uint"
140#  endif
141#endif
142
143/* Integral types with 32 bits or more. */
144#if !defined(LZO_UINT32_MAX)
145#  if (UINT_MAX >= LZO_0xffffffffL)
146     typedef unsigned int       lzo_uint32;
147     typedef int                lzo_int32;
148#    define LZO_UINT32_MAX      UINT_MAX
149#    define LZO_INT32_MAX       INT_MAX
150#    define LZO_INT32_MIN       INT_MIN
151#  elif (ULONG_MAX >= LZO_0xffffffffL)
152     typedef unsigned long      lzo_uint32;
153     typedef long               lzo_int32;
154#    define LZO_UINT32_MAX      ULONG_MAX
155#    define LZO_INT32_MAX       LONG_MAX
156#    define LZO_INT32_MIN       LONG_MIN
157#  else
158#    error "lzo_uint32"
159#  endif
160#endif
161
162/* The larger type of lzo_uint and lzo_uint32. */
163#if (LZO_UINT_MAX >= LZO_UINT32_MAX)
164#  define lzo_xint              lzo_uint
165#else
166#  define lzo_xint              lzo_uint32
167#endif
168
169/* Memory model that allows to access memory at offsets of lzo_uint. */
170#if !defined(__LZO_MMODEL)
171#  if (LZO_UINT_MAX <= UINT_MAX)
172#    define __LZO_MMODEL        /*empty*/
173#  elif defined(LZO_HAVE_MM_HUGE_PTR)
174#    define __LZO_MMODEL_HUGE   1
175#    define __LZO_MMODEL        __huge
176#  else
177#    define __LZO_MMODEL        /*empty*/
178#  endif
179#endif
180
181/* no typedef here because of const-pointer issues */
182#define lzo_bytep               unsigned char __LZO_MMODEL *
183#define lzo_charp               char __LZO_MMODEL *
184#define lzo_voidp               void __LZO_MMODEL *
185#define lzo_shortp              short __LZO_MMODEL *
186#define lzo_ushortp             unsigned short __LZO_MMODEL *
187#define lzo_uint32p             lzo_uint32 __LZO_MMODEL *
188#define lzo_int32p              lzo_int32 __LZO_MMODEL *
189#define lzo_uintp               lzo_uint __LZO_MMODEL *
190#define lzo_intp                lzo_int __LZO_MMODEL *
191#define lzo_xintp               lzo_xint __LZO_MMODEL *
192#define lzo_voidpp              lzo_voidp __LZO_MMODEL *
193#define lzo_bytepp              lzo_bytep __LZO_MMODEL *
194/* deprecated - use 'lzo_bytep' instead of 'lzo_byte *' */
195#define lzo_byte                unsigned char __LZO_MMODEL
196
197typedef int lzo_bool;
198
199
200/***********************************************************************
201// function types
202************************************************************************/
203
204/* name mangling */
205#if !defined(__LZO_EXTERN_C)
206#  ifdef __cplusplus
207#    define __LZO_EXTERN_C      extern "C"
208#  else
209#    define __LZO_EXTERN_C      extern
210#  endif
211#endif
212
213/* calling convention */
214#if !defined(__LZO_CDECL)
215#  define __LZO_CDECL           __lzo_cdecl
216#endif
217
218/* DLL export information */
219#if !defined(__LZO_EXPORT1)
220#  define __LZO_EXPORT1         /*empty*/
221#endif
222#if !defined(__LZO_EXPORT2)
223#  define __LZO_EXPORT2         /*empty*/
224#endif
225
226/* __cdecl calling convention for public C and assembly functions */
227#if !defined(LZO_PUBLIC)
228#  define LZO_PUBLIC(_rettype)  __LZO_EXPORT1 _rettype __LZO_EXPORT2 __LZO_CDECL
229#endif
230#if !defined(LZO_EXTERN)
231#  define LZO_EXTERN(_rettype)  __LZO_EXTERN_C LZO_PUBLIC(_rettype)
232#endif
233#if !defined(LZO_PRIVATE)
234#  define LZO_PRIVATE(_rettype) static _rettype __LZO_CDECL
235#endif
236
237/* function types */
238typedef int
239(__LZO_CDECL *lzo_compress_t)   ( const lzo_bytep src, lzo_uint  src_len,
240                                        lzo_bytep dst, lzo_uintp dst_len,
241                                        lzo_voidp wrkmem );
242
243typedef int
244(__LZO_CDECL *lzo_decompress_t) ( const lzo_bytep src, lzo_uint  src_len,
245                                        lzo_bytep dst, lzo_uintp dst_len,
246                                        lzo_voidp wrkmem );
247
248typedef int
249(__LZO_CDECL *lzo_optimize_t)   (       lzo_bytep src, lzo_uint  src_len,
250                                        lzo_bytep dst, lzo_uintp dst_len,
251                                        lzo_voidp wrkmem );
252
253typedef int
254(__LZO_CDECL *lzo_compress_dict_t)(const lzo_bytep src, lzo_uint  src_len,
255                                         lzo_bytep dst, lzo_uintp dst_len,
256                                         lzo_voidp wrkmem,
257                                   const lzo_bytep dict, lzo_uint dict_len );
258
259typedef int
260(__LZO_CDECL *lzo_decompress_dict_t)(const lzo_bytep src, lzo_uint  src_len,
261                                           lzo_bytep dst, lzo_uintp dst_len,
262                                           lzo_voidp wrkmem,
263                                     const lzo_bytep dict, lzo_uint dict_len );
264
265
266/* Callback interface. Currently only the progress indicator ("nprogress")
267 * is used, but this may change in a future release. */
268
269struct lzo_callback_t;
270typedef struct lzo_callback_t lzo_callback_t;
271#define lzo_callback_p lzo_callback_t __LZO_MMODEL *
272
273/* malloc & free function types */
274typedef lzo_voidp (__LZO_CDECL *lzo_alloc_func_t)
275    (lzo_callback_p self, lzo_uint items, lzo_uint size);
276typedef void      (__LZO_CDECL *lzo_free_func_t)
277    (lzo_callback_p self, lzo_voidp ptr);
278
279/* a progress indicator callback function */
280typedef void (__LZO_CDECL *lzo_progress_func_t)
281    (lzo_callback_p, lzo_uint, lzo_uint, int);
282
283struct lzo_callback_t
284{
285    /* custom allocators (set to 0 to disable) */
286    lzo_alloc_func_t nalloc;                /* [not used right now] */
287    lzo_free_func_t nfree;                  /* [not used right now] */
288
289    /* a progress indicator callback function (set to 0 to disable) */
290    lzo_progress_func_t nprogress;
291
292    /* NOTE: the first parameter "self" of the nalloc/nfree/nprogress
293     * callbacks points back to this struct, so you are free to store
294     * some extra info in the following variables. */
295    lzo_voidp user1;
296    lzo_xint user2;
297    lzo_xint user3;
298};
299
300
301/***********************************************************************
302// error codes and prototypes
303************************************************************************/
304
305/* Error codes for the compression/decompression functions. Negative
306 * values are errors, positive values will be used for special but
307 * normal events.
308 */
309#define LZO_E_OK                    0
310#define LZO_E_ERROR                 (-1)
311#define LZO_E_OUT_OF_MEMORY         (-2)    /* [not used right now] */
312#define LZO_E_NOT_COMPRESSIBLE      (-3)    /* [not used right now] */
313#define LZO_E_INPUT_OVERRUN         (-4)
314#define LZO_E_OUTPUT_OVERRUN        (-5)
315#define LZO_E_LOOKBEHIND_OVERRUN    (-6)
316#define LZO_E_EOF_NOT_FOUND         (-7)
317#define LZO_E_INPUT_NOT_CONSUMED    (-8)
318#define LZO_E_NOT_YET_IMPLEMENTED   (-9)    /* [not used right now] */
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),(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)
356    lzo_adler32(lzo_uint32 c, const lzo_bytep buf, lzo_uint len);
357LZO_EXTERN(lzo_uint32)
358    lzo_crc32(lzo_uint32 c, const lzo_bytep buf, lzo_uint len);
359LZO_EXTERN(const lzo_uint32p)
360    lzo_get_crc32_table(void);
361
362/* misc. */
363LZO_EXTERN(int) _lzo_config_check(void);
364typedef union { lzo_bytep p; lzo_uint u; } __lzo_pu_u;
365typedef union { lzo_bytep p; lzo_uint32 u32; } __lzo_pu32_u;
366typedef union { void *vp; lzo_bytep bp; lzo_uint u; lzo_uint32 u32; unsigned long l; } lzo_align_t;
367
368/* align a char pointer on a boundary that is a multiple of 'size' */
369LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp p, lzo_uint size);
370#define LZO_PTR_ALIGN_UP(p,size) \
371    ((p) + (lzo_uint) __lzo_align_gap((const lzo_voidp)(p),(lzo_uint)(size)))
372
373
374/***********************************************************************
375// deprecated macros - only for backward compatibility with LZO v1.xx
376************************************************************************/
377
378#if defined(LZO_CFG_COMPAT)
379
380#define __LZOCONF_H 1
381
382#if defined(LZO_ARCH_I086)
383#  define __LZO_i386 1
384#elif defined(LZO_ARCH_I386)
385#  define __LZO_i386 1
386#endif
387
388#if defined(LZO_OS_DOS16)
389#  define __LZO_DOS 1
390#  define __LZO_DOS16 1
391#elif defined(LZO_OS_DOS32)
392#  define __LZO_DOS 1
393#elif defined(LZO_OS_WIN16)
394#  define __LZO_WIN 1
395#  define __LZO_WIN16 1
396#elif defined(LZO_OS_WIN32)
397#  define __LZO_WIN 1
398#endif
399
400#define __LZO_CMODEL            /*empty*/
401#define __LZO_DMODEL            /*empty*/
402#define __LZO_ENTRY             __LZO_CDECL
403#define LZO_EXTERN_CDECL        LZO_EXTERN
404#define LZO_ALIGN               LZO_PTR_ALIGN_UP
405
406#define lzo_compress_asm_t      lzo_compress_t
407#define lzo_decompress_asm_t    lzo_decompress_t
408
409#endif /* LZO_CFG_COMPAT */
410
411
412#ifdef __cplusplus
413} /* extern "C" */
414#endif
415
416#endif /* already included */
417
418
419/* vim:set ts=4 et: */
420