lzoconf.h

Go to the documentation of this file.
00001 /* lzoconf.h -- configuration for the LZO real-time data compression library
00002 
00003    This file is part of the LZO real-time data compression library.
00004 
00005    Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer
00006    Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer
00007    Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer
00008    Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
00009    Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
00010    Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
00011    Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
00012    Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
00013    Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
00014    Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
00015    All Rights Reserved.
00016 
00017    The LZO library is free software; you can redistribute it and/or
00018    modify it under the terms of the GNU General Public License,
00019    version 2, as published by the Free Software Foundation.
00020 
00021    The LZO library is distributed in the hope that it will be useful,
00022    but WITHOUT ANY WARRANTY; without even the implied warranty of
00023    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00024    GNU General Public License for more details.
00025 
00026    You should have received a copy of the GNU General Public License
00027    along with the LZO library; see the file COPYING.
00028    If not, write to the Free Software Foundation, Inc.,
00029    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00030 
00031    Markus F.X.J. Oberhumer
00032    <markus@oberhumer.com>
00033    http://www.oberhumer.com/opensource/lzo/
00034  */
00035 
00036 
00037 #ifndef __LZOCONF_H_INCLUDED
00038 #define __LZOCONF_H_INCLUDED
00039 
00040 #define LZO_VERSION             0x2020
00041 #define LZO_VERSION_STRING      "2.02"
00042 #define LZO_VERSION_DATE        "Oct 17 2005"
00043 
00044 /* internal Autoconf configuration file - only used when building LZO */
00045 #if defined(LZO_HAVE_CONFIG_H)
00046 #  include <config.h>
00047 #endif
00048 #include <limits.h>
00049 #include <stddef.h>
00050 
00051 
00052 /***********************************************************************
00053 // LZO requires a conforming <limits.h>
00054 ************************************************************************/
00055 
00056 #if !defined(CHAR_BIT) || (CHAR_BIT != 8)
00057 #  error "invalid CHAR_BIT"
00058 #endif
00059 #if !defined(UCHAR_MAX) || !defined(UINT_MAX) || !defined(ULONG_MAX)
00060 #  error "check your compiler installation"
00061 #endif
00062 #if (USHRT_MAX < 1) || (UINT_MAX < 1) || (ULONG_MAX < 1)
00063 #  error "your limits.h macros are broken"
00064 #endif
00065 
00066 /* get OS and architecture defines */
00067 #ifndef __LZODEFS_H_INCLUDED
00068 #include "lzodefs.h"
00069 #endif
00070 
00071 
00072 #ifdef __cplusplus
00073 extern "C" {
00074 #endif
00075 
00076 
00077 /***********************************************************************
00078 // some core defines
00079 ************************************************************************/
00080 
00081 #if !defined(LZO_UINT32_C)
00082 #  if (UINT_MAX < LZO_0xffffffffL)
00083 #    define LZO_UINT32_C(c)     c ## UL
00084 #  else
00085 #    define LZO_UINT32_C(c)     ((c) + 0U)
00086 #  endif
00087 #endif
00088 
00089 /* memory checkers */
00090 #if !defined(__LZO_CHECKER)
00091 #  if defined(__BOUNDS_CHECKING_ON)
00092 #    define __LZO_CHECKER       1
00093 #  elif defined(__CHECKER__)
00094 #    define __LZO_CHECKER       1
00095 #  elif defined(__INSURE__)
00096 #    define __LZO_CHECKER       1
00097 #  elif defined(__PURIFY__)
00098 #    define __LZO_CHECKER       1
00099 #  endif
00100 #endif
00101 
00102 
00103 /***********************************************************************
00104 // integral and pointer types
00105 ************************************************************************/
00106 
00107 /* lzo_uint should match size_t */
00108 #if !defined(LZO_UINT_MAX)
00109 #  if defined(LZO_ABI_LLP64) /* WIN64 */
00110 #    if defined(LZO_OS_WIN64)
00111      typedef unsigned __int64   lzo_uint;
00112      typedef __int64            lzo_int;
00113 #    else
00114      typedef unsigned long long lzo_uint;
00115      typedef long long          lzo_int;
00116 #    endif
00117 #    define LZO_UINT_MAX        0xffffffffffffffffull
00118 #    define LZO_INT_MAX         9223372036854775807LL
00119 #    define LZO_INT_MIN         (-1LL - LZO_INT_MAX)
00120 #  elif defined(LZO_ABI_IP32L64) /* MIPS R5900 */
00121      typedef unsigned int       lzo_uint;
00122      typedef int                lzo_int;
00123 #    define LZO_UINT_MAX        UINT_MAX
00124 #    define LZO_INT_MAX         INT_MAX
00125 #    define LZO_INT_MIN         INT_MIN
00126 #  elif (ULONG_MAX >= LZO_0xffffffffL)
00127      typedef unsigned long      lzo_uint;
00128      typedef long               lzo_int;
00129 #    define LZO_UINT_MAX        ULONG_MAX
00130 #    define LZO_INT_MAX         LONG_MAX
00131 #    define LZO_INT_MIN         LONG_MIN
00132 #  else
00133 #    error "lzo_uint"
00134 #  endif
00135 #endif
00136 
00137 /* Integral types with 32 bits or more. */
00138 #if !defined(LZO_UINT32_MAX)
00139 #  if (UINT_MAX >= LZO_0xffffffffL)
00140      typedef unsigned int       lzo_uint32;
00141      typedef int                lzo_int32;
00142 #    define LZO_UINT32_MAX      UINT_MAX
00143 #    define LZO_INT32_MAX       INT_MAX
00144 #    define LZO_INT32_MIN       INT_MIN
00145 #  elif (ULONG_MAX >= LZO_0xffffffffL)
00146      typedef unsigned long      lzo_uint32;
00147      typedef long               lzo_int32;
00148 #    define LZO_UINT32_MAX      ULONG_MAX
00149 #    define LZO_INT32_MAX       LONG_MAX
00150 #    define LZO_INT32_MIN       LONG_MIN
00151 #  else
00152 #    error "lzo_uint32"
00153 #  endif
00154 #endif
00155 
00156 /* The larger type of lzo_uint and lzo_uint32. */
00157 #if (LZO_UINT_MAX >= LZO_UINT32_MAX)
00158 #  define lzo_xint              lzo_uint
00159 #else
00160 #  define lzo_xint              lzo_uint32
00161 #endif
00162 
00163 /* Memory model that allows to access memory at offsets of lzo_uint. */
00164 #if !defined(__LZO_MMODEL)
00165 #  if (LZO_UINT_MAX <= UINT_MAX)
00166 #    define __LZO_MMODEL
00167 #  elif defined(LZO_HAVE_MM_HUGE_PTR)
00168 #    define __LZO_MMODEL_HUGE   1
00169 #    define __LZO_MMODEL        __huge
00170 #  else
00171 #    define __LZO_MMODEL
00172 #  endif
00173 #endif
00174 
00175 /* no typedef here because of const-pointer issues */
00176 #define lzo_bytep               unsigned char __LZO_MMODEL *
00177 #define lzo_charp               char __LZO_MMODEL *
00178 #define lzo_voidp               void __LZO_MMODEL *
00179 #define lzo_shortp              short __LZO_MMODEL *
00180 #define lzo_ushortp             unsigned short __LZO_MMODEL *
00181 #define lzo_uint32p             lzo_uint32 __LZO_MMODEL *
00182 #define lzo_int32p              lzo_int32 __LZO_MMODEL *
00183 #define lzo_uintp               lzo_uint __LZO_MMODEL *
00184 #define lzo_intp                lzo_int __LZO_MMODEL *
00185 #define lzo_xintp               lzo_xint __LZO_MMODEL *
00186 #define lzo_voidpp              lzo_voidp __LZO_MMODEL *
00187 #define lzo_bytepp              lzo_bytep __LZO_MMODEL *
00188 /* deprecated - use `lzo_bytep' instead of `lzo_byte *' */
00189 #define lzo_byte                unsigned char __LZO_MMODEL
00190 
00191 typedef int lzo_bool;
00192 
00193 
00194 /***********************************************************************
00195 // function types
00196 ************************************************************************/
00197 
00198 /* name mangling */
00199 #if !defined(__LZO_EXTERN_C)
00200 #  ifdef __cplusplus
00201 #    define __LZO_EXTERN_C      extern "C"
00202 #  else
00203 #    define __LZO_EXTERN_C      extern
00204 #  endif
00205 #endif
00206 
00207 /* calling convention */
00208 #if !defined(__LZO_CDECL)
00209 #  define __LZO_CDECL           __lzo_cdecl
00210 #endif
00211 
00212 /* DLL export information */
00213 #if !defined(__LZO_EXPORT1)
00214 #  define __LZO_EXPORT1
00215 #endif
00216 #if !defined(__LZO_EXPORT2)
00217 #  define __LZO_EXPORT2
00218 #endif
00219 
00220 /* __cdecl calling convention for public C and assembly functions */
00221 #if !defined(LZO_PUBLIC)
00222 #  define LZO_PUBLIC(_rettype)  __LZO_EXPORT1 _rettype __LZO_EXPORT2 __LZO_CDECL
00223 #endif
00224 #if !defined(LZO_EXTERN)
00225 #  define LZO_EXTERN(_rettype)  __LZO_EXTERN_C LZO_PUBLIC(_rettype)
00226 #endif
00227 #if !defined(LZO_PRIVATE)
00228 #  define LZO_PRIVATE(_rettype) static _rettype __LZO_CDECL
00229 #endif
00230 
00231 /* function types */
00232 typedef int
00233 (__LZO_CDECL *lzo_compress_t)   ( const lzo_bytep src, lzo_uint  src_len,
00234                                         lzo_bytep dst, lzo_uintp dst_len,
00235                                         lzo_voidp wrkmem );
00236 
00237 typedef int
00238 (__LZO_CDECL *lzo_decompress_t) ( const lzo_bytep src, lzo_uint  src_len,
00239                                         lzo_bytep dst, lzo_uintp dst_len,
00240                                         lzo_voidp wrkmem );
00241 
00242 typedef int
00243 (__LZO_CDECL *lzo_optimize_t)   (       lzo_bytep src, lzo_uint  src_len,
00244                                         lzo_bytep dst, lzo_uintp dst_len,
00245                                         lzo_voidp wrkmem );
00246 
00247 typedef int
00248 (__LZO_CDECL *lzo_compress_dict_t)(const lzo_bytep src, lzo_uint  src_len,
00249                                          lzo_bytep dst, lzo_uintp dst_len,
00250                                          lzo_voidp wrkmem,
00251                                    const lzo_bytep dict, lzo_uint dict_len );
00252 
00253 typedef int
00254 (__LZO_CDECL *lzo_decompress_dict_t)(const lzo_bytep src, lzo_uint  src_len,
00255                                            lzo_bytep dst, lzo_uintp dst_len,
00256                                            lzo_voidp wrkmem,
00257                                      const lzo_bytep dict, lzo_uint dict_len );
00258 
00259 
00260 /* Callback interface. Currently only the progress indicator ("nprogress")
00261  * is used, but this may change in a future release. */
00262 
00263 struct lzo_callback_t;
00264 typedef struct lzo_callback_t lzo_callback_t;
00265 #define lzo_callback_p lzo_callback_t __LZO_MMODEL *
00266 
00267 /* malloc & free function types */
00268 typedef lzo_voidp (__LZO_CDECL *lzo_alloc_func_t)
00269     (lzo_callback_p self, lzo_uint items, lzo_uint size);
00270 typedef void      (__LZO_CDECL *lzo_free_func_t)
00271     (lzo_callback_p self, lzo_voidp ptr);
00272 
00273 /* a progress indicator callback function */
00274 typedef void (__LZO_CDECL *lzo_progress_func_t)
00275     (lzo_callback_p, lzo_uint, lzo_uint, int);
00276 
00277 struct lzo_callback_t
00278 {
00279     /* custom allocators (set to 0 to disable) */
00280     lzo_alloc_func_t nalloc;                /* [not used right now] */
00281     lzo_free_func_t nfree;                  /* [not used right now] */
00282 
00283     /* a progress indicator callback function (set to 0 to disable) */
00284     lzo_progress_func_t nprogress;
00285 
00286     /* NOTE: the first parameter "self" of the nalloc/nfree/nprogress
00287      * callbacks points back to this struct, so you are free to store
00288      * some extra info in the following variables. */
00289     lzo_voidp user1;
00290     lzo_xint user2;
00291     lzo_xint user3;
00292 };
00293 
00294 
00295 /***********************************************************************
00296 // error codes and prototypes
00297 ************************************************************************/
00298 
00299 /* Error codes for the compression/decompression functions. Negative
00300  * values are errors, positive values will be used for special but
00301  * normal events.
00302  */
00303 #define LZO_E_OK                    0
00304 #define LZO_E_ERROR                 (-1)
00305 #define LZO_E_OUT_OF_MEMORY         (-2)    /* [not used right now] */
00306 #define LZO_E_NOT_COMPRESSIBLE      (-3)    /* [not used right now] */
00307 #define LZO_E_INPUT_OVERRUN         (-4)
00308 #define LZO_E_OUTPUT_OVERRUN        (-5)
00309 #define LZO_E_LOOKBEHIND_OVERRUN    (-6)
00310 #define LZO_E_EOF_NOT_FOUND         (-7)
00311 #define LZO_E_INPUT_NOT_CONSUMED    (-8)
00312 #define LZO_E_NOT_YET_IMPLEMENTED   (-9)    /* [not used right now] */
00313 
00314 
00315 #ifndef lzo_sizeof_dict_t
00316 #  define lzo_sizeof_dict_t     ((unsigned)sizeof(lzo_bytep))
00317 #endif
00318 
00319 /* lzo_init() should be the first function you call.
00320  * Check the return code !
00321  *
00322  * lzo_init() is a macro to allow checking that the library and the
00323  * compiler's view of various types are consistent.
00324  */
00325 #define lzo_init() __lzo_init_v2(LZO_VERSION,(int)sizeof(short),(int)sizeof(int),\
00326     (int)sizeof(long),(int)sizeof(lzo_uint32),(int)sizeof(lzo_uint),\
00327     (int)lzo_sizeof_dict_t,(int)sizeof(char *),(int)sizeof(lzo_voidp),\
00328     (int)sizeof(lzo_callback_t))
00329 LZO_EXTERN(int) __lzo_init_v2(unsigned,int,int,int,int,int,int,int,int,int);
00330 
00331 /* version functions (useful for shared libraries) */
00332 LZO_EXTERN(unsigned) lzo_version(void);
00333 LZO_EXTERN(const char *) lzo_version_string(void);
00334 LZO_EXTERN(const char *) lzo_version_date(void);
00335 LZO_EXTERN(const lzo_charp) _lzo_version_string(void);
00336 LZO_EXTERN(const lzo_charp) _lzo_version_date(void);
00337 
00338 /* string functions */
00339 LZO_EXTERN(int)
00340 lzo_memcmp(const lzo_voidp _s1, const lzo_voidp _s2, lzo_uint _len);
00341 LZO_EXTERN(lzo_voidp)
00342 lzo_memcpy(lzo_voidp _dest, const lzo_voidp _src, lzo_uint _len);
00343 LZO_EXTERN(lzo_voidp)
00344 lzo_memmove(lzo_voidp _dest, const lzo_voidp _src, lzo_uint _len);
00345 LZO_EXTERN(lzo_voidp)
00346 lzo_memset(lzo_voidp _s, int _c, lzo_uint _len);
00347 
00348 /* checksum functions */
00349 LZO_EXTERN(lzo_uint32)
00350 lzo_adler32(lzo_uint32 _adler, const lzo_bytep _buf, lzo_uint _len);
00351 LZO_EXTERN(lzo_uint32)
00352 lzo_crc32(lzo_uint32 _c, const lzo_bytep _buf, lzo_uint _len);
00353 LZO_EXTERN(const lzo_uint32p)
00354 lzo_get_crc32_table(void);
00355 
00356 /* misc. */
00357 LZO_EXTERN(int) _lzo_config_check(void);
00358 typedef union { lzo_bytep p; lzo_uint u; } __lzo_pu_u;
00359 typedef union { lzo_bytep p; lzo_uint32 u32; } __lzo_pu32_u;
00360 typedef union { void *vp; lzo_bytep bp; lzo_uint32 u32; long l; } lzo_align_t;
00361 
00362 /* align a char pointer on a boundary that is a multiple of `size' */
00363 LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp _ptr, lzo_uint _size);
00364 #define LZO_PTR_ALIGN_UP(_ptr,_size) \
00365     ((_ptr) + (lzo_uint) __lzo_align_gap((const lzo_voidp)(_ptr),(lzo_uint)(_size)))
00366 
00367 
00368 /***********************************************************************
00369 // deprecated macros - only for backward compatibility with LZO v1.xx
00370 ************************************************************************/
00371 
00372 #if defined(LZO_CFG_COMPAT)
00373 
00374 #define __LZOCONF_H 1
00375 
00376 #if defined(LZO_ARCH_I086)
00377 #  define __LZO_i386 1
00378 #elif defined(LZO_ARCH_I386)
00379 #  define __LZO_i386 1
00380 #endif
00381 
00382 #if defined(LZO_OS_DOS16)
00383 #  define __LZO_DOS 1
00384 #  define __LZO_DOS16 1
00385 #elif defined(LZO_OS_DOS32)
00386 #  define __LZO_DOS 1
00387 #elif defined(LZO_OS_WIN16)
00388 #  define __LZO_WIN 1
00389 #  define __LZO_WIN16 1
00390 #elif defined(LZO_OS_WIN32)
00391 #  define __LZO_WIN 1
00392 #endif
00393 
00394 #define __LZO_CMODEL
00395 #define __LZO_DMODEL
00396 #define __LZO_ENTRY             __LZO_CDECL
00397 #define LZO_EXTERN_CDECL        LZO_EXTERN
00398 #define LZO_ALIGN               LZO_PTR_ALIGN_UP
00399 
00400 #define lzo_compress_asm_t      lzo_compress_t
00401 #define lzo_decompress_asm_t    lzo_decompress_t
00402 
00403 #endif /* LZO_CFG_COMPAT */
00404 
00405 
00406 #ifdef __cplusplus
00407 } /* extern "C" */
00408 #endif
00409 
00410 #endif /* already included */
00411 
00412 
00413 /* vim:set ts=4 et: */