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