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