1/* minilzo.c -- mini subset of 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 * NOTE: 42 * the full LZO package can be found at 43 * http://www.oberhumer.com/opensource/lzo/ 44 */ 45 46#define __LZO_IN_MINILZO 47#define LZO_BUILD 48 49#if defined(LZO_CFG_FREESTANDING) 50# undef MINILZO_HAVE_CONFIG_H 51# define LZO_LIBC_FREESTANDING 1 52# define LZO_OS_FREESTANDING 1 53#endif 54 55#ifdef MINILZO_HAVE_CONFIG_H 56# include <config.h> 57#endif 58#include <limits.h> 59#include <stddef.h> 60#if defined(MINILZO_CFG_USE_INTERNAL_LZODEFS) 61 62#ifndef __LZODEFS_H_INCLUDED 63#define __LZODEFS_H_INCLUDED 1 64 65#if defined(__CYGWIN32__) && !defined(__CYGWIN__) 66# define __CYGWIN__ __CYGWIN32__ 67#endif 68#if defined(__IBMCPP__) && !defined(__IBMC__) 69# define __IBMC__ __IBMCPP__ 70#endif 71#if defined(__ICL) && defined(_WIN32) && !defined(__INTEL_COMPILER) 72# define __INTEL_COMPILER __ICL 73#endif 74#if 1 && defined(__INTERIX) && defined(__GNUC__) && !defined(_ALL_SOURCE) 75# define _ALL_SOURCE 1 76#endif 77#if defined(__mips__) && defined(__R5900__) 78# if !defined(__LONG_MAX__) 79# define __LONG_MAX__ 9223372036854775807L 80# endif 81#endif 82#if defined(__INTEL_COMPILER) && defined(__linux__) 83# pragma warning(disable: 193) 84#endif 85#if defined(__KEIL__) && defined(__C166__) 86# pragma warning disable = 322 87#elif 0 && defined(__C251__) 88# pragma warning disable = 322 89#endif 90#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__) 91# if (_MSC_VER >= 1300) 92# pragma warning(disable: 4668) 93# endif 94#endif 95#if 0 && defined(__WATCOMC__) 96# if (__WATCOMC__ >= 1050) && (__WATCOMC__ < 1060) 97# pragma warning 203 9 98# endif 99#endif 100#if defined(__BORLANDC__) && defined(__MSDOS__) && !defined(__FLAT__) 101# pragma option -h 102#endif 103#if 0 104#define LZO_0xffffL 0xfffful 105#define LZO_0xffffffffL 0xfffffffful 106#else 107#define LZO_0xffffL 65535ul 108#define LZO_0xffffffffL 4294967295ul 109#endif 110#if (LZO_0xffffL == LZO_0xffffffffL) 111# error "your preprocessor is broken 1" 112#endif 113#if (16ul * 16384ul != 262144ul) 114# error "your preprocessor is broken 2" 115#endif 116#if 0 117#if (32767 >= 4294967295ul) 118# error "your preprocessor is broken 3" 119#endif 120#if (65535u >= 4294967295ul) 121# error "your preprocessor is broken 4" 122#endif 123#endif 124#if (UINT_MAX == LZO_0xffffL) 125#if defined(__ZTC__) && defined(__I86__) && !defined(__OS2__) 126# if !defined(MSDOS) 127# define MSDOS 1 128# endif 129# if !defined(_MSDOS) 130# define _MSDOS 1 131# endif 132#elif 0 && defined(__VERSION) && defined(MB_LEN_MAX) 133# if (__VERSION == 520) && (MB_LEN_MAX == 1) 134# if !defined(__AZTEC_C__) 135# define __AZTEC_C__ __VERSION 136# endif 137# if !defined(__DOS__) 138# define __DOS__ 1 139# endif 140# endif 141#endif 142#endif 143#if defined(_MSC_VER) && defined(M_I86HM) && (UINT_MAX == LZO_0xffffL) 144# define ptrdiff_t long 145# define _PTRDIFF_T_DEFINED 146#endif 147#if (UINT_MAX == LZO_0xffffL) 148# undef __LZO_RENAME_A 149# undef __LZO_RENAME_B 150# if defined(__AZTEC_C__) && defined(__DOS__) 151# define __LZO_RENAME_A 1 152# elif defined(_MSC_VER) && defined(MSDOS) 153# if (_MSC_VER < 600) 154# define __LZO_RENAME_A 1 155# elif (_MSC_VER < 700) 156# define __LZO_RENAME_B 1 157# endif 158# elif defined(__TSC__) && defined(__OS2__) 159# define __LZO_RENAME_A 1 160# elif defined(__MSDOS__) && defined(__TURBOC__) && (__TURBOC__ < 0x0410) 161# define __LZO_RENAME_A 1 162# elif defined(__PACIFIC__) && defined(DOS) 163# if !defined(__far) 164# define __far far 165# endif 166# if !defined(__near) 167# define __near near 168# endif 169# endif 170# if defined(__LZO_RENAME_A) 171# if !defined(__cdecl) 172# define __cdecl cdecl 173# endif 174# if !defined(__far) 175# define __far far 176# endif 177# if !defined(__huge) 178# define __huge huge 179# endif 180# if !defined(__near) 181# define __near near 182# endif 183# if !defined(__pascal) 184# define __pascal pascal 185# endif 186# if !defined(__huge) 187# define __huge huge 188# endif 189# elif defined(__LZO_RENAME_B) 190# if !defined(__cdecl) 191# define __cdecl _cdecl 192# endif 193# if !defined(__far) 194# define __far _far 195# endif 196# if !defined(__huge) 197# define __huge _huge 198# endif 199# if !defined(__near) 200# define __near _near 201# endif 202# if !defined(__pascal) 203# define __pascal _pascal 204# endif 205# elif (defined(__PUREC__) || defined(__TURBOC__)) && defined(__TOS__) 206# if !defined(__cdecl) 207# define __cdecl cdecl 208# endif 209# if !defined(__pascal) 210# define __pascal pascal 211# endif 212# endif 213# undef __LZO_RENAME_A 214# undef __LZO_RENAME_B 215#endif 216#if (UINT_MAX == LZO_0xffffL) 217#if defined(__AZTEC_C__) && defined(__DOS__) 218# define LZO_BROKEN_CDECL_ALT_SYNTAX 1 219#elif defined(_MSC_VER) && defined(MSDOS) 220# if (_MSC_VER < 600) 221# define LZO_BROKEN_INTEGRAL_CONSTANTS 1 222# endif 223# if (_MSC_VER < 700) 224# define LZO_BROKEN_INTEGRAL_PROMOTION 1 225# define LZO_BROKEN_SIZEOF 1 226# endif 227#elif defined(__PACIFIC__) && defined(DOS) 228# define LZO_BROKEN_INTEGRAL_CONSTANTS 1 229#elif defined(__TURBOC__) && defined(__MSDOS__) 230# if (__TURBOC__ < 0x0150) 231# define LZO_BROKEN_CDECL_ALT_SYNTAX 1 232# define LZO_BROKEN_INTEGRAL_CONSTANTS 1 233# define LZO_BROKEN_INTEGRAL_PROMOTION 1 234# endif 235# if (__TURBOC__ < 0x0200) 236# define LZO_BROKEN_SIZEOF 1 237# endif 238# if (__TURBOC__ < 0x0400) && defined(__cplusplus) 239# define LZO_BROKEN_CDECL_ALT_SYNTAX 1 240# endif 241#elif (defined(__PUREC__) || defined(__TURBOC__)) && defined(__TOS__) 242# define LZO_BROKEN_CDECL_ALT_SYNTAX 1 243# define LZO_BROKEN_SIZEOF 1 244#endif 245#endif 246#if defined(__WATCOMC__) && (__WATCOMC__ < 900) 247# define LZO_BROKEN_INTEGRAL_CONSTANTS 1 248#endif 249#if defined(_CRAY) && defined(_CRAY1) 250# define LZO_BROKEN_SIGNED_RIGHT_SHIFT 1 251#endif 252#define LZO_PP_STRINGIZE(x) #x 253#define LZO_PP_MACRO_EXPAND(x) LZO_PP_STRINGIZE(x) 254#define LZO_PP_CONCAT2(a,b) a ## b 255#define LZO_PP_CONCAT3(a,b,c) a ## b ## c 256#define LZO_PP_CONCAT4(a,b,c,d) a ## b ## c ## d 257#define LZO_PP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e 258#define LZO_PP_ECONCAT2(a,b) LZO_PP_CONCAT2(a,b) 259#define LZO_PP_ECONCAT3(a,b,c) LZO_PP_CONCAT3(a,b,c) 260#define LZO_PP_ECONCAT4(a,b,c,d) LZO_PP_CONCAT4(a,b,c,d) 261#define LZO_PP_ECONCAT5(a,b,c,d,e) LZO_PP_CONCAT5(a,b,c,d,e) 262#if 1 263#define LZO_CPP_STRINGIZE(x) #x 264#define LZO_CPP_MACRO_EXPAND(x) LZO_CPP_STRINGIZE(x) 265#define LZO_CPP_CONCAT2(a,b) a ## b 266#define LZO_CPP_CONCAT3(a,b,c) a ## b ## c 267#define LZO_CPP_CONCAT4(a,b,c,d) a ## b ## c ## d 268#define LZO_CPP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e 269#define LZO_CPP_ECONCAT2(a,b) LZO_CPP_CONCAT2(a,b) 270#define LZO_CPP_ECONCAT3(a,b,c) LZO_CPP_CONCAT3(a,b,c) 271#define LZO_CPP_ECONCAT4(a,b,c,d) LZO_CPP_CONCAT4(a,b,c,d) 272#define LZO_CPP_ECONCAT5(a,b,c,d,e) LZO_CPP_CONCAT5(a,b,c,d,e) 273#endif 274#define __LZO_MASK_GEN(o,b) (((((o) << ((b)-1)) - (o)) << 1) + (o)) 275#if 1 && defined(__cplusplus) 276# if !defined(__STDC_CONSTANT_MACROS) 277# define __STDC_CONSTANT_MACROS 1 278# endif 279# if !defined(__STDC_LIMIT_MACROS) 280# define __STDC_LIMIT_MACROS 1 281# endif 282#endif 283#if defined(__cplusplus) 284# define LZO_EXTERN_C extern "C" 285#else 286# define LZO_EXTERN_C extern 287#endif 288#if !defined(__LZO_OS_OVERRIDE) 289#if defined(LZO_OS_FREESTANDING) 290# define LZO_INFO_OS "freestanding" 291#elif defined(LZO_OS_EMBEDDED) 292# define LZO_INFO_OS "embedded" 293#elif 1 && defined(__IAR_SYSTEMS_ICC__) 294# define LZO_OS_EMBEDDED 1 295# define LZO_INFO_OS "embedded" 296#elif defined(__CYGWIN__) && defined(__GNUC__) 297# define LZO_OS_CYGWIN 1 298# define LZO_INFO_OS "cygwin" 299#elif defined(__EMX__) && defined(__GNUC__) 300# define LZO_OS_EMX 1 301# define LZO_INFO_OS "emx" 302#elif defined(__BEOS__) 303# define LZO_OS_BEOS 1 304# define LZO_INFO_OS "beos" 305#elif defined(__Lynx__) 306# define LZO_OS_LYNXOS 1 307# define LZO_INFO_OS "lynxos" 308#elif defined(__OS400__) 309# define LZO_OS_OS400 1 310# define LZO_INFO_OS "os400" 311#elif defined(__QNX__) 312# define LZO_OS_QNX 1 313# define LZO_INFO_OS "qnx" 314#elif defined(__BORLANDC__) && defined(__DPMI32__) && (__BORLANDC__ >= 0x0460) 315# define LZO_OS_DOS32 1 316# define LZO_INFO_OS "dos32" 317#elif defined(__BORLANDC__) && defined(__DPMI16__) 318# define LZO_OS_DOS16 1 319# define LZO_INFO_OS "dos16" 320#elif defined(__ZTC__) && defined(DOS386) 321# define LZO_OS_DOS32 1 322# define LZO_INFO_OS "dos32" 323#elif defined(__OS2__) || defined(__OS2V2__) 324# if (UINT_MAX == LZO_0xffffL) 325# define LZO_OS_OS216 1 326# define LZO_INFO_OS "os216" 327# elif (UINT_MAX == LZO_0xffffffffL) 328# define LZO_OS_OS2 1 329# define LZO_INFO_OS "os2" 330# else 331# error "check your limits.h header" 332# endif 333#elif defined(__WIN64__) || defined(_WIN64) || defined(WIN64) 334# define LZO_OS_WIN64 1 335# define LZO_INFO_OS "win64" 336#elif defined(__WIN32__) || defined(_WIN32) || defined(WIN32) || defined(__WINDOWS_386__) 337# define LZO_OS_WIN32 1 338# define LZO_INFO_OS "win32" 339#elif defined(__MWERKS__) && defined(__INTEL__) 340# define LZO_OS_WIN32 1 341# define LZO_INFO_OS "win32" 342#elif defined(__WINDOWS__) || defined(_WINDOWS) || defined(_Windows) 343# if (UINT_MAX == LZO_0xffffL) 344# define LZO_OS_WIN16 1 345# define LZO_INFO_OS "win16" 346# elif (UINT_MAX == LZO_0xffffffffL) 347# define LZO_OS_WIN32 1 348# define LZO_INFO_OS "win32" 349# else 350# error "check your limits.h header" 351# endif 352#elif defined(__DOS__) || defined(__MSDOS__) || defined(_MSDOS) || defined(MSDOS) || (defined(__PACIFIC__) && defined(DOS)) 353# if (UINT_MAX == LZO_0xffffL) 354# define LZO_OS_DOS16 1 355# define LZO_INFO_OS "dos16" 356# elif (UINT_MAX == LZO_0xffffffffL) 357# define LZO_OS_DOS32 1 358# define LZO_INFO_OS "dos32" 359# else 360# error "check your limits.h header" 361# endif 362#elif defined(__WATCOMC__) 363# if defined(__NT__) && (UINT_MAX == LZO_0xffffL) 364# define LZO_OS_DOS16 1 365# define LZO_INFO_OS "dos16" 366# elif defined(__NT__) && (__WATCOMC__ < 1100) 367# define LZO_OS_WIN32 1 368# define LZO_INFO_OS "win32" 369# elif defined(__linux__) || defined(__LINUX__) 370# define LZO_OS_POSIX 1 371# define LZO_INFO_OS "posix" 372# else 373# error "please specify a target using the -bt compiler option" 374# endif 375#elif defined(__palmos__) 376# define LZO_OS_PALMOS 1 377# define LZO_INFO_OS "palmos" 378#elif defined(__TOS__) || defined(__atarist__) 379# define LZO_OS_TOS 1 380# define LZO_INFO_OS "tos" 381#elif defined(macintosh) && !defined(__ppc__) 382# define LZO_OS_MACCLASSIC 1 383# define LZO_INFO_OS "macclassic" 384#elif defined(__VMS) 385# define LZO_OS_VMS 1 386# define LZO_INFO_OS "vms" 387#elif ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) 388# define LZO_OS_CONSOLE 1 389# define LZO_OS_CONSOLE_PS2 1 390# define LZO_INFO_OS "console" 391# define LZO_INFO_OS_CONSOLE "ps2" 392#elif (defined(__mips__) && defined(__psp__)) 393# define LZO_OS_CONSOLE 1 394# define LZO_OS_CONSOLE_PSP 1 395# define LZO_INFO_OS "console" 396# define LZO_INFO_OS_CONSOLE "psp" 397#else 398# define LZO_OS_POSIX 1 399# define LZO_INFO_OS "posix" 400#endif 401#if (LZO_OS_POSIX) 402# if defined(_AIX) || defined(__AIX__) || defined(__aix__) 403# define LZO_OS_POSIX_AIX 1 404# define LZO_INFO_OS_POSIX "aix" 405# elif defined(__FreeBSD__) 406# define LZO_OS_POSIX_FREEBSD 1 407# define LZO_INFO_OS_POSIX "freebsd" 408# elif defined(__hpux__) || defined(__hpux) 409# define LZO_OS_POSIX_HPUX 1 410# define LZO_INFO_OS_POSIX "hpux" 411# elif defined(__INTERIX) 412# define LZO_OS_POSIX_INTERIX 1 413# define LZO_INFO_OS_POSIX "interix" 414# elif defined(__IRIX__) || defined(__irix__) 415# define LZO_OS_POSIX_IRIX 1 416# define LZO_INFO_OS_POSIX "irix" 417# elif defined(__linux__) || defined(__linux) || defined(__LINUX__) 418# define LZO_OS_POSIX_LINUX 1 419# define LZO_INFO_OS_POSIX "linux" 420# elif defined(__APPLE__) || defined(__MACOS__) 421# define LZO_OS_POSIX_MACOSX 1 422# define LZO_INFO_OS_POSIX "macosx" 423# elif defined(__minix__) || defined(__minix) 424# define LZO_OS_POSIX_MINIX 1 425# define LZO_INFO_OS_POSIX "minix" 426# elif defined(__NetBSD__) 427# define LZO_OS_POSIX_NETBSD 1 428# define LZO_INFO_OS_POSIX "netbsd" 429# elif defined(__OpenBSD__) 430# define LZO_OS_POSIX_OPENBSD 1 431# define LZO_INFO_OS_POSIX "openbsd" 432# elif defined(__osf__) 433# define LZO_OS_POSIX_OSF 1 434# define LZO_INFO_OS_POSIX "osf" 435# elif defined(__solaris__) || defined(__sun) 436# if defined(__SVR4) || defined(__svr4__) 437# define LZO_OS_POSIX_SOLARIS 1 438# define LZO_INFO_OS_POSIX "solaris" 439# else 440# define LZO_OS_POSIX_SUNOS 1 441# define LZO_INFO_OS_POSIX "sunos" 442# endif 443# elif defined(__ultrix__) || defined(__ultrix) 444# define LZO_OS_POSIX_ULTRIX 1 445# define LZO_INFO_OS_POSIX "ultrix" 446# elif defined(_UNICOS) 447# define LZO_OS_POSIX_UNICOS 1 448# define LZO_INFO_OS_POSIX "unicos" 449# else 450# define LZO_OS_POSIX_UNKNOWN 1 451# define LZO_INFO_OS_POSIX "unknown" 452# endif 453#endif 454#endif 455#if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) 456# if (UINT_MAX != LZO_0xffffL) 457# error "this should not happen" 458# endif 459# if (ULONG_MAX != LZO_0xffffffffL) 460# error "this should not happen" 461# endif 462#endif 463#if (LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_WIN32 || LZO_OS_WIN64) 464# if (UINT_MAX != LZO_0xffffffffL) 465# error "this should not happen" 466# endif 467# if (ULONG_MAX != LZO_0xffffffffL) 468# error "this should not happen" 469# endif 470#endif 471#if defined(CIL) && defined(_GNUCC) && defined(__GNUC__) 472# define LZO_CC_CILLY 1 473# define LZO_INFO_CC "Cilly" 474# if defined(__CILLY__) 475# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__CILLY__) 476# else 477# define LZO_INFO_CCVER "unknown" 478# endif 479#elif 0 && defined(SDCC) && defined(__VERSION__) && !defined(__GNUC__) 480# define LZO_CC_SDCC 1 481# define LZO_INFO_CC "sdcc" 482# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(SDCC) 483#elif defined(__PATHSCALE__) && defined(__PATHCC_PATCHLEVEL__) 484# define LZO_CC_PATHSCALE (__PATHCC__ * 0x10000L + __PATHCC_MINOR__ * 0x100 + __PATHCC_PATCHLEVEL__) 485# define LZO_INFO_CC "Pathscale C" 486# define LZO_INFO_CCVER __PATHSCALE__ 487#elif defined(__INTEL_COMPILER) 488# define LZO_CC_INTELC 1 489# define LZO_INFO_CC "Intel C" 490# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__INTEL_COMPILER) 491# if defined(_WIN32) || defined(_WIN64) 492# define LZO_CC_SYNTAX_MSC 1 493# else 494# define LZO_CC_SYNTAX_GNUC 1 495# endif 496#elif defined(__POCC__) && defined(_WIN32) 497# define LZO_CC_PELLESC 1 498# define LZO_INFO_CC "Pelles C" 499# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__POCC__) 500#elif defined(__llvm__) && defined(__GNUC__) && defined(__VERSION__) 501# if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) 502# define LZO_CC_LLVM (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) 503# else 504# define LZO_CC_LLVM (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) 505# endif 506# define LZO_INFO_CC "llvm-gcc" 507# define LZO_INFO_CCVER __VERSION__ 508#elif defined(__GNUC__) && defined(__VERSION__) 509# if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) 510# define LZO_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) 511# elif defined(__GNUC_MINOR__) 512# define LZO_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) 513# else 514# define LZO_CC_GNUC (__GNUC__ * 0x10000L) 515# endif 516# define LZO_INFO_CC "gcc" 517# define LZO_INFO_CCVER __VERSION__ 518#elif defined(__ACK__) && defined(_ACK) 519# define LZO_CC_ACK 1 520# define LZO_INFO_CC "Amsterdam Compiler Kit C" 521# define LZO_INFO_CCVER "unknown" 522#elif defined(__AZTEC_C__) 523# define LZO_CC_AZTECC 1 524# define LZO_INFO_CC "Aztec C" 525# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__AZTEC_C__) 526#elif defined(__BORLANDC__) 527# define LZO_CC_BORLANDC 1 528# define LZO_INFO_CC "Borland C" 529# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__BORLANDC__) 530#elif defined(_CRAYC) && defined(_RELEASE) 531# define LZO_CC_CRAYC 1 532# define LZO_INFO_CC "Cray C" 533# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_RELEASE) 534#elif defined(__DMC__) && defined(__SC__) 535# define LZO_CC_DMC 1 536# define LZO_INFO_CC "Digital Mars C" 537# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__DMC__) 538#elif defined(__DECC) 539# define LZO_CC_DECC 1 540# define LZO_INFO_CC "DEC C" 541# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__DECC) 542#elif defined(__HIGHC__) 543# define LZO_CC_HIGHC 1 544# define LZO_INFO_CC "MetaWare High C" 545# define LZO_INFO_CCVER "unknown" 546#elif defined(__IAR_SYSTEMS_ICC__) 547# define LZO_CC_IARC 1 548# define LZO_INFO_CC "IAR C" 549# if defined(__VER__) 550# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__VER__) 551# else 552# define LZO_INFO_CCVER "unknown" 553# endif 554#elif defined(__IBMC__) 555# define LZO_CC_IBMC 1 556# define LZO_INFO_CC "IBM C" 557# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__IBMC__) 558#elif defined(__KEIL__) && defined(__C166__) 559# define LZO_CC_KEILC 1 560# define LZO_INFO_CC "Keil C" 561# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__C166__) 562#elif defined(__LCC__) && defined(_WIN32) && defined(__LCCOPTIMLEVEL) 563# define LZO_CC_LCCWIN32 1 564# define LZO_INFO_CC "lcc-win32" 565# define LZO_INFO_CCVER "unknown" 566#elif defined(__LCC__) 567# define LZO_CC_LCC 1 568# define LZO_INFO_CC "lcc" 569# if defined(__LCC_VERSION__) 570# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__LCC_VERSION__) 571# else 572# define LZO_INFO_CCVER "unknown" 573# endif 574#elif defined(_MSC_VER) 575# define LZO_CC_MSC 1 576# define LZO_INFO_CC "Microsoft C" 577# if defined(_MSC_FULL_VER) 578# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) "." LZO_PP_MACRO_EXPAND(_MSC_FULL_VER) 579# else 580# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) 581# endif 582#elif defined(__MWERKS__) 583# define LZO_CC_MWERKS 1 584# define LZO_INFO_CC "Metrowerks C" 585# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__MWERKS__) 586#elif (defined(__NDPC__) || defined(__NDPX__)) && defined(__i386) 587# define LZO_CC_NDPC 1 588# define LZO_INFO_CC "Microway NDP C" 589# define LZO_INFO_CCVER "unknown" 590#elif defined(__PACIFIC__) 591# define LZO_CC_PACIFICC 1 592# define LZO_INFO_CC "Pacific C" 593# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PACIFIC__) 594#elif defined(__PGI) && (defined(__linux__) || defined(__WIN32__)) 595# define LZO_CC_PGI 1 596# define LZO_INFO_CC "Portland Group PGI C" 597# define LZO_INFO_CCVER "unknown" 598#elif defined(__PUREC__) && defined(__TOS__) 599# define LZO_CC_PUREC 1 600# define LZO_INFO_CC "Pure C" 601# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PUREC__) 602#elif defined(__SC__) && defined(__ZTC__) 603# define LZO_CC_SYMANTECC 1 604# define LZO_INFO_CC "Symantec C" 605# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SC__) 606#elif defined(__SUNPRO_C) 607# define LZO_INFO_CC "SunPro C" 608# if ((__SUNPRO_C)+0 > 0) 609# define LZO_CC_SUNPROC __SUNPRO_C 610# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_C) 611# else 612# define LZO_CC_SUNPROC 1 613# define LZO_INFO_CCVER "unknown" 614# endif 615#elif defined(__SUNPRO_CC) 616# define LZO_INFO_CC "SunPro C" 617# if ((__SUNPRO_CC)+0 > 0) 618# define LZO_CC_SUNPROC __SUNPRO_CC 619# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_CC) 620# else 621# define LZO_CC_SUNPROC 1 622# define LZO_INFO_CCVER "unknown" 623# endif 624#elif defined(__TINYC__) 625# define LZO_CC_TINYC 1 626# define LZO_INFO_CC "Tiny C" 627# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TINYC__) 628#elif defined(__TSC__) 629# define LZO_CC_TOPSPEEDC 1 630# define LZO_INFO_CC "TopSpeed C" 631# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TSC__) 632#elif defined(__WATCOMC__) 633# define LZO_CC_WATCOMC 1 634# define LZO_INFO_CC "Watcom C" 635# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__WATCOMC__) 636#elif defined(__TURBOC__) 637# define LZO_CC_TURBOC 1 638# define LZO_INFO_CC "Turbo C" 639# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TURBOC__) 640#elif defined(__ZTC__) 641# define LZO_CC_ZORTECHC 1 642# define LZO_INFO_CC "Zortech C" 643# if (__ZTC__ == 0x310) 644# define LZO_INFO_CCVER "0x310" 645# else 646# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__ZTC__) 647# endif 648#else 649# define LZO_CC_UNKNOWN 1 650# define LZO_INFO_CC "unknown" 651# define LZO_INFO_CCVER "unknown" 652#endif 653#if 0 && (LZO_CC_MSC && (_MSC_VER >= 1200)) && !defined(_MSC_FULL_VER) 654# error "LZO_CC_MSC: _MSC_FULL_VER is not defined" 655#endif 656#if !defined(__LZO_ARCH_OVERRIDE) && !defined(LZO_ARCH_GENERIC) && defined(_CRAY) 657# if (UINT_MAX > LZO_0xffffffffL) && defined(_CRAY) 658# if defined(_CRAYMPP) || defined(_CRAYT3D) || defined(_CRAYT3E) 659# define LZO_ARCH_CRAY_MPP 1 660# elif defined(_CRAY1) 661# define LZO_ARCH_CRAY_PVP 1 662# endif 663# endif 664#endif 665#if !defined(__LZO_ARCH_OVERRIDE) 666#if defined(LZO_ARCH_GENERIC) 667# define LZO_INFO_ARCH "generic" 668#elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) 669# define LZO_ARCH_I086 1 670# define LZO_ARCH_IA16 1 671# define LZO_INFO_ARCH "i086" 672#elif defined(__alpha__) || defined(__alpha) || defined(_M_ALPHA) 673# define LZO_ARCH_ALPHA 1 674# define LZO_INFO_ARCH "alpha" 675#elif (LZO_ARCH_CRAY_MPP) && (defined(_CRAYT3D) || defined(_CRAYT3E)) 676# define LZO_ARCH_ALPHA 1 677# define LZO_INFO_ARCH "alpha" 678#elif defined(__amd64__) || defined(__x86_64__) || defined(_M_AMD64) 679# define LZO_ARCH_AMD64 1 680# define LZO_INFO_ARCH "amd64" 681#elif defined(__thumb__) || (defined(_M_ARM) && defined(_M_THUMB)) 682# define LZO_ARCH_ARM 1 683# define LZO_ARCH_ARM_THUMB 1 684# define LZO_INFO_ARCH "arm_thumb" 685#elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCARM__) 686# define LZO_ARCH_ARM 1 687# if defined(__CPU_MODE__) && ((__CPU_MODE__)+0 == 1) 688# define LZO_ARCH_ARM_THUMB 1 689# define LZO_INFO_ARCH "arm_thumb" 690# elif defined(__CPU_MODE__) && ((__CPU_MODE__)+0 == 2) 691# define LZO_INFO_ARCH "arm" 692# else 693# define LZO_INFO_ARCH "arm" 694# endif 695#elif defined(__arm__) || defined(_M_ARM) 696# define LZO_ARCH_ARM 1 697# define LZO_INFO_ARCH "arm" 698#elif (UINT_MAX <= LZO_0xffffL) && defined(__AVR__) 699# define LZO_ARCH_AVR 1 700# define LZO_INFO_ARCH "avr" 701#elif defined(__bfin__) 702# define LZO_ARCH_BLACKFIN 1 703# define LZO_INFO_ARCH "blackfin" 704#elif (UINT_MAX == LZO_0xffffL) && defined(__C166__) 705# define LZO_ARCH_C166 1 706# define LZO_INFO_ARCH "c166" 707#elif defined(__cris__) 708# define LZO_ARCH_CRIS 1 709# define LZO_INFO_ARCH "cris" 710#elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCEZ80__) 711# define LZO_ARCH_EZ80 1 712# define LZO_INFO_ARCH "ez80" 713#elif defined(__H8300__) || defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) 714# define LZO_ARCH_H8300 1 715# define LZO_INFO_ARCH "h8300" 716#elif defined(__hppa__) || defined(__hppa) 717# define LZO_ARCH_HPPA 1 718# define LZO_INFO_ARCH "hppa" 719#elif defined(__386__) || defined(__i386__) || defined(__i386) || defined(_M_IX86) || defined(_M_I386) 720# define LZO_ARCH_I386 1 721# define LZO_ARCH_IA32 1 722# define LZO_INFO_ARCH "i386" 723#elif (LZO_CC_ZORTECHC && defined(__I86__)) 724# define LZO_ARCH_I386 1 725# define LZO_ARCH_IA32 1 726# define LZO_INFO_ARCH "i386" 727#elif (LZO_OS_DOS32 && LZO_CC_HIGHC) && defined(_I386) 728# define LZO_ARCH_I386 1 729# define LZO_ARCH_IA32 1 730# define LZO_INFO_ARCH "i386" 731#elif defined(__ia64__) || defined(__ia64) || defined(_M_IA64) 732# define LZO_ARCH_IA64 1 733# define LZO_INFO_ARCH "ia64" 734#elif (UINT_MAX == LZO_0xffffL) && defined(__m32c__) 735# define LZO_ARCH_M16C 1 736# define LZO_INFO_ARCH "m16c" 737#elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCM16C__) 738# define LZO_ARCH_M16C 1 739# define LZO_INFO_ARCH "m16c" 740#elif defined(__m32r__) 741# define LZO_ARCH_M32R 1 742# define LZO_INFO_ARCH "m32r" 743#elif (LZO_OS_TOS) || defined(__m68k__) || defined(__m68000__) || defined(__mc68000__) || defined(__mc68020__) || defined(_M_M68K) 744# define LZO_ARCH_M68K 1 745# define LZO_INFO_ARCH "m68k" 746#elif (UINT_MAX == LZO_0xffffL) && defined(__C251__) 747# define LZO_ARCH_MCS251 1 748# define LZO_INFO_ARCH "mcs251" 749#elif (UINT_MAX == LZO_0xffffL) && defined(__C51__) 750# define LZO_ARCH_MCS51 1 751# define LZO_INFO_ARCH "mcs51" 752#elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICC8051__) 753# define LZO_ARCH_MCS51 1 754# define LZO_INFO_ARCH "mcs51" 755#elif defined(__mips__) || defined(__mips) || defined(_MIPS_ARCH) || defined(_M_MRX000) 756# define LZO_ARCH_MIPS 1 757# define LZO_INFO_ARCH "mips" 758#elif (UINT_MAX == LZO_0xffffL) && defined(__MSP430__) 759# define LZO_ARCH_MSP430 1 760# define LZO_INFO_ARCH "msp430" 761#elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICC430__) 762# define LZO_ARCH_MSP430 1 763# define LZO_INFO_ARCH "msp430" 764#elif defined(__powerpc__) || defined(__powerpc) || defined(__ppc__) || defined(__PPC__) || defined(_M_PPC) || defined(_ARCH_PPC) || defined(_ARCH_PWR) 765# define LZO_ARCH_POWERPC 1 766# define LZO_INFO_ARCH "powerpc" 767#elif defined(__s390__) || defined(__s390) || defined(__s390x__) || defined(__s390x) 768# define LZO_ARCH_S390 1 769# define LZO_INFO_ARCH "s390" 770#elif defined(__sh__) || defined(_M_SH) 771# define LZO_ARCH_SH 1 772# define LZO_INFO_ARCH "sh" 773#elif defined(__sparc__) || defined(__sparc) || defined(__sparcv8) 774# define LZO_ARCH_SPARC 1 775# define LZO_INFO_ARCH "sparc" 776#elif defined(__SPU__) 777# define LZO_ARCH_SPU 1 778# define LZO_INFO_ARCH "spu" 779#elif (UINT_MAX == LZO_0xffffL) && defined(__z80) 780# define LZO_ARCH_Z80 1 781# define LZO_INFO_ARCH "z80" 782#elif (LZO_ARCH_CRAY_PVP) 783# if defined(_CRAYSV1) 784# define LZO_ARCH_CRAY_SV1 1 785# define LZO_INFO_ARCH "cray_sv1" 786# elif (_ADDR64) 787# define LZO_ARCH_CRAY_T90 1 788# define LZO_INFO_ARCH "cray_t90" 789# elif (_ADDR32) 790# define LZO_ARCH_CRAY_YMP 1 791# define LZO_INFO_ARCH "cray_ymp" 792# else 793# define LZO_ARCH_CRAY_XMP 1 794# define LZO_INFO_ARCH "cray_xmp" 795# endif 796#else 797# define LZO_ARCH_UNKNOWN 1 798# define LZO_INFO_ARCH "unknown" 799#endif 800#endif 801#if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_DOS32 || LZO_OS_OS2) 802# error "FIXME - missing define for CPU architecture" 803#endif 804#if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN32) 805# error "FIXME - missing WIN32 define for CPU architecture" 806#endif 807#if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN64) 808# error "FIXME - missing WIN64 define for CPU architecture" 809#endif 810#if (LZO_OS_OS216 || LZO_OS_WIN16) 811# define LZO_ARCH_I086PM 1 812# define LZO_ARCH_IA16PM 1 813#elif 1 && (LZO_OS_DOS16 && defined(BLX286)) 814# define LZO_ARCH_I086PM 1 815# define LZO_ARCH_IA16PM 1 816#elif 1 && (LZO_OS_DOS16 && defined(DOSX286)) 817# define LZO_ARCH_I086PM 1 818# define LZO_ARCH_IA16PM 1 819#elif 1 && (LZO_OS_DOS16 && LZO_CC_BORLANDC && defined(__DPMI16__)) 820# define LZO_ARCH_I086PM 1 821# define LZO_ARCH_IA16PM 1 822#endif 823#if defined(LZO_ARCH_ARM_THUMB) && !defined(LZO_ARCH_ARM) 824# error "this should not happen" 825#endif 826#if defined(LZO_ARCH_I086PM) && !defined(LZO_ARCH_I086) 827# error "this should not happen" 828#endif 829#if (LZO_ARCH_I086) 830# if (UINT_MAX != LZO_0xffffL) 831# error "this should not happen" 832# endif 833# if (ULONG_MAX != LZO_0xffffffffL) 834# error "this should not happen" 835# endif 836#endif 837#if (LZO_ARCH_I386) 838# if (UINT_MAX != LZO_0xffffL) && defined(__i386_int16__) 839# error "this should not happen" 840# endif 841# if (UINT_MAX != LZO_0xffffffffL) && !defined(__i386_int16__) 842# error "this should not happen" 843# endif 844# if (ULONG_MAX != LZO_0xffffffffL) 845# error "this should not happen" 846# endif 847#endif 848#if !defined(__LZO_MM_OVERRIDE) 849#if (LZO_ARCH_I086) 850#if (UINT_MAX != LZO_0xffffL) 851# error "this should not happen" 852#endif 853#if defined(__TINY__) || defined(M_I86TM) || defined(_M_I86TM) 854# define LZO_MM_TINY 1 855#elif defined(__HUGE__) || defined(_HUGE_) || defined(M_I86HM) || defined(_M_I86HM) 856# define LZO_MM_HUGE 1 857#elif defined(__SMALL__) || defined(M_I86SM) || defined(_M_I86SM) || defined(SMALL_MODEL) 858# define LZO_MM_SMALL 1 859#elif defined(__MEDIUM__) || defined(M_I86MM) || defined(_M_I86MM) 860# define LZO_MM_MEDIUM 1 861#elif defined(__COMPACT__) || defined(M_I86CM) || defined(_M_I86CM) 862# define LZO_MM_COMPACT 1 863#elif defined(__LARGE__) || defined(M_I86LM) || defined(_M_I86LM) || defined(LARGE_MODEL) 864# define LZO_MM_LARGE 1 865#elif (LZO_CC_AZTECC) 866# if defined(_LARGE_CODE) && defined(_LARGE_DATA) 867# define LZO_MM_LARGE 1 868# elif defined(_LARGE_CODE) 869# define LZO_MM_MEDIUM 1 870# elif defined(_LARGE_DATA) 871# define LZO_MM_COMPACT 1 872# else 873# define LZO_MM_SMALL 1 874# endif 875#elif (LZO_CC_ZORTECHC && defined(__VCM__)) 876# define LZO_MM_LARGE 1 877#else 878# error "unknown memory model" 879#endif 880#if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) 881#define LZO_HAVE_MM_HUGE_PTR 1 882#define LZO_HAVE_MM_HUGE_ARRAY 1 883#if (LZO_MM_TINY) 884# undef LZO_HAVE_MM_HUGE_ARRAY 885#endif 886#if (LZO_CC_AZTECC || LZO_CC_PACIFICC || LZO_CC_ZORTECHC) 887# undef LZO_HAVE_MM_HUGE_PTR 888# undef LZO_HAVE_MM_HUGE_ARRAY 889#elif (LZO_CC_DMC || LZO_CC_SYMANTECC) 890# undef LZO_HAVE_MM_HUGE_ARRAY 891#elif (LZO_CC_MSC && defined(_QC)) 892# undef LZO_HAVE_MM_HUGE_ARRAY 893# if (_MSC_VER < 600) 894# undef LZO_HAVE_MM_HUGE_PTR 895# endif 896#elif (LZO_CC_TURBOC && (__TURBOC__ < 0x0295)) 897# undef LZO_HAVE_MM_HUGE_ARRAY 898#endif 899#if (LZO_ARCH_I086PM) && !defined(LZO_HAVE_MM_HUGE_PTR) 900# if (LZO_OS_DOS16) 901# error "this should not happen" 902# elif (LZO_CC_ZORTECHC) 903# else 904# error "this should not happen" 905# endif 906#endif 907#ifdef __cplusplus 908extern "C" { 909#endif 910#if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0200)) 911 extern void __near __cdecl _AHSHIFT(void); 912# define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT) 913#elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) 914 extern void __near __cdecl _AHSHIFT(void); 915# define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT) 916#elif (LZO_CC_MSC || LZO_CC_TOPSPEEDC) 917 extern void __near __cdecl _AHSHIFT(void); 918# define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT) 919#elif (LZO_CC_TURBOC && (__TURBOC__ >= 0x0295)) 920 extern void __near __cdecl _AHSHIFT(void); 921# define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT) 922#elif ((LZO_CC_AZTECC || LZO_CC_PACIFICC || LZO_CC_TURBOC) && LZO_OS_DOS16) 923# define LZO_MM_AHSHIFT 12 924#elif (LZO_CC_WATCOMC) 925 extern unsigned char _HShift; 926# define LZO_MM_AHSHIFT ((unsigned) _HShift) 927#else 928# error "FIXME - implement LZO_MM_AHSHIFT" 929#endif 930#ifdef __cplusplus 931} 932#endif 933#endif 934#elif (LZO_ARCH_C166) 935#if !defined(__MODEL__) 936# error "FIXME - C166 __MODEL__" 937#elif ((__MODEL__) == 0) 938# define LZO_MM_SMALL 1 939#elif ((__MODEL__) == 1) 940# define LZO_MM_SMALL 1 941#elif ((__MODEL__) == 2) 942# define LZO_MM_LARGE 1 943#elif ((__MODEL__) == 3) 944# define LZO_MM_TINY 1 945#elif ((__MODEL__) == 4) 946# define LZO_MM_XTINY 1 947#elif ((__MODEL__) == 5) 948# define LZO_MM_XSMALL 1 949#else 950# error "FIXME - C166 __MODEL__" 951#endif 952#elif (LZO_ARCH_MCS251) 953#if !defined(__MODEL__) 954# error "FIXME - MCS251 __MODEL__" 955#elif ((__MODEL__) == 0) 956# define LZO_MM_SMALL 1 957#elif ((__MODEL__) == 2) 958# define LZO_MM_LARGE 1 959#elif ((__MODEL__) == 3) 960# define LZO_MM_TINY 1 961#elif ((__MODEL__) == 4) 962# define LZO_MM_XTINY 1 963#elif ((__MODEL__) == 5) 964# define LZO_MM_XSMALL 1 965#else 966# error "FIXME - MCS251 __MODEL__" 967#endif 968#elif (LZO_ARCH_MCS51) 969#if !defined(__MODEL__) 970# error "FIXME - MCS51 __MODEL__" 971#elif ((__MODEL__) == 1) 972# define LZO_MM_SMALL 1 973#elif ((__MODEL__) == 2) 974# define LZO_MM_LARGE 1 975#elif ((__MODEL__) == 3) 976# define LZO_MM_TINY 1 977#elif ((__MODEL__) == 4) 978# define LZO_MM_XTINY 1 979#elif ((__MODEL__) == 5) 980# define LZO_MM_XSMALL 1 981#else 982# error "FIXME - MCS51 __MODEL__" 983#endif 984#elif (LZO_ARCH_CRAY_PVP) 985# define LZO_MM_PVP 1 986#else 987# define LZO_MM_FLAT 1 988#endif 989#if (LZO_MM_COMPACT) 990# define LZO_INFO_MM "compact" 991#elif (LZO_MM_FLAT) 992# define LZO_INFO_MM "flat" 993#elif (LZO_MM_HUGE) 994# define LZO_INFO_MM "huge" 995#elif (LZO_MM_LARGE) 996# define LZO_INFO_MM "large" 997#elif (LZO_MM_MEDIUM) 998# define LZO_INFO_MM "medium" 999#elif (LZO_MM_PVP) 1000# define LZO_INFO_MM "pvp" 1001#elif (LZO_MM_SMALL) 1002# define LZO_INFO_MM "small" 1003#elif (LZO_MM_TINY) 1004# define LZO_INFO_MM "tiny" 1005#else 1006# error "unknown memory model" 1007#endif 1008#endif 1009#if defined(SIZEOF_SHORT) 1010# define LZO_SIZEOF_SHORT (SIZEOF_SHORT) 1011#endif 1012#if defined(SIZEOF_INT) 1013# define LZO_SIZEOF_INT (SIZEOF_INT) 1014#endif 1015#if defined(SIZEOF_LONG) 1016# define LZO_SIZEOF_LONG (SIZEOF_LONG) 1017#endif 1018#if defined(SIZEOF_LONG_LONG) 1019# define LZO_SIZEOF_LONG_LONG (SIZEOF_LONG_LONG) 1020#endif 1021#if defined(SIZEOF___INT16) 1022# define LZO_SIZEOF___INT16 (SIZEOF___INT16) 1023#endif 1024#if defined(SIZEOF___INT32) 1025# define LZO_SIZEOF___INT32 (SIZEOF___INT32) 1026#endif 1027#if defined(SIZEOF___INT64) 1028# define LZO_SIZEOF___INT64 (SIZEOF___INT64) 1029#endif 1030#if defined(SIZEOF_VOID_P) 1031# define LZO_SIZEOF_VOID_P (SIZEOF_VOID_P) 1032#endif 1033#if defined(SIZEOF_SIZE_T) 1034# define LZO_SIZEOF_SIZE_T (SIZEOF_SIZE_T) 1035#endif 1036#if defined(SIZEOF_PTRDIFF_T) 1037# define LZO_SIZEOF_PTRDIFF_T (SIZEOF_PTRDIFF_T) 1038#endif 1039#define __LZO_LSR(x,b) (((x)+0ul) >> (b)) 1040#if !defined(LZO_SIZEOF_SHORT) 1041# if (LZO_ARCH_CRAY_PVP) 1042# define LZO_SIZEOF_SHORT 8 1043# elif (USHRT_MAX == LZO_0xffffL) 1044# define LZO_SIZEOF_SHORT 2 1045# elif (__LZO_LSR(USHRT_MAX,7) == 1) 1046# define LZO_SIZEOF_SHORT 1 1047# elif (__LZO_LSR(USHRT_MAX,15) == 1) 1048# define LZO_SIZEOF_SHORT 2 1049# elif (__LZO_LSR(USHRT_MAX,31) == 1) 1050# define LZO_SIZEOF_SHORT 4 1051# elif (__LZO_LSR(USHRT_MAX,63) == 1) 1052# define LZO_SIZEOF_SHORT 8 1053# elif (__LZO_LSR(USHRT_MAX,127) == 1) 1054# define LZO_SIZEOF_SHORT 16 1055# else 1056# error "LZO_SIZEOF_SHORT" 1057# endif 1058#endif 1059#if !defined(LZO_SIZEOF_INT) 1060# if (LZO_ARCH_CRAY_PVP) 1061# define LZO_SIZEOF_INT 8 1062# elif (UINT_MAX == LZO_0xffffL) 1063# define LZO_SIZEOF_INT 2 1064# elif (UINT_MAX == LZO_0xffffffffL) 1065# define LZO_SIZEOF_INT 4 1066# elif (__LZO_LSR(UINT_MAX,7) == 1) 1067# define LZO_SIZEOF_INT 1 1068# elif (__LZO_LSR(UINT_MAX,15) == 1) 1069# define LZO_SIZEOF_INT 2 1070# elif (__LZO_LSR(UINT_MAX,31) == 1) 1071# define LZO_SIZEOF_INT 4 1072# elif (__LZO_LSR(UINT_MAX,63) == 1) 1073# define LZO_SIZEOF_INT 8 1074# elif (__LZO_LSR(UINT_MAX,127) == 1) 1075# define LZO_SIZEOF_INT 16 1076# else 1077# error "LZO_SIZEOF_INT" 1078# endif 1079#endif 1080#if !defined(LZO_SIZEOF_LONG) 1081# if (ULONG_MAX == LZO_0xffffffffL) 1082# define LZO_SIZEOF_LONG 4 1083# elif (__LZO_LSR(ULONG_MAX,7) == 1) 1084# define LZO_SIZEOF_LONG 1 1085# elif (__LZO_LSR(ULONG_MAX,15) == 1) 1086# define LZO_SIZEOF_LONG 2 1087# elif (__LZO_LSR(ULONG_MAX,31) == 1) 1088# define LZO_SIZEOF_LONG 4 1089# elif (__LZO_LSR(ULONG_MAX,63) == 1) 1090# define LZO_SIZEOF_LONG 8 1091# elif (__LZO_LSR(ULONG_MAX,127) == 1) 1092# define LZO_SIZEOF_LONG 16 1093# else 1094# error "LZO_SIZEOF_LONG" 1095# endif 1096#endif 1097#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) 1098#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) 1099# if defined(__LONG_MAX__) && defined(__LONG_LONG_MAX__) 1100# if (LZO_CC_GNUC >= 0x030300ul) 1101# if ((__LONG_MAX__)+0 == (__LONG_LONG_MAX__)+0) 1102# define LZO_SIZEOF_LONG_LONG LZO_SIZEOF_LONG 1103# elif (__LZO_LSR(__LONG_LONG_MAX__,30) == 1) 1104# define LZO_SIZEOF_LONG_LONG 4 1105# endif 1106# endif 1107# endif 1108#endif 1109#endif 1110#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) 1111#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) 1112#if (LZO_ARCH_I086 && LZO_CC_DMC) 1113#elif (LZO_CC_CILLY) && defined(__GNUC__) 1114# define LZO_SIZEOF_LONG_LONG 8 1115#elif (LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) 1116# define LZO_SIZEOF_LONG_LONG 8 1117#elif ((LZO_OS_WIN32 || LZO_OS_WIN64 || defined(_WIN32)) && LZO_CC_MSC && (_MSC_VER >= 1400)) 1118# define LZO_SIZEOF_LONG_LONG 8 1119#elif (LZO_OS_WIN64 || defined(_WIN64)) 1120# define LZO_SIZEOF___INT64 8 1121#elif (LZO_ARCH_I386 && (LZO_CC_DMC)) 1122# define LZO_SIZEOF_LONG_LONG 8 1123#elif (LZO_ARCH_I386 && (LZO_CC_SYMANTECC && (__SC__ >= 0x700))) 1124# define LZO_SIZEOF_LONG_LONG 8 1125#elif (LZO_ARCH_I386 && (LZO_CC_INTELC && defined(__linux__))) 1126# define LZO_SIZEOF_LONG_LONG 8 1127#elif (LZO_ARCH_I386 && (LZO_CC_MWERKS || LZO_CC_PELLESC || LZO_CC_PGI || LZO_CC_SUNPROC)) 1128# define LZO_SIZEOF_LONG_LONG 8 1129#elif (LZO_ARCH_I386 && (LZO_CC_INTELC || LZO_CC_MSC)) 1130# define LZO_SIZEOF___INT64 8 1131#elif ((LZO_OS_WIN32 || defined(_WIN32)) && (LZO_CC_MSC)) 1132# define LZO_SIZEOF___INT64 8 1133#elif (LZO_ARCH_I386 && (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0520))) 1134# define LZO_SIZEOF___INT64 8 1135#elif (LZO_ARCH_I386 && (LZO_CC_WATCOMC && (__WATCOMC__ >= 1100))) 1136# define LZO_SIZEOF___INT64 8 1137#elif (LZO_CC_WATCOMC && defined(_INTEGRAL_MAX_BITS) && (_INTEGRAL_MAX_BITS == 64)) 1138# define LZO_SIZEOF___INT64 8 1139#elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) 1140# define LZO_SIZEOF_LONG_LONG 8 1141#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) 1142# define LZO_SIZEOF_LONG_LONG 8 1143#elif (LZO_CC_SDCC) && (LZO_SIZEOF_INT == 2) 1144#elif 1 && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) 1145# define LZO_SIZEOF_LONG_LONG 8 1146#endif 1147#endif 1148#endif 1149#if defined(__cplusplus) && defined(LZO_CC_GNUC) 1150# if (LZO_CC_GNUC < 0x020800ul) 1151# undef LZO_SIZEOF_LONG_LONG 1152# endif 1153#endif 1154#if defined(LZO_CFG_NO_LONG_LONG) || defined(__NO_LONG_LONG) 1155# undef LZO_SIZEOF_LONG_LONG 1156#endif 1157#if !defined(LZO_SIZEOF_VOID_P) 1158#if (LZO_ARCH_I086) 1159# define __LZO_WORDSIZE 2 1160# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM) 1161# define LZO_SIZEOF_VOID_P 2 1162# elif (LZO_MM_COMPACT || LZO_MM_LARGE || LZO_MM_HUGE) 1163# define LZO_SIZEOF_VOID_P 4 1164# else 1165# error "LZO_MM" 1166# endif 1167#elif (LZO_ARCH_AVR || LZO_ARCH_Z80) 1168# define __LZO_WORDSIZE 1 1169# define LZO_SIZEOF_VOID_P 2 1170#elif (LZO_ARCH_C166 || LZO_ARCH_MCS51 || LZO_ARCH_MCS251 || LZO_ARCH_MSP430) 1171# define LZO_SIZEOF_VOID_P 2 1172#elif (LZO_ARCH_H8300) 1173# if defined(__NORMAL_MODE__) 1174# define __LZO_WORDSIZE 4 1175# define LZO_SIZEOF_VOID_P 2 1176# elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) 1177# define __LZO_WORDSIZE 4 1178# define LZO_SIZEOF_VOID_P 4 1179# else 1180# define __LZO_WORDSIZE 2 1181# define LZO_SIZEOF_VOID_P 2 1182# endif 1183# if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_SIZEOF_INT == 4) 1184# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_INT 1185# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_INT 1186# endif 1187#elif (LZO_ARCH_M16C) 1188# define __LZO_WORDSIZE 2 1189# if defined(__m32c_cpu__) || defined(__m32cm_cpu__) 1190# define LZO_SIZEOF_VOID_P 4 1191# else 1192# define LZO_SIZEOF_VOID_P 2 1193# endif 1194#elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) 1195# define __LZO_WORDSIZE 8 1196# define LZO_SIZEOF_VOID_P 4 1197#elif defined(__LLP64__) || defined(__LLP64) || defined(_LLP64) || defined(_WIN64) 1198# define __LZO_WORDSIZE 8 1199# define LZO_SIZEOF_VOID_P 8 1200#elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) 1201# define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG 1202# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG 1203# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG 1204#elif (LZO_OS_OS400 || defined(__OS400__)) 1205# define __LZO_WORDSIZE LZO_SIZEOF_LONG 1206# define LZO_SIZEOF_VOID_P 16 1207# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG 1208# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG 1209#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) 1210# define LZO_SIZEOF_VOID_P 8 1211# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG 1212# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG 1213#elif (LZO_ARCH_SPU) 1214# if 0 1215# define __LZO_WORDSIZE 16 1216# endif 1217# define LZO_SIZEOF_VOID_P 4 1218#else 1219# define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG 1220#endif 1221#endif 1222#if !defined(LZO_WORDSIZE) 1223# if defined(__LZO_WORDSIZE) 1224# define LZO_WORDSIZE __LZO_WORDSIZE 1225# else 1226# define LZO_WORDSIZE LZO_SIZEOF_VOID_P 1227# endif 1228#endif 1229#if !defined(LZO_SIZEOF_SIZE_T) 1230#if (LZO_ARCH_I086 || LZO_ARCH_M16C) 1231# define LZO_SIZEOF_SIZE_T 2 1232#else 1233# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_VOID_P 1234#endif 1235#endif 1236#if !defined(LZO_SIZEOF_PTRDIFF_T) 1237#if (LZO_ARCH_I086) 1238# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM || LZO_MM_HUGE) 1239# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_VOID_P 1240# elif (LZO_MM_COMPACT || LZO_MM_LARGE) 1241# if (LZO_CC_BORLANDC || LZO_CC_TURBOC) 1242# define LZO_SIZEOF_PTRDIFF_T 4 1243# else 1244# define LZO_SIZEOF_PTRDIFF_T 2 1245# endif 1246# else 1247# error "LZO_MM" 1248# endif 1249#else 1250# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_SIZE_T 1251#endif 1252#endif 1253#if defined(LZO_ABI_NEUTRAL_ENDIAN) 1254# undef LZO_ABI_BIG_ENDIAN 1255# undef LZO_ABI_LITTLE_ENDIAN 1256#elif !defined(LZO_ABI_BIG_ENDIAN) && !defined(LZO_ABI_LITTLE_ENDIAN) 1257#if (LZO_ARCH_ALPHA) && (LZO_ARCH_CRAY_MPP) 1258# define LZO_ABI_BIG_ENDIAN 1 1259#elif (LZO_ARCH_ALPHA || LZO_ARCH_AMD64 || LZO_ARCH_BLACKFIN || LZO_ARCH_CRIS || LZO_ARCH_I086 || LZO_ARCH_I386 || LZO_ARCH_MSP430) 1260# define LZO_ABI_LITTLE_ENDIAN 1 1261#elif (LZO_ARCH_M68K || LZO_ARCH_S390) 1262# define LZO_ABI_BIG_ENDIAN 1 1263#elif 1 && defined(__IAR_SYSTEMS_ICC__) && defined(__LITTLE_ENDIAN__) 1264# if (__LITTLE_ENDIAN__ == 1) 1265# define LZO_ABI_LITTLE_ENDIAN 1 1266# else 1267# define LZO_ABI_BIG_ENDIAN 1 1268# endif 1269#elif 1 && defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) 1270# define LZO_ABI_BIG_ENDIAN 1 1271#elif 1 && defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__) 1272# define LZO_ABI_LITTLE_ENDIAN 1 1273#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEB__) && !defined(__ARMEL__) 1274# define LZO_ABI_BIG_ENDIAN 1 1275#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEL__) && !defined(__ARMEB__) 1276# define LZO_ABI_LITTLE_ENDIAN 1 1277#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEB__) && !defined(__MIPSEL__) 1278# define LZO_ABI_BIG_ENDIAN 1 1279#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEL__) && !defined(__MIPSEB__) 1280# define LZO_ABI_LITTLE_ENDIAN 1 1281#endif 1282#endif 1283#if defined(LZO_ABI_BIG_ENDIAN) && defined(LZO_ABI_LITTLE_ENDIAN) 1284# error "this should not happen" 1285#endif 1286#if defined(LZO_ABI_BIG_ENDIAN) 1287# define LZO_INFO_ABI_ENDIAN "be" 1288#elif defined(LZO_ABI_LITTLE_ENDIAN) 1289# define LZO_INFO_ABI_ENDIAN "le" 1290#elif defined(LZO_ABI_NEUTRAL_ENDIAN) 1291# define LZO_INFO_ABI_ENDIAN "neutral" 1292#endif 1293#if (LZO_SIZEOF_INT == 1 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) 1294# define LZO_ABI_I8LP16 1 1295# define LZO_INFO_ABI_PM "i8lp16" 1296#elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) 1297# define LZO_ABI_ILP16 1 1298# define LZO_INFO_ABI_PM "ilp16" 1299#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4) 1300# define LZO_ABI_ILP32 1 1301# define LZO_INFO_ABI_PM "ilp32" 1302#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 8 && LZO_SIZEOF_SIZE_T == 8) 1303# define LZO_ABI_LLP64 1 1304# define LZO_INFO_ABI_PM "llp64" 1305#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) 1306# define LZO_ABI_LP64 1 1307# define LZO_INFO_ABI_PM "lp64" 1308#elif (LZO_SIZEOF_INT == 8 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) 1309# define LZO_ABI_ILP64 1 1310# define LZO_INFO_ABI_PM "ilp64" 1311#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 4) 1312# define LZO_ABI_IP32L64 1 1313# define LZO_INFO_ABI_PM "ip32l64" 1314#endif 1315#if !defined(__LZO_LIBC_OVERRIDE) 1316#if defined(LZO_LIBC_NAKED) 1317# define LZO_INFO_LIBC "naked" 1318#elif defined(LZO_LIBC_FREESTANDING) 1319# define LZO_INFO_LIBC "freestanding" 1320#elif defined(LZO_LIBC_MOSTLY_FREESTANDING) 1321# define LZO_INFO_LIBC "mfreestanding" 1322#elif defined(LZO_LIBC_ISOC90) 1323# define LZO_INFO_LIBC "isoc90" 1324#elif defined(LZO_LIBC_ISOC99) 1325# define LZO_INFO_LIBC "isoc99" 1326#elif defined(__dietlibc__) 1327# define LZO_LIBC_DIETLIBC 1 1328# define LZO_INFO_LIBC "dietlibc" 1329#elif defined(_NEWLIB_VERSION) 1330# define LZO_LIBC_NEWLIB 1 1331# define LZO_INFO_LIBC "newlib" 1332#elif defined(__UCLIBC__) && defined(__UCLIBC_MAJOR__) && defined(__UCLIBC_MINOR__) 1333# if defined(__UCLIBC_SUBLEVEL__) 1334# define LZO_LIBC_UCLIBC (__UCLIBC_MAJOR__ * 0x10000L + __UCLIBC_MINOR__ * 0x100 + __UCLIBC_SUBLEVEL__) 1335# else 1336# define LZO_LIBC_UCLIBC 0x00090bL 1337# endif 1338# define LZO_INFO_LIBC "uclibc" 1339#elif defined(__GLIBC__) && defined(__GLIBC_MINOR__) 1340# define LZO_LIBC_GLIBC (__GLIBC__ * 0x10000L + __GLIBC_MINOR__ * 0x100) 1341# define LZO_INFO_LIBC "glibc" 1342#elif (LZO_CC_MWERKS) && defined(__MSL__) 1343# define LZO_LIBC_MSL __MSL__ 1344# define LZO_INFO_LIBC "msl" 1345#elif 1 && defined(__IAR_SYSTEMS_ICC__) 1346# define LZO_LIBC_ISOC90 1 1347# define LZO_INFO_LIBC "isoc90" 1348#else 1349# define LZO_LIBC_DEFAULT 1 1350# define LZO_INFO_LIBC "default" 1351#endif 1352#endif 1353#if !defined(__lzo_gnuc_extension__) 1354#if (LZO_CC_GNUC >= 0x020800ul) 1355# define __lzo_gnuc_extension__ __extension__ 1356#elif (LZO_CC_LLVM || LZO_CC_PATHSCALE) 1357# define __lzo_gnuc_extension__ __extension__ 1358#else 1359# define __lzo_gnuc_extension__ 1360#endif 1361#endif 1362#if !defined(__lzo_ua_volatile) 1363# define __lzo_ua_volatile volatile 1364#endif 1365#if !defined(__lzo_alignof) 1366#if (LZO_CC_CILLY || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) 1367# define __lzo_alignof(e) __alignof__(e) 1368#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 700)) 1369# define __lzo_alignof(e) __alignof__(e) 1370#elif (LZO_CC_MSC && (_MSC_VER >= 1300)) 1371# define __lzo_alignof(e) __alignof(e) 1372#endif 1373#endif 1374#if defined(__lzo_alignof) 1375# define __lzo_HAVE_alignof 1 1376#endif 1377#if !defined(__lzo_constructor) 1378#if (LZO_CC_GNUC >= 0x030400ul) 1379# define __lzo_constructor __attribute__((__constructor__,__used__)) 1380#elif (LZO_CC_GNUC >= 0x020700ul) 1381# define __lzo_constructor __attribute__((__constructor__)) 1382#elif (LZO_CC_LLVM || LZO_CC_PATHSCALE) 1383# define __lzo_constructor __attribute__((__constructor__)) 1384#endif 1385#endif 1386#if defined(__lzo_constructor) 1387# define __lzo_HAVE_constructor 1 1388#endif 1389#if !defined(__lzo_destructor) 1390#if (LZO_CC_GNUC >= 0x030400ul) 1391# define __lzo_destructor __attribute__((__destructor__,__used__)) 1392#elif (LZO_CC_GNUC >= 0x020700ul) 1393# define __lzo_destructor __attribute__((__destructor__)) 1394#elif (LZO_CC_LLVM || LZO_CC_PATHSCALE) 1395# define __lzo_destructor __attribute__((__destructor__)) 1396#endif 1397#endif 1398#if defined(__lzo_destructor) 1399# define __lzo_HAVE_destructor 1 1400#endif 1401#if defined(__lzo_HAVE_destructor) && !defined(__lzo_HAVE_constructor) 1402# error "this should not happen" 1403#endif 1404#if !defined(__lzo_inline) 1405#if (LZO_CC_TURBOC && (__TURBOC__ <= 0x0295)) 1406#elif defined(__cplusplus) 1407# define __lzo_inline inline 1408#elif (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0550)) 1409# define __lzo_inline __inline 1410#elif (LZO_CC_CILLY || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) 1411# define __lzo_inline __inline__ 1412#elif (LZO_CC_DMC) 1413# define __lzo_inline __inline 1414#elif (LZO_CC_INTELC) 1415# define __lzo_inline __inline 1416#elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x2405)) 1417# define __lzo_inline __inline 1418#elif (LZO_CC_MSC && (_MSC_VER >= 900)) 1419# define __lzo_inline __inline 1420#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) 1421# define __lzo_inline inline 1422#endif 1423#endif 1424#if defined(__lzo_inline) 1425# define __lzo_HAVE_inline 1 1426#else 1427# define __lzo_inline 1428#endif 1429#if !defined(__lzo_forceinline) 1430#if (LZO_CC_GNUC >= 0x030200ul) 1431# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) 1432#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) 1433# define __lzo_forceinline __forceinline 1434#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC) 1435# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) 1436#elif (LZO_CC_LLVM || LZO_CC_PATHSCALE) 1437# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) 1438#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) 1439# define __lzo_forceinline __forceinline 1440#endif 1441#endif 1442#if defined(__lzo_forceinline) 1443# define __lzo_HAVE_forceinline 1 1444#else 1445# define __lzo_forceinline 1446#endif 1447#if !defined(__lzo_noinline) 1448#if 1 && (LZO_ARCH_I386) && (LZO_CC_GNUC >= 0x040000ul) && (LZO_CC_GNUC < 0x040003ul) 1449# define __lzo_noinline __attribute__((__noinline__,__used__)) 1450#elif (LZO_CC_GNUC >= 0x030200ul) 1451# define __lzo_noinline __attribute__((__noinline__)) 1452#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_MSC) 1453# define __lzo_noinline __declspec(noinline) 1454#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC) 1455# define __lzo_noinline __attribute__((__noinline__)) 1456#elif (LZO_CC_LLVM || LZO_CC_PATHSCALE) 1457# define __lzo_noinline __attribute__((__noinline__)) 1458#elif (LZO_CC_MSC && (_MSC_VER >= 1300)) 1459# define __lzo_noinline __declspec(noinline) 1460#elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x3200) && (LZO_OS_WIN32 || LZO_OS_WIN64)) 1461# if defined(__cplusplus) 1462# else 1463# define __lzo_noinline __declspec(noinline) 1464# endif 1465#endif 1466#endif 1467#if defined(__lzo_noinline) 1468# define __lzo_HAVE_noinline 1 1469#else 1470# define __lzo_noinline 1471#endif 1472#if (defined(__lzo_HAVE_forceinline) || defined(__lzo_HAVE_noinline)) && !defined(__lzo_HAVE_inline) 1473# error "this should not happen" 1474#endif 1475#if !defined(__lzo_noreturn) 1476#if (LZO_CC_GNUC >= 0x020700ul) 1477# define __lzo_noreturn __attribute__((__noreturn__)) 1478#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) 1479# define __lzo_noreturn __declspec(noreturn) 1480#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_GNUC) 1481# define __lzo_noreturn __attribute__((__noreturn__)) 1482#elif (LZO_CC_LLVM || LZO_CC_PATHSCALE) 1483# define __lzo_noreturn __attribute__((__noreturn__)) 1484#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) 1485# define __lzo_noreturn __declspec(noreturn) 1486#endif 1487#endif 1488#if defined(__lzo_noreturn) 1489# define __lzo_HAVE_noreturn 1 1490#else 1491# define __lzo_noreturn 1492#endif 1493#if !defined(__lzo_nothrow) 1494#if (LZO_CC_GNUC >= 0x030300ul) 1495# define __lzo_nothrow __attribute__((__nothrow__)) 1496#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) && defined(__cplusplus) 1497# define __lzo_nothrow __declspec(nothrow) 1498#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC) 1499# define __lzo_nothrow __attribute__((__nothrow__)) 1500#elif (LZO_CC_LLVM || LZO_CC_PATHSCALE) 1501# define __lzo_nothrow __attribute__((__nothrow__)) 1502#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) && defined(__cplusplus) 1503# define __lzo_nothrow __declspec(nothrow) 1504#endif 1505#endif 1506#if defined(__lzo_nothrow) 1507# define __lzo_HAVE_nothrow 1 1508#else 1509# define __lzo_nothrow 1510#endif 1511#if !defined(__lzo_restrict) 1512#if (LZO_CC_GNUC >= 0x030400ul) 1513# define __lzo_restrict __restrict__ 1514#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_GNUC) 1515# define __lzo_restrict __restrict__ 1516#elif (LZO_CC_LLVM) 1517# define __lzo_restrict __restrict__ 1518#elif (LZO_CC_MSC && (_MSC_VER >= 1400)) 1519# define __lzo_restrict __restrict 1520#endif 1521#endif 1522#if defined(__lzo_restrict) 1523# define __lzo_HAVE_restrict 1 1524#else 1525# define __lzo_restrict 1526#endif 1527#if !defined(__lzo_likely) && !defined(__lzo_unlikely) 1528#if (LZO_CC_GNUC >= 0x030200ul) 1529# define __lzo_likely(e) (__builtin_expect(!!(e),1)) 1530# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) 1531#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800)) 1532# define __lzo_likely(e) (__builtin_expect(!!(e),1)) 1533# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) 1534#elif (LZO_CC_LLVM || LZO_CC_PATHSCALE) 1535# define __lzo_likely(e) (__builtin_expect(!!(e),1)) 1536# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) 1537#endif 1538#endif 1539#if defined(__lzo_likely) 1540# define __lzo_HAVE_likely 1 1541#else 1542# define __lzo_likely(e) (e) 1543#endif 1544#if defined(__lzo_unlikely) 1545# define __lzo_HAVE_unlikely 1 1546#else 1547# define __lzo_unlikely(e) (e) 1548#endif 1549#if !defined(LZO_UNUSED) 1550# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) 1551# define LZO_UNUSED(var) ((void) &var) 1552# elif (LZO_CC_BORLANDC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PELLESC || LZO_CC_TURBOC) 1553# define LZO_UNUSED(var) if (&var) ; else 1554# elif (LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) 1555# define LZO_UNUSED(var) ((void) var) 1556# elif (LZO_CC_MSC && (_MSC_VER < 900)) 1557# define LZO_UNUSED(var) if (&var) ; else 1558# elif (LZO_CC_KEILC) 1559# define LZO_UNUSED(var) {extern int __lzo_unused[1-2*!(sizeof(var)>0)];} 1560# elif (LZO_CC_PACIFICC) 1561# define LZO_UNUSED(var) ((void) sizeof(var)) 1562# elif (LZO_CC_WATCOMC) && defined(__cplusplus) 1563# define LZO_UNUSED(var) ((void) var) 1564# else 1565# define LZO_UNUSED(var) ((void) &var) 1566# endif 1567#endif 1568#if !defined(LZO_UNUSED_FUNC) 1569# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) 1570# define LZO_UNUSED_FUNC(func) ((void) func) 1571# elif (LZO_CC_BORLANDC || LZO_CC_NDPC || LZO_CC_TURBOC) 1572# define LZO_UNUSED_FUNC(func) if (func) ; else 1573# elif (LZO_CC_LLVM) 1574# define LZO_UNUSED_FUNC(func) ((void) &func) 1575# elif (LZO_CC_MSC && (_MSC_VER < 900)) 1576# define LZO_UNUSED_FUNC(func) if (func) ; else 1577# elif (LZO_CC_MSC) 1578# define LZO_UNUSED_FUNC(func) ((void) &func) 1579# elif (LZO_CC_KEILC || LZO_CC_PELLESC) 1580# define LZO_UNUSED_FUNC(func) {extern int __lzo_unused[1-2*!(sizeof((int)func)>0)];} 1581# else 1582# define LZO_UNUSED_FUNC(func) ((void) func) 1583# endif 1584#endif 1585#if !defined(LZO_UNUSED_LABEL) 1586# if (LZO_CC_WATCOMC) && defined(__cplusplus) 1587# define LZO_UNUSED_LABEL(l) switch(0) case 1:goto l 1588# elif (LZO_CC_INTELC || LZO_CC_WATCOMC) 1589# define LZO_UNUSED_LABEL(l) if (0) goto l 1590# else 1591# define LZO_UNUSED_LABEL(l) switch(0) case 1:goto l 1592# endif 1593#endif 1594#if !defined(LZO_DEFINE_UNINITIALIZED_VAR) 1595# if 0 1596# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var 1597# elif 0 && (LZO_CC_GNUC) 1598# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = var 1599# else 1600# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = init 1601# endif 1602#endif 1603#if !defined(LZO_COMPILE_TIME_ASSERT_HEADER) 1604# if (LZO_CC_AZTECC || LZO_CC_ZORTECHC) 1605# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-!(e)]; 1606# elif (LZO_CC_DMC || LZO_CC_SYMANTECC) 1607# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1u-2*!(e)]; 1608# elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) 1609# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-!(e)]; 1610# else 1611# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-2*!(e)]; 1612# endif 1613#endif 1614#if !defined(LZO_COMPILE_TIME_ASSERT) 1615# if (LZO_CC_AZTECC) 1616# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __lzo_cta_t[1-!(e)];} 1617# elif (LZO_CC_DMC || LZO_CC_PACIFICC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) 1618# define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; 1619# elif (LZO_CC_MSC && (_MSC_VER < 900)) 1620# define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; 1621# elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) 1622# define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; 1623# else 1624# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __lzo_cta_t[1-2*!(e)];} 1625# endif 1626#endif 1627#if (LZO_ARCH_I086 || LZO_ARCH_I386) && (LZO_OS_DOS16 || LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_OS216 || LZO_OS_WIN16 || LZO_OS_WIN32 || LZO_OS_WIN64) 1628# if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC) 1629# elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) 1630# define __lzo_cdecl __cdecl 1631# define __lzo_cdecl_atexit 1632# define __lzo_cdecl_main __cdecl 1633# if (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC)) 1634# define __lzo_cdecl_qsort __pascal 1635# elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC)) 1636# define __lzo_cdecl_qsort _stdcall 1637# else 1638# define __lzo_cdecl_qsort __cdecl 1639# endif 1640# elif (LZO_CC_WATCOMC) 1641# define __lzo_cdecl __cdecl 1642# else 1643# define __lzo_cdecl __cdecl 1644# define __lzo_cdecl_atexit __cdecl 1645# define __lzo_cdecl_main __cdecl 1646# define __lzo_cdecl_qsort __cdecl 1647# endif 1648# if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC || LZO_CC_WATCOMC) 1649# elif (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC)) 1650# define __lzo_cdecl_sighandler __pascal 1651# elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC)) 1652# define __lzo_cdecl_sighandler _stdcall 1653# elif (LZO_CC_MSC && (_MSC_VER >= 1400)) && defined(_M_CEE_PURE) 1654# define __lzo_cdecl_sighandler __clrcall 1655# elif (LZO_CC_MSC && (_MSC_VER >= 600 && _MSC_VER < 700)) 1656# if defined(_DLL) 1657# define __lzo_cdecl_sighandler _far _cdecl _loadds 1658# elif defined(_MT) 1659# define __lzo_cdecl_sighandler _far _cdecl 1660# else 1661# define __lzo_cdecl_sighandler _cdecl 1662# endif 1663# else 1664# define __lzo_cdecl_sighandler __cdecl 1665# endif 1666#elif (LZO_ARCH_I386) && (LZO_CC_WATCOMC) 1667# define __lzo_cdecl __cdecl 1668#elif (LZO_ARCH_M68K && LZO_OS_TOS && (LZO_CC_PUREC || LZO_CC_TURBOC)) 1669# define __lzo_cdecl cdecl 1670#endif 1671#if !defined(__lzo_cdecl) 1672# define __lzo_cdecl 1673#endif 1674#if !defined(__lzo_cdecl_atexit) 1675# define __lzo_cdecl_atexit 1676#endif 1677#if !defined(__lzo_cdecl_main) 1678# define __lzo_cdecl_main 1679#endif 1680#if !defined(__lzo_cdecl_qsort) 1681# define __lzo_cdecl_qsort 1682#endif 1683#if !defined(__lzo_cdecl_sighandler) 1684# define __lzo_cdecl_sighandler 1685#endif 1686#if !defined(__lzo_cdecl_va) 1687# define __lzo_cdecl_va __lzo_cdecl 1688#endif 1689#if !defined(LZO_CFG_NO_WINDOWS_H) 1690#if (LZO_OS_CYGWIN || (LZO_OS_EMX && defined(__RSXNT__)) || LZO_OS_WIN32 || LZO_OS_WIN64) 1691# if (LZO_CC_WATCOMC && (__WATCOMC__ < 1000)) 1692# elif (LZO_OS_WIN32 && LZO_CC_GNUC) && defined(__PW32__) 1693# elif ((LZO_OS_CYGWIN || defined(__MINGW32__)) && (LZO_CC_GNUC && (LZO_CC_GNUC < 0x025f00ul))) 1694# else 1695# define LZO_HAVE_WINDOWS_H 1 1696# endif 1697#endif 1698#endif 1699#if (LZO_ARCH_ALPHA) 1700# define LZO_OPT_AVOID_UINT_INDEX 1 1701# define LZO_OPT_AVOID_SHORT 1 1702# define LZO_OPT_AVOID_USHORT 1 1703#elif (LZO_ARCH_AMD64) 1704# define LZO_OPT_AVOID_INT_INDEX 1 1705# define LZO_OPT_AVOID_UINT_INDEX 1 1706# define LZO_OPT_UNALIGNED16 1 1707# define LZO_OPT_UNALIGNED32 1 1708# define LZO_OPT_UNALIGNED64 1 1709#elif (LZO_ARCH_ARM && LZO_ARCH_ARM_THUMB) 1710#elif (LZO_ARCH_ARM) 1711# define LZO_OPT_AVOID_SHORT 1 1712# define LZO_OPT_AVOID_USHORT 1 1713#elif (LZO_ARCH_CRIS) 1714# define LZO_OPT_UNALIGNED16 1 1715# define LZO_OPT_UNALIGNED32 1 1716#elif (LZO_ARCH_I386) 1717# define LZO_OPT_UNALIGNED16 1 1718# define LZO_OPT_UNALIGNED32 1 1719#elif (LZO_ARCH_IA64) 1720# define LZO_OPT_AVOID_INT_INDEX 1 1721# define LZO_OPT_AVOID_UINT_INDEX 1 1722# define LZO_OPT_PREFER_POSTINC 1 1723#elif (LZO_ARCH_M68K) 1724# define LZO_OPT_PREFER_POSTINC 1 1725# define LZO_OPT_PREFER_PREDEC 1 1726# if defined(__mc68020__) && !defined(__mcoldfire__) 1727# define LZO_OPT_UNALIGNED16 1 1728# define LZO_OPT_UNALIGNED32 1 1729# endif 1730#elif (LZO_ARCH_MIPS) 1731# define LZO_OPT_AVOID_UINT_INDEX 1 1732#elif (LZO_ARCH_POWERPC) 1733# define LZO_OPT_PREFER_PREINC 1 1734# define LZO_OPT_PREFER_PREDEC 1 1735# if defined(LZO_ABI_BIG_ENDIAN) 1736# define LZO_OPT_UNALIGNED16 1 1737# define LZO_OPT_UNALIGNED32 1 1738# endif 1739#elif (LZO_ARCH_S390) 1740# define LZO_OPT_UNALIGNED16 1 1741# define LZO_OPT_UNALIGNED32 1 1742# if (LZO_SIZEOF_SIZE_T == 8) 1743# define LZO_OPT_UNALIGNED64 1 1744# endif 1745#elif (LZO_ARCH_SH) 1746# define LZO_OPT_PREFER_POSTINC 1 1747# define LZO_OPT_PREFER_PREDEC 1 1748#endif 1749#if !defined(LZO_CFG_NO_INLINE_ASM) 1750#if defined(LZO_CC_LLVM) 1751# define LZO_CFG_NO_INLINE_ASM 1 1752#endif 1753#endif 1754#if !defined(LZO_CFG_NO_UNALIGNED) 1755#if defined(LZO_ABI_NEUTRAL_ENDIAN) || defined(LZO_ARCH_GENERIC) 1756# define LZO_CFG_NO_UNALIGNED 1 1757#endif 1758#endif 1759#if defined(LZO_CFG_NO_UNALIGNED) 1760# undef LZO_OPT_UNALIGNED16 1761# undef LZO_OPT_UNALIGNED32 1762# undef LZO_OPT_UNALIGNED64 1763#endif 1764#if defined(LZO_CFG_NO_INLINE_ASM) 1765#elif (LZO_ARCH_I386 && (LZO_OS_DOS32 || LZO_OS_WIN32) && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) 1766# define LZO_ASM_SYNTAX_MSC 1 1767#elif (LZO_OS_WIN64 && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) 1768#elif (LZO_ARCH_I386 && (LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) 1769# define LZO_ASM_SYNTAX_GNUC 1 1770#elif (LZO_ARCH_AMD64 && (LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) 1771# define LZO_ASM_SYNTAX_GNUC 1 1772#endif 1773#if (LZO_ASM_SYNTAX_GNUC) 1774#if (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC < 0x020000ul)) 1775# define __LZO_ASM_CLOBBER "ax" 1776#elif (LZO_CC_INTELC) 1777# define __LZO_ASM_CLOBBER "memory" 1778#else 1779# define __LZO_ASM_CLOBBER "cc", "memory" 1780#endif 1781#endif 1782#if defined(__LZO_INFOSTR_MM) 1783#elif (LZO_MM_FLAT) && (defined(__LZO_INFOSTR_PM) || defined(LZO_INFO_ABI_PM)) 1784# define __LZO_INFOSTR_MM "" 1785#elif defined(LZO_INFO_MM) 1786# define __LZO_INFOSTR_MM "." LZO_INFO_MM 1787#else 1788# define __LZO_INFOSTR_MM "" 1789#endif 1790#if defined(__LZO_INFOSTR_PM) 1791#elif defined(LZO_INFO_ABI_PM) 1792# define __LZO_INFOSTR_PM "." LZO_INFO_ABI_PM 1793#else 1794# define __LZO_INFOSTR_PM "" 1795#endif 1796#if defined(__LZO_INFOSTR_ENDIAN) 1797#elif defined(LZO_INFO_ABI_ENDIAN) 1798# define __LZO_INFOSTR_ENDIAN "." LZO_INFO_ABI_ENDIAN 1799#else 1800# define __LZO_INFOSTR_ENDIAN "" 1801#endif 1802#if defined(__LZO_INFOSTR_OSNAME) 1803#elif defined(LZO_INFO_OS_CONSOLE) 1804# define __LZO_INFOSTR_OSNAME LZO_INFO_OS "." LZO_INFO_OS_CONSOLE 1805#elif defined(LZO_INFO_OS_POSIX) 1806# define __LZO_INFOSTR_OSNAME LZO_INFO_OS "." LZO_INFO_OS_POSIX 1807#else 1808# define __LZO_INFOSTR_OSNAME LZO_INFO_OS 1809#endif 1810#if defined(__LZO_INFOSTR_LIBC) 1811#elif defined(LZO_INFO_LIBC) 1812# define __LZO_INFOSTR_LIBC "." LZO_INFO_LIBC 1813#else 1814# define __LZO_INFOSTR_LIBC "" 1815#endif 1816#if defined(__LZO_INFOSTR_CCVER) 1817#elif defined(LZO_INFO_CCVER) 1818# define __LZO_INFOSTR_CCVER " " LZO_INFO_CCVER 1819#else 1820# define __LZO_INFOSTR_CCVER "" 1821#endif 1822#define LZO_INFO_STRING \ 1823 LZO_INFO_ARCH __LZO_INFOSTR_MM __LZO_INFOSTR_PM __LZO_INFOSTR_ENDIAN \ 1824 " " __LZO_INFOSTR_OSNAME __LZO_INFOSTR_LIBC " " LZO_INFO_CC __LZO_INFOSTR_CCVER 1825 1826#endif 1827 1828#endif 1829 1830#undef LZO_HAVE_CONFIG_H 1831#include "minilzo.h" 1832 1833#if !defined(MINILZO_VERSION) || (MINILZO_VERSION != 0x2030) 1834# error "version mismatch in miniLZO source files" 1835#endif 1836 1837#ifdef MINILZO_HAVE_CONFIG_H 1838# define LZO_HAVE_CONFIG_H 1839#endif 1840 1841#ifndef __LZO_CONF_H 1842#define __LZO_CONF_H 1843 1844#if !defined(__LZO_IN_MINILZO) 1845#if defined(LZO_CFG_FREESTANDING) 1846# define LZO_LIBC_FREESTANDING 1 1847# define LZO_OS_FREESTANDING 1 1848# define ACC_LIBC_FREESTANDING 1 1849# define ACC_OS_FREESTANDING 1 1850#endif 1851#if defined(LZO_CFG_NO_UNALIGNED) 1852# define ACC_CFG_NO_UNALIGNED 1 1853#endif 1854#if defined(LZO_ARCH_GENERIC) 1855# define ACC_ARCH_GENERIC 1 1856#endif 1857#if defined(LZO_ABI_NEUTRAL_ENDIAN) 1858# define ACC_ABI_NEUTRAL_ENDIAN 1 1859#endif 1860#if defined(LZO_HAVE_CONFIG_H) 1861# define ACC_CONFIG_NO_HEADER 1 1862#endif 1863#if defined(LZO_CFG_EXTRA_CONFIG_HEADER) 1864# include LZO_CFG_EXTRA_CONFIG_HEADER 1865#endif 1866#if defined(__LZOCONF_H) || defined(__LZOCONF_H_INCLUDED) 1867# error "include this file first" 1868#endif 1869#include "lzo/lzoconf.h" 1870#endif 1871 1872#if (LZO_VERSION < 0x02000) || !defined(__LZOCONF_H_INCLUDED) 1873# error "version mismatch" 1874#endif 1875 1876#if (LZO_CC_BORLANDC && LZO_ARCH_I086) 1877# pragma option -h 1878#endif 1879 1880#if (LZO_CC_MSC && (_MSC_VER >= 1000)) 1881# pragma warning(disable: 4127 4701) 1882#endif 1883#if (LZO_CC_MSC && (_MSC_VER >= 1300)) 1884# pragma warning(disable: 4820) 1885# pragma warning(disable: 4514 4710 4711) 1886#endif 1887 1888#if (LZO_CC_SUNPROC) 1889# pragma error_messages(off,E_END_OF_LOOP_CODE_NOT_REACHED) 1890# pragma error_messages(off,E_LOOP_NOT_ENTERED_AT_TOP) 1891#endif 1892 1893#if defined(__LZO_MMODEL_HUGE) && (!LZO_HAVE_MM_HUGE_PTR) 1894# error "this should not happen - check defines for __huge" 1895#endif 1896 1897#if defined(__LZO_IN_MINILZO) || defined(LZO_CFG_FREESTANDING) 1898#elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) 1899# define ACC_WANT_ACC_INCD_H 1 1900# define ACC_WANT_ACC_INCE_H 1 1901# define ACC_WANT_ACC_INCI_H 1 1902#elif 1 1903# include <string.h> 1904#else 1905# define ACC_WANT_ACC_INCD_H 1 1906#endif 1907 1908#if (LZO_ARCH_I086) 1909# define ACC_MM_AHSHIFT LZO_MM_AHSHIFT 1910# define ACC_PTR_FP_OFF(x) (((const unsigned __far*)&(x))[0]) 1911# define ACC_PTR_FP_SEG(x) (((const unsigned __far*)&(x))[1]) 1912# define ACC_PTR_MK_FP(s,o) ((void __far*)(((unsigned long)(s)<<16)+(unsigned)(o))) 1913#endif 1914 1915#if !defined(lzo_uintptr_t) 1916# if defined(__LZO_MMODEL_HUGE) 1917# define lzo_uintptr_t unsigned long 1918# elif 1 && defined(LZO_OS_OS400) && (LZO_SIZEOF_VOID_P == 16) 1919# define __LZO_UINTPTR_T_IS_POINTER 1 1920 typedef char* lzo_uintptr_t; 1921# define lzo_uintptr_t lzo_uintptr_t 1922# elif (LZO_SIZEOF_SIZE_T == LZO_SIZEOF_VOID_P) 1923# define lzo_uintptr_t size_t 1924# elif (LZO_SIZEOF_LONG == LZO_SIZEOF_VOID_P) 1925# define lzo_uintptr_t unsigned long 1926# elif (LZO_SIZEOF_INT == LZO_SIZEOF_VOID_P) 1927# define lzo_uintptr_t unsigned int 1928# elif (LZO_SIZEOF_LONG_LONG == LZO_SIZEOF_VOID_P) 1929# define lzo_uintptr_t unsigned long long 1930# else 1931# define lzo_uintptr_t size_t 1932# endif 1933#endif 1934LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp)) 1935 1936#if 1 && !defined(LZO_CFG_FREESTANDING) 1937#if 1 && !defined(HAVE_STRING_H) 1938#define HAVE_STRING_H 1 1939#endif 1940#if 1 && !defined(HAVE_MEMCMP) 1941#define HAVE_MEMCMP 1 1942#endif 1943#if 1 && !defined(HAVE_MEMCPY) 1944#define HAVE_MEMCPY 1 1945#endif 1946#if 1 && !defined(HAVE_MEMMOVE) 1947#define HAVE_MEMMOVE 1 1948#endif 1949#if 1 && !defined(HAVE_MEMSET) 1950#define HAVE_MEMSET 1 1951#endif 1952#endif 1953 1954#if 1 && defined(HAVE_STRING_H) 1955#include <string.h> 1956#endif 1957 1958#if defined(LZO_CFG_FREESTANDING) 1959# undef HAVE_MEMCMP 1960# undef HAVE_MEMCPY 1961# undef HAVE_MEMMOVE 1962# undef HAVE_MEMSET 1963#endif 1964 1965#if !defined(HAVE_MEMCMP) 1966# undef memcmp 1967# define memcmp(a,b,c) lzo_memcmp(a,b,c) 1968#elif !defined(__LZO_MMODEL_HUGE) 1969# define lzo_memcmp(a,b,c) memcmp(a,b,c) 1970#endif 1971#if !defined(HAVE_MEMCPY) 1972# undef memcpy 1973# define memcpy(a,b,c) lzo_memcpy(a,b,c) 1974#elif !defined(__LZO_MMODEL_HUGE) 1975# define lzo_memcpy(a,b,c) memcpy(a,b,c) 1976#endif 1977#if !defined(HAVE_MEMMOVE) 1978# undef memmove 1979# define memmove(a,b,c) lzo_memmove(a,b,c) 1980#elif !defined(__LZO_MMODEL_HUGE) 1981# define lzo_memmove(a,b,c) memmove(a,b,c) 1982#endif 1983#if !defined(HAVE_MEMSET) 1984# undef memset 1985# define memset(a,b,c) lzo_memset(a,b,c) 1986#elif !defined(__LZO_MMODEL_HUGE) 1987# define lzo_memset(a,b,c) memset(a,b,c) 1988#endif 1989 1990#undef NDEBUG 1991#if defined(LZO_CFG_FREESTANDING) 1992# undef LZO_DEBUG 1993# define NDEBUG 1 1994# undef assert 1995# define assert(e) ((void)0) 1996#else 1997# if !defined(LZO_DEBUG) 1998# define NDEBUG 1 1999# endif 2000# include <assert.h> 2001#endif 2002 2003#if 0 && defined(__BOUNDS_CHECKING_ON) 2004# include <unchecked.h> 2005#else 2006# define BOUNDS_CHECKING_OFF_DURING(stmt) stmt 2007# define BOUNDS_CHECKING_OFF_IN_EXPR(expr) (expr) 2008#endif 2009 2010#if !defined(__lzo_inline) 2011# define __lzo_inline 2012#endif 2013#if !defined(__lzo_forceinline) 2014# define __lzo_forceinline 2015#endif 2016#if !defined(__lzo_noinline) 2017# define __lzo_noinline 2018#endif 2019 2020#if 1 2021# define LZO_BYTE(x) ((unsigned char) (x)) 2022#else 2023# define LZO_BYTE(x) ((unsigned char) ((x) & 0xff)) 2024#endif 2025 2026#define LZO_MAX(a,b) ((a) >= (b) ? (a) : (b)) 2027#define LZO_MIN(a,b) ((a) <= (b) ? (a) : (b)) 2028#define LZO_MAX3(a,b,c) ((a) >= (b) ? LZO_MAX(a,c) : LZO_MAX(b,c)) 2029#define LZO_MIN3(a,b,c) ((a) <= (b) ? LZO_MIN(a,c) : LZO_MIN(b,c)) 2030 2031#define lzo_sizeof(type) ((lzo_uint) (sizeof(type))) 2032 2033#define LZO_HIGH(array) ((lzo_uint) (sizeof(array)/sizeof(*(array)))) 2034 2035#define LZO_SIZE(bits) (1u << (bits)) 2036#define LZO_MASK(bits) (LZO_SIZE(bits) - 1) 2037 2038#define LZO_LSIZE(bits) (1ul << (bits)) 2039#define LZO_LMASK(bits) (LZO_LSIZE(bits) - 1) 2040 2041#define LZO_USIZE(bits) ((lzo_uint) 1 << (bits)) 2042#define LZO_UMASK(bits) (LZO_USIZE(bits) - 1) 2043 2044#if !defined(DMUL) 2045#if 0 2046 2047# define DMUL(a,b) ((lzo_xint) ((lzo_uint32)(a) * (lzo_uint32)(b))) 2048#else 2049# define DMUL(a,b) ((lzo_xint) ((a) * (b))) 2050#endif 2051#endif 2052 2053#if 1 && !defined(LZO_CFG_NO_UNALIGNED) 2054#if 1 && (LZO_ARCH_AMD64 || LZO_ARCH_I386) 2055# if (LZO_SIZEOF_SHORT == 2) 2056# define LZO_UNALIGNED_OK_2 2057# endif 2058# if (LZO_SIZEOF_INT == 4) 2059# define LZO_UNALIGNED_OK_4 2060# endif 2061#endif 2062#endif 2063 2064#if defined(LZO_UNALIGNED_OK_2) 2065 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(short) == 2) 2066#endif 2067#if defined(LZO_UNALIGNED_OK_4) 2068 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint32) == 4) 2069#elif defined(LZO_ALIGNED_OK_4) 2070 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint32) == 4) 2071#endif 2072 2073#define MEMCPY8_DS(dest,src,len) \ 2074 lzo_memcpy(dest,src,len); dest += len; src += len 2075 2076#define BZERO8_PTR(s,l,n) \ 2077 lzo_memset((lzo_voidp)(s),0,(lzo_uint)(l)*(n)) 2078 2079#define MEMCPY_DS(dest,src,len) \ 2080 do *dest++ = *src++; while (--len > 0) 2081 2082__LZO_EXTERN_C int __lzo_init_done; 2083__LZO_EXTERN_C const char __lzo_copyright[]; 2084LZO_EXTERN(const lzo_bytep) lzo_copyright(void); 2085 2086#ifndef __LZO_PTR_H 2087#define __LZO_PTR_H 2088 2089#ifdef __cplusplus 2090extern "C" { 2091#endif 2092 2093#if !defined(lzo_uintptr_t) 2094# if defined(__LZO_MMODEL_HUGE) 2095# define lzo_uintptr_t unsigned long 2096# else 2097# define lzo_uintptr_t acc_uintptr_t 2098# ifdef __ACC_INTPTR_T_IS_POINTER 2099# define __LZO_UINTPTR_T_IS_POINTER 1 2100# endif 2101# endif 2102#endif 2103 2104#if (LZO_ARCH_I086) 2105#define PTR(a) ((lzo_bytep) (a)) 2106#define PTR_ALIGNED_4(a) ((ACC_PTR_FP_OFF(a) & 3) == 0) 2107#define PTR_ALIGNED2_4(a,b) (((ACC_PTR_FP_OFF(a) | ACC_PTR_FP_OFF(b)) & 3) == 0) 2108#elif (LZO_MM_PVP) 2109#define PTR(a) ((lzo_bytep) (a)) 2110#define PTR_ALIGNED_8(a) ((((lzo_uintptr_t)(a)) >> 61) == 0) 2111#define PTR_ALIGNED2_8(a,b) ((((lzo_uintptr_t)(a)|(lzo_uintptr_t)(b)) >> 61) == 0) 2112#else 2113#define PTR(a) ((lzo_uintptr_t) (a)) 2114#define PTR_LINEAR(a) PTR(a) 2115#define PTR_ALIGNED_4(a) ((PTR_LINEAR(a) & 3) == 0) 2116#define PTR_ALIGNED_8(a) ((PTR_LINEAR(a) & 7) == 0) 2117#define PTR_ALIGNED2_4(a,b) (((PTR_LINEAR(a) | PTR_LINEAR(b)) & 3) == 0) 2118#define PTR_ALIGNED2_8(a,b) (((PTR_LINEAR(a) | PTR_LINEAR(b)) & 7) == 0) 2119#endif 2120 2121#define PTR_LT(a,b) (PTR(a) < PTR(b)) 2122#define PTR_GE(a,b) (PTR(a) >= PTR(b)) 2123#define PTR_DIFF(a,b) (PTR(a) - PTR(b)) 2124#define pd(a,b) ((lzo_uint) ((a)-(b))) 2125 2126LZO_EXTERN(lzo_uintptr_t) 2127__lzo_ptr_linear(const lzo_voidp ptr); 2128 2129typedef union 2130{ 2131 char a_char; 2132 unsigned char a_uchar; 2133 short a_short; 2134 unsigned short a_ushort; 2135 int a_int; 2136 unsigned int a_uint; 2137 long a_long; 2138 unsigned long a_ulong; 2139 lzo_int a_lzo_int; 2140 lzo_uint a_lzo_uint; 2141 lzo_int32 a_lzo_int32; 2142 lzo_uint32 a_lzo_uint32; 2143 ptrdiff_t a_ptrdiff_t; 2144 lzo_uintptr_t a_lzo_uintptr_t; 2145 lzo_voidp a_lzo_voidp; 2146 void * a_void_p; 2147 lzo_bytep a_lzo_bytep; 2148 lzo_bytepp a_lzo_bytepp; 2149 lzo_uintp a_lzo_uintp; 2150 lzo_uint * a_lzo_uint_p; 2151 lzo_uint32p a_lzo_uint32p; 2152 lzo_uint32 * a_lzo_uint32_p; 2153 unsigned char * a_uchar_p; 2154 char * a_char_p; 2155} 2156lzo_full_align_t; 2157 2158#ifdef __cplusplus 2159} 2160#endif 2161 2162#endif 2163 2164#define LZO_DETERMINISTIC 2165 2166#define LZO_DICT_USE_PTR 2167#if 0 && (LZO_ARCH_I086) 2168# undef LZO_DICT_USE_PTR 2169#endif 2170 2171#if defined(LZO_DICT_USE_PTR) 2172# define lzo_dict_t const lzo_bytep 2173# define lzo_dict_p lzo_dict_t __LZO_MMODEL * 2174#else 2175# define lzo_dict_t lzo_uint 2176# define lzo_dict_p lzo_dict_t __LZO_MMODEL * 2177#endif 2178 2179#endif 2180 2181#if !defined(MINILZO_CFG_SKIP_LZO_PTR) 2182 2183LZO_PUBLIC(lzo_uintptr_t) 2184__lzo_ptr_linear(const lzo_voidp ptr) 2185{ 2186 lzo_uintptr_t p; 2187 2188#if (LZO_ARCH_I086) 2189 p = (((lzo_uintptr_t)(ACC_PTR_FP_SEG(ptr))) << (16 - ACC_MM_AHSHIFT)) + (ACC_PTR_FP_OFF(ptr)); 2190#elif (LZO_MM_PVP) 2191 p = (lzo_uintptr_t) (ptr); 2192 p = (p << 3) | (p >> 61); 2193#else 2194 p = (lzo_uintptr_t) PTR_LINEAR(ptr); 2195#endif 2196 2197 return p; 2198} 2199 2200LZO_PUBLIC(unsigned) 2201__lzo_align_gap(const lzo_voidp ptr, lzo_uint size) 2202{ 2203#if defined(__LZO_UINTPTR_T_IS_POINTER) 2204 size_t n = (size_t) ptr; 2205 n = (((n + size - 1) / size) * size) - n; 2206#else 2207 lzo_uintptr_t p, n; 2208 p = __lzo_ptr_linear(ptr); 2209 n = (((p + size - 1) / size) * size) - p; 2210#endif 2211 2212 assert(size > 0); 2213 assert((long)n >= 0); 2214 assert(n <= size); 2215 return (unsigned)n; 2216} 2217 2218#endif 2219 2220/* If you use the LZO library in a product, I would appreciate that you 2221 * keep this copyright string in the executable of your product. 2222 */ 2223 2224const char __lzo_copyright[] = 2225#if !defined(__LZO_IN_MINLZO) 2226 LZO_VERSION_STRING; 2227#else 2228 "\r\n\n" 2229 "LZO data compression library.\n" 2230 "$Copyright: LZO (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Markus Franz Xaver Johannes Oberhumer\n" 2231 "<markus@oberhumer.com>\n" 2232 "http://www.oberhumer.com $\n\n" 2233 "$Id: LZO version: v" LZO_VERSION_STRING ", " LZO_VERSION_DATE " $\n" 2234 "$Built: " __DATE__ " " __TIME__ " $\n" 2235 "$Info: " LZO_INFO_STRING " $\n"; 2236#endif 2237 2238LZO_PUBLIC(const lzo_bytep) 2239lzo_copyright(void) 2240{ 2241#if (LZO_OS_DOS16 && LZO_CC_TURBOC) 2242 return (lzo_voidp) __lzo_copyright; 2243#else 2244 return (const lzo_bytep) __lzo_copyright; 2245#endif 2246} 2247 2248LZO_PUBLIC(unsigned) 2249lzo_version(void) 2250{ 2251 return LZO_VERSION; 2252} 2253 2254LZO_PUBLIC(const char *) 2255lzo_version_string(void) 2256{ 2257 return LZO_VERSION_STRING; 2258} 2259 2260LZO_PUBLIC(const char *) 2261lzo_version_date(void) 2262{ 2263 return LZO_VERSION_DATE; 2264} 2265 2266LZO_PUBLIC(const lzo_charp) 2267_lzo_version_string(void) 2268{ 2269 return LZO_VERSION_STRING; 2270} 2271 2272LZO_PUBLIC(const lzo_charp) 2273_lzo_version_date(void) 2274{ 2275 return LZO_VERSION_DATE; 2276} 2277 2278#define LZO_BASE 65521u 2279#define LZO_NMAX 5552 2280 2281#define LZO_DO1(buf,i) s1 += buf[i]; s2 += s1 2282#define LZO_DO2(buf,i) LZO_DO1(buf,i); LZO_DO1(buf,i+1); 2283#define LZO_DO4(buf,i) LZO_DO2(buf,i); LZO_DO2(buf,i+2); 2284#define LZO_DO8(buf,i) LZO_DO4(buf,i); LZO_DO4(buf,i+4); 2285#define LZO_DO16(buf,i) LZO_DO8(buf,i); LZO_DO8(buf,i+8); 2286 2287LZO_PUBLIC(lzo_uint32) 2288lzo_adler32(lzo_uint32 adler, const lzo_bytep buf, lzo_uint len) 2289{ 2290 lzo_uint32 s1 = adler & 0xffff; 2291 lzo_uint32 s2 = (adler >> 16) & 0xffff; 2292 unsigned k; 2293 2294 if (buf == NULL) 2295 return 1; 2296 2297 while (len > 0) 2298 { 2299 k = len < LZO_NMAX ? (unsigned) len : LZO_NMAX; 2300 len -= k; 2301 if (k >= 16) do 2302 { 2303 LZO_DO16(buf,0); 2304 buf += 16; 2305 k -= 16; 2306 } while (k >= 16); 2307 if (k != 0) do 2308 { 2309 s1 += *buf++; 2310 s2 += s1; 2311 } while (--k > 0); 2312 s1 %= LZO_BASE; 2313 s2 %= LZO_BASE; 2314 } 2315 return (s2 << 16) | s1; 2316} 2317 2318#undef LZO_DO1 2319#undef LZO_DO2 2320#undef LZO_DO4 2321#undef LZO_DO8 2322#undef LZO_DO16 2323 2324#if !defined(MINILZO_CFG_SKIP_LZO_STRING) 2325#undef lzo_memcmp 2326#undef lzo_memcpy 2327#undef lzo_memmove 2328#undef lzo_memset 2329#if !defined(__LZO_MMODEL_HUGE) 2330# undef LZO_HAVE_MM_HUGE_PTR 2331#endif 2332#define lzo_hsize_t lzo_uint 2333#define lzo_hvoid_p lzo_voidp 2334#define lzo_hbyte_p lzo_bytep 2335#define LZOLIB_PUBLIC(r,f) LZO_PUBLIC(r) f 2336#define lzo_hmemcmp lzo_memcmp 2337#define lzo_hmemcpy lzo_memcpy 2338#define lzo_hmemmove lzo_memmove 2339#define lzo_hmemset lzo_memset 2340#define __LZOLIB_HMEMCPY_CH_INCLUDED 1 2341#if !defined(LZOLIB_PUBLIC) 2342# define LZOLIB_PUBLIC(r,f) r __LZOLIB_FUNCNAME(f) 2343#endif 2344LZOLIB_PUBLIC(int, lzo_hmemcmp) (const lzo_hvoid_p s1, const lzo_hvoid_p s2, lzo_hsize_t len) 2345{ 2346#if (LZO_HAVE_MM_HUGE_PTR) || !defined(HAVE_MEMCMP) 2347 const lzo_hbyte_p p1 = (const lzo_hbyte_p) s1; 2348 const lzo_hbyte_p p2 = (const lzo_hbyte_p) s2; 2349 if __lzo_likely(len > 0) do 2350 { 2351 int d = *p1 - *p2; 2352 if (d != 0) 2353 return d; 2354 p1++; p2++; 2355 } while __lzo_likely(--len > 0); 2356 return 0; 2357#else 2358 return memcmp(s1, s2, len); 2359#endif 2360} 2361LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemcpy) (lzo_hvoid_p dest, const lzo_hvoid_p src, lzo_hsize_t len) 2362{ 2363#if (LZO_HAVE_MM_HUGE_PTR) || !defined(HAVE_MEMCPY) 2364 lzo_hbyte_p p1 = (lzo_hbyte_p) dest; 2365 const lzo_hbyte_p p2 = (const lzo_hbyte_p) src; 2366 if (!(len > 0) || p1 == p2) 2367 return dest; 2368 do 2369 *p1++ = *p2++; 2370 while __lzo_likely(--len > 0); 2371 return dest; 2372#else 2373 return memcpy(dest, src, len); 2374#endif 2375} 2376LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemmove) (lzo_hvoid_p dest, const lzo_hvoid_p src, lzo_hsize_t len) 2377{ 2378#if (LZO_HAVE_MM_HUGE_PTR) || !defined(HAVE_MEMMOVE) 2379 lzo_hbyte_p p1 = (lzo_hbyte_p) dest; 2380 const lzo_hbyte_p p2 = (const lzo_hbyte_p) src; 2381 if (!(len > 0) || p1 == p2) 2382 return dest; 2383 if (p1 < p2) 2384 { 2385 do 2386 *p1++ = *p2++; 2387 while __lzo_likely(--len > 0); 2388 } 2389 else 2390 { 2391 p1 += len; 2392 p2 += len; 2393 do 2394 *--p1 = *--p2; 2395 while __lzo_likely(--len > 0); 2396 } 2397 return dest; 2398#else 2399 return memmove(dest, src, len); 2400#endif 2401} 2402LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemset) (lzo_hvoid_p s, int c, lzo_hsize_t len) 2403{ 2404#if (LZO_HAVE_MM_HUGE_PTR) || !defined(HAVE_MEMSET) 2405 lzo_hbyte_p p = (lzo_hbyte_p) s; 2406 if __lzo_likely(len > 0) do 2407 *p++ = (unsigned char) c; 2408 while __lzo_likely(--len > 0); 2409 return s; 2410#else 2411 return memset(s, c, len); 2412#endif 2413} 2414#undef LZOLIB_PUBLIC 2415#endif 2416 2417#if !defined(__LZO_IN_MINILZO) 2418 2419#define ACC_WANT_ACC_CHK_CH 1 2420#undef ACCCHK_ASSERT 2421 2422 ACCCHK_ASSERT_IS_SIGNED_T(lzo_int) 2423 ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uint) 2424 2425 ACCCHK_ASSERT_IS_SIGNED_T(lzo_int32) 2426 ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uint32) 2427 ACCCHK_ASSERT((LZO_UINT32_C(1) << (int)(8*sizeof(LZO_UINT32_C(1))-1)) > 0) 2428 ACCCHK_ASSERT(sizeof(lzo_uint32) >= 4) 2429 2430#if !defined(__LZO_UINTPTR_T_IS_POINTER) 2431 ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uintptr_t) 2432#endif 2433 ACCCHK_ASSERT(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp)) 2434 2435 ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_xint) 2436 ACCCHK_ASSERT(sizeof(lzo_xint) >= sizeof(lzo_uint32)) 2437 ACCCHK_ASSERT(sizeof(lzo_xint) >= sizeof(lzo_uint)) 2438 ACCCHK_ASSERT(sizeof(lzo_xint) == sizeof(lzo_uint32) || sizeof(lzo_xint) == sizeof(lzo_uint)) 2439 2440#endif 2441#undef ACCCHK_ASSERT 2442 2443LZO_PUBLIC(int) 2444_lzo_config_check(void) 2445{ 2446 lzo_bool r = 1; 2447 union { unsigned char c[2*sizeof(lzo_xint)]; lzo_xint l[2]; } u; 2448 lzo_uintptr_t p; 2449 2450#if !defined(LZO_CFG_NO_CONFIG_CHECK) 2451#if defined(LZO_ABI_BIG_ENDIAN) 2452 u.l[0] = u.l[1] = 0; u.c[sizeof(lzo_xint) - 1] = 128; 2453 r &= (u.l[0] == 128); 2454#endif 2455#if defined(LZO_ABI_LITTLE_ENDIAN) 2456 u.l[0] = u.l[1] = 0; u.c[0] = 128; 2457 r &= (u.l[0] == 128); 2458#endif 2459#if defined(LZO_UNALIGNED_OK_2) 2460 p = (lzo_uintptr_t) (const lzo_voidp) &u.c[0]; 2461 u.l[0] = u.l[1] = 0; 2462 r &= ((* (const lzo_ushortp) (p+1)) == 0); 2463#endif 2464#if defined(LZO_UNALIGNED_OK_4) 2465 p = (lzo_uintptr_t) (const lzo_voidp) &u.c[0]; 2466 u.l[0] = u.l[1] = 0; 2467 r &= ((* (const lzo_uint32p) (p+1)) == 0); 2468#endif 2469#endif 2470 2471 LZO_UNUSED(u); LZO_UNUSED(p); 2472 return r == 1 ? LZO_E_OK : LZO_E_ERROR; 2473} 2474 2475int __lzo_init_done = 0; 2476 2477LZO_PUBLIC(int) 2478__lzo_init_v2(unsigned v, int s1, int s2, int s3, int s4, int s5, 2479 int s6, int s7, int s8, int s9) 2480{ 2481 int r; 2482 2483#if defined(__LZO_IN_MINILZO) 2484#elif (LZO_CC_MSC && ((_MSC_VER) < 700)) 2485#else 2486#define ACC_WANT_ACC_CHK_CH 1 2487#undef ACCCHK_ASSERT 2488#define ACCCHK_ASSERT(expr) LZO_COMPILE_TIME_ASSERT(expr) 2489#endif 2490#undef ACCCHK_ASSERT 2491 2492 __lzo_init_done = 1; 2493 2494 if (v == 0) 2495 return LZO_E_ERROR; 2496 2497 r = (s1 == -1 || s1 == (int) sizeof(short)) && 2498 (s2 == -1 || s2 == (int) sizeof(int)) && 2499 (s3 == -1 || s3 == (int) sizeof(long)) && 2500 (s4 == -1 || s4 == (int) sizeof(lzo_uint32)) && 2501 (s5 == -1 || s5 == (int) sizeof(lzo_uint)) && 2502 (s6 == -1 || s6 == (int) lzo_sizeof_dict_t) && 2503 (s7 == -1 || s7 == (int) sizeof(char *)) && 2504 (s8 == -1 || s8 == (int) sizeof(lzo_voidp)) && 2505 (s9 == -1 || s9 == (int) sizeof(lzo_callback_t)); 2506 if (!r) 2507 return LZO_E_ERROR; 2508 2509 r = _lzo_config_check(); 2510 if (r != LZO_E_OK) 2511 return r; 2512 2513 return r; 2514} 2515 2516#if !defined(__LZO_IN_MINILZO) 2517 2518#if (LZO_OS_WIN16 && LZO_CC_WATCOMC) && defined(__SW_BD) 2519 2520#if 0 2521BOOL FAR PASCAL LibMain ( HANDLE hInstance, WORD wDataSegment, 2522 WORD wHeapSize, LPSTR lpszCmdLine ) 2523#else 2524int __far __pascal LibMain ( int a, short b, short c, long d ) 2525#endif 2526{ 2527 LZO_UNUSED(a); LZO_UNUSED(b); LZO_UNUSED(c); LZO_UNUSED(d); 2528 return 1; 2529} 2530 2531#endif 2532 2533#endif 2534 2535#define do_compress _lzo1x_1_do_compress 2536 2537#if !defined(MINILZO_CFG_SKIP_LZO1X_1_COMPRESS) 2538 2539#define LZO_NEED_DICT_H 2540#define D_BITS 14 2541#define D_INDEX1(d,p) d = DM(DMUL(0x21,DX3(p,5,5,6)) >> 5) 2542#define D_INDEX2(d,p) d = (d & (D_MASK & 0x7ff)) ^ (D_HIGH | 0x1f) 2543 2544#ifndef __LZO_CONFIG1X_H 2545#define __LZO_CONFIG1X_H 2546 2547#if !defined(LZO1X) && !defined(LZO1Y) && !defined(LZO1Z) 2548# define LZO1X 2549#endif 2550 2551#if !defined(__LZO_IN_MINILZO) 2552#include "lzo/lzo1x.h" 2553#endif 2554 2555#define LZO_EOF_CODE 2556#undef LZO_DETERMINISTIC 2557 2558#define M1_MAX_OFFSET 0x0400 2559#ifndef M2_MAX_OFFSET 2560#define M2_MAX_OFFSET 0x0800 2561#endif 2562#define M3_MAX_OFFSET 0x4000 2563#define M4_MAX_OFFSET 0xbfff 2564 2565#define MX_MAX_OFFSET (M1_MAX_OFFSET + M2_MAX_OFFSET) 2566 2567#define M1_MIN_LEN 2 2568#define M1_MAX_LEN 2 2569#define M2_MIN_LEN 3 2570#ifndef M2_MAX_LEN 2571#define M2_MAX_LEN 8 2572#endif 2573#define M3_MIN_LEN 3 2574#define M3_MAX_LEN 33 2575#define M4_MIN_LEN 3 2576#define M4_MAX_LEN 9 2577 2578#define M1_MARKER 0 2579#define M2_MARKER 64 2580#define M3_MARKER 32 2581#define M4_MARKER 16 2582 2583#ifndef MIN_LOOKAHEAD 2584#define MIN_LOOKAHEAD (M2_MAX_LEN + 1) 2585#endif 2586 2587#if defined(LZO_NEED_DICT_H) 2588 2589#ifndef LZO_HASH 2590#define LZO_HASH LZO_HASH_LZO_INCREMENTAL_B 2591#endif 2592#define DL_MIN_LEN M2_MIN_LEN 2593 2594#ifndef __LZO_DICT_H 2595#define __LZO_DICT_H 2596 2597#ifdef __cplusplus 2598extern "C" { 2599#endif 2600 2601#if !defined(D_BITS) && defined(DBITS) 2602# define D_BITS DBITS 2603#endif 2604#if !defined(D_BITS) 2605# error "D_BITS is not defined" 2606#endif 2607#if (D_BITS < 16) 2608# define D_SIZE LZO_SIZE(D_BITS) 2609# define D_MASK LZO_MASK(D_BITS) 2610#else 2611# define D_SIZE LZO_USIZE(D_BITS) 2612# define D_MASK LZO_UMASK(D_BITS) 2613#endif 2614#define D_HIGH ((D_MASK >> 1) + 1) 2615 2616#if !defined(DD_BITS) 2617# define DD_BITS 0 2618#endif 2619#define DD_SIZE LZO_SIZE(DD_BITS) 2620#define DD_MASK LZO_MASK(DD_BITS) 2621 2622#if !defined(DL_BITS) 2623# define DL_BITS (D_BITS - DD_BITS) 2624#endif 2625#if (DL_BITS < 16) 2626# define DL_SIZE LZO_SIZE(DL_BITS) 2627# define DL_MASK LZO_MASK(DL_BITS) 2628#else 2629# define DL_SIZE LZO_USIZE(DL_BITS) 2630# define DL_MASK LZO_UMASK(DL_BITS) 2631#endif 2632 2633#if (D_BITS != DL_BITS + DD_BITS) 2634# error "D_BITS does not match" 2635#endif 2636#if (D_BITS < 8 || D_BITS > 18) 2637# error "invalid D_BITS" 2638#endif 2639#if (DL_BITS < 8 || DL_BITS > 20) 2640# error "invalid DL_BITS" 2641#endif 2642#if (DD_BITS < 0 || DD_BITS > 6) 2643# error "invalid DD_BITS" 2644#endif 2645 2646#if !defined(DL_MIN_LEN) 2647# define DL_MIN_LEN 3 2648#endif 2649#if !defined(DL_SHIFT) 2650# define DL_SHIFT ((DL_BITS + (DL_MIN_LEN - 1)) / DL_MIN_LEN) 2651#endif 2652 2653#define LZO_HASH_GZIP 1 2654#define LZO_HASH_GZIP_INCREMENTAL 2 2655#define LZO_HASH_LZO_INCREMENTAL_A 3 2656#define LZO_HASH_LZO_INCREMENTAL_B 4 2657 2658#if !defined(LZO_HASH) 2659# error "choose a hashing strategy" 2660#endif 2661 2662#undef DM 2663#undef DX 2664 2665#if (DL_MIN_LEN == 3) 2666# define _DV2_A(p,shift1,shift2) \ 2667 (((( (lzo_xint)((p)[0]) << shift1) ^ (p)[1]) << shift2) ^ (p)[2]) 2668# define _DV2_B(p,shift1,shift2) \ 2669 (((( (lzo_xint)((p)[2]) << shift1) ^ (p)[1]) << shift2) ^ (p)[0]) 2670# define _DV3_B(p,shift1,shift2,shift3) \ 2671 ((_DV2_B((p)+1,shift1,shift2) << (shift3)) ^ (p)[0]) 2672#elif (DL_MIN_LEN == 2) 2673# define _DV2_A(p,shift1,shift2) \ 2674 (( (lzo_xint)(p[0]) << shift1) ^ p[1]) 2675# define _DV2_B(p,shift1,shift2) \ 2676 (( (lzo_xint)(p[1]) << shift1) ^ p[2]) 2677#else 2678# error "invalid DL_MIN_LEN" 2679#endif 2680#define _DV_A(p,shift) _DV2_A(p,shift,shift) 2681#define _DV_B(p,shift) _DV2_B(p,shift,shift) 2682#define DA2(p,s1,s2) \ 2683 (((((lzo_xint)((p)[2]) << (s2)) + (p)[1]) << (s1)) + (p)[0]) 2684#define DS2(p,s1,s2) \ 2685 (((((lzo_xint)((p)[2]) << (s2)) - (p)[1]) << (s1)) - (p)[0]) 2686#define DX2(p,s1,s2) \ 2687 (((((lzo_xint)((p)[2]) << (s2)) ^ (p)[1]) << (s1)) ^ (p)[0]) 2688#define DA3(p,s1,s2,s3) ((DA2((p)+1,s2,s3) << (s1)) + (p)[0]) 2689#define DS3(p,s1,s2,s3) ((DS2((p)+1,s2,s3) << (s1)) - (p)[0]) 2690#define DX3(p,s1,s2,s3) ((DX2((p)+1,s2,s3) << (s1)) ^ (p)[0]) 2691#define DMS(v,s) ((lzo_uint) (((v) & (D_MASK >> (s))) << (s))) 2692#define DM(v) DMS(v,0) 2693 2694#if (LZO_HASH == LZO_HASH_GZIP) 2695# define _DINDEX(dv,p) (_DV_A((p),DL_SHIFT)) 2696 2697#elif (LZO_HASH == LZO_HASH_GZIP_INCREMENTAL) 2698# define __LZO_HASH_INCREMENTAL 2699# define DVAL_FIRST(dv,p) dv = _DV_A((p),DL_SHIFT) 2700# define DVAL_NEXT(dv,p) dv = (((dv) << DL_SHIFT) ^ p[2]) 2701# define _DINDEX(dv,p) (dv) 2702# define DVAL_LOOKAHEAD DL_MIN_LEN 2703 2704#elif (LZO_HASH == LZO_HASH_LZO_INCREMENTAL_A) 2705# define __LZO_HASH_INCREMENTAL 2706# define DVAL_FIRST(dv,p) dv = _DV_A((p),5) 2707# define DVAL_NEXT(dv,p) \ 2708 dv ^= (lzo_xint)(p[-1]) << (2*5); dv = (((dv) << 5) ^ p[2]) 2709# define _DINDEX(dv,p) ((DMUL(0x9f5f,dv)) >> 5) 2710# define DVAL_LOOKAHEAD DL_MIN_LEN 2711 2712#elif (LZO_HASH == LZO_HASH_LZO_INCREMENTAL_B) 2713# define __LZO_HASH_INCREMENTAL 2714# define DVAL_FIRST(dv,p) dv = _DV_B((p),5) 2715# define DVAL_NEXT(dv,p) \ 2716 dv ^= p[-1]; dv = (((dv) >> 5) ^ ((lzo_xint)(p[2]) << (2*5))) 2717# define _DINDEX(dv,p) ((DMUL(0x9f5f,dv)) >> 5) 2718# define DVAL_LOOKAHEAD DL_MIN_LEN 2719 2720#else 2721# error "choose a hashing strategy" 2722#endif 2723 2724#ifndef DINDEX 2725#define DINDEX(dv,p) ((lzo_uint)((_DINDEX(dv,p)) & DL_MASK) << DD_BITS) 2726#endif 2727#if !defined(DINDEX1) && defined(D_INDEX1) 2728#define DINDEX1 D_INDEX1 2729#endif 2730#if !defined(DINDEX2) && defined(D_INDEX2) 2731#define DINDEX2 D_INDEX2 2732#endif 2733 2734#if !defined(__LZO_HASH_INCREMENTAL) 2735# define DVAL_FIRST(dv,p) ((void) 0) 2736# define DVAL_NEXT(dv,p) ((void) 0) 2737# define DVAL_LOOKAHEAD 0 2738#endif 2739 2740#if !defined(DVAL_ASSERT) 2741#if defined(__LZO_HASH_INCREMENTAL) && !defined(NDEBUG) 2742static void DVAL_ASSERT(lzo_xint dv, const lzo_bytep p) 2743{ 2744 lzo_xint df; 2745 DVAL_FIRST(df,(p)); 2746 assert(DINDEX(dv,p) == DINDEX(df,p)); 2747} 2748#else 2749# define DVAL_ASSERT(dv,p) ((void) 0) 2750#endif 2751#endif 2752 2753#if defined(LZO_DICT_USE_PTR) 2754# define DENTRY(p,in) (p) 2755# define GINDEX(m_pos,m_off,dict,dindex,in) m_pos = dict[dindex] 2756#else 2757# define DENTRY(p,in) ((lzo_uint) ((p)-(in))) 2758# define GINDEX(m_pos,m_off,dict,dindex,in) m_off = dict[dindex] 2759#endif 2760 2761#if (DD_BITS == 0) 2762 2763# define UPDATE_D(dict,drun,dv,p,in) dict[ DINDEX(dv,p) ] = DENTRY(p,in) 2764# define UPDATE_I(dict,drun,index,p,in) dict[index] = DENTRY(p,in) 2765# define UPDATE_P(ptr,drun,p,in) (ptr)[0] = DENTRY(p,in) 2766 2767#else 2768 2769# define UPDATE_D(dict,drun,dv,p,in) \ 2770 dict[ DINDEX(dv,p) + drun++ ] = DENTRY(p,in); drun &= DD_MASK 2771# define UPDATE_I(dict,drun,index,p,in) \ 2772 dict[ (index) + drun++ ] = DENTRY(p,in); drun &= DD_MASK 2773# define UPDATE_P(ptr,drun,p,in) \ 2774 (ptr) [ drun++ ] = DENTRY(p,in); drun &= DD_MASK 2775 2776#endif 2777 2778#if defined(LZO_DICT_USE_PTR) 2779 2780#define LZO_CHECK_MPOS_DET(m_pos,m_off,in,ip,max_offset) \ 2781 (m_pos == NULL || (m_off = pd(ip, m_pos)) > max_offset) 2782 2783#define LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,max_offset) \ 2784 (BOUNDS_CHECKING_OFF_IN_EXPR(( \ 2785 m_pos = ip - (lzo_uint) PTR_DIFF(ip,m_pos), \ 2786 PTR_LT(m_pos,in) || \ 2787 (m_off = (lzo_uint) PTR_DIFF(ip,m_pos)) <= 0 || \ 2788 m_off > max_offset ))) 2789 2790#else 2791 2792#define LZO_CHECK_MPOS_DET(m_pos,m_off,in,ip,max_offset) \ 2793 (m_off == 0 || \ 2794 ((m_off = pd(ip, in) - m_off) > max_offset) || \ 2795 (m_pos = (ip) - (m_off), 0) ) 2796 2797#define LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,max_offset) \ 2798 (pd(ip, in) <= m_off || \ 2799 ((m_off = pd(ip, in) - m_off) > max_offset) || \ 2800 (m_pos = (ip) - (m_off), 0) ) 2801 2802#endif 2803 2804#if defined(LZO_DETERMINISTIC) 2805# define LZO_CHECK_MPOS LZO_CHECK_MPOS_DET 2806#else 2807# define LZO_CHECK_MPOS LZO_CHECK_MPOS_NON_DET 2808#endif 2809 2810#ifdef __cplusplus 2811} 2812#endif 2813 2814#endif 2815 2816#endif 2817 2818#endif 2819 2820#define DO_COMPRESS lzo1x_1_compress 2821 2822static __lzo_noinline lzo_uint 2823do_compress ( const lzo_bytep in , lzo_uint in_len, 2824 lzo_bytep out, lzo_uintp out_len, 2825 lzo_voidp wrkmem ) 2826{ 2827 register const lzo_bytep ip; 2828 lzo_bytep op; 2829 const lzo_bytep const in_end = in + in_len; 2830 const lzo_bytep const ip_end = in + in_len - M2_MAX_LEN - 5; 2831 const lzo_bytep ii; 2832 lzo_dict_p const dict = (lzo_dict_p) wrkmem; 2833 2834 op = out; 2835 ip = in; 2836 ii = ip; 2837 2838 ip += 4; 2839 for (;;) 2840 { 2841 register const lzo_bytep m_pos; 2842 lzo_uint m_off; 2843 lzo_uint m_len; 2844 lzo_uint dindex; 2845 2846 DINDEX1(dindex,ip); 2847 GINDEX(m_pos,m_off,dict,dindex,in); 2848 if (LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,M4_MAX_OFFSET)) 2849 goto literal; 2850#if 1 2851 if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3]) 2852 goto try_match; 2853 DINDEX2(dindex,ip); 2854#endif 2855 GINDEX(m_pos,m_off,dict,dindex,in); 2856 if (LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,M4_MAX_OFFSET)) 2857 goto literal; 2858 if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3]) 2859 goto try_match; 2860 goto literal; 2861 2862try_match: 2863#if 1 && defined(LZO_UNALIGNED_OK_2) 2864 if (* (const lzo_ushortp) m_pos != * (const lzo_ushortp) ip) 2865#else 2866 if (m_pos[0] != ip[0] || m_pos[1] != ip[1]) 2867#endif 2868 { 2869 } 2870 else 2871 { 2872 if __lzo_likely(m_pos[2] == ip[2]) 2873 { 2874#if 0 2875 if (m_off <= M2_MAX_OFFSET) 2876 goto match; 2877 if (lit <= 3) 2878 goto match; 2879 if (lit == 3) 2880 { 2881 assert(op - 2 > out); op[-2] |= LZO_BYTE(3); 2882 *op++ = *ii++; *op++ = *ii++; *op++ = *ii++; 2883 goto code_match; 2884 } 2885 if (m_pos[3] == ip[3]) 2886#endif 2887 goto match; 2888 } 2889 else 2890 { 2891#if 0 2892#if 0 2893 if (m_off <= M1_MAX_OFFSET && lit > 0 && lit <= 3) 2894#else 2895 if (m_off <= M1_MAX_OFFSET && lit == 3) 2896#endif 2897 { 2898 register lzo_uint t; 2899 2900 t = lit; 2901 assert(op - 2 > out); op[-2] |= LZO_BYTE(t); 2902 do *op++ = *ii++; while (--t > 0); 2903 assert(ii == ip); 2904 m_off -= 1; 2905 *op++ = LZO_BYTE(M1_MARKER | ((m_off & 3) << 2)); 2906 *op++ = LZO_BYTE(m_off >> 2); 2907 ip += 2; 2908 goto match_done; 2909 } 2910#endif 2911 } 2912 } 2913 2914literal: 2915 UPDATE_I(dict,0,dindex,ip,in); 2916 ++ip; 2917 if __lzo_unlikely(ip >= ip_end) 2918 break; 2919 continue; 2920 2921match: 2922 UPDATE_I(dict,0,dindex,ip,in); 2923 if (pd(ip,ii) > 0) 2924 { 2925 register lzo_uint t = pd(ip,ii); 2926 2927 if (t <= 3) 2928 { 2929 assert(op - 2 > out); 2930 op[-2] |= LZO_BYTE(t); 2931 } 2932 else if (t <= 18) 2933 *op++ = LZO_BYTE(t - 3); 2934 else 2935 { 2936 register lzo_uint tt = t - 18; 2937 2938 *op++ = 0; 2939 while (tt > 255) 2940 { 2941 tt -= 255; 2942 *op++ = 0; 2943 } 2944 assert(tt > 0); 2945 *op++ = LZO_BYTE(tt); 2946 } 2947 do *op++ = *ii++; while (--t > 0); 2948 } 2949 2950 assert(ii == ip); 2951 ip += 3; 2952 if (m_pos[3] != *ip++ || m_pos[4] != *ip++ || m_pos[5] != *ip++ || 2953 m_pos[6] != *ip++ || m_pos[7] != *ip++ || m_pos[8] != *ip++ 2954#ifdef LZO1Y 2955 || m_pos[ 9] != *ip++ || m_pos[10] != *ip++ || m_pos[11] != *ip++ 2956 || m_pos[12] != *ip++ || m_pos[13] != *ip++ || m_pos[14] != *ip++ 2957#endif 2958 ) 2959 { 2960 --ip; 2961 m_len = pd(ip, ii); 2962 assert(m_len >= 3); assert(m_len <= M2_MAX_LEN); 2963 2964 if (m_off <= M2_MAX_OFFSET) 2965 { 2966 m_off -= 1; 2967#if defined(LZO1X) 2968 *op++ = LZO_BYTE(((m_len - 1) << 5) | ((m_off & 7) << 2)); 2969 *op++ = LZO_BYTE(m_off >> 3); 2970#elif defined(LZO1Y) 2971 *op++ = LZO_BYTE(((m_len + 1) << 4) | ((m_off & 3) << 2)); 2972 *op++ = LZO_BYTE(m_off >> 2); 2973#endif 2974 } 2975 else if (m_off <= M3_MAX_OFFSET) 2976 { 2977 m_off -= 1; 2978 *op++ = LZO_BYTE(M3_MARKER | (m_len - 2)); 2979 goto m3_m4_offset; 2980 } 2981 else 2982#if defined(LZO1X) 2983 { 2984 m_off -= 0x4000; 2985 assert(m_off > 0); assert(m_off <= 0x7fff); 2986 *op++ = LZO_BYTE(M4_MARKER | 2987 ((m_off & 0x4000) >> 11) | (m_len - 2)); 2988 goto m3_m4_offset; 2989 } 2990#elif defined(LZO1Y) 2991 goto m4_match; 2992#endif 2993 } 2994 else 2995 { 2996 { 2997 const lzo_bytep end = in_end; 2998 const lzo_bytep m = m_pos + M2_MAX_LEN + 1; 2999 while (ip < end && *m == *ip) 3000 m++, ip++; 3001 m_len = pd(ip, ii); 3002 } 3003 assert(m_len > M2_MAX_LEN); 3004 3005 if (m_off <= M3_MAX_OFFSET) 3006 { 3007 m_off -= 1; 3008 if (m_len <= 33) 3009 *op++ = LZO_BYTE(M3_MARKER | (m_len - 2)); 3010 else 3011 { 3012 m_len -= 33; 3013 *op++ = M3_MARKER | 0; 3014 goto m3_m4_len; 3015 } 3016 } 3017 else 3018 { 3019#if defined(LZO1Y) 3020m4_match: 3021#endif 3022 m_off -= 0x4000; 3023 assert(m_off > 0); assert(m_off <= 0x7fff); 3024 if (m_len <= M4_MAX_LEN) 3025 *op++ = LZO_BYTE(M4_MARKER | 3026 ((m_off & 0x4000) >> 11) | (m_len - 2)); 3027 else 3028 { 3029 m_len -= M4_MAX_LEN; 3030 *op++ = LZO_BYTE(M4_MARKER | ((m_off & 0x4000) >> 11)); 3031m3_m4_len: 3032 while (m_len > 255) 3033 { 3034 m_len -= 255; 3035 *op++ = 0; 3036 } 3037 assert(m_len > 0); 3038 *op++ = LZO_BYTE(m_len); 3039 } 3040 } 3041 3042m3_m4_offset: 3043 *op++ = LZO_BYTE((m_off & 63) << 2); 3044 *op++ = LZO_BYTE(m_off >> 6); 3045 } 3046 3047#if 0 3048match_done: 3049#endif 3050 ii = ip; 3051 if __lzo_unlikely(ip >= ip_end) 3052 break; 3053 } 3054 3055 *out_len = pd(op, out); 3056 return pd(in_end,ii); 3057} 3058 3059LZO_PUBLIC(int) 3060DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len, 3061 lzo_bytep out, lzo_uintp out_len, 3062 lzo_voidp wrkmem ) 3063{ 3064 lzo_bytep op = out; 3065 lzo_uint t; 3066 3067 if __lzo_unlikely(in_len <= M2_MAX_LEN + 5) 3068 t = in_len; 3069 else 3070 { 3071 t = do_compress(in,in_len,op,out_len,wrkmem); 3072 op += *out_len; 3073 } 3074 3075 if (t > 0) 3076 { 3077 const lzo_bytep ii = in + in_len - t; 3078 3079 if (op == out && t <= 238) 3080 *op++ = LZO_BYTE(17 + t); 3081 else if (t <= 3) 3082 op[-2] |= LZO_BYTE(t); 3083 else if (t <= 18) 3084 *op++ = LZO_BYTE(t - 3); 3085 else 3086 { 3087 lzo_uint tt = t - 18; 3088 3089 *op++ = 0; 3090 while (tt > 255) 3091 { 3092 tt -= 255; 3093 *op++ = 0; 3094 } 3095 assert(tt > 0); 3096 *op++ = LZO_BYTE(tt); 3097 } 3098 do *op++ = *ii++; while (--t > 0); 3099 } 3100 3101 *op++ = M4_MARKER | 1; 3102 *op++ = 0; 3103 *op++ = 0; 3104 3105 *out_len = pd(op, out); 3106 return LZO_E_OK; 3107} 3108 3109#endif 3110 3111#undef do_compress 3112#undef DO_COMPRESS 3113#undef LZO_HASH 3114 3115#undef LZO_TEST_OVERRUN 3116#undef DO_DECOMPRESS 3117#define DO_DECOMPRESS lzo1x_decompress 3118 3119#if !defined(MINILZO_CFG_SKIP_LZO1X_DECOMPRESS) 3120 3121#if defined(LZO_TEST_OVERRUN) 3122# if !defined(LZO_TEST_OVERRUN_INPUT) 3123# define LZO_TEST_OVERRUN_INPUT 2 3124# endif 3125# if !defined(LZO_TEST_OVERRUN_OUTPUT) 3126# define LZO_TEST_OVERRUN_OUTPUT 2 3127# endif 3128# if !defined(LZO_TEST_OVERRUN_LOOKBEHIND) 3129# define LZO_TEST_OVERRUN_LOOKBEHIND 3130# endif 3131#endif 3132 3133#undef TEST_IP 3134#undef TEST_OP 3135#undef TEST_LB 3136#undef TEST_LBO 3137#undef NEED_IP 3138#undef NEED_OP 3139#undef HAVE_TEST_IP 3140#undef HAVE_TEST_OP 3141#undef HAVE_NEED_IP 3142#undef HAVE_NEED_OP 3143#undef HAVE_ANY_IP 3144#undef HAVE_ANY_OP 3145 3146#if defined(LZO_TEST_OVERRUN_INPUT) 3147# if (LZO_TEST_OVERRUN_INPUT >= 1) 3148# define TEST_IP (ip < ip_end) 3149# endif 3150# if (LZO_TEST_OVERRUN_INPUT >= 2) 3151# define NEED_IP(x) \ 3152 if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x)) goto input_overrun 3153# endif 3154#endif 3155 3156#if defined(LZO_TEST_OVERRUN_OUTPUT) 3157# if (LZO_TEST_OVERRUN_OUTPUT >= 1) 3158# define TEST_OP (op <= op_end) 3159# endif 3160# if (LZO_TEST_OVERRUN_OUTPUT >= 2) 3161# undef TEST_OP 3162# define NEED_OP(x) \ 3163 if ((lzo_uint)(op_end - op) < (lzo_uint)(x)) goto output_overrun 3164# endif 3165#endif 3166 3167#if defined(LZO_TEST_OVERRUN_LOOKBEHIND) 3168# define TEST_LB(m_pos) if (m_pos < out || m_pos >= op) goto lookbehind_overrun 3169# define TEST_LBO(m_pos,o) if (m_pos < out || m_pos >= op - (o)) goto lookbehind_overrun 3170#else 3171# define TEST_LB(m_pos) ((void) 0) 3172# define TEST_LBO(m_pos,o) ((void) 0) 3173#endif 3174 3175#if !defined(LZO_EOF_CODE) && !defined(TEST_IP) 3176# define TEST_IP (ip < ip_end) 3177#endif 3178 3179#if defined(TEST_IP) 3180# define HAVE_TEST_IP 3181#else 3182# define TEST_IP 1 3183#endif 3184#if defined(TEST_OP) 3185# define HAVE_TEST_OP 3186#else 3187# define TEST_OP 1 3188#endif 3189 3190#if defined(NEED_IP) 3191# define HAVE_NEED_IP 3192#else 3193# define NEED_IP(x) ((void) 0) 3194#endif 3195#if defined(NEED_OP) 3196# define HAVE_NEED_OP 3197#else 3198# define NEED_OP(x) ((void) 0) 3199#endif 3200 3201#if defined(HAVE_TEST_IP) || defined(HAVE_NEED_IP) 3202# define HAVE_ANY_IP 3203#endif 3204#if defined(HAVE_TEST_OP) || defined(HAVE_NEED_OP) 3205# define HAVE_ANY_OP 3206#endif 3207 3208#undef __COPY4 3209#define __COPY4(dst,src) * (lzo_uint32p)(dst) = * (const lzo_uint32p)(src) 3210 3211#undef COPY4 3212#if defined(LZO_UNALIGNED_OK_4) 3213# define COPY4(dst,src) __COPY4(dst,src) 3214#elif defined(LZO_ALIGNED_OK_4) 3215# define COPY4(dst,src) __COPY4((lzo_uintptr_t)(dst),(lzo_uintptr_t)(src)) 3216#endif 3217 3218#if defined(DO_DECOMPRESS) 3219LZO_PUBLIC(int) 3220DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, 3221 lzo_bytep out, lzo_uintp out_len, 3222 lzo_voidp wrkmem ) 3223#endif 3224{ 3225 register lzo_bytep op; 3226 register const lzo_bytep ip; 3227 register lzo_uint t; 3228#if defined(COPY_DICT) 3229 lzo_uint m_off; 3230 const lzo_bytep dict_end; 3231#else 3232 register const lzo_bytep m_pos; 3233#endif 3234 3235 const lzo_bytep const ip_end = in + in_len; 3236#if defined(HAVE_ANY_OP) 3237 lzo_bytep const op_end = out + *out_len; 3238#endif 3239#if defined(LZO1Z) 3240 lzo_uint last_m_off = 0; 3241#endif 3242 3243 LZO_UNUSED(wrkmem); 3244 3245#if defined(COPY_DICT) 3246 if (dict) 3247 { 3248 if (dict_len > M4_MAX_OFFSET) 3249 { 3250 dict += dict_len - M4_MAX_OFFSET; 3251 dict_len = M4_MAX_OFFSET; 3252 } 3253 dict_end = dict + dict_len; 3254 } 3255 else 3256 { 3257 dict_len = 0; 3258 dict_end = NULL; 3259 } 3260#endif 3261 3262 *out_len = 0; 3263 3264 op = out; 3265 ip = in; 3266 3267 if (*ip > 17) 3268 { 3269 t = *ip++ - 17; 3270 if (t < 4) 3271 goto match_next; 3272 assert(t > 0); NEED_OP(t); NEED_IP(t+1); 3273 do *op++ = *ip++; while (--t > 0); 3274 goto first_literal_run; 3275 } 3276 3277 while (TEST_IP && TEST_OP) 3278 { 3279 t = *ip++; 3280 if (t >= 16) 3281 goto match; 3282 if (t == 0) 3283 { 3284 NEED_IP(1); 3285 while (*ip == 0) 3286 { 3287 t += 255; 3288 ip++; 3289 NEED_IP(1); 3290 } 3291 t += 15 + *ip++; 3292 } 3293 assert(t > 0); NEED_OP(t+3); NEED_IP(t+4); 3294#if defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) 3295#if !defined(LZO_UNALIGNED_OK_4) 3296 if (PTR_ALIGNED2_4(op,ip)) 3297 { 3298#endif 3299 COPY4(op,ip); 3300 op += 4; ip += 4; 3301 if (--t > 0) 3302 { 3303 if (t >= 4) 3304 { 3305 do { 3306 COPY4(op,ip); 3307 op += 4; ip += 4; t -= 4; 3308 } while (t >= 4); 3309 if (t > 0) do *op++ = *ip++; while (--t > 0); 3310 } 3311 else 3312 do *op++ = *ip++; while (--t > 0); 3313 } 3314#if !defined(LZO_UNALIGNED_OK_4) 3315 } 3316 else 3317#endif 3318#endif 3319#if !defined(LZO_UNALIGNED_OK_4) 3320 { 3321 *op++ = *ip++; *op++ = *ip++; *op++ = *ip++; 3322 do *op++ = *ip++; while (--t > 0); 3323 } 3324#endif 3325 3326first_literal_run: 3327 3328 t = *ip++; 3329 if (t >= 16) 3330 goto match; 3331#if defined(COPY_DICT) 3332#if defined(LZO1Z) 3333 m_off = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2); 3334 last_m_off = m_off; 3335#else 3336 m_off = (1 + M2_MAX_OFFSET) + (t >> 2) + (*ip++ << 2); 3337#endif 3338 NEED_OP(3); 3339 t = 3; COPY_DICT(t,m_off) 3340#else 3341#if defined(LZO1Z) 3342 t = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2); 3343 m_pos = op - t; 3344 last_m_off = t; 3345#else 3346 m_pos = op - (1 + M2_MAX_OFFSET); 3347 m_pos -= t >> 2; 3348 m_pos -= *ip++ << 2; 3349#endif 3350 TEST_LB(m_pos); NEED_OP(3); 3351 *op++ = *m_pos++; *op++ = *m_pos++; *op++ = *m_pos; 3352#endif 3353 goto match_done; 3354 3355 do { 3356match: 3357 if (t >= 64) 3358 { 3359#if defined(COPY_DICT) 3360#if defined(LZO1X) 3361 m_off = 1 + ((t >> 2) & 7) + (*ip++ << 3); 3362 t = (t >> 5) - 1; 3363#elif defined(LZO1Y) 3364 m_off = 1 + ((t >> 2) & 3) + (*ip++ << 2); 3365 t = (t >> 4) - 3; 3366#elif defined(LZO1Z) 3367 m_off = t & 0x1f; 3368 if (m_off >= 0x1c) 3369 m_off = last_m_off; 3370 else 3371 { 3372 m_off = 1 + (m_off << 6) + (*ip++ >> 2); 3373 last_m_off = m_off; 3374 } 3375 t = (t >> 5) - 1; 3376#endif 3377#else 3378#if defined(LZO1X) 3379 m_pos = op - 1; 3380 m_pos -= (t >> 2) & 7; 3381 m_pos -= *ip++ << 3; 3382 t = (t >> 5) - 1; 3383#elif defined(LZO1Y) 3384 m_pos = op - 1; 3385 m_pos -= (t >> 2) & 3; 3386 m_pos -= *ip++ << 2; 3387 t = (t >> 4) - 3; 3388#elif defined(LZO1Z) 3389 { 3390 lzo_uint off = t & 0x1f; 3391 m_pos = op; 3392 if (off >= 0x1c) 3393 { 3394 assert(last_m_off > 0); 3395 m_pos -= last_m_off; 3396 } 3397 else 3398 { 3399 off = 1 + (off << 6) + (*ip++ >> 2); 3400 m_pos -= off; 3401 last_m_off = off; 3402 } 3403 } 3404 t = (t >> 5) - 1; 3405#endif 3406 TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1); 3407 goto copy_match; 3408#endif 3409 } 3410 else if (t >= 32) 3411 { 3412 t &= 31; 3413 if (t == 0) 3414 { 3415 NEED_IP(1); 3416 while (*ip == 0) 3417 { 3418 t += 255; 3419 ip++; 3420 NEED_IP(1); 3421 } 3422 t += 31 + *ip++; 3423 } 3424#if defined(COPY_DICT) 3425#if defined(LZO1Z) 3426 m_off = 1 + (ip[0] << 6) + (ip[1] >> 2); 3427 last_m_off = m_off; 3428#else 3429 m_off = 1 + (ip[0] >> 2) + (ip[1] << 6); 3430#endif 3431#else 3432#if defined(LZO1Z) 3433 { 3434 lzo_uint off = 1 + (ip[0] << 6) + (ip[1] >> 2); 3435 m_pos = op - off; 3436 last_m_off = off; 3437 } 3438#elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN) 3439 m_pos = op - 1; 3440 m_pos -= (* (const lzo_ushortp) ip) >> 2; 3441#else 3442 m_pos = op - 1; 3443 m_pos -= (ip[0] >> 2) + (ip[1] << 6); 3444#endif 3445#endif 3446 ip += 2; 3447 } 3448 else if (t >= 16) 3449 { 3450#if defined(COPY_DICT) 3451 m_off = (t & 8) << 11; 3452#else 3453 m_pos = op; 3454 m_pos -= (t & 8) << 11; 3455#endif 3456 t &= 7; 3457 if (t == 0) 3458 { 3459 NEED_IP(1); 3460 while (*ip == 0) 3461 { 3462 t += 255; 3463 ip++; 3464 NEED_IP(1); 3465 } 3466 t += 7 + *ip++; 3467 } 3468#if defined(COPY_DICT) 3469#if defined(LZO1Z) 3470 m_off += (ip[0] << 6) + (ip[1] >> 2); 3471#else 3472 m_off += (ip[0] >> 2) + (ip[1] << 6); 3473#endif 3474 ip += 2; 3475 if (m_off == 0) 3476 goto eof_found; 3477 m_off += 0x4000; 3478#if defined(LZO1Z) 3479 last_m_off = m_off; 3480#endif 3481#else 3482#if defined(LZO1Z) 3483 m_pos -= (ip[0] << 6) + (ip[1] >> 2); 3484#elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN) 3485 m_pos -= (* (const lzo_ushortp) ip) >> 2; 3486#else 3487 m_pos -= (ip[0] >> 2) + (ip[1] << 6); 3488#endif 3489 ip += 2; 3490 if (m_pos == op) 3491 goto eof_found; 3492 m_pos -= 0x4000; 3493#if defined(LZO1Z) 3494 last_m_off = pd((const lzo_bytep)op, m_pos); 3495#endif 3496#endif 3497 } 3498 else 3499 { 3500#if defined(COPY_DICT) 3501#if defined(LZO1Z) 3502 m_off = 1 + (t << 6) + (*ip++ >> 2); 3503 last_m_off = m_off; 3504#else 3505 m_off = 1 + (t >> 2) + (*ip++ << 2); 3506#endif 3507 NEED_OP(2); 3508 t = 2; COPY_DICT(t,m_off) 3509#else 3510#if defined(LZO1Z) 3511 t = 1 + (t << 6) + (*ip++ >> 2); 3512 m_pos = op - t; 3513 last_m_off = t; 3514#else 3515 m_pos = op - 1; 3516 m_pos -= t >> 2; 3517 m_pos -= *ip++ << 2; 3518#endif 3519 TEST_LB(m_pos); NEED_OP(2); 3520 *op++ = *m_pos++; *op++ = *m_pos; 3521#endif 3522 goto match_done; 3523 } 3524 3525#if defined(COPY_DICT) 3526 3527 NEED_OP(t+3-1); 3528 t += 3-1; COPY_DICT(t,m_off) 3529 3530#else 3531 3532 TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1); 3533#if defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) 3534#if !defined(LZO_UNALIGNED_OK_4) 3535 if (t >= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op,m_pos)) 3536 { 3537 assert((op - m_pos) >= 4); 3538#else 3539 if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4) 3540 { 3541#endif 3542 COPY4(op,m_pos); 3543 op += 4; m_pos += 4; t -= 4 - (3 - 1); 3544 do { 3545 COPY4(op,m_pos); 3546 op += 4; m_pos += 4; t -= 4; 3547 } while (t >= 4); 3548 if (t > 0) do *op++ = *m_pos++; while (--t > 0); 3549 } 3550 else 3551#endif 3552 { 3553copy_match: 3554 *op++ = *m_pos++; *op++ = *m_pos++; 3555 do *op++ = *m_pos++; while (--t > 0); 3556 } 3557 3558#endif 3559 3560match_done: 3561#if defined(LZO1Z) 3562 t = ip[-1] & 3; 3563#else 3564 t = ip[-2] & 3; 3565#endif 3566 if (t == 0) 3567 break; 3568 3569match_next: 3570 assert(t > 0); assert(t < 4); NEED_OP(t); NEED_IP(t+1); 3571#if 0 3572 do *op++ = *ip++; while (--t > 0); 3573#else 3574 *op++ = *ip++; 3575 if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } } 3576#endif 3577 t = *ip++; 3578 } while (TEST_IP && TEST_OP); 3579 } 3580 3581#if defined(HAVE_TEST_IP) || defined(HAVE_TEST_OP) 3582 *out_len = pd(op, out); 3583 return LZO_E_EOF_NOT_FOUND; 3584#endif 3585 3586eof_found: 3587 assert(t == 1); 3588 *out_len = pd(op, out); 3589 return (ip == ip_end ? LZO_E_OK : 3590 (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN)); 3591 3592#if defined(HAVE_NEED_IP) 3593input_overrun: 3594 *out_len = pd(op, out); 3595 return LZO_E_INPUT_OVERRUN; 3596#endif 3597 3598#if defined(HAVE_NEED_OP) 3599output_overrun: 3600 *out_len = pd(op, out); 3601 return LZO_E_OUTPUT_OVERRUN; 3602#endif 3603 3604#if defined(LZO_TEST_OVERRUN_LOOKBEHIND) 3605lookbehind_overrun: 3606 *out_len = pd(op, out); 3607 return LZO_E_LOOKBEHIND_OVERRUN; 3608#endif 3609} 3610 3611#endif 3612 3613#define LZO_TEST_OVERRUN 3614#undef DO_DECOMPRESS 3615#define DO_DECOMPRESS lzo1x_decompress_safe 3616 3617#if !defined(MINILZO_CFG_SKIP_LZO1X_DECOMPRESS_SAFE) 3618 3619#if defined(LZO_TEST_OVERRUN) 3620# if !defined(LZO_TEST_OVERRUN_INPUT) 3621# define LZO_TEST_OVERRUN_INPUT 2 3622# endif 3623# if !defined(LZO_TEST_OVERRUN_OUTPUT) 3624# define LZO_TEST_OVERRUN_OUTPUT 2 3625# endif 3626# if !defined(LZO_TEST_OVERRUN_LOOKBEHIND) 3627# define LZO_TEST_OVERRUN_LOOKBEHIND 3628# endif 3629#endif 3630 3631#undef TEST_IP 3632#undef TEST_OP 3633#undef TEST_LB 3634#undef TEST_LBO 3635#undef NEED_IP 3636#undef NEED_OP 3637#undef HAVE_TEST_IP 3638#undef HAVE_TEST_OP 3639#undef HAVE_NEED_IP 3640#undef HAVE_NEED_OP 3641#undef HAVE_ANY_IP 3642#undef HAVE_ANY_OP 3643 3644#if defined(LZO_TEST_OVERRUN_INPUT) 3645# if (LZO_TEST_OVERRUN_INPUT >= 1) 3646# define TEST_IP (ip < ip_end) 3647# endif 3648# if (LZO_TEST_OVERRUN_INPUT >= 2) 3649# define NEED_IP(x) \ 3650 if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x)) goto input_overrun 3651# endif 3652#endif 3653 3654#if defined(LZO_TEST_OVERRUN_OUTPUT) 3655# if (LZO_TEST_OVERRUN_OUTPUT >= 1) 3656# define TEST_OP (op <= op_end) 3657# endif 3658# if (LZO_TEST_OVERRUN_OUTPUT >= 2) 3659# undef TEST_OP 3660# define NEED_OP(x) \ 3661 if ((lzo_uint)(op_end - op) < (lzo_uint)(x)) goto output_overrun 3662# endif 3663#endif 3664 3665#if defined(LZO_TEST_OVERRUN_LOOKBEHIND) 3666# define TEST_LB(m_pos) if (m_pos < out || m_pos >= op) goto lookbehind_overrun 3667# define TEST_LBO(m_pos,o) if (m_pos < out || m_pos >= op - (o)) goto lookbehind_overrun 3668#else 3669# define TEST_LB(m_pos) ((void) 0) 3670# define TEST_LBO(m_pos,o) ((void) 0) 3671#endif 3672 3673#if !defined(LZO_EOF_CODE) && !defined(TEST_IP) 3674# define TEST_IP (ip < ip_end) 3675#endif 3676 3677#if defined(TEST_IP) 3678# define HAVE_TEST_IP 3679#else 3680# define TEST_IP 1 3681#endif 3682#if defined(TEST_OP) 3683# define HAVE_TEST_OP 3684#else 3685# define TEST_OP 1 3686#endif 3687 3688#if defined(NEED_IP) 3689# define HAVE_NEED_IP 3690#else 3691# define NEED_IP(x) ((void) 0) 3692#endif 3693#if defined(NEED_OP) 3694# define HAVE_NEED_OP 3695#else 3696# define NEED_OP(x) ((void) 0) 3697#endif 3698 3699#if defined(HAVE_TEST_IP) || defined(HAVE_NEED_IP) 3700# define HAVE_ANY_IP 3701#endif 3702#if defined(HAVE_TEST_OP) || defined(HAVE_NEED_OP) 3703# define HAVE_ANY_OP 3704#endif 3705 3706#undef __COPY4 3707#define __COPY4(dst,src) * (lzo_uint32p)(dst) = * (const lzo_uint32p)(src) 3708 3709#undef COPY4 3710#if defined(LZO_UNALIGNED_OK_4) 3711# define COPY4(dst,src) __COPY4(dst,src) 3712#elif defined(LZO_ALIGNED_OK_4) 3713# define COPY4(dst,src) __COPY4((lzo_uintptr_t)(dst),(lzo_uintptr_t)(src)) 3714#endif 3715 3716#if defined(DO_DECOMPRESS) 3717LZO_PUBLIC(int) 3718DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, 3719 lzo_bytep out, lzo_uintp out_len, 3720 lzo_voidp wrkmem ) 3721#endif 3722{ 3723 register lzo_bytep op; 3724 register const lzo_bytep ip; 3725 register lzo_uint t; 3726#if defined(COPY_DICT) 3727 lzo_uint m_off; 3728 const lzo_bytep dict_end; 3729#else 3730 register const lzo_bytep m_pos; 3731#endif 3732 3733 const lzo_bytep const ip_end = in + in_len; 3734#if defined(HAVE_ANY_OP) 3735 lzo_bytep const op_end = out + *out_len; 3736#endif 3737#if defined(LZO1Z) 3738 lzo_uint last_m_off = 0; 3739#endif 3740 3741 LZO_UNUSED(wrkmem); 3742 3743#if defined(COPY_DICT) 3744 if (dict) 3745 { 3746 if (dict_len > M4_MAX_OFFSET) 3747 { 3748 dict += dict_len - M4_MAX_OFFSET; 3749 dict_len = M4_MAX_OFFSET; 3750 } 3751 dict_end = dict + dict_len; 3752 } 3753 else 3754 { 3755 dict_len = 0; 3756 dict_end = NULL; 3757 } 3758#endif 3759 3760 *out_len = 0; 3761 3762 op = out; 3763 ip = in; 3764 3765 if (*ip > 17) 3766 { 3767 t = *ip++ - 17; 3768 if (t < 4) 3769 goto match_next; 3770 assert(t > 0); NEED_OP(t); NEED_IP(t+1); 3771 do *op++ = *ip++; while (--t > 0); 3772 goto first_literal_run; 3773 } 3774 3775 while (TEST_IP && TEST_OP) 3776 { 3777 t = *ip++; 3778 if (t >= 16) 3779 goto match; 3780 if (t == 0) 3781 { 3782 NEED_IP(1); 3783 while (*ip == 0) 3784 { 3785 t += 255; 3786 ip++; 3787 NEED_IP(1); 3788 } 3789 t += 15 + *ip++; 3790 } 3791 assert(t > 0); NEED_OP(t+3); NEED_IP(t+4); 3792#if defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) 3793#if !defined(LZO_UNALIGNED_OK_4) 3794 if (PTR_ALIGNED2_4(op,ip)) 3795 { 3796#endif 3797 COPY4(op,ip); 3798 op += 4; ip += 4; 3799 if (--t > 0) 3800 { 3801 if (t >= 4) 3802 { 3803 do { 3804 COPY4(op,ip); 3805 op += 4; ip += 4; t -= 4; 3806 } while (t >= 4); 3807 if (t > 0) do *op++ = *ip++; while (--t > 0); 3808 } 3809 else 3810 do *op++ = *ip++; while (--t > 0); 3811 } 3812#if !defined(LZO_UNALIGNED_OK_4) 3813 } 3814 else 3815#endif 3816#endif 3817#if !defined(LZO_UNALIGNED_OK_4) 3818 { 3819 *op++ = *ip++; *op++ = *ip++; *op++ = *ip++; 3820 do *op++ = *ip++; while (--t > 0); 3821 } 3822#endif 3823 3824first_literal_run: 3825 3826 t = *ip++; 3827 if (t >= 16) 3828 goto match; 3829#if defined(COPY_DICT) 3830#if defined(LZO1Z) 3831 m_off = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2); 3832 last_m_off = m_off; 3833#else 3834 m_off = (1 + M2_MAX_OFFSET) + (t >> 2) + (*ip++ << 2); 3835#endif 3836 NEED_OP(3); 3837 t = 3; COPY_DICT(t,m_off) 3838#else 3839#if defined(LZO1Z) 3840 t = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2); 3841 m_pos = op - t; 3842 last_m_off = t; 3843#else 3844 m_pos = op - (1 + M2_MAX_OFFSET); 3845 m_pos -= t >> 2; 3846 m_pos -= *ip++ << 2; 3847#endif 3848 TEST_LB(m_pos); NEED_OP(3); 3849 *op++ = *m_pos++; *op++ = *m_pos++; *op++ = *m_pos; 3850#endif 3851 goto match_done; 3852 3853 do { 3854match: 3855 if (t >= 64) 3856 { 3857#if defined(COPY_DICT) 3858#if defined(LZO1X) 3859 m_off = 1 + ((t >> 2) & 7) + (*ip++ << 3); 3860 t = (t >> 5) - 1; 3861#elif defined(LZO1Y) 3862 m_off = 1 + ((t >> 2) & 3) + (*ip++ << 2); 3863 t = (t >> 4) - 3; 3864#elif defined(LZO1Z) 3865 m_off = t & 0x1f; 3866 if (m_off >= 0x1c) 3867 m_off = last_m_off; 3868 else 3869 { 3870 m_off = 1 + (m_off << 6) + (*ip++ >> 2); 3871 last_m_off = m_off; 3872 } 3873 t = (t >> 5) - 1; 3874#endif 3875#else 3876#if defined(LZO1X) 3877 m_pos = op - 1; 3878 m_pos -= (t >> 2) & 7; 3879 m_pos -= *ip++ << 3; 3880 t = (t >> 5) - 1; 3881#elif defined(LZO1Y) 3882 m_pos = op - 1; 3883 m_pos -= (t >> 2) & 3; 3884 m_pos -= *ip++ << 2; 3885 t = (t >> 4) - 3; 3886#elif defined(LZO1Z) 3887 { 3888 lzo_uint off = t & 0x1f; 3889 m_pos = op; 3890 if (off >= 0x1c) 3891 { 3892 assert(last_m_off > 0); 3893 m_pos -= last_m_off; 3894 } 3895 else 3896 { 3897 off = 1 + (off << 6) + (*ip++ >> 2); 3898 m_pos -= off; 3899 last_m_off = off; 3900 } 3901 } 3902 t = (t >> 5) - 1; 3903#endif 3904 TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1); 3905 goto copy_match; 3906#endif 3907 } 3908 else if (t >= 32) 3909 { 3910 t &= 31; 3911 if (t == 0) 3912 { 3913 NEED_IP(1); 3914 while (*ip == 0) 3915 { 3916 t += 255; 3917 ip++; 3918 NEED_IP(1); 3919 } 3920 t += 31 + *ip++; 3921 } 3922#if defined(COPY_DICT) 3923#if defined(LZO1Z) 3924 m_off = 1 + (ip[0] << 6) + (ip[1] >> 2); 3925 last_m_off = m_off; 3926#else 3927 m_off = 1 + (ip[0] >> 2) + (ip[1] << 6); 3928#endif 3929#else 3930#if defined(LZO1Z) 3931 { 3932 lzo_uint off = 1 + (ip[0] << 6) + (ip[1] >> 2); 3933 m_pos = op - off; 3934 last_m_off = off; 3935 } 3936#elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN) 3937 m_pos = op - 1; 3938 m_pos -= (* (const lzo_ushortp) ip) >> 2; 3939#else 3940 m_pos = op - 1; 3941 m_pos -= (ip[0] >> 2) + (ip[1] << 6); 3942#endif 3943#endif 3944 ip += 2; 3945 } 3946 else if (t >= 16) 3947 { 3948#if defined(COPY_DICT) 3949 m_off = (t & 8) << 11; 3950#else 3951 m_pos = op; 3952 m_pos -= (t & 8) << 11; 3953#endif 3954 t &= 7; 3955 if (t == 0) 3956 { 3957 NEED_IP(1); 3958 while (*ip == 0) 3959 { 3960 t += 255; 3961 ip++; 3962 NEED_IP(1); 3963 } 3964 t += 7 + *ip++; 3965 } 3966#if defined(COPY_DICT) 3967#if defined(LZO1Z) 3968 m_off += (ip[0] << 6) + (ip[1] >> 2); 3969#else 3970 m_off += (ip[0] >> 2) + (ip[1] << 6); 3971#endif 3972 ip += 2; 3973 if (m_off == 0) 3974 goto eof_found; 3975 m_off += 0x4000; 3976#if defined(LZO1Z) 3977 last_m_off = m_off; 3978#endif 3979#else 3980#if defined(LZO1Z) 3981 m_pos -= (ip[0] << 6) + (ip[1] >> 2); 3982#elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN) 3983 m_pos -= (* (const lzo_ushortp) ip) >> 2; 3984#else 3985 m_pos -= (ip[0] >> 2) + (ip[1] << 6); 3986#endif 3987 ip += 2; 3988 if (m_pos == op) 3989 goto eof_found; 3990 m_pos -= 0x4000; 3991#if defined(LZO1Z) 3992 last_m_off = pd((const lzo_bytep)op, m_pos); 3993#endif 3994#endif 3995 } 3996 else 3997 { 3998#if defined(COPY_DICT) 3999#if defined(LZO1Z) 4000 m_off = 1 + (t << 6) + (*ip++ >> 2); 4001 last_m_off = m_off; 4002#else 4003 m_off = 1 + (t >> 2) + (*ip++ << 2); 4004#endif 4005 NEED_OP(2); 4006 t = 2; COPY_DICT(t,m_off) 4007#else 4008#if defined(LZO1Z) 4009 t = 1 + (t << 6) + (*ip++ >> 2); 4010 m_pos = op - t; 4011 last_m_off = t; 4012#else 4013 m_pos = op - 1; 4014 m_pos -= t >> 2; 4015 m_pos -= *ip++ << 2; 4016#endif 4017 TEST_LB(m_pos); NEED_OP(2); 4018 *op++ = *m_pos++; *op++ = *m_pos; 4019#endif 4020 goto match_done; 4021 } 4022 4023#if defined(COPY_DICT) 4024 4025 NEED_OP(t+3-1); 4026 t += 3-1; COPY_DICT(t,m_off) 4027 4028#else 4029 4030 TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1); 4031#if defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) 4032#if !defined(LZO_UNALIGNED_OK_4) 4033 if (t >= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op,m_pos)) 4034 { 4035 assert((op - m_pos) >= 4); 4036#else 4037 if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4) 4038 { 4039#endif 4040 COPY4(op,m_pos); 4041 op += 4; m_pos += 4; t -= 4 - (3 - 1); 4042 do { 4043 COPY4(op,m_pos); 4044 op += 4; m_pos += 4; t -= 4; 4045 } while (t >= 4); 4046 if (t > 0) do *op++ = *m_pos++; while (--t > 0); 4047 } 4048 else 4049#endif 4050 { 4051copy_match: 4052 *op++ = *m_pos++; *op++ = *m_pos++; 4053 do *op++ = *m_pos++; while (--t > 0); 4054 } 4055 4056#endif 4057 4058match_done: 4059#if defined(LZO1Z) 4060 t = ip[-1] & 3; 4061#else 4062 t = ip[-2] & 3; 4063#endif 4064 if (t == 0) 4065 break; 4066 4067match_next: 4068 assert(t > 0); assert(t < 4); NEED_OP(t); NEED_IP(t+1); 4069#if 0 4070 do *op++ = *ip++; while (--t > 0); 4071#else 4072 *op++ = *ip++; 4073 if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } } 4074#endif 4075 t = *ip++; 4076 } while (TEST_IP && TEST_OP); 4077 } 4078 4079#if defined(HAVE_TEST_IP) || defined(HAVE_TEST_OP) 4080 *out_len = pd(op, out); 4081 return LZO_E_EOF_NOT_FOUND; 4082#endif 4083 4084eof_found: 4085 assert(t == 1); 4086 *out_len = pd(op, out); 4087 return (ip == ip_end ? LZO_E_OK : 4088 (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN)); 4089 4090#if defined(HAVE_NEED_IP) 4091input_overrun: 4092 *out_len = pd(op, out); 4093 return LZO_E_INPUT_OVERRUN; 4094#endif 4095 4096#if defined(HAVE_NEED_OP) 4097output_overrun: 4098 *out_len = pd(op, out); 4099 return LZO_E_OUTPUT_OVERRUN; 4100#endif 4101 4102#if defined(LZO_TEST_OVERRUN_LOOKBEHIND) 4103lookbehind_overrun: 4104 *out_len = pd(op, out); 4105 return LZO_E_LOOKBEHIND_OVERRUN; 4106#endif 4107} 4108 4109#endif 4110 4111/***** End of minilzo.c *****/ 4112 4113