Ticket #5733: mythtv-lzo-crash-fix.patch

File mythtv-lzo-crash-fix.patch, 256.0 KB (added by jan.nijs@…, 17 years ago)
  • libs/libmythtv/lzoconf.h

    diff -uNr mythtv-0.21-orig/libs/libmythtv/lzoconf.h mythtv-0.21/libs/libmythtv/lzoconf.h
    old new  
    22
    33   This file is part of the LZO real-time data compression library.
    44
     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
    513   Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
    614   Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
    715   Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
    816   Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
    917   Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
     18   All Rights Reserved.
    1019
    1120   The LZO library is free software; you can redistribute it and/or
    1221   modify it under the terms of the GNU General Public License as
     
    2130   You should have received a copy of the GNU General Public License
    2231   along with the LZO library; see the file COPYING.
    2332   If not, write to the Free Software Foundation, Inc.,
    24    59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
     33   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
    2534
    2635   Markus F.X.J. Oberhumer
    27    <markus.oberhumer@jk.uni-linz.ac.at>
    28    http://wildsau.idv.uni-linz.ac.at/mfx/lzo.html
     36   <markus@oberhumer.com>
     37   http://www.oberhumer.com/opensource/lzo/
    2938 */
    3039
    3140
    32 #ifndef __LZOCONF_H
    33 #define __LZOCONF_H
     41#ifndef __LZOCONF_H_INCLUDED
     42#define __LZOCONF_H_INCLUDED
    3443
    35 #define LZO_VERSION             0x1070
    36 #define LZO_VERSION_STRING      "1.07"
    37 #define LZO_VERSION_DATE        "Oct 18 2000"
     44#define LZO_VERSION             0x2030
     45#define LZO_VERSION_STRING      "2.03"
     46#define LZO_VERSION_DATE        "Apr 30 2008"
    3847
    3948/* internal Autoconf configuration file - only used when building LZO */
    4049#if defined(LZO_HAVE_CONFIG_H)
    4150#  include <config.h>
    4251#endif
    4352#include <limits.h>
    44 
    45 #ifdef __cplusplus
    46 extern "C" {
    47 #endif
     53#include <stddef.h>
    4854
    4955
    5056/***********************************************************************
     
    6167#  error "your limits.h macros are broken"
    6268#endif
    6369
    64 /* workaround a cpp bug under hpux 10.20 */
    65 #define LZO_0xffffffffL     4294967295ul
     70/* get OS and architecture defines */
     71#ifndef __LZODEFS_H_INCLUDED
     72#include "lzodefs.h"
     73#endif
    6674
    6775
    68 /***********************************************************************
    69 // architecture defines
    70 ************************************************************************/
    71 
    72 #if !defined(__LZO_WIN) && !defined(__LZO_DOS) && !defined(__LZO_OS2)
    73 #  if defined(__WINDOWS__) || defined(_WINDOWS) || defined(_Windows)
    74 #    define __LZO_WIN
    75 #  elif defined(__WIN32__) || defined(_WIN32) || defined(WIN32)
    76 #    define __LZO_WIN
    77 #  elif defined(__NT__) || defined(__NT_DLL__) || defined(__WINDOWS_386__)
    78 #    define __LZO_WIN
    79 #  elif defined(__DOS__) || defined(__MSDOS__) || defined(MSDOS)
    80 #    define __LZO_DOS
    81 #  elif defined(__OS2__) || defined(__OS2V2__) || defined(OS2)
    82 #    define __LZO_OS2
    83 #  elif defined(__palmos__)
    84 #    define __LZO_PALMOS
    85 #  elif defined(__TOS__) || defined(__atarist__)
    86 #    define __LZO_TOS
    87 #  endif
     76#ifdef __cplusplus
     77extern "C" {
    8878#endif
    8979
    90 #if (UINT_MAX < LZO_0xffffffffL)
    91 #  if defined(__LZO_WIN)
    92 #    define __LZO_WIN16
    93 #  elif defined(__LZO_DOS)
    94 #    define __LZO_DOS16
    95 #  elif defined(__LZO_PALMOS)
    96 #    define __LZO_PALMOS16
    97 #  elif defined(__LZO_TOS)
    98 #    define __LZO_TOS16
    99 #  elif defined(__C166__)
    100 #  else
    101 #    error "16-bit target not supported - contact me for porting hints"
    102 #  endif
    103 #endif
    10480
    105 #if !defined(__LZO_i386)
    106 #  if defined(__LZO_DOS) || defined(__LZO_WIN16)
    107 #    define __LZO_i386
    108 #  elif defined(__i386__) || defined(__386__) || defined(_M_IX86)
    109 #    define __LZO_i386
    110 #  endif
    111 #endif
     81/***********************************************************************
     82// some core defines
     83************************************************************************/
    11284
    113 #if defined(__LZO_STRICT_16BIT)
     85#if !defined(LZO_UINT32_C)
    11486#  if (UINT_MAX < LZO_0xffffffffL)
    115 #    include <lzo16bit.h>
     87#    define LZO_UINT32_C(c)     c ## UL
     88#  else
     89#    define LZO_UINT32_C(c)     ((c) + 0U)
    11690#  endif
    11791#endif
    11892
    11993/* memory checkers */
    12094#if !defined(__LZO_CHECKER)
    12195#  if defined(__BOUNDS_CHECKING_ON)
    122 #    define __LZO_CHECKER
     96#    define __LZO_CHECKER       1
    12397#  elif defined(__CHECKER__)
    124 #    define __LZO_CHECKER
     98#    define __LZO_CHECKER       1
    12599#  elif defined(__INSURE__)
    126 #    define __LZO_CHECKER
     100#    define __LZO_CHECKER       1
    127101#  elif defined(__PURIFY__)
    128 #    define __LZO_CHECKER
     102#    define __LZO_CHECKER       1
    129103#  endif
    130104#endif
    131105
     
    134108// integral and pointer types
    135109************************************************************************/
    136110
    137 /* Integral types with 32 bits or more */
     111/* lzo_uint should match size_t */
     112#if !defined(LZO_UINT_MAX)
     113#  if defined(LZO_ABI_LLP64) /* WIN64 */
     114#    if defined(LZO_OS_WIN64)
     115     typedef unsigned __int64   lzo_uint;
     116     typedef __int64            lzo_int;
     117#    else
     118     typedef unsigned long long lzo_uint;
     119     typedef long long          lzo_int;
     120#    endif
     121#    define LZO_UINT_MAX        0xffffffffffffffffull
     122#    define LZO_INT_MAX         9223372036854775807LL
     123#    define LZO_INT_MIN         (-1LL - LZO_INT_MAX)
     124#  elif defined(LZO_ABI_IP32L64) /* MIPS R5900 */
     125     typedef unsigned int       lzo_uint;
     126     typedef int                lzo_int;
     127#    define LZO_UINT_MAX        UINT_MAX
     128#    define LZO_INT_MAX         INT_MAX
     129#    define LZO_INT_MIN         INT_MIN
     130#  elif (ULONG_MAX >= LZO_0xffffffffL)
     131     typedef unsigned long      lzo_uint;
     132     typedef long               lzo_int;
     133#    define LZO_UINT_MAX        ULONG_MAX
     134#    define LZO_INT_MAX         LONG_MAX
     135#    define LZO_INT_MIN         LONG_MIN
     136#  else
     137#    error "lzo_uint"
     138#  endif
     139#endif
     140
     141/* Integral types with 32 bits or more. */
    138142#if !defined(LZO_UINT32_MAX)
    139143#  if (UINT_MAX >= LZO_0xffffffffL)
    140144     typedef unsigned int       lzo_uint32;
     
    153157#  endif
    154158#endif
    155159
    156 /* lzo_uint is used like size_t */
    157 #if !defined(LZO_UINT_MAX)
    158 #  if (UINT_MAX >= LZO_0xffffffffL)
    159      typedef unsigned int       lzo_uint;
    160      typedef int                lzo_int;
    161 #    define LZO_UINT_MAX        UINT_MAX
    162 #    define LZO_INT_MAX         INT_MAX
    163 #    define LZO_INT_MIN         INT_MIN
    164 #  elif (ULONG_MAX >= LZO_0xffffffffL)
    165      typedef unsigned long      lzo_uint;
    166      typedef long               lzo_int;
    167 #    define LZO_UINT_MAX        ULONG_MAX
    168 #    define LZO_INT_MAX         LONG_MAX
    169 #    define LZO_INT_MIN         LONG_MIN
    170 #  else
    171 #    error "lzo_uint"
    172 #  endif
     160/* The larger type of lzo_uint and lzo_uint32. */
     161#if (LZO_UINT_MAX >= LZO_UINT32_MAX)
     162#  define lzo_xint              lzo_uint
     163#else
     164#  define lzo_xint              lzo_uint32
    173165#endif
    174166
    175 
    176167/* Memory model that allows to access memory at offsets of lzo_uint. */
    177168#if !defined(__LZO_MMODEL)
    178169#  if (LZO_UINT_MAX <= UINT_MAX)
    179170#    define __LZO_MMODEL
    180 #  elif defined(__LZO_DOS16) || defined(__LZO_WIN16)
     171#  elif defined(LZO_HAVE_MM_HUGE_PTR)
     172#    define __LZO_MMODEL_HUGE   1
    181173#    define __LZO_MMODEL        __huge
    182 #    define LZO_999_UNSUPPORTED
    183 #  elif defined(__LZO_PALMOS16) || defined(__LZO_TOS16)
    184 #    define __LZO_MMODEL
    185174#  else
    186 #    error "__LZO_MMODEL"
     175#    define __LZO_MMODEL
    187176#  endif
    188177#endif
    189178
    190179/* no typedef here because of const-pointer issues */
    191 #define lzo_byte                unsigned char __LZO_MMODEL
    192180#define lzo_bytep               unsigned char __LZO_MMODEL *
    193181#define lzo_charp               char __LZO_MMODEL *
    194182#define lzo_voidp               void __LZO_MMODEL *
     
    198186#define lzo_int32p              lzo_int32 __LZO_MMODEL *
    199187#define lzo_uintp               lzo_uint __LZO_MMODEL *
    200188#define lzo_intp                lzo_int __LZO_MMODEL *
     189#define lzo_xintp               lzo_xint __LZO_MMODEL *
    201190#define lzo_voidpp              lzo_voidp __LZO_MMODEL *
    202191#define lzo_bytepp              lzo_bytep __LZO_MMODEL *
     192/* deprecated - use `lzo_bytep' instead of `lzo_byte *' */
     193#define lzo_byte                unsigned char __LZO_MMODEL
    203194
    204195typedef int lzo_bool;
    205196
    206 #ifndef lzo_sizeof_dict_t
    207 #  define lzo_sizeof_dict_t     sizeof(lzo_bytep)
    208 #endif
    209 
    210197
    211198/***********************************************************************
    212199// function types
    213200************************************************************************/
    214201
    215 /* linkage */
     202/* name mangling */
    216203#if !defined(__LZO_EXTERN_C)
    217204#  ifdef __cplusplus
    218205#    define __LZO_EXTERN_C      extern "C"
     
    221208#  endif
    222209#endif
    223210
    224 /* calling conventions */
     211/* calling convention */
    225212#if !defined(__LZO_CDECL)
    226 #  if defined(__LZO_DOS16) || defined(__LZO_WIN16)
    227 #    define __LZO_CDECL         __far __cdecl
    228 #  elif defined(__LZO_i386) && defined(_MSC_VER)
    229 #    define __LZO_CDECL         __cdecl
    230 #  elif defined(__LZO_i386) && defined(__WATCOMC__)
    231 #    define __LZO_CDECL         __near __cdecl
    232 #  else
    233 #    define __LZO_CDECL
    234 #  endif
    235 #endif
    236 #if !defined(__LZO_ENTRY)
    237 #  define __LZO_ENTRY           __LZO_CDECL
     213#  define __LZO_CDECL           __lzo_cdecl
    238214#endif
    239215
    240216/* DLL export information */
     
    245221#  define __LZO_EXPORT2
    246222#endif
    247223
    248 /* calling convention for C functions */
     224/* __cdecl calling convention for public C and assembly functions */
    249225#if !defined(LZO_PUBLIC)
    250 #  define LZO_PUBLIC(_rettype)  __LZO_EXPORT1 _rettype __LZO_EXPORT2 __LZO_ENTRY
     226#  define LZO_PUBLIC(_rettype)  __LZO_EXPORT1 _rettype __LZO_EXPORT2 __LZO_CDECL
    251227#endif
    252228#if !defined(LZO_EXTERN)
    253229#  define LZO_EXTERN(_rettype)  __LZO_EXTERN_C LZO_PUBLIC(_rettype)
    254230#endif
    255231#if !defined(LZO_PRIVATE)
    256 #  define LZO_PRIVATE(_rettype) static _rettype __LZO_ENTRY
     232#  define LZO_PRIVATE(_rettype) static _rettype __LZO_CDECL
    257233#endif
    258234
    259 /* cdecl calling convention for assembler functions */
    260 #if !defined(LZO_PUBLIC_CDECL)
    261 #  define LZO_PUBLIC_CDECL(_rettype) \
    262                 __LZO_EXPORT1 _rettype __LZO_EXPORT2 __LZO_CDECL
    263 #endif
    264 #if !defined(LZO_EXTERN_CDECL)
    265 #  define LZO_EXTERN_CDECL(_rettype)  __LZO_EXTERN_C LZO_PUBLIC_CDECL(_rettype)
    266 #endif
    267 
    268 
     235/* function types */
    269236typedef int
    270 (__LZO_ENTRY *lzo_compress_t)   ( const lzo_byte *src, lzo_uint  src_len,
    271                                         lzo_byte *dst, lzo_uint *dst_len,
     237(__LZO_CDECL *lzo_compress_t)   ( const lzo_bytep src, lzo_uint  src_len,
     238                                        lzo_bytep dst, lzo_uintp dst_len,
    272239                                        lzo_voidp wrkmem );
    273240
    274241typedef int
    275 (__LZO_ENTRY *lzo_decompress_t) ( const lzo_byte *src, lzo_uint  src_len,
    276                                         lzo_byte *dst, lzo_uint *dst_len,
     242(__LZO_CDECL *lzo_decompress_t) ( const lzo_bytep src, lzo_uint  src_len,
     243                                        lzo_bytep dst, lzo_uintp dst_len,
    277244                                        lzo_voidp wrkmem );
    278245
    279246typedef int
    280 (__LZO_ENTRY *lzo_optimize_t)   (       lzo_byte *src, lzo_uint  src_len,
    281                                         lzo_byte *dst, lzo_uint *dst_len,
     247(__LZO_CDECL *lzo_optimize_t)   (       lzo_bytep src, lzo_uint  src_len,
     248                                        lzo_bytep dst, lzo_uintp dst_len,
    282249                                        lzo_voidp wrkmem );
    283250
    284251typedef int
    285 (__LZO_ENTRY *lzo_compress_dict_t)(const lzo_byte *src, lzo_uint  src_len,
    286                                         lzo_byte *dst, lzo_uint *dst_len,
    287                                         lzo_voidp wrkmem,
    288                                   const lzo_byte *dict, lzo_uint dict_len );
     252(__LZO_CDECL *lzo_compress_dict_t)(const lzo_bytep src, lzo_uint  src_len,
     253                                         lzo_bytep dst, lzo_uintp dst_len,
     254                                         lzo_voidp wrkmem,
     255                                   const lzo_bytep dict, lzo_uint dict_len );
    289256
    290257typedef int
    291 (__LZO_ENTRY *lzo_decompress_dict_t)(const lzo_byte *src, lzo_uint  src_len,
    292                                         lzo_byte *dst, lzo_uint *dst_len,
    293                                         lzo_voidp wrkmem,
    294                                   const lzo_byte *dict, lzo_uint dict_len );
    295 
     258(__LZO_CDECL *lzo_decompress_dict_t)(const lzo_bytep src, lzo_uint  src_len,
     259                                           lzo_bytep dst, lzo_uintp dst_len,
     260                                           lzo_voidp wrkmem,
     261                                     const lzo_bytep dict, lzo_uint dict_len );
     262
     263
     264/* Callback interface. Currently only the progress indicator ("nprogress")
     265 * is used, but this may change in a future release. */
     266
     267struct lzo_callback_t;
     268typedef struct lzo_callback_t lzo_callback_t;
     269#define lzo_callback_p lzo_callback_t __LZO_MMODEL *
     270
     271/* malloc & free function types */
     272typedef lzo_voidp (__LZO_CDECL *lzo_alloc_func_t)
     273    (lzo_callback_p self, lzo_uint items, lzo_uint size);
     274typedef void      (__LZO_CDECL *lzo_free_func_t)
     275    (lzo_callback_p self, lzo_voidp ptr);
    296276
    297277/* a progress indicator callback function */
    298 typedef void (__LZO_ENTRY *lzo_progress_callback_t) (lzo_uint, lzo_uint);
     278typedef void (__LZO_CDECL *lzo_progress_func_t)
     279    (lzo_callback_p, lzo_uint, lzo_uint, int);
     280
     281struct lzo_callback_t
     282{
     283    /* custom allocators (set to 0 to disable) */
     284    lzo_alloc_func_t nalloc;                /* [not used right now] */
     285    lzo_free_func_t nfree;                  /* [not used right now] */
     286
     287    /* a progress indicator callback function (set to 0 to disable) */
     288    lzo_progress_func_t nprogress;
     289
     290    /* NOTE: the first parameter "self" of the nalloc/nfree/nprogress
     291     * callbacks points back to this struct, so you are free to store
     292     * some extra info in the following variables. */
     293    lzo_voidp user1;
     294    lzo_xint user2;
     295    lzo_xint user3;
     296};
    299297
    300298
    301299/***********************************************************************
     
    308306 */
    309307#define LZO_E_OK                    0
    310308#define LZO_E_ERROR                 (-1)
    311 #define LZO_E_OUT_OF_MEMORY         (-2)    /* not used right now */
    312 #define LZO_E_NOT_COMPRESSIBLE      (-3)    /* not used right now */
     309#define LZO_E_OUT_OF_MEMORY         (-2)    /* [not used right now] */
     310#define LZO_E_NOT_COMPRESSIBLE      (-3)    /* [not used right now] */
    313311#define LZO_E_INPUT_OVERRUN         (-4)
    314312#define LZO_E_OUTPUT_OVERRUN        (-5)
    315313#define LZO_E_LOOKBEHIND_OVERRUN    (-6)
    316314#define LZO_E_EOF_NOT_FOUND         (-7)
    317315#define LZO_E_INPUT_NOT_CONSUMED    (-8)
     316#define LZO_E_NOT_YET_IMPLEMENTED   (-9)    /* [not used right now] */
    318317
    319318
     319#ifndef lzo_sizeof_dict_t
     320#  define lzo_sizeof_dict_t     ((unsigned)sizeof(lzo_bytep))
     321#endif
     322
    320323/* lzo_init() should be the first function you call.
    321324 * Check the return code !
    322325 *
    323326 * lzo_init() is a macro to allow checking that the library and the
    324327 * compiler's view of various types are consistent.
    325328 */
    326 #define lzo_init() __lzo_init2(LZO_VERSION,(int)sizeof(short),(int)sizeof(int),\
     329#define lzo_init() __lzo_init_v2(LZO_VERSION,(int)sizeof(short),(int)sizeof(int),\
    327330    (int)sizeof(long),(int)sizeof(lzo_uint32),(int)sizeof(lzo_uint),\
    328331    (int)lzo_sizeof_dict_t,(int)sizeof(char *),(int)sizeof(lzo_voidp),\
    329     (int)sizeof(lzo_compress_t))
    330 LZO_EXTERN(int) __lzo_init2(unsigned,int,int,int,int,int,int,int,int,int);
     332    (int)sizeof(lzo_callback_t))
     333LZO_EXTERN(int) __lzo_init_v2(unsigned,int,int,int,int,int,int,int,int,int);
    331334
    332335/* version functions (useful for shared libraries) */
    333336LZO_EXTERN(unsigned) lzo_version(void);
     
    348351
    349352/* checksum functions */
    350353LZO_EXTERN(lzo_uint32)
    351 lzo_adler32(lzo_uint32 _adler, const lzo_byte *_buf, lzo_uint _len);
     354lzo_adler32(lzo_uint32 _adler, const lzo_bytep _buf, lzo_uint _len);
    352355LZO_EXTERN(lzo_uint32)
    353 lzo_crc32(lzo_uint32 _c, const lzo_byte *_buf, lzo_uint _len);
    354 
    355 /* memory allocation functions */
    356 LZO_EXTERN(lzo_bytep) lzo_alloc(lzo_uint _nelems, lzo_uint _size);
    357 LZO_EXTERN(lzo_bytep) lzo_malloc(lzo_uint _size);
    358 LZO_EXTERN(void) lzo_free(lzo_voidp _ptr);
    359 
    360 typedef lzo_bytep (__LZO_ENTRY *lzo_alloc_hook_t) (lzo_uint, lzo_uint);
    361 typedef void (__LZO_ENTRY *lzo_free_hook_t) (lzo_voidp);
    362 
    363 extern lzo_alloc_hook_t lzo_alloc_hook;
    364 extern lzo_free_hook_t lzo_free_hook;
     356lzo_crc32(lzo_uint32 _c, const lzo_bytep _buf, lzo_uint _len);
     357LZO_EXTERN(const lzo_uint32p)
     358lzo_get_crc32_table(void);
    365359
    366360/* misc. */
    367 LZO_EXTERN(lzo_bool) lzo_assert(int _expr);
    368361LZO_EXTERN(int) _lzo_config_check(void);
    369362typedef union { lzo_bytep p; lzo_uint u; } __lzo_pu_u;
    370363typedef union { lzo_bytep p; lzo_uint32 u32; } __lzo_pu32_u;
     364typedef union { void *vp; lzo_bytep bp; lzo_uint32 u32; long l; } lzo_align_t;
    371365
    372366/* align a char pointer on a boundary that is a multiple of `size' */
    373367LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp _ptr, lzo_uint _size);
    374368#define LZO_PTR_ALIGN_UP(_ptr,_size) \
    375369    ((_ptr) + (lzo_uint) __lzo_align_gap((const lzo_voidp)(_ptr),(lzo_uint)(_size)))
    376370
    377 /* deprecated - only for backward compatibility */
    378 #define LZO_ALIGN(_ptr,_size) LZO_PTR_ALIGN_UP(_ptr,_size)
     371
     372/***********************************************************************
     373// deprecated macros - only for backward compatibility with LZO v1.xx
     374************************************************************************/
     375
     376#if defined(LZO_CFG_COMPAT)
     377
     378#define __LZOCONF_H 1
     379
     380#if defined(LZO_ARCH_I086)
     381#  define __LZO_i386 1
     382#elif defined(LZO_ARCH_I386)
     383#  define __LZO_i386 1
     384#endif
     385
     386#if defined(LZO_OS_DOS16)
     387#  define __LZO_DOS 1
     388#  define __LZO_DOS16 1
     389#elif defined(LZO_OS_DOS32)
     390#  define __LZO_DOS 1
     391#elif defined(LZO_OS_WIN16)
     392#  define __LZO_WIN 1
     393#  define __LZO_WIN16 1
     394#elif defined(LZO_OS_WIN32)
     395#  define __LZO_WIN 1
     396#endif
     397
     398#define __LZO_CMODEL
     399#define __LZO_DMODEL
     400#define __LZO_ENTRY             __LZO_CDECL
     401#define LZO_EXTERN_CDECL        LZO_EXTERN
     402#define LZO_ALIGN               LZO_PTR_ALIGN_UP
     403
     404#define lzo_compress_asm_t      lzo_compress_t
     405#define lzo_decompress_asm_t    lzo_decompress_t
     406
     407#endif /* LZO_CFG_COMPAT */
    379408
    380409
    381410#ifdef __cplusplus
     
    384413
    385414#endif /* already included */
    386415
     416
     417/* vim:set ts=4 et: */
  • libs/libmythtv/lzodefs.h

    diff -uNr mythtv-0.21-orig/libs/libmythtv/lzodefs.h mythtv-0.21/libs/libmythtv/lzodefs.h
    old new  
     1/* lzodefs.h -- architecture, OS and compiler specific defines
     2
     3   This file is part of the LZO real-time data compression library.
     4
     5   Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer
     6   Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer
     7   Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer
     8   Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer
     9   Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer
     10   Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer
     11   Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
     12   Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
     13   Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
     14   Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
     15   Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
     16   Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
     17   Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
     18   All Rights Reserved.
     19
     20   The LZO library is free software; you can redistribute it and/or
     21   modify it under the terms of the GNU General Public License as
     22   published by the Free Software Foundation; either version 2 of
     23   the License, or (at your option) any later version.
     24
     25   The LZO library is distributed in the hope that it will be useful,
     26   but WITHOUT ANY WARRANTY; without even the implied warranty of
     27   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     28   GNU General Public License for more details.
     29
     30   You should have received a copy of the GNU General Public License
     31   along with the LZO library; see the file COPYING.
     32   If not, write to the Free Software Foundation, Inc.,
     33   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
     34
     35   Markus F.X.J. Oberhumer
     36   <markus@oberhumer.com>
     37   http://www.oberhumer.com/opensource/lzo/
     38 */
     39
     40
     41#ifndef __LZODEFS_H_INCLUDED
     42#define __LZODEFS_H_INCLUDED 1
     43
     44#if defined(__CYGWIN32__) && !defined(__CYGWIN__)
     45#  define __CYGWIN__ __CYGWIN32__
     46#endif
     47#if defined(__IBMCPP__) && !defined(__IBMC__)
     48#  define __IBMC__ __IBMCPP__
     49#endif
     50#if defined(__ICL) && defined(_WIN32) && !defined(__INTEL_COMPILER)
     51#  define __INTEL_COMPILER __ICL
     52#endif
     53#if 1 && defined(__INTERIX) && defined(__GNUC__) && !defined(_ALL_SOURCE)
     54#  define _ALL_SOURCE 1
     55#endif
     56#if defined(__mips__) && defined(__R5900__)
     57#  if !defined(__LONG_MAX__)
     58#    define __LONG_MAX__ 9223372036854775807L
     59#  endif
     60#endif
     61#if defined(__INTEL_COMPILER) && defined(__linux__)
     62#  pragma warning(disable: 193)
     63#endif
     64#if defined(__KEIL__) && defined(__C166__)
     65#  pragma warning disable = 322
     66#elif 0 && defined(__C251__)
     67#  pragma warning disable = 322
     68#endif
     69#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__)
     70#  if (_MSC_VER >= 1300)
     71#    pragma warning(disable: 4668)
     72#  endif
     73#endif
     74#if 0 && defined(__WATCOMC__)
     75#  if (__WATCOMC__ >= 1050) && (__WATCOMC__ < 1060)
     76#    pragma warning 203 9
     77#  endif
     78#endif
     79#if defined(__BORLANDC__) && defined(__MSDOS__) && !defined(__FLAT__)
     80#  pragma option -h
     81#endif
     82#if 0
     83#define LZO_0xffffL             0xfffful
     84#define LZO_0xffffffffL         0xfffffffful
     85#else
     86#define LZO_0xffffL             65535ul
     87#define LZO_0xffffffffL         4294967295ul
     88#endif
     89#if (LZO_0xffffL == LZO_0xffffffffL)
     90#  error "your preprocessor is broken 1"
     91#endif
     92#if (16ul * 16384ul != 262144ul)
     93#  error "your preprocessor is broken 2"
     94#endif
     95#if 0
     96#if (32767 >= 4294967295ul)
     97#  error "your preprocessor is broken 3"
     98#endif
     99#if (65535u >= 4294967295ul)
     100#  error "your preprocessor is broken 4"
     101#endif
     102#endif
     103#if (UINT_MAX == LZO_0xffffL)
     104#if defined(__ZTC__) && defined(__I86__) && !defined(__OS2__)
     105#  if !defined(MSDOS)
     106#    define MSDOS 1
     107#  endif
     108#  if !defined(_MSDOS)
     109#    define _MSDOS 1
     110#  endif
     111#elif 0 && defined(__VERSION) && defined(MB_LEN_MAX)
     112#  if (__VERSION == 520) && (MB_LEN_MAX == 1)
     113#    if !defined(__AZTEC_C__)
     114#      define __AZTEC_C__ __VERSION
     115#    endif
     116#    if !defined(__DOS__)
     117#      define __DOS__ 1
     118#    endif
     119#  endif
     120#endif
     121#endif
     122#if defined(_MSC_VER) && defined(M_I86HM) && (UINT_MAX == LZO_0xffffL)
     123#  define ptrdiff_t long
     124#  define _PTRDIFF_T_DEFINED
     125#endif
     126#if (UINT_MAX == LZO_0xffffL)
     127#  undef __LZO_RENAME_A
     128#  undef __LZO_RENAME_B
     129#  if defined(__AZTEC_C__) && defined(__DOS__)
     130#    define __LZO_RENAME_A 1
     131#  elif defined(_MSC_VER) && defined(MSDOS)
     132#    if (_MSC_VER < 600)
     133#      define __LZO_RENAME_A 1
     134#    elif (_MSC_VER < 700)
     135#      define __LZO_RENAME_B 1
     136#    endif
     137#  elif defined(__TSC__) && defined(__OS2__)
     138#    define __LZO_RENAME_A 1
     139#  elif defined(__MSDOS__) && defined(__TURBOC__) && (__TURBOC__ < 0x0410)
     140#    define __LZO_RENAME_A 1
     141#  elif defined(__PACIFIC__) && defined(DOS)
     142#    if !defined(__far)
     143#      define __far far
     144#    endif
     145#    if !defined(__near)
     146#      define __near near
     147#    endif
     148#  endif
     149#  if defined(__LZO_RENAME_A)
     150#    if !defined(__cdecl)
     151#      define __cdecl cdecl
     152#    endif
     153#    if !defined(__far)
     154#      define __far far
     155#    endif
     156#    if !defined(__huge)
     157#      define __huge huge
     158#    endif
     159#    if !defined(__near)
     160#      define __near near
     161#    endif
     162#    if !defined(__pascal)
     163#      define __pascal pascal
     164#    endif
     165#    if !defined(__huge)
     166#      define __huge huge
     167#    endif
     168#  elif defined(__LZO_RENAME_B)
     169#    if !defined(__cdecl)
     170#      define __cdecl _cdecl
     171#    endif
     172#    if !defined(__far)
     173#      define __far _far
     174#    endif
     175#    if !defined(__huge)
     176#      define __huge _huge
     177#    endif
     178#    if !defined(__near)
     179#      define __near _near
     180#    endif
     181#    if !defined(__pascal)
     182#      define __pascal _pascal
     183#    endif
     184#  elif (defined(__PUREC__) || defined(__TURBOC__)) && defined(__TOS__)
     185#    if !defined(__cdecl)
     186#      define __cdecl cdecl
     187#    endif
     188#    if !defined(__pascal)
     189#      define __pascal pascal
     190#    endif
     191#  endif
     192#  undef __LZO_RENAME_A
     193#  undef __LZO_RENAME_B
     194#endif
     195#if (UINT_MAX == LZO_0xffffL)
     196#if defined(__AZTEC_C__) && defined(__DOS__)
     197#  define LZO_BROKEN_CDECL_ALT_SYNTAX 1
     198#elif defined(_MSC_VER) && defined(MSDOS)
     199#  if (_MSC_VER < 600)
     200#    define LZO_BROKEN_INTEGRAL_CONSTANTS 1
     201#  endif
     202#  if (_MSC_VER < 700)
     203#    define LZO_BROKEN_INTEGRAL_PROMOTION 1
     204#    define LZO_BROKEN_SIZEOF 1
     205#  endif
     206#elif defined(__PACIFIC__) && defined(DOS)
     207#  define LZO_BROKEN_INTEGRAL_CONSTANTS 1
     208#elif defined(__TURBOC__) && defined(__MSDOS__)
     209#  if (__TURBOC__ < 0x0150)
     210#    define LZO_BROKEN_CDECL_ALT_SYNTAX 1
     211#    define LZO_BROKEN_INTEGRAL_CONSTANTS 1
     212#    define LZO_BROKEN_INTEGRAL_PROMOTION 1
     213#  endif
     214#  if (__TURBOC__ < 0x0200)
     215#    define LZO_BROKEN_SIZEOF 1
     216#  endif
     217#  if (__TURBOC__ < 0x0400) && defined(__cplusplus)
     218#    define LZO_BROKEN_CDECL_ALT_SYNTAX 1
     219#  endif
     220#elif (defined(__PUREC__) || defined(__TURBOC__)) && defined(__TOS__)
     221#  define LZO_BROKEN_CDECL_ALT_SYNTAX 1
     222#  define LZO_BROKEN_SIZEOF 1
     223#endif
     224#endif
     225#if defined(__WATCOMC__) && (__WATCOMC__ < 900)
     226#  define LZO_BROKEN_INTEGRAL_CONSTANTS 1
     227#endif
     228#if defined(_CRAY) && defined(_CRAY1)
     229#  define LZO_BROKEN_SIGNED_RIGHT_SHIFT 1
     230#endif
     231#define LZO_PP_STRINGIZE(x)             #x
     232#define LZO_PP_MACRO_EXPAND(x)          LZO_PP_STRINGIZE(x)
     233#define LZO_PP_CONCAT2(a,b)             a ## b
     234#define LZO_PP_CONCAT3(a,b,c)           a ## b ## c
     235#define LZO_PP_CONCAT4(a,b,c,d)         a ## b ## c ## d
     236#define LZO_PP_CONCAT5(a,b,c,d,e)       a ## b ## c ## d ## e
     237#define LZO_PP_ECONCAT2(a,b)            LZO_PP_CONCAT2(a,b)
     238#define LZO_PP_ECONCAT3(a,b,c)          LZO_PP_CONCAT3(a,b,c)
     239#define LZO_PP_ECONCAT4(a,b,c,d)        LZO_PP_CONCAT4(a,b,c,d)
     240#define LZO_PP_ECONCAT5(a,b,c,d,e)      LZO_PP_CONCAT5(a,b,c,d,e)
     241#if 1
     242#define LZO_CPP_STRINGIZE(x)            #x
     243#define LZO_CPP_MACRO_EXPAND(x)         LZO_CPP_STRINGIZE(x)
     244#define LZO_CPP_CONCAT2(a,b)            a ## b
     245#define LZO_CPP_CONCAT3(a,b,c)          a ## b ## c
     246#define LZO_CPP_CONCAT4(a,b,c,d)        a ## b ## c ## d
     247#define LZO_CPP_CONCAT5(a,b,c,d,e)      a ## b ## c ## d ## e
     248#define LZO_CPP_ECONCAT2(a,b)           LZO_CPP_CONCAT2(a,b)
     249#define LZO_CPP_ECONCAT3(a,b,c)         LZO_CPP_CONCAT3(a,b,c)
     250#define LZO_CPP_ECONCAT4(a,b,c,d)       LZO_CPP_CONCAT4(a,b,c,d)
     251#define LZO_CPP_ECONCAT5(a,b,c,d,e)     LZO_CPP_CONCAT5(a,b,c,d,e)
     252#endif
     253#define __LZO_MASK_GEN(o,b)     (((((o) << ((b)-1)) - (o)) << 1) + (o))
     254#if 1 && defined(__cplusplus)
     255#  if !defined(__STDC_CONSTANT_MACROS)
     256#    define __STDC_CONSTANT_MACROS 1
     257#  endif
     258#  if !defined(__STDC_LIMIT_MACROS)
     259#    define __STDC_LIMIT_MACROS 1
     260#  endif
     261#endif
     262#if defined(__cplusplus)
     263#  define LZO_EXTERN_C extern "C"
     264#else
     265#  define LZO_EXTERN_C extern
     266#endif
     267#if !defined(__LZO_OS_OVERRIDE)
     268#if defined(LZO_OS_FREESTANDING)
     269#  define LZO_INFO_OS           "freestanding"
     270#elif defined(LZO_OS_EMBEDDED)
     271#  define LZO_INFO_OS           "embedded"
     272#elif 1 && defined(__IAR_SYSTEMS_ICC__)
     273#  define LZO_OS_EMBEDDED       1
     274#  define LZO_INFO_OS           "embedded"
     275#elif defined(__CYGWIN__) && defined(__GNUC__)
     276#  define LZO_OS_CYGWIN         1
     277#  define LZO_INFO_OS           "cygwin"
     278#elif defined(__EMX__) && defined(__GNUC__)
     279#  define LZO_OS_EMX            1
     280#  define LZO_INFO_OS           "emx"
     281#elif defined(__BEOS__)
     282#  define LZO_OS_BEOS           1
     283#  define LZO_INFO_OS           "beos"
     284#elif defined(__Lynx__)
     285#  define LZO_OS_LYNXOS         1
     286#  define LZO_INFO_OS           "lynxos"
     287#elif defined(__OS400__)
     288#  define LZO_OS_OS400          1
     289#  define LZO_INFO_OS           "os400"
     290#elif defined(__QNX__)
     291#  define LZO_OS_QNX            1
     292#  define LZO_INFO_OS           "qnx"
     293#elif defined(__BORLANDC__) && defined(__DPMI32__) && (__BORLANDC__ >= 0x0460)
     294#  define LZO_OS_DOS32          1
     295#  define LZO_INFO_OS           "dos32"
     296#elif defined(__BORLANDC__) && defined(__DPMI16__)
     297#  define LZO_OS_DOS16          1
     298#  define LZO_INFO_OS           "dos16"
     299#elif defined(__ZTC__) && defined(DOS386)
     300#  define LZO_OS_DOS32          1
     301#  define LZO_INFO_OS           "dos32"
     302#elif defined(__OS2__) || defined(__OS2V2__)
     303#  if (UINT_MAX == LZO_0xffffL)
     304#    define LZO_OS_OS216        1
     305#    define LZO_INFO_OS         "os216"
     306#  elif (UINT_MAX == LZO_0xffffffffL)
     307#    define LZO_OS_OS2          1
     308#    define LZO_INFO_OS         "os2"
     309#  else
     310#    error "check your limits.h header"
     311#  endif
     312#elif defined(__WIN64__) || defined(_WIN64) || defined(WIN64)
     313#  define LZO_OS_WIN64          1
     314#  define LZO_INFO_OS           "win64"
     315#elif defined(__WIN32__) || defined(_WIN32) || defined(WIN32) || defined(__WINDOWS_386__)
     316#  define LZO_OS_WIN32          1
     317#  define LZO_INFO_OS           "win32"
     318#elif defined(__MWERKS__) && defined(__INTEL__)
     319#  define LZO_OS_WIN32          1
     320#  define LZO_INFO_OS           "win32"
     321#elif defined(__WINDOWS__) || defined(_WINDOWS) || defined(_Windows)
     322#  if (UINT_MAX == LZO_0xffffL)
     323#    define LZO_OS_WIN16        1
     324#    define LZO_INFO_OS         "win16"
     325#  elif (UINT_MAX == LZO_0xffffffffL)
     326#    define LZO_OS_WIN32        1
     327#    define LZO_INFO_OS         "win32"
     328#  else
     329#    error "check your limits.h header"
     330#  endif
     331#elif defined(__DOS__) || defined(__MSDOS__) || defined(_MSDOS) || defined(MSDOS) || (defined(__PACIFIC__) && defined(DOS))
     332#  if (UINT_MAX == LZO_0xffffL)
     333#    define LZO_OS_DOS16        1
     334#    define LZO_INFO_OS         "dos16"
     335#  elif (UINT_MAX == LZO_0xffffffffL)
     336#    define LZO_OS_DOS32        1
     337#    define LZO_INFO_OS         "dos32"
     338#  else
     339#    error "check your limits.h header"
     340#  endif
     341#elif defined(__WATCOMC__)
     342#  if defined(__NT__) && (UINT_MAX == LZO_0xffffL)
     343#    define LZO_OS_DOS16        1
     344#    define LZO_INFO_OS         "dos16"
     345#  elif defined(__NT__) && (__WATCOMC__ < 1100)
     346#    define LZO_OS_WIN32        1
     347#    define LZO_INFO_OS         "win32"
     348#  elif defined(__linux__) || defined(__LINUX__)
     349#    define LZO_OS_POSIX        1
     350#    define LZO_INFO_OS         "posix"
     351#  else
     352#    error "please specify a target using the -bt compiler option"
     353#  endif
     354#elif defined(__palmos__)
     355#  define LZO_OS_PALMOS         1
     356#  define LZO_INFO_OS           "palmos"
     357#elif defined(__TOS__) || defined(__atarist__)
     358#  define LZO_OS_TOS            1
     359#  define LZO_INFO_OS           "tos"
     360#elif defined(macintosh) && !defined(__ppc__)
     361#  define LZO_OS_MACCLASSIC     1
     362#  define LZO_INFO_OS           "macclassic"
     363#elif defined(__VMS)
     364#  define LZO_OS_VMS            1
     365#  define LZO_INFO_OS           "vms"
     366#elif ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__))
     367#  define LZO_OS_CONSOLE        1
     368#  define LZO_OS_CONSOLE_PS2    1
     369#  define LZO_INFO_OS           "console"
     370#  define LZO_INFO_OS_CONSOLE   "ps2"
     371#elif (defined(__mips__) && defined(__psp__))
     372#  define LZO_OS_CONSOLE        1
     373#  define LZO_OS_CONSOLE_PSP    1
     374#  define LZO_INFO_OS           "console"
     375#  define LZO_INFO_OS_CONSOLE   "psp"
     376#else
     377#  define LZO_OS_POSIX          1
     378#  define LZO_INFO_OS           "posix"
     379#endif
     380#if (LZO_OS_POSIX)
     381#  if defined(_AIX) || defined(__AIX__) || defined(__aix__)
     382#    define LZO_OS_POSIX_AIX        1
     383#    define LZO_INFO_OS_POSIX       "aix"
     384#  elif defined(__FreeBSD__)
     385#    define LZO_OS_POSIX_FREEBSD    1
     386#    define LZO_INFO_OS_POSIX       "freebsd"
     387#  elif defined(__hpux__) || defined(__hpux)
     388#    define LZO_OS_POSIX_HPUX       1
     389#    define LZO_INFO_OS_POSIX       "hpux"
     390#  elif defined(__INTERIX)
     391#    define LZO_OS_POSIX_INTERIX    1
     392#    define LZO_INFO_OS_POSIX       "interix"
     393#  elif defined(__IRIX__) || defined(__irix__)
     394#    define LZO_OS_POSIX_IRIX       1
     395#    define LZO_INFO_OS_POSIX       "irix"
     396#  elif defined(__linux__) || defined(__linux) || defined(__LINUX__)
     397#    define LZO_OS_POSIX_LINUX      1
     398#    define LZO_INFO_OS_POSIX       "linux"
     399#  elif defined(__APPLE__) || defined(__MACOS__)
     400#    define LZO_OS_POSIX_MACOSX     1
     401#    define LZO_INFO_OS_POSIX       "macosx"
     402#  elif defined(__minix__) || defined(__minix)
     403#    define LZO_OS_POSIX_MINIX      1
     404#    define LZO_INFO_OS_POSIX       "minix"
     405#  elif defined(__NetBSD__)
     406#    define LZO_OS_POSIX_NETBSD     1
     407#    define LZO_INFO_OS_POSIX       "netbsd"
     408#  elif defined(__OpenBSD__)
     409#    define LZO_OS_POSIX_OPENBSD    1
     410#    define LZO_INFO_OS_POSIX       "openbsd"
     411#  elif defined(__osf__)
     412#    define LZO_OS_POSIX_OSF        1
     413#    define LZO_INFO_OS_POSIX       "osf"
     414#  elif defined(__solaris__) || defined(__sun)
     415#    if defined(__SVR4) || defined(__svr4__)
     416#      define LZO_OS_POSIX_SOLARIS  1
     417#      define LZO_INFO_OS_POSIX     "solaris"
     418#    else
     419#      define LZO_OS_POSIX_SUNOS    1
     420#      define LZO_INFO_OS_POSIX     "sunos"
     421#    endif
     422#  elif defined(__ultrix__) || defined(__ultrix)
     423#    define LZO_OS_POSIX_ULTRIX     1
     424#    define LZO_INFO_OS_POSIX       "ultrix"
     425#  elif defined(_UNICOS)
     426#    define LZO_OS_POSIX_UNICOS     1
     427#    define LZO_INFO_OS_POSIX       "unicos"
     428#  else
     429#    define LZO_OS_POSIX_UNKNOWN    1
     430#    define LZO_INFO_OS_POSIX       "unknown"
     431#  endif
     432#endif
     433#endif
     434#if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16)
     435#  if (UINT_MAX != LZO_0xffffL)
     436#    error "this should not happen"
     437#  endif
     438#  if (ULONG_MAX != LZO_0xffffffffL)
     439#    error "this should not happen"
     440#  endif
     441#endif
     442#if (LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_WIN32 || LZO_OS_WIN64)
     443#  if (UINT_MAX != LZO_0xffffffffL)
     444#    error "this should not happen"
     445#  endif
     446#  if (ULONG_MAX != LZO_0xffffffffL)
     447#    error "this should not happen"
     448#  endif
     449#endif
     450#if defined(CIL) && defined(_GNUCC) && defined(__GNUC__)
     451#  define LZO_CC_CILLY          1
     452#  define LZO_INFO_CC           "Cilly"
     453#  if defined(__CILLY__)
     454#    define LZO_INFO_CCVER      LZO_PP_MACRO_EXPAND(__CILLY__)
     455#  else
     456#    define LZO_INFO_CCVER      "unknown"
     457#  endif
     458#elif 0 && defined(SDCC) && defined(__VERSION__) && !defined(__GNUC__)
     459#  define LZO_CC_SDCC           1
     460#  define LZO_INFO_CC           "sdcc"
     461#  define LZO_INFO_CCVER        LZO_PP_MACRO_EXPAND(SDCC)
     462#elif defined(__PATHSCALE__) && defined(__PATHCC_PATCHLEVEL__)
     463#  define LZO_CC_PATHSCALE      (__PATHCC__ * 0x10000L + __PATHCC_MINOR__ * 0x100 + __PATHCC_PATCHLEVEL__)
     464#  define LZO_INFO_CC           "Pathscale C"
     465#  define LZO_INFO_CCVER        __PATHSCALE__
     466#elif defined(__INTEL_COMPILER)
     467#  define LZO_CC_INTELC         1
     468#  define LZO_INFO_CC           "Intel C"
     469#  define LZO_INFO_CCVER        LZO_PP_MACRO_EXPAND(__INTEL_COMPILER)
     470#  if defined(_WIN32) || defined(_WIN64)
     471#    define LZO_CC_SYNTAX_MSC 1
     472#  else
     473#    define LZO_CC_SYNTAX_GNUC 1
     474#  endif
     475#elif defined(__POCC__) && defined(_WIN32)
     476#  define LZO_CC_PELLESC        1
     477#  define LZO_INFO_CC           "Pelles C"
     478#  define LZO_INFO_CCVER        LZO_PP_MACRO_EXPAND(__POCC__)
     479#elif defined(__llvm__) && defined(__GNUC__) && defined(__VERSION__)
     480#  if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
     481#    define LZO_CC_LLVM         (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__)
     482#  else
     483#    define LZO_CC_LLVM         (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100)
     484#  endif
     485#  define LZO_INFO_CC           "llvm-gcc"
     486#  define LZO_INFO_CCVER        __VERSION__
     487#elif defined(__GNUC__) && defined(__VERSION__)
     488#  if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
     489#    define LZO_CC_GNUC         (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__)
     490#  elif defined(__GNUC_MINOR__)
     491#    define LZO_CC_GNUC         (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100)
     492#  else
     493#    define LZO_CC_GNUC         (__GNUC__ * 0x10000L)
     494#  endif
     495#  define LZO_INFO_CC           "gcc"
     496#  define LZO_INFO_CCVER        __VERSION__
     497#elif defined(__ACK__) && defined(_ACK)
     498#  define LZO_CC_ACK            1
     499#  define LZO_INFO_CC           "Amsterdam Compiler Kit C"
     500#  define LZO_INFO_CCVER        "unknown"
     501#elif defined(__AZTEC_C__)
     502#  define LZO_CC_AZTECC         1
     503#  define LZO_INFO_CC           "Aztec C"
     504#  define LZO_INFO_CCVER        LZO_PP_MACRO_EXPAND(__AZTEC_C__)
     505#elif defined(__BORLANDC__)
     506#  define LZO_CC_BORLANDC       1
     507#  define LZO_INFO_CC           "Borland C"
     508#  define LZO_INFO_CCVER        LZO_PP_MACRO_EXPAND(__BORLANDC__)
     509#elif defined(_CRAYC) && defined(_RELEASE)
     510#  define LZO_CC_CRAYC          1
     511#  define LZO_INFO_CC           "Cray C"
     512#  define LZO_INFO_CCVER        LZO_PP_MACRO_EXPAND(_RELEASE)
     513#elif defined(__DMC__) && defined(__SC__)
     514#  define LZO_CC_DMC            1
     515#  define LZO_INFO_CC           "Digital Mars C"
     516#  define LZO_INFO_CCVER        LZO_PP_MACRO_EXPAND(__DMC__)
     517#elif defined(__DECC)
     518#  define LZO_CC_DECC           1
     519#  define LZO_INFO_CC           "DEC C"
     520#  define LZO_INFO_CCVER        LZO_PP_MACRO_EXPAND(__DECC)
     521#elif defined(__HIGHC__)
     522#  define LZO_CC_HIGHC          1
     523#  define LZO_INFO_CC           "MetaWare High C"
     524#  define LZO_INFO_CCVER        "unknown"
     525#elif defined(__IAR_SYSTEMS_ICC__)
     526#  define LZO_CC_IARC           1
     527#  define LZO_INFO_CC           "IAR C"
     528#  if defined(__VER__)
     529#    define LZO_INFO_CCVER      LZO_PP_MACRO_EXPAND(__VER__)
     530#  else
     531#    define LZO_INFO_CCVER      "unknown"
     532#  endif
     533#elif defined(__IBMC__)
     534#  define LZO_CC_IBMC           1
     535#  define LZO_INFO_CC           "IBM C"
     536#  define LZO_INFO_CCVER        LZO_PP_MACRO_EXPAND(__IBMC__)
     537#elif defined(__KEIL__) && defined(__C166__)
     538#  define LZO_CC_KEILC          1
     539#  define LZO_INFO_CC           "Keil C"
     540#  define LZO_INFO_CCVER        LZO_PP_MACRO_EXPAND(__C166__)
     541#elif defined(__LCC__) && defined(_WIN32) && defined(__LCCOPTIMLEVEL)
     542#  define LZO_CC_LCCWIN32       1
     543#  define LZO_INFO_CC           "lcc-win32"
     544#  define LZO_INFO_CCVER        "unknown"
     545#elif defined(__LCC__)
     546#  define LZO_CC_LCC            1
     547#  define LZO_INFO_CC           "lcc"
     548#  if defined(__LCC_VERSION__)
     549#    define LZO_INFO_CCVER      LZO_PP_MACRO_EXPAND(__LCC_VERSION__)
     550#  else
     551#    define LZO_INFO_CCVER      "unknown"
     552#  endif
     553#elif defined(_MSC_VER)
     554#  define LZO_CC_MSC            1
     555#  define LZO_INFO_CC           "Microsoft C"
     556#  if defined(_MSC_FULL_VER)
     557#    define LZO_INFO_CCVER      LZO_PP_MACRO_EXPAND(_MSC_VER) "." LZO_PP_MACRO_EXPAND(_MSC_FULL_VER)
     558#  else
     559#    define LZO_INFO_CCVER      LZO_PP_MACRO_EXPAND(_MSC_VER)
     560#  endif
     561#elif defined(__MWERKS__)
     562#  define LZO_CC_MWERKS         1
     563#  define LZO_INFO_CC           "Metrowerks C"
     564#  define LZO_INFO_CCVER        LZO_PP_MACRO_EXPAND(__MWERKS__)
     565#elif (defined(__NDPC__) || defined(__NDPX__)) && defined(__i386)
     566#  define LZO_CC_NDPC           1
     567#  define LZO_INFO_CC           "Microway NDP C"
     568#  define LZO_INFO_CCVER        "unknown"
     569#elif defined(__PACIFIC__)
     570#  define LZO_CC_PACIFICC       1
     571#  define LZO_INFO_CC           "Pacific C"
     572#  define LZO_INFO_CCVER        LZO_PP_MACRO_EXPAND(__PACIFIC__)
     573#elif defined(__PGI) && (defined(__linux__) || defined(__WIN32__))
     574#  define LZO_CC_PGI            1
     575#  define LZO_INFO_CC           "Portland Group PGI C"
     576#  define LZO_INFO_CCVER        "unknown"
     577#elif defined(__PUREC__) && defined(__TOS__)
     578#  define LZO_CC_PUREC          1
     579#  define LZO_INFO_CC           "Pure C"
     580#  define LZO_INFO_CCVER        LZO_PP_MACRO_EXPAND(__PUREC__)
     581#elif defined(__SC__) && defined(__ZTC__)
     582#  define LZO_CC_SYMANTECC      1
     583#  define LZO_INFO_CC           "Symantec C"
     584#  define LZO_INFO_CCVER        LZO_PP_MACRO_EXPAND(__SC__)
     585#elif defined(__SUNPRO_C)
     586#  define LZO_INFO_CC           "SunPro C"
     587#  if ((__SUNPRO_C)+0 > 0)
     588#    define LZO_CC_SUNPROC      __SUNPRO_C
     589#    define LZO_INFO_CCVER      LZO_PP_MACRO_EXPAND(__SUNPRO_C)
     590#  else
     591#    define LZO_CC_SUNPROC      1
     592#    define LZO_INFO_CCVER      "unknown"
     593#  endif
     594#elif defined(__SUNPRO_CC)
     595#  define LZO_INFO_CC           "SunPro C"
     596#  if ((__SUNPRO_CC)+0 > 0)
     597#    define LZO_CC_SUNPROC      __SUNPRO_CC
     598#    define LZO_INFO_CCVER      LZO_PP_MACRO_EXPAND(__SUNPRO_CC)
     599#  else
     600#    define LZO_CC_SUNPROC      1
     601#    define LZO_INFO_CCVER      "unknown"
     602#  endif
     603#elif defined(__TINYC__)
     604#  define LZO_CC_TINYC          1
     605#  define LZO_INFO_CC           "Tiny C"
     606#  define LZO_INFO_CCVER        LZO_PP_MACRO_EXPAND(__TINYC__)
     607#elif defined(__TSC__)
     608#  define LZO_CC_TOPSPEEDC      1
     609#  define LZO_INFO_CC           "TopSpeed C"
     610#  define LZO_INFO_CCVER        LZO_PP_MACRO_EXPAND(__TSC__)
     611#elif defined(__WATCOMC__)
     612#  define LZO_CC_WATCOMC        1
     613#  define LZO_INFO_CC           "Watcom C"
     614#  define LZO_INFO_CCVER        LZO_PP_MACRO_EXPAND(__WATCOMC__)
     615#elif defined(__TURBOC__)
     616#  define LZO_CC_TURBOC         1
     617#  define LZO_INFO_CC           "Turbo C"
     618#  define LZO_INFO_CCVER        LZO_PP_MACRO_EXPAND(__TURBOC__)
     619#elif defined(__ZTC__)
     620#  define LZO_CC_ZORTECHC       1
     621#  define LZO_INFO_CC           "Zortech C"
     622#  if (__ZTC__ == 0x310)
     623#    define LZO_INFO_CCVER      "0x310"
     624#  else
     625#    define LZO_INFO_CCVER      LZO_PP_MACRO_EXPAND(__ZTC__)
     626#  endif
     627#else
     628#  define LZO_CC_UNKNOWN        1
     629#  define LZO_INFO_CC           "unknown"
     630#  define LZO_INFO_CCVER        "unknown"
     631#endif
     632#if 0 && (LZO_CC_MSC && (_MSC_VER >= 1200)) && !defined(_MSC_FULL_VER)
     633#  error "LZO_CC_MSC: _MSC_FULL_VER is not defined"
     634#endif
     635#if !defined(__LZO_ARCH_OVERRIDE) && !defined(LZO_ARCH_GENERIC) && defined(_CRAY)
     636#  if (UINT_MAX > LZO_0xffffffffL) && defined(_CRAY)
     637#    if defined(_CRAYMPP) || defined(_CRAYT3D) || defined(_CRAYT3E)
     638#      define LZO_ARCH_CRAY_MPP     1
     639#    elif defined(_CRAY1)
     640#      define LZO_ARCH_CRAY_PVP     1
     641#    endif
     642#  endif
     643#endif
     644#if !defined(__LZO_ARCH_OVERRIDE)
     645#if defined(LZO_ARCH_GENERIC)
     646#  define LZO_INFO_ARCH             "generic"
     647#elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16)
     648#  define LZO_ARCH_I086             1
     649#  define LZO_ARCH_IA16             1
     650#  define LZO_INFO_ARCH             "i086"
     651#elif defined(__alpha__) || defined(__alpha) || defined(_M_ALPHA)
     652#  define LZO_ARCH_ALPHA            1
     653#  define LZO_INFO_ARCH             "alpha"
     654#elif (LZO_ARCH_CRAY_MPP) && (defined(_CRAYT3D) || defined(_CRAYT3E))
     655#  define LZO_ARCH_ALPHA            1
     656#  define LZO_INFO_ARCH             "alpha"
     657#elif defined(__amd64__) || defined(__x86_64__) || defined(_M_AMD64)
     658#  define LZO_ARCH_AMD64            1
     659#  define LZO_INFO_ARCH             "amd64"
     660#elif defined(__thumb__) || (defined(_M_ARM) && defined(_M_THUMB))
     661#  define LZO_ARCH_ARM              1
     662#  define LZO_ARCH_ARM_THUMB        1
     663#  define LZO_INFO_ARCH             "arm_thumb"
     664#elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCARM__)
     665#  define LZO_ARCH_ARM              1
     666#  if defined(__CPU_MODE__) && ((__CPU_MODE__)+0 == 1)
     667#    define LZO_ARCH_ARM_THUMB      1
     668#    define LZO_INFO_ARCH           "arm_thumb"
     669#  elif defined(__CPU_MODE__) && ((__CPU_MODE__)+0 == 2)
     670#    define LZO_INFO_ARCH           "arm"
     671#  else
     672#    define LZO_INFO_ARCH           "arm"
     673#  endif
     674#elif defined(__arm__) || defined(_M_ARM)
     675#  define LZO_ARCH_ARM              1
     676#  define LZO_INFO_ARCH             "arm"
     677#elif (UINT_MAX <= LZO_0xffffL) && defined(__AVR__)
     678#  define LZO_ARCH_AVR              1
     679#  define LZO_INFO_ARCH             "avr"
     680#elif defined(__bfin__)
     681#  define LZO_ARCH_BLACKFIN         1
     682#  define LZO_INFO_ARCH             "blackfin"
     683#elif (UINT_MAX == LZO_0xffffL) && defined(__C166__)
     684#  define LZO_ARCH_C166             1
     685#  define LZO_INFO_ARCH             "c166"
     686#elif defined(__cris__)
     687#  define LZO_ARCH_CRIS             1
     688#  define LZO_INFO_ARCH             "cris"
     689#elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCEZ80__)
     690#  define LZO_ARCH_EZ80             1
     691#  define LZO_INFO_ARCH             "ez80"
     692#elif defined(__H8300__) || defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__)
     693#  define LZO_ARCH_H8300            1
     694#  define LZO_INFO_ARCH             "h8300"
     695#elif defined(__hppa__) || defined(__hppa)
     696#  define LZO_ARCH_HPPA             1
     697#  define LZO_INFO_ARCH             "hppa"
     698#elif defined(__386__) || defined(__i386__) || defined(__i386) || defined(_M_IX86) || defined(_M_I386)
     699#  define LZO_ARCH_I386             1
     700#  define LZO_ARCH_IA32             1
     701#  define LZO_INFO_ARCH             "i386"
     702#elif (LZO_CC_ZORTECHC && defined(__I86__))
     703#  define LZO_ARCH_I386             1
     704#  define LZO_ARCH_IA32             1
     705#  define LZO_INFO_ARCH             "i386"
     706#elif (LZO_OS_DOS32 && LZO_CC_HIGHC) && defined(_I386)
     707#  define LZO_ARCH_I386             1
     708#  define LZO_ARCH_IA32             1
     709#  define LZO_INFO_ARCH             "i386"
     710#elif defined(__ia64__) || defined(__ia64) || defined(_M_IA64)
     711#  define LZO_ARCH_IA64             1
     712#  define LZO_INFO_ARCH             "ia64"
     713#elif (UINT_MAX == LZO_0xffffL) && defined(__m32c__)
     714#  define LZO_ARCH_M16C             1
     715#  define LZO_INFO_ARCH             "m16c"
     716#elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCM16C__)
     717#  define LZO_ARCH_M16C             1
     718#  define LZO_INFO_ARCH             "m16c"
     719#elif defined(__m32r__)
     720#  define LZO_ARCH_M32R             1
     721#  define LZO_INFO_ARCH             "m32r"
     722#elif (LZO_OS_TOS) || defined(__m68k__) || defined(__m68000__) || defined(__mc68000__) || defined(__mc68020__) || defined(_M_M68K)
     723#  define LZO_ARCH_M68K             1
     724#  define LZO_INFO_ARCH             "m68k"
     725#elif (UINT_MAX == LZO_0xffffL) && defined(__C251__)
     726#  define LZO_ARCH_MCS251           1
     727#  define LZO_INFO_ARCH             "mcs251"
     728#elif (UINT_MAX == LZO_0xffffL) && defined(__C51__)
     729#  define LZO_ARCH_MCS51            1
     730#  define LZO_INFO_ARCH             "mcs51"
     731#elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICC8051__)
     732#  define LZO_ARCH_MCS51            1
     733#  define LZO_INFO_ARCH             "mcs51"
     734#elif defined(__mips__) || defined(__mips) || defined(_MIPS_ARCH) || defined(_M_MRX000)
     735#  define LZO_ARCH_MIPS             1
     736#  define LZO_INFO_ARCH             "mips"
     737#elif (UINT_MAX == LZO_0xffffL) && defined(__MSP430__)
     738#  define LZO_ARCH_MSP430           1
     739#  define LZO_INFO_ARCH             "msp430"
     740#elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICC430__)
     741#  define LZO_ARCH_MSP430           1
     742#  define LZO_INFO_ARCH             "msp430"
     743#elif defined(__powerpc__) || defined(__powerpc) || defined(__ppc__) || defined(__PPC__) || defined(_M_PPC) || defined(_ARCH_PPC) || defined(_ARCH_PWR)
     744#  define LZO_ARCH_POWERPC          1
     745#  define LZO_INFO_ARCH             "powerpc"
     746#elif defined(__s390__) || defined(__s390) || defined(__s390x__) || defined(__s390x)
     747#  define LZO_ARCH_S390             1
     748#  define LZO_INFO_ARCH             "s390"
     749#elif defined(__sh__) || defined(_M_SH)
     750#  define LZO_ARCH_SH               1
     751#  define LZO_INFO_ARCH             "sh"
     752#elif defined(__sparc__) || defined(__sparc) || defined(__sparcv8)
     753#  define LZO_ARCH_SPARC            1
     754#  define LZO_INFO_ARCH             "sparc"
     755#elif defined(__SPU__)
     756#  define LZO_ARCH_SPU              1
     757#  define LZO_INFO_ARCH             "spu"
     758#elif (UINT_MAX == LZO_0xffffL) && defined(__z80)
     759#  define LZO_ARCH_Z80              1
     760#  define LZO_INFO_ARCH             "z80"
     761#elif (LZO_ARCH_CRAY_PVP)
     762#  if defined(_CRAYSV1)
     763#    define LZO_ARCH_CRAY_SV1       1
     764#    define LZO_INFO_ARCH           "cray_sv1"
     765#  elif (_ADDR64)
     766#    define LZO_ARCH_CRAY_T90       1
     767#    define LZO_INFO_ARCH           "cray_t90"
     768#  elif (_ADDR32)
     769#    define LZO_ARCH_CRAY_YMP       1
     770#    define LZO_INFO_ARCH           "cray_ymp"
     771#  else
     772#    define LZO_ARCH_CRAY_XMP       1
     773#    define LZO_INFO_ARCH           "cray_xmp"
     774#  endif
     775#else
     776#  define LZO_ARCH_UNKNOWN          1
     777#  define LZO_INFO_ARCH             "unknown"
     778#endif
     779#endif
     780#if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_DOS32 || LZO_OS_OS2)
     781#  error "FIXME - missing define for CPU architecture"
     782#endif
     783#if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN32)
     784#  error "FIXME - missing WIN32 define for CPU architecture"
     785#endif
     786#if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN64)
     787#  error "FIXME - missing WIN64 define for CPU architecture"
     788#endif
     789#if (LZO_OS_OS216 || LZO_OS_WIN16)
     790#  define LZO_ARCH_I086PM           1
     791#  define LZO_ARCH_IA16PM           1
     792#elif 1 && (LZO_OS_DOS16 && defined(BLX286))
     793#  define LZO_ARCH_I086PM           1
     794#  define LZO_ARCH_IA16PM           1
     795#elif 1 && (LZO_OS_DOS16 && defined(DOSX286))
     796#  define LZO_ARCH_I086PM           1
     797#  define LZO_ARCH_IA16PM           1
     798#elif 1 && (LZO_OS_DOS16 && LZO_CC_BORLANDC && defined(__DPMI16__))
     799#  define LZO_ARCH_I086PM           1
     800#  define LZO_ARCH_IA16PM           1
     801#endif
     802#if defined(LZO_ARCH_ARM_THUMB) && !defined(LZO_ARCH_ARM)
     803#  error "this should not happen"
     804#endif
     805#if defined(LZO_ARCH_I086PM) && !defined(LZO_ARCH_I086)
     806#  error "this should not happen"
     807#endif
     808#if (LZO_ARCH_I086)
     809#  if (UINT_MAX != LZO_0xffffL)
     810#    error "this should not happen"
     811#  endif
     812#  if (ULONG_MAX != LZO_0xffffffffL)
     813#    error "this should not happen"
     814#  endif
     815#endif
     816#if (LZO_ARCH_I386)
     817#  if (UINT_MAX != LZO_0xffffL) && defined(__i386_int16__)
     818#    error "this should not happen"
     819#  endif
     820#  if (UINT_MAX != LZO_0xffffffffL) && !defined(__i386_int16__)
     821#    error "this should not happen"
     822#  endif
     823#  if (ULONG_MAX != LZO_0xffffffffL)
     824#    error "this should not happen"
     825#  endif
     826#endif
     827#if !defined(__LZO_MM_OVERRIDE)
     828#if (LZO_ARCH_I086)
     829#if (UINT_MAX != LZO_0xffffL)
     830#  error "this should not happen"
     831#endif
     832#if defined(__TINY__) || defined(M_I86TM) || defined(_M_I86TM)
     833#  define LZO_MM_TINY           1
     834#elif defined(__HUGE__) || defined(_HUGE_) || defined(M_I86HM) || defined(_M_I86HM)
     835#  define LZO_MM_HUGE           1
     836#elif defined(__SMALL__) || defined(M_I86SM) || defined(_M_I86SM) || defined(SMALL_MODEL)
     837#  define LZO_MM_SMALL          1
     838#elif defined(__MEDIUM__) || defined(M_I86MM) || defined(_M_I86MM)
     839#  define LZO_MM_MEDIUM         1
     840#elif defined(__COMPACT__) || defined(M_I86CM) || defined(_M_I86CM)
     841#  define LZO_MM_COMPACT        1
     842#elif defined(__LARGE__) || defined(M_I86LM) || defined(_M_I86LM) || defined(LARGE_MODEL)
     843#  define LZO_MM_LARGE          1
     844#elif (LZO_CC_AZTECC)
     845#  if defined(_LARGE_CODE) && defined(_LARGE_DATA)
     846#    define LZO_MM_LARGE        1
     847#  elif defined(_LARGE_CODE)
     848#    define LZO_MM_MEDIUM       1
     849#  elif defined(_LARGE_DATA)
     850#    define LZO_MM_COMPACT      1
     851#  else
     852#    define LZO_MM_SMALL        1
     853#  endif
     854#elif (LZO_CC_ZORTECHC && defined(__VCM__))
     855#  define LZO_MM_LARGE          1
     856#else
     857#  error "unknown memory model"
     858#endif
     859#if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16)
     860#define LZO_HAVE_MM_HUGE_PTR        1
     861#define LZO_HAVE_MM_HUGE_ARRAY      1
     862#if (LZO_MM_TINY)
     863#  undef LZO_HAVE_MM_HUGE_ARRAY
     864#endif
     865#if (LZO_CC_AZTECC || LZO_CC_PACIFICC || LZO_CC_ZORTECHC)
     866#  undef LZO_HAVE_MM_HUGE_PTR
     867#  undef LZO_HAVE_MM_HUGE_ARRAY
     868#elif (LZO_CC_DMC || LZO_CC_SYMANTECC)
     869#  undef LZO_HAVE_MM_HUGE_ARRAY
     870#elif (LZO_CC_MSC && defined(_QC))
     871#  undef LZO_HAVE_MM_HUGE_ARRAY
     872#  if (_MSC_VER < 600)
     873#    undef LZO_HAVE_MM_HUGE_PTR
     874#  endif
     875#elif (LZO_CC_TURBOC && (__TURBOC__ < 0x0295))
     876#  undef LZO_HAVE_MM_HUGE_ARRAY
     877#endif
     878#if (LZO_ARCH_I086PM) && !defined(LZO_HAVE_MM_HUGE_PTR)
     879#  if (LZO_OS_DOS16)
     880#    error "this should not happen"
     881#  elif (LZO_CC_ZORTECHC)
     882#  else
     883#    error "this should not happen"
     884#  endif
     885#endif
     886#ifdef __cplusplus
     887extern "C" {
     888#endif
     889#if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0200))
     890   extern void __near __cdecl _AHSHIFT(void);
     891#  define LZO_MM_AHSHIFT      ((unsigned) _AHSHIFT)
     892#elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC)
     893   extern void __near __cdecl _AHSHIFT(void);
     894#  define LZO_MM_AHSHIFT      ((unsigned) _AHSHIFT)
     895#elif (LZO_CC_MSC || LZO_CC_TOPSPEEDC)
     896   extern void __near __cdecl _AHSHIFT(void);
     897#  define LZO_MM_AHSHIFT      ((unsigned) _AHSHIFT)
     898#elif (LZO_CC_TURBOC && (__TURBOC__ >= 0x0295))
     899   extern void __near __cdecl _AHSHIFT(void);
     900#  define LZO_MM_AHSHIFT      ((unsigned) _AHSHIFT)
     901#elif ((LZO_CC_AZTECC || LZO_CC_PACIFICC || LZO_CC_TURBOC) && LZO_OS_DOS16)
     902#  define LZO_MM_AHSHIFT      12
     903#elif (LZO_CC_WATCOMC)
     904   extern unsigned char _HShift;
     905#  define LZO_MM_AHSHIFT      ((unsigned) _HShift)
     906#else
     907#  error "FIXME - implement LZO_MM_AHSHIFT"
     908#endif
     909#ifdef __cplusplus
     910}
     911#endif
     912#endif
     913#elif (LZO_ARCH_C166)
     914#if !defined(__MODEL__)
     915#  error "FIXME - C166 __MODEL__"
     916#elif ((__MODEL__) == 0)
     917#  define LZO_MM_SMALL          1
     918#elif ((__MODEL__) == 1)
     919#  define LZO_MM_SMALL          1
     920#elif ((__MODEL__) == 2)
     921#  define LZO_MM_LARGE          1
     922#elif ((__MODEL__) == 3)
     923#  define LZO_MM_TINY           1
     924#elif ((__MODEL__) == 4)
     925#  define LZO_MM_XTINY          1
     926#elif ((__MODEL__) == 5)
     927#  define LZO_MM_XSMALL         1
     928#else
     929#  error "FIXME - C166 __MODEL__"
     930#endif
     931#elif (LZO_ARCH_MCS251)
     932#if !defined(__MODEL__)
     933#  error "FIXME - MCS251 __MODEL__"
     934#elif ((__MODEL__) == 0)
     935#  define LZO_MM_SMALL          1
     936#elif ((__MODEL__) == 2)
     937#  define LZO_MM_LARGE          1
     938#elif ((__MODEL__) == 3)
     939#  define LZO_MM_TINY           1
     940#elif ((__MODEL__) == 4)
     941#  define LZO_MM_XTINY          1
     942#elif ((__MODEL__) == 5)
     943#  define LZO_MM_XSMALL         1
     944#else
     945#  error "FIXME - MCS251 __MODEL__"
     946#endif
     947#elif (LZO_ARCH_MCS51)
     948#if !defined(__MODEL__)
     949#  error "FIXME - MCS51 __MODEL__"
     950#elif ((__MODEL__) == 1)
     951#  define LZO_MM_SMALL          1
     952#elif ((__MODEL__) == 2)
     953#  define LZO_MM_LARGE          1
     954#elif ((__MODEL__) == 3)
     955#  define LZO_MM_TINY           1
     956#elif ((__MODEL__) == 4)
     957#  define LZO_MM_XTINY          1
     958#elif ((__MODEL__) == 5)
     959#  define LZO_MM_XSMALL         1
     960#else
     961#  error "FIXME - MCS51 __MODEL__"
     962#endif
     963#elif (LZO_ARCH_CRAY_PVP)
     964#  define LZO_MM_PVP            1
     965#else
     966#  define LZO_MM_FLAT           1
     967#endif
     968#if (LZO_MM_COMPACT)
     969#  define LZO_INFO_MM           "compact"
     970#elif (LZO_MM_FLAT)
     971#  define LZO_INFO_MM           "flat"
     972#elif (LZO_MM_HUGE)
     973#  define LZO_INFO_MM           "huge"
     974#elif (LZO_MM_LARGE)
     975#  define LZO_INFO_MM           "large"
     976#elif (LZO_MM_MEDIUM)
     977#  define LZO_INFO_MM           "medium"
     978#elif (LZO_MM_PVP)
     979#  define LZO_INFO_MM           "pvp"
     980#elif (LZO_MM_SMALL)
     981#  define LZO_INFO_MM           "small"
     982#elif (LZO_MM_TINY)
     983#  define LZO_INFO_MM           "tiny"
     984#else
     985#  error "unknown memory model"
     986#endif
     987#endif
     988#if defined(SIZEOF_SHORT)
     989#  define LZO_SIZEOF_SHORT          (SIZEOF_SHORT)
     990#endif
     991#if defined(SIZEOF_INT)
     992#  define LZO_SIZEOF_INT            (SIZEOF_INT)
     993#endif
     994#if defined(SIZEOF_LONG)
     995#  define LZO_SIZEOF_LONG           (SIZEOF_LONG)
     996#endif
     997#if defined(SIZEOF_LONG_LONG)
     998#  define LZO_SIZEOF_LONG_LONG      (SIZEOF_LONG_LONG)
     999#endif
     1000#if defined(SIZEOF___INT16)
     1001#  define LZO_SIZEOF___INT16        (SIZEOF___INT16)
     1002#endif
     1003#if defined(SIZEOF___INT32)
     1004#  define LZO_SIZEOF___INT32        (SIZEOF___INT32)
     1005#endif
     1006#if defined(SIZEOF___INT64)
     1007#  define LZO_SIZEOF___INT64        (SIZEOF___INT64)
     1008#endif
     1009#if defined(SIZEOF_VOID_P)
     1010#  define LZO_SIZEOF_VOID_P         (SIZEOF_VOID_P)
     1011#endif
     1012#if defined(SIZEOF_SIZE_T)
     1013#  define LZO_SIZEOF_SIZE_T         (SIZEOF_SIZE_T)
     1014#endif
     1015#if defined(SIZEOF_PTRDIFF_T)
     1016#  define LZO_SIZEOF_PTRDIFF_T      (SIZEOF_PTRDIFF_T)
     1017#endif
     1018#define __LZO_LSR(x,b)    (((x)+0ul) >> (b))
     1019#if !defined(LZO_SIZEOF_SHORT)
     1020#  if (LZO_ARCH_CRAY_PVP)
     1021#    define LZO_SIZEOF_SHORT        8
     1022#  elif (USHRT_MAX == LZO_0xffffL)
     1023#    define LZO_SIZEOF_SHORT        2
     1024#  elif (__LZO_LSR(USHRT_MAX,7) == 1)
     1025#    define LZO_SIZEOF_SHORT        1
     1026#  elif (__LZO_LSR(USHRT_MAX,15) == 1)
     1027#    define LZO_SIZEOF_SHORT        2
     1028#  elif (__LZO_LSR(USHRT_MAX,31) == 1)
     1029#    define LZO_SIZEOF_SHORT        4
     1030#  elif (__LZO_LSR(USHRT_MAX,63) == 1)
     1031#    define LZO_SIZEOF_SHORT        8
     1032#  elif (__LZO_LSR(USHRT_MAX,127) == 1)
     1033#    define LZO_SIZEOF_SHORT        16
     1034#  else
     1035#    error "LZO_SIZEOF_SHORT"
     1036#  endif
     1037#endif
     1038#if !defined(LZO_SIZEOF_INT)
     1039#  if (LZO_ARCH_CRAY_PVP)
     1040#    define LZO_SIZEOF_INT          8
     1041#  elif (UINT_MAX == LZO_0xffffL)
     1042#    define LZO_SIZEOF_INT          2
     1043#  elif (UINT_MAX == LZO_0xffffffffL)
     1044#    define LZO_SIZEOF_INT          4
     1045#  elif (__LZO_LSR(UINT_MAX,7) == 1)
     1046#    define LZO_SIZEOF_INT          1
     1047#  elif (__LZO_LSR(UINT_MAX,15) == 1)
     1048#    define LZO_SIZEOF_INT          2
     1049#  elif (__LZO_LSR(UINT_MAX,31) == 1)
     1050#    define LZO_SIZEOF_INT          4
     1051#  elif (__LZO_LSR(UINT_MAX,63) == 1)
     1052#    define LZO_SIZEOF_INT          8
     1053#  elif (__LZO_LSR(UINT_MAX,127) == 1)
     1054#    define LZO_SIZEOF_INT          16
     1055#  else
     1056#    error "LZO_SIZEOF_INT"
     1057#  endif
     1058#endif
     1059#if !defined(LZO_SIZEOF_LONG)
     1060#  if (ULONG_MAX == LZO_0xffffffffL)
     1061#    define LZO_SIZEOF_LONG         4
     1062#  elif (__LZO_LSR(ULONG_MAX,7) == 1)
     1063#    define LZO_SIZEOF_LONG         1
     1064#  elif (__LZO_LSR(ULONG_MAX,15) == 1)
     1065#    define LZO_SIZEOF_LONG         2
     1066#  elif (__LZO_LSR(ULONG_MAX,31) == 1)
     1067#    define LZO_SIZEOF_LONG         4
     1068#  elif (__LZO_LSR(ULONG_MAX,63) == 1)
     1069#    define LZO_SIZEOF_LONG         8
     1070#  elif (__LZO_LSR(ULONG_MAX,127) == 1)
     1071#    define LZO_SIZEOF_LONG         16
     1072#  else
     1073#    error "LZO_SIZEOF_LONG"
     1074#  endif
     1075#endif
     1076#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64)
     1077#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8)
     1078#  if defined(__LONG_MAX__) && defined(__LONG_LONG_MAX__)
     1079#    if (LZO_CC_GNUC >= 0x030300ul)
     1080#      if ((__LONG_MAX__)+0 == (__LONG_LONG_MAX__)+0)
     1081#        define LZO_SIZEOF_LONG_LONG      LZO_SIZEOF_LONG
     1082#      elif (__LZO_LSR(__LONG_LONG_MAX__,30) == 1)
     1083#        define LZO_SIZEOF_LONG_LONG      4
     1084#      endif
     1085#    endif
     1086#  endif
     1087#endif
     1088#endif
     1089#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64)
     1090#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8)
     1091#if (LZO_ARCH_I086 && LZO_CC_DMC)
     1092#elif (LZO_CC_CILLY) && defined(__GNUC__)
     1093#  define LZO_SIZEOF_LONG_LONG      8
     1094#elif (LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE)
     1095#  define LZO_SIZEOF_LONG_LONG      8
     1096#elif ((LZO_OS_WIN32 || LZO_OS_WIN64 || defined(_WIN32)) && LZO_CC_MSC && (_MSC_VER >= 1400))
     1097#  define LZO_SIZEOF_LONG_LONG      8
     1098#elif (LZO_OS_WIN64 || defined(_WIN64))
     1099#  define LZO_SIZEOF___INT64        8
     1100#elif (LZO_ARCH_I386 && (LZO_CC_DMC))
     1101#  define LZO_SIZEOF_LONG_LONG      8
     1102#elif (LZO_ARCH_I386 && (LZO_CC_SYMANTECC && (__SC__ >= 0x700)))
     1103#  define LZO_SIZEOF_LONG_LONG      8
     1104#elif (LZO_ARCH_I386 && (LZO_CC_INTELC && defined(__linux__)))
     1105#  define LZO_SIZEOF_LONG_LONG      8
     1106#elif (LZO_ARCH_I386 && (LZO_CC_MWERKS || LZO_CC_PELLESC || LZO_CC_PGI || LZO_CC_SUNPROC))
     1107#  define LZO_SIZEOF_LONG_LONG      8
     1108#elif (LZO_ARCH_I386 && (LZO_CC_INTELC || LZO_CC_MSC))
     1109#  define LZO_SIZEOF___INT64        8
     1110#elif ((LZO_OS_WIN32 || defined(_WIN32)) && (LZO_CC_MSC))
     1111#  define LZO_SIZEOF___INT64        8
     1112#elif (LZO_ARCH_I386 && (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0520)))
     1113#  define LZO_SIZEOF___INT64        8
     1114#elif (LZO_ARCH_I386 && (LZO_CC_WATCOMC && (__WATCOMC__ >= 1100)))
     1115#  define LZO_SIZEOF___INT64        8
     1116#elif (LZO_CC_WATCOMC && defined(_INTEGRAL_MAX_BITS) && (_INTEGRAL_MAX_BITS == 64))
     1117#  define LZO_SIZEOF___INT64        8
     1118#elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__)
     1119#  define LZO_SIZEOF_LONG_LONG      8
     1120#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64)
     1121#  define LZO_SIZEOF_LONG_LONG      8
     1122#elif (LZO_CC_SDCC) && (LZO_SIZEOF_INT == 2)
     1123#elif 1 && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
     1124#  define LZO_SIZEOF_LONG_LONG      8
     1125#endif
     1126#endif
     1127#endif
     1128#if defined(__cplusplus) && defined(LZO_CC_GNUC)
     1129#  if (LZO_CC_GNUC < 0x020800ul)
     1130#    undef LZO_SIZEOF_LONG_LONG
     1131#  endif
     1132#endif
     1133#if defined(LZO_CFG_NO_LONG_LONG) || defined(__NO_LONG_LONG)
     1134#  undef LZO_SIZEOF_LONG_LONG
     1135#endif
     1136#if !defined(LZO_SIZEOF_VOID_P)
     1137#if (LZO_ARCH_I086)
     1138#  define __LZO_WORDSIZE            2
     1139#  if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM)
     1140#    define LZO_SIZEOF_VOID_P       2
     1141#  elif (LZO_MM_COMPACT || LZO_MM_LARGE || LZO_MM_HUGE)
     1142#    define LZO_SIZEOF_VOID_P       4
     1143#  else
     1144#    error "LZO_MM"
     1145#  endif
     1146#elif (LZO_ARCH_AVR || LZO_ARCH_Z80)
     1147#  define __LZO_WORDSIZE            1
     1148#  define LZO_SIZEOF_VOID_P         2
     1149#elif (LZO_ARCH_C166 || LZO_ARCH_MCS51 || LZO_ARCH_MCS251 || LZO_ARCH_MSP430)
     1150#  define LZO_SIZEOF_VOID_P         2
     1151#elif (LZO_ARCH_H8300)
     1152#  if defined(__NORMAL_MODE__)
     1153#    define __LZO_WORDSIZE          4
     1154#    define LZO_SIZEOF_VOID_P       2
     1155#  elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__)
     1156#    define __LZO_WORDSIZE          4
     1157#    define LZO_SIZEOF_VOID_P       4
     1158#  else
     1159#    define __LZO_WORDSIZE          2
     1160#    define LZO_SIZEOF_VOID_P       2
     1161#  endif
     1162#  if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_SIZEOF_INT == 4)
     1163#    define LZO_SIZEOF_SIZE_T       LZO_SIZEOF_INT
     1164#    define LZO_SIZEOF_PTRDIFF_T    LZO_SIZEOF_INT
     1165#  endif
     1166#elif (LZO_ARCH_M16C)
     1167#  define __LZO_WORDSIZE            2
     1168#  if defined(__m32c_cpu__) || defined(__m32cm_cpu__)
     1169#    define LZO_SIZEOF_VOID_P       4
     1170#  else
     1171#    define LZO_SIZEOF_VOID_P       2
     1172#  endif
     1173#elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__))
     1174#  define __LZO_WORDSIZE            8
     1175#  define LZO_SIZEOF_VOID_P         4
     1176#elif defined(__LLP64__) || defined(__LLP64) || defined(_LLP64) || defined(_WIN64)
     1177#  define __LZO_WORDSIZE            8
     1178#  define LZO_SIZEOF_VOID_P         8
     1179#elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__)
     1180#  define LZO_SIZEOF_VOID_P         LZO_SIZEOF_LONG
     1181#  define LZO_SIZEOF_SIZE_T         LZO_SIZEOF_LONG
     1182#  define LZO_SIZEOF_PTRDIFF_T      LZO_SIZEOF_LONG
     1183#elif (LZO_OS_OS400 || defined(__OS400__))
     1184#  define __LZO_WORDSIZE            LZO_SIZEOF_LONG
     1185#  define LZO_SIZEOF_VOID_P         16
     1186#  define LZO_SIZEOF_SIZE_T         LZO_SIZEOF_LONG
     1187#  define LZO_SIZEOF_PTRDIFF_T      LZO_SIZEOF_LONG
     1188#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64)
     1189#  define LZO_SIZEOF_VOID_P         8
     1190#  define LZO_SIZEOF_SIZE_T         LZO_SIZEOF_LONG
     1191#  define LZO_SIZEOF_PTRDIFF_T      LZO_SIZEOF_LONG
     1192#elif (LZO_ARCH_SPU)
     1193# if 0
     1194#  define __LZO_WORDSIZE            16
     1195# endif
     1196#  define LZO_SIZEOF_VOID_P         4
     1197#else
     1198#  define LZO_SIZEOF_VOID_P         LZO_SIZEOF_LONG
     1199#endif
     1200#endif
     1201#if !defined(LZO_WORDSIZE)
     1202#  if defined(__LZO_WORDSIZE)
     1203#    define LZO_WORDSIZE            __LZO_WORDSIZE
     1204#  else
     1205#    define LZO_WORDSIZE            LZO_SIZEOF_VOID_P
     1206#  endif
     1207#endif
     1208#if !defined(LZO_SIZEOF_SIZE_T)
     1209#if (LZO_ARCH_I086 || LZO_ARCH_M16C)
     1210#  define LZO_SIZEOF_SIZE_T         2
     1211#else
     1212#  define LZO_SIZEOF_SIZE_T         LZO_SIZEOF_VOID_P
     1213#endif
     1214#endif
     1215#if !defined(LZO_SIZEOF_PTRDIFF_T)
     1216#if (LZO_ARCH_I086)
     1217#  if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM || LZO_MM_HUGE)
     1218#    define LZO_SIZEOF_PTRDIFF_T    LZO_SIZEOF_VOID_P
     1219#  elif (LZO_MM_COMPACT || LZO_MM_LARGE)
     1220#    if (LZO_CC_BORLANDC || LZO_CC_TURBOC)
     1221#      define LZO_SIZEOF_PTRDIFF_T  4
     1222#    else
     1223#      define LZO_SIZEOF_PTRDIFF_T  2
     1224#    endif
     1225#  else
     1226#    error "LZO_MM"
     1227#  endif
     1228#else
     1229#  define LZO_SIZEOF_PTRDIFF_T      LZO_SIZEOF_SIZE_T
     1230#endif
     1231#endif
     1232#if defined(LZO_ABI_NEUTRAL_ENDIAN)
     1233#  undef LZO_ABI_BIG_ENDIAN
     1234#  undef LZO_ABI_LITTLE_ENDIAN
     1235#elif !defined(LZO_ABI_BIG_ENDIAN) && !defined(LZO_ABI_LITTLE_ENDIAN)
     1236#if (LZO_ARCH_ALPHA) && (LZO_ARCH_CRAY_MPP)
     1237#  define LZO_ABI_BIG_ENDIAN        1
     1238#elif (LZO_ARCH_ALPHA || LZO_ARCH_AMD64 || LZO_ARCH_BLACKFIN || LZO_ARCH_CRIS || LZO_ARCH_I086 || LZO_ARCH_I386 || LZO_ARCH_MSP430)
     1239#  define LZO_ABI_LITTLE_ENDIAN     1
     1240#elif (LZO_ARCH_M68K || LZO_ARCH_S390)
     1241#  define LZO_ABI_BIG_ENDIAN        1
     1242#elif 1 && defined(__IAR_SYSTEMS_ICC__) && defined(__LITTLE_ENDIAN__)
     1243#  if (__LITTLE_ENDIAN__ == 1)
     1244#    define LZO_ABI_LITTLE_ENDIAN   1
     1245#  else
     1246#    define LZO_ABI_BIG_ENDIAN      1
     1247#  endif
     1248#elif 1 && defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__)
     1249#  define LZO_ABI_BIG_ENDIAN        1
     1250#elif 1 && defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)
     1251#  define LZO_ABI_LITTLE_ENDIAN     1
     1252#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEB__) && !defined(__ARMEL__)
     1253#  define LZO_ABI_BIG_ENDIAN        1
     1254#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEL__) && !defined(__ARMEB__)
     1255#  define LZO_ABI_LITTLE_ENDIAN     1
     1256#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEB__) && !defined(__MIPSEL__)
     1257#  define LZO_ABI_BIG_ENDIAN        1
     1258#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEL__) && !defined(__MIPSEB__)
     1259#  define LZO_ABI_LITTLE_ENDIAN     1
     1260#endif
     1261#endif
     1262#if defined(LZO_ABI_BIG_ENDIAN) && defined(LZO_ABI_LITTLE_ENDIAN)
     1263#  error "this should not happen"
     1264#endif
     1265#if defined(LZO_ABI_BIG_ENDIAN)
     1266#  define LZO_INFO_ABI_ENDIAN       "be"
     1267#elif defined(LZO_ABI_LITTLE_ENDIAN)
     1268#  define LZO_INFO_ABI_ENDIAN       "le"
     1269#elif defined(LZO_ABI_NEUTRAL_ENDIAN)
     1270#  define LZO_INFO_ABI_ENDIAN       "neutral"
     1271#endif
     1272#if (LZO_SIZEOF_INT == 1 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2)
     1273#  define LZO_ABI_I8LP16         1
     1274#  define LZO_INFO_ABI_PM       "i8lp16"
     1275#elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2)
     1276#  define LZO_ABI_ILP16         1
     1277#  define LZO_INFO_ABI_PM       "ilp16"
     1278#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4)
     1279#  define LZO_ABI_ILP32         1
     1280#  define LZO_INFO_ABI_PM       "ilp32"
     1281#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 8 && LZO_SIZEOF_SIZE_T == 8)
     1282#  define LZO_ABI_LLP64         1
     1283#  define LZO_INFO_ABI_PM       "llp64"
     1284#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8)
     1285#  define LZO_ABI_LP64          1
     1286#  define LZO_INFO_ABI_PM       "lp64"
     1287#elif (LZO_SIZEOF_INT == 8 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8)
     1288#  define LZO_ABI_ILP64         1
     1289#  define LZO_INFO_ABI_PM       "ilp64"
     1290#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 4)
     1291#  define LZO_ABI_IP32L64       1
     1292#  define LZO_INFO_ABI_PM       "ip32l64"
     1293#endif
     1294#if !defined(__LZO_LIBC_OVERRIDE)
     1295#if defined(LZO_LIBC_NAKED)
     1296#  define LZO_INFO_LIBC         "naked"
     1297#elif defined(LZO_LIBC_FREESTANDING)
     1298#  define LZO_INFO_LIBC         "freestanding"
     1299#elif defined(LZO_LIBC_MOSTLY_FREESTANDING)
     1300#  define LZO_INFO_LIBC         "mfreestanding"
     1301#elif defined(LZO_LIBC_ISOC90)
     1302#  define LZO_INFO_LIBC         "isoc90"
     1303#elif defined(LZO_LIBC_ISOC99)
     1304#  define LZO_INFO_LIBC         "isoc99"
     1305#elif defined(__dietlibc__)
     1306#  define LZO_LIBC_DIETLIBC     1
     1307#  define LZO_INFO_LIBC         "dietlibc"
     1308#elif defined(_NEWLIB_VERSION)
     1309#  define LZO_LIBC_NEWLIB       1
     1310#  define LZO_INFO_LIBC         "newlib"
     1311#elif defined(__UCLIBC__) && defined(__UCLIBC_MAJOR__) && defined(__UCLIBC_MINOR__)
     1312#  if defined(__UCLIBC_SUBLEVEL__)
     1313#    define LZO_LIBC_UCLIBC     (__UCLIBC_MAJOR__ * 0x10000L + __UCLIBC_MINOR__ * 0x100 + __UCLIBC_SUBLEVEL__)
     1314#  else
     1315#    define LZO_LIBC_UCLIBC     0x00090bL
     1316#  endif
     1317#  define LZO_INFO_LIBC         "uclibc"
     1318#elif defined(__GLIBC__) && defined(__GLIBC_MINOR__)
     1319#  define LZO_LIBC_GLIBC        (__GLIBC__ * 0x10000L + __GLIBC_MINOR__ * 0x100)
     1320#  define LZO_INFO_LIBC         "glibc"
     1321#elif (LZO_CC_MWERKS) && defined(__MSL__)
     1322#  define LZO_LIBC_MSL          __MSL__
     1323#  define LZO_INFO_LIBC         "msl"
     1324#elif 1 && defined(__IAR_SYSTEMS_ICC__)
     1325#  define LZO_LIBC_ISOC90       1
     1326#  define LZO_INFO_LIBC         "isoc90"
     1327#else
     1328#  define LZO_LIBC_DEFAULT      1
     1329#  define LZO_INFO_LIBC         "default"
     1330#endif
     1331#endif
     1332#if !defined(__lzo_gnuc_extension__)
     1333#if (LZO_CC_GNUC >= 0x020800ul)
     1334#  define __lzo_gnuc_extension__    __extension__
     1335#elif (LZO_CC_LLVM || LZO_CC_PATHSCALE)
     1336#  define __lzo_gnuc_extension__    __extension__
     1337#else
     1338#  define __lzo_gnuc_extension__
     1339#endif
     1340#endif
     1341#if !defined(__lzo_ua_volatile)
     1342#  define __lzo_ua_volatile     volatile
     1343#endif
     1344#if !defined(__lzo_alignof)
     1345#if (LZO_CC_CILLY || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI)
     1346#  define __lzo_alignof(e)      __alignof__(e)
     1347#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 700))
     1348#  define __lzo_alignof(e)      __alignof__(e)
     1349#elif (LZO_CC_MSC && (_MSC_VER >= 1300))
     1350#  define __lzo_alignof(e)      __alignof(e)
     1351#endif
     1352#endif
     1353#if defined(__lzo_alignof)
     1354#  define __lzo_HAVE_alignof 1
     1355#endif
     1356#if !defined(__lzo_constructor)
     1357#if (LZO_CC_GNUC >= 0x030400ul)
     1358#  define __lzo_constructor     __attribute__((__constructor__,__used__))
     1359#elif (LZO_CC_GNUC >= 0x020700ul)
     1360#  define __lzo_constructor     __attribute__((__constructor__))
     1361#elif (LZO_CC_LLVM || LZO_CC_PATHSCALE)
     1362#  define __lzo_constructor     __attribute__((__constructor__))
     1363#endif
     1364#endif
     1365#if defined(__lzo_constructor)
     1366#  define __lzo_HAVE_constructor 1
     1367#endif
     1368#if !defined(__lzo_destructor)
     1369#if (LZO_CC_GNUC >= 0x030400ul)
     1370#  define __lzo_destructor      __attribute__((__destructor__,__used__))
     1371#elif (LZO_CC_GNUC >= 0x020700ul)
     1372#  define __lzo_destructor      __attribute__((__destructor__))
     1373#elif (LZO_CC_LLVM || LZO_CC_PATHSCALE)
     1374#  define __lzo_destructor      __attribute__((__destructor__))
     1375#endif
     1376#endif
     1377#if defined(__lzo_destructor)
     1378#  define __lzo_HAVE_destructor 1
     1379#endif
     1380#if defined(__lzo_HAVE_destructor) && !defined(__lzo_HAVE_constructor)
     1381#  error "this should not happen"
     1382#endif
     1383#if !defined(__lzo_inline)
     1384#if (LZO_CC_TURBOC && (__TURBOC__ <= 0x0295))
     1385#elif defined(__cplusplus)
     1386#  define __lzo_inline          inline
     1387#elif (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0550))
     1388#  define __lzo_inline          __inline
     1389#elif (LZO_CC_CILLY || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI)
     1390#  define __lzo_inline          __inline__
     1391#elif (LZO_CC_DMC)
     1392#  define __lzo_inline          __inline
     1393#elif (LZO_CC_INTELC)
     1394#  define __lzo_inline          __inline
     1395#elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x2405))
     1396#  define __lzo_inline          __inline
     1397#elif (LZO_CC_MSC && (_MSC_VER >= 900))
     1398#  define __lzo_inline          __inline
     1399#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
     1400#  define __lzo_inline          inline
     1401#endif
     1402#endif
     1403#if defined(__lzo_inline)
     1404#  define __lzo_HAVE_inline 1
     1405#else
     1406#  define __lzo_inline
     1407#endif
     1408#if !defined(__lzo_forceinline)
     1409#if (LZO_CC_GNUC >= 0x030200ul)
     1410#  define __lzo_forceinline     __inline__ __attribute__((__always_inline__))
     1411#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC)
     1412#  define __lzo_forceinline     __forceinline
     1413#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC)
     1414#  define __lzo_forceinline     __inline__ __attribute__((__always_inline__))
     1415#elif (LZO_CC_LLVM || LZO_CC_PATHSCALE)
     1416#  define __lzo_forceinline     __inline__ __attribute__((__always_inline__))
     1417#elif (LZO_CC_MSC && (_MSC_VER >= 1200))
     1418#  define __lzo_forceinline     __forceinline
     1419#endif
     1420#endif
     1421#if defined(__lzo_forceinline)
     1422#  define __lzo_HAVE_forceinline 1
     1423#else
     1424#  define __lzo_forceinline
     1425#endif
     1426#if !defined(__lzo_noinline)
     1427#if 1 && (LZO_ARCH_I386) && (LZO_CC_GNUC >= 0x040000ul) && (LZO_CC_GNUC < 0x040003ul)
     1428#  define __lzo_noinline        __attribute__((__noinline__,__used__))
     1429#elif (LZO_CC_GNUC >= 0x030200ul)
     1430#  define __lzo_noinline        __attribute__((__noinline__))
     1431#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_MSC)
     1432#  define __lzo_noinline        __declspec(noinline)
     1433#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC)
     1434#  define __lzo_noinline        __attribute__((__noinline__))
     1435#elif (LZO_CC_LLVM || LZO_CC_PATHSCALE)
     1436#  define __lzo_noinline        __attribute__((__noinline__))
     1437#elif (LZO_CC_MSC && (_MSC_VER >= 1300))
     1438#  define __lzo_noinline        __declspec(noinline)
     1439#elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x3200) && (LZO_OS_WIN32 || LZO_OS_WIN64))
     1440#  if defined(__cplusplus)
     1441#  else
     1442#    define __lzo_noinline      __declspec(noinline)
     1443#  endif
     1444#endif
     1445#endif
     1446#if defined(__lzo_noinline)
     1447#  define __lzo_HAVE_noinline 1
     1448#else
     1449#  define __lzo_noinline
     1450#endif
     1451#if (defined(__lzo_HAVE_forceinline) || defined(__lzo_HAVE_noinline)) && !defined(__lzo_HAVE_inline)
     1452#  error "this should not happen"
     1453#endif
     1454#if !defined(__lzo_noreturn)
     1455#if (LZO_CC_GNUC >= 0x020700ul)
     1456#  define __lzo_noreturn        __attribute__((__noreturn__))
     1457#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC)
     1458#  define __lzo_noreturn        __declspec(noreturn)
     1459#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_GNUC)
     1460#  define __lzo_noreturn        __attribute__((__noreturn__))
     1461#elif (LZO_CC_LLVM || LZO_CC_PATHSCALE)
     1462#  define __lzo_noreturn        __attribute__((__noreturn__))
     1463#elif (LZO_CC_MSC && (_MSC_VER >= 1200))
     1464#  define __lzo_noreturn        __declspec(noreturn)
     1465#endif
     1466#endif
     1467#if defined(__lzo_noreturn)
     1468#  define __lzo_HAVE_noreturn 1
     1469#else
     1470#  define __lzo_noreturn
     1471#endif
     1472#if !defined(__lzo_nothrow)
     1473#if (LZO_CC_GNUC >= 0x030300ul)
     1474#  define __lzo_nothrow         __attribute__((__nothrow__))
     1475#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) && defined(__cplusplus)
     1476#  define __lzo_nothrow         __declspec(nothrow)
     1477#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC)
     1478#  define __lzo_nothrow         __attribute__((__nothrow__))
     1479#elif (LZO_CC_LLVM || LZO_CC_PATHSCALE)
     1480#  define __lzo_nothrow         __attribute__((__nothrow__))
     1481#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) && defined(__cplusplus)
     1482#  define __lzo_nothrow         __declspec(nothrow)
     1483#endif
     1484#endif
     1485#if defined(__lzo_nothrow)
     1486#  define __lzo_HAVE_nothrow 1
     1487#else
     1488#  define __lzo_nothrow
     1489#endif
     1490#if !defined(__lzo_restrict)
     1491#if (LZO_CC_GNUC >= 0x030400ul)
     1492#  define __lzo_restrict        __restrict__
     1493#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_GNUC)
     1494#  define __lzo_restrict        __restrict__
     1495#elif (LZO_CC_LLVM)
     1496#  define __lzo_restrict        __restrict__
     1497#elif (LZO_CC_MSC && (_MSC_VER >= 1400))
     1498#  define __lzo_restrict        __restrict
     1499#endif
     1500#endif
     1501#if defined(__lzo_restrict)
     1502#  define __lzo_HAVE_restrict 1
     1503#else
     1504#  define __lzo_restrict
     1505#endif
     1506#if !defined(__lzo_likely) && !defined(__lzo_unlikely)
     1507#if (LZO_CC_GNUC >= 0x030200ul)
     1508#  define __lzo_likely(e)       (__builtin_expect(!!(e),1))
     1509#  define __lzo_unlikely(e)     (__builtin_expect(!!(e),0))
     1510#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800))
     1511#  define __lzo_likely(e)       (__builtin_expect(!!(e),1))
     1512#  define __lzo_unlikely(e)     (__builtin_expect(!!(e),0))
     1513#elif (LZO_CC_LLVM || LZO_CC_PATHSCALE)
     1514#  define __lzo_likely(e)       (__builtin_expect(!!(e),1))
     1515#  define __lzo_unlikely(e)     (__builtin_expect(!!(e),0))
     1516#endif
     1517#endif
     1518#if defined(__lzo_likely)
     1519#  define __lzo_HAVE_likely 1
     1520#else
     1521#  define __lzo_likely(e)       (e)
     1522#endif
     1523#if defined(__lzo_unlikely)
     1524#  define __lzo_HAVE_unlikely 1
     1525#else
     1526#  define __lzo_unlikely(e)     (e)
     1527#endif
     1528#if !defined(LZO_UNUSED)
     1529#  if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600))
     1530#    define LZO_UNUSED(var)         ((void) &var)
     1531#  elif (LZO_CC_BORLANDC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PELLESC || LZO_CC_TURBOC)
     1532#    define LZO_UNUSED(var)         if (&var) ; else
     1533#  elif (LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE)
     1534#    define LZO_UNUSED(var)         ((void) var)
     1535#  elif (LZO_CC_MSC && (_MSC_VER < 900))
     1536#    define LZO_UNUSED(var)         if (&var) ; else
     1537#  elif (LZO_CC_KEILC)
     1538#    define LZO_UNUSED(var)         {extern int __lzo_unused[1-2*!(sizeof(var)>0)];}
     1539#  elif (LZO_CC_PACIFICC)
     1540#    define LZO_UNUSED(var)         ((void) sizeof(var))
     1541#  elif (LZO_CC_WATCOMC) && defined(__cplusplus)
     1542#    define LZO_UNUSED(var)         ((void) var)
     1543#  else
     1544#    define LZO_UNUSED(var)         ((void) &var)
     1545#  endif
     1546#endif
     1547#if !defined(LZO_UNUSED_FUNC)
     1548#  if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600))
     1549#    define LZO_UNUSED_FUNC(func)   ((void) func)
     1550#  elif (LZO_CC_BORLANDC || LZO_CC_NDPC || LZO_CC_TURBOC)
     1551#    define LZO_UNUSED_FUNC(func)   if (func) ; else
     1552#  elif (LZO_CC_LLVM)
     1553#    define LZO_UNUSED_FUNC(func)   ((void) &func)
     1554#  elif (LZO_CC_MSC && (_MSC_VER < 900))
     1555#    define LZO_UNUSED_FUNC(func)   if (func) ; else
     1556#  elif (LZO_CC_MSC)
     1557#    define LZO_UNUSED_FUNC(func)   ((void) &func)
     1558#  elif (LZO_CC_KEILC || LZO_CC_PELLESC)
     1559#    define LZO_UNUSED_FUNC(func)   {extern int __lzo_unused[1-2*!(sizeof((int)func)>0)];}
     1560#  else
     1561#    define LZO_UNUSED_FUNC(func)   ((void) func)
     1562#  endif
     1563#endif
     1564#if !defined(LZO_UNUSED_LABEL)
     1565#  if (LZO_CC_WATCOMC) && defined(__cplusplus)
     1566#    define LZO_UNUSED_LABEL(l)     switch(0) case 1:goto l
     1567#  elif (LZO_CC_INTELC || LZO_CC_WATCOMC)
     1568#    define LZO_UNUSED_LABEL(l)     if (0) goto l
     1569#  else
     1570#    define LZO_UNUSED_LABEL(l)     switch(0) case 1:goto l
     1571#  endif
     1572#endif
     1573#if !defined(LZO_DEFINE_UNINITIALIZED_VAR)
     1574#  if 0
     1575#    define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init)  type var
     1576#  elif 0 && (LZO_CC_GNUC)
     1577#    define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init)  type var = var
     1578#  else
     1579#    define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init)  type var = init
     1580#  endif
     1581#endif
     1582#if !defined(LZO_COMPILE_TIME_ASSERT_HEADER)
     1583#  if (LZO_CC_AZTECC || LZO_CC_ZORTECHC)
     1584#    define LZO_COMPILE_TIME_ASSERT_HEADER(e)  extern int __lzo_cta[1-!(e)];
     1585#  elif (LZO_CC_DMC || LZO_CC_SYMANTECC)
     1586#    define LZO_COMPILE_TIME_ASSERT_HEADER(e)  extern int __lzo_cta[1u-2*!(e)];
     1587#  elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295))
     1588#    define LZO_COMPILE_TIME_ASSERT_HEADER(e)  extern int __lzo_cta[1-!(e)];
     1589#  else
     1590#    define LZO_COMPILE_TIME_ASSERT_HEADER(e)  extern int __lzo_cta[1-2*!(e)];
     1591#  endif
     1592#endif
     1593#if !defined(LZO_COMPILE_TIME_ASSERT)
     1594#  if (LZO_CC_AZTECC)
     1595#    define LZO_COMPILE_TIME_ASSERT(e)  {typedef int __lzo_cta_t[1-!(e)];}
     1596#  elif (LZO_CC_DMC || LZO_CC_PACIFICC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC)
     1597#    define LZO_COMPILE_TIME_ASSERT(e)  switch(0) case 1:case !(e):break;
     1598#  elif (LZO_CC_MSC && (_MSC_VER < 900))
     1599#    define LZO_COMPILE_TIME_ASSERT(e)  switch(0) case 1:case !(e):break;
     1600#  elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295))
     1601#    define LZO_COMPILE_TIME_ASSERT(e)  switch(0) case 1:case !(e):break;
     1602#  else
     1603#    define LZO_COMPILE_TIME_ASSERT(e)  {typedef int __lzo_cta_t[1-2*!(e)];}
     1604#  endif
     1605#endif
     1606#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)
     1607#  if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC)
     1608#  elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC)
     1609#    define __lzo_cdecl                 __cdecl
     1610#    define __lzo_cdecl_atexit
     1611#    define __lzo_cdecl_main            __cdecl
     1612#    if (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC))
     1613#      define __lzo_cdecl_qsort         __pascal
     1614#    elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC))
     1615#      define __lzo_cdecl_qsort         _stdcall
     1616#    else
     1617#      define __lzo_cdecl_qsort         __cdecl
     1618#    endif
     1619#  elif (LZO_CC_WATCOMC)
     1620#    define __lzo_cdecl                 __cdecl
     1621#  else
     1622#    define __lzo_cdecl                 __cdecl
     1623#    define __lzo_cdecl_atexit          __cdecl
     1624#    define __lzo_cdecl_main            __cdecl
     1625#    define __lzo_cdecl_qsort           __cdecl
     1626#  endif
     1627#  if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC || LZO_CC_WATCOMC)
     1628#  elif (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC))
     1629#    define __lzo_cdecl_sighandler      __pascal
     1630#  elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC))
     1631#    define __lzo_cdecl_sighandler      _stdcall
     1632#  elif (LZO_CC_MSC && (_MSC_VER >= 1400)) && defined(_M_CEE_PURE)
     1633#    define __lzo_cdecl_sighandler      __clrcall
     1634#  elif (LZO_CC_MSC && (_MSC_VER >= 600 && _MSC_VER < 700))
     1635#    if defined(_DLL)
     1636#      define __lzo_cdecl_sighandler    _far _cdecl _loadds
     1637#    elif defined(_MT)
     1638#      define __lzo_cdecl_sighandler    _far _cdecl
     1639#    else
     1640#      define __lzo_cdecl_sighandler    _cdecl
     1641#    endif
     1642#  else
     1643#    define __lzo_cdecl_sighandler      __cdecl
     1644#  endif
     1645#elif (LZO_ARCH_I386) && (LZO_CC_WATCOMC)
     1646#  define __lzo_cdecl                   __cdecl
     1647#elif (LZO_ARCH_M68K && LZO_OS_TOS && (LZO_CC_PUREC || LZO_CC_TURBOC))
     1648#  define __lzo_cdecl                   cdecl
     1649#endif
     1650#if !defined(__lzo_cdecl)
     1651#  define __lzo_cdecl
     1652#endif
     1653#if !defined(__lzo_cdecl_atexit)
     1654#  define __lzo_cdecl_atexit
     1655#endif
     1656#if !defined(__lzo_cdecl_main)
     1657#  define __lzo_cdecl_main
     1658#endif
     1659#if !defined(__lzo_cdecl_qsort)
     1660#  define __lzo_cdecl_qsort
     1661#endif
     1662#if !defined(__lzo_cdecl_sighandler)
     1663#  define __lzo_cdecl_sighandler
     1664#endif
     1665#if !defined(__lzo_cdecl_va)
     1666#  define __lzo_cdecl_va                __lzo_cdecl
     1667#endif
     1668#if !defined(LZO_CFG_NO_WINDOWS_H)
     1669#if (LZO_OS_CYGWIN || (LZO_OS_EMX && defined(__RSXNT__)) || LZO_OS_WIN32 || LZO_OS_WIN64)
     1670#  if (LZO_CC_WATCOMC && (__WATCOMC__ < 1000))
     1671#  elif (LZO_OS_WIN32 && LZO_CC_GNUC) && defined(__PW32__)
     1672#  elif ((LZO_OS_CYGWIN || defined(__MINGW32__)) && (LZO_CC_GNUC && (LZO_CC_GNUC < 0x025f00ul)))
     1673#  else
     1674#    define LZO_HAVE_WINDOWS_H 1
     1675#  endif
     1676#endif
     1677#endif
     1678#if (LZO_ARCH_ALPHA)
     1679#  define LZO_OPT_AVOID_UINT_INDEX  1
     1680#  define LZO_OPT_AVOID_SHORT       1
     1681#  define LZO_OPT_AVOID_USHORT      1
     1682#elif (LZO_ARCH_AMD64)
     1683#  define LZO_OPT_AVOID_INT_INDEX   1
     1684#  define LZO_OPT_AVOID_UINT_INDEX  1
     1685#  define LZO_OPT_UNALIGNED16       1
     1686#  define LZO_OPT_UNALIGNED32       1
     1687#  define LZO_OPT_UNALIGNED64       1
     1688#elif (LZO_ARCH_ARM && LZO_ARCH_ARM_THUMB)
     1689#elif (LZO_ARCH_ARM)
     1690#  define LZO_OPT_AVOID_SHORT       1
     1691#  define LZO_OPT_AVOID_USHORT      1
     1692#elif (LZO_ARCH_CRIS)
     1693#  define LZO_OPT_UNALIGNED16       1
     1694#  define LZO_OPT_UNALIGNED32       1
     1695#elif (LZO_ARCH_I386)
     1696#  define LZO_OPT_UNALIGNED16       1
     1697#  define LZO_OPT_UNALIGNED32       1
     1698#elif (LZO_ARCH_IA64)
     1699#  define LZO_OPT_AVOID_INT_INDEX   1
     1700#  define LZO_OPT_AVOID_UINT_INDEX  1
     1701#  define LZO_OPT_PREFER_POSTINC    1
     1702#elif (LZO_ARCH_M68K)
     1703#  define LZO_OPT_PREFER_POSTINC    1
     1704#  define LZO_OPT_PREFER_PREDEC     1
     1705#  if defined(__mc68020__) && !defined(__mcoldfire__)
     1706#    define LZO_OPT_UNALIGNED16     1
     1707#    define LZO_OPT_UNALIGNED32     1
     1708#  endif
     1709#elif (LZO_ARCH_MIPS)
     1710#  define LZO_OPT_AVOID_UINT_INDEX  1
     1711#elif (LZO_ARCH_POWERPC)
     1712#  define LZO_OPT_PREFER_PREINC     1
     1713#  define LZO_OPT_PREFER_PREDEC     1
     1714#  if defined(LZO_ABI_BIG_ENDIAN)
     1715#    define LZO_OPT_UNALIGNED16     1
     1716#    define LZO_OPT_UNALIGNED32     1
     1717#  endif
     1718#elif (LZO_ARCH_S390)
     1719#  define LZO_OPT_UNALIGNED16       1
     1720#  define LZO_OPT_UNALIGNED32       1
     1721#  if (LZO_SIZEOF_SIZE_T == 8)
     1722#    define LZO_OPT_UNALIGNED64     1
     1723#  endif
     1724#elif (LZO_ARCH_SH)
     1725#  define LZO_OPT_PREFER_POSTINC    1
     1726#  define LZO_OPT_PREFER_PREDEC     1
     1727#endif
     1728#if !defined(LZO_CFG_NO_INLINE_ASM)
     1729#if defined(LZO_CC_LLVM)
     1730#  define LZO_CFG_NO_INLINE_ASM 1
     1731#endif
     1732#endif
     1733#if !defined(LZO_CFG_NO_UNALIGNED)
     1734#if defined(LZO_ABI_NEUTRAL_ENDIAN) || defined(LZO_ARCH_GENERIC)
     1735#  define LZO_CFG_NO_UNALIGNED 1
     1736#endif
     1737#endif
     1738#if defined(LZO_CFG_NO_UNALIGNED)
     1739#  undef LZO_OPT_UNALIGNED16
     1740#  undef LZO_OPT_UNALIGNED32
     1741#  undef LZO_OPT_UNALIGNED64
     1742#endif
     1743#if defined(LZO_CFG_NO_INLINE_ASM)
     1744#elif (LZO_ARCH_I386 && (LZO_OS_DOS32 || LZO_OS_WIN32) && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC))
     1745#  define LZO_ASM_SYNTAX_MSC 1
     1746#elif (LZO_OS_WIN64 && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC))
     1747#elif (LZO_ARCH_I386 && (LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE))
     1748#  define LZO_ASM_SYNTAX_GNUC 1
     1749#elif (LZO_ARCH_AMD64 && (LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE))
     1750#  define LZO_ASM_SYNTAX_GNUC 1
     1751#endif
     1752#if (LZO_ASM_SYNTAX_GNUC)
     1753#if (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC < 0x020000ul))
     1754#  define __LZO_ASM_CLOBBER         "ax"
     1755#elif (LZO_CC_INTELC)
     1756#  define __LZO_ASM_CLOBBER         "memory"
     1757#else
     1758#  define __LZO_ASM_CLOBBER         "cc", "memory"
     1759#endif
     1760#endif
     1761#if defined(__LZO_INFOSTR_MM)
     1762#elif (LZO_MM_FLAT) && (defined(__LZO_INFOSTR_PM) || defined(LZO_INFO_ABI_PM))
     1763#  define __LZO_INFOSTR_MM          ""
     1764#elif defined(LZO_INFO_MM)
     1765#  define __LZO_INFOSTR_MM          "." LZO_INFO_MM
     1766#else
     1767#  define __LZO_INFOSTR_MM          ""
     1768#endif
     1769#if defined(__LZO_INFOSTR_PM)
     1770#elif defined(LZO_INFO_ABI_PM)
     1771#  define __LZO_INFOSTR_PM          "." LZO_INFO_ABI_PM
     1772#else
     1773#  define __LZO_INFOSTR_PM          ""
     1774#endif
     1775#if defined(__LZO_INFOSTR_ENDIAN)
     1776#elif defined(LZO_INFO_ABI_ENDIAN)
     1777#  define __LZO_INFOSTR_ENDIAN      "." LZO_INFO_ABI_ENDIAN
     1778#else
     1779#  define __LZO_INFOSTR_ENDIAN      ""
     1780#endif
     1781#if defined(__LZO_INFOSTR_OSNAME)
     1782#elif defined(LZO_INFO_OS_CONSOLE)
     1783#  define __LZO_INFOSTR_OSNAME      LZO_INFO_OS "." LZO_INFO_OS_CONSOLE
     1784#elif defined(LZO_INFO_OS_POSIX)
     1785#  define __LZO_INFOSTR_OSNAME      LZO_INFO_OS "." LZO_INFO_OS_POSIX
     1786#else
     1787#  define __LZO_INFOSTR_OSNAME      LZO_INFO_OS
     1788#endif
     1789#if defined(__LZO_INFOSTR_LIBC)
     1790#elif defined(LZO_INFO_LIBC)
     1791#  define __LZO_INFOSTR_LIBC        "." LZO_INFO_LIBC
     1792#else
     1793#  define __LZO_INFOSTR_LIBC        ""
     1794#endif
     1795#if defined(__LZO_INFOSTR_CCVER)
     1796#elif defined(LZO_INFO_CCVER)
     1797#  define __LZO_INFOSTR_CCVER       " " LZO_INFO_CCVER
     1798#else
     1799#  define __LZO_INFOSTR_CCVER       ""
     1800#endif
     1801#define LZO_INFO_STRING \
     1802    LZO_INFO_ARCH __LZO_INFOSTR_MM __LZO_INFOSTR_PM __LZO_INFOSTR_ENDIAN \
     1803    " " __LZO_INFOSTR_OSNAME __LZO_INFOSTR_LIBC " " LZO_INFO_CC __LZO_INFOSTR_CCVER
     1804
     1805#endif /* already included */
     1806
     1807/* vim:set ts=4 et: */
  • libs/libmythtv/minilzo.cpp

    diff -uNr mythtv-0.21-orig/libs/libmythtv/minilzo.cpp mythtv-0.21/libs/libmythtv/minilzo.cpp
    old new  
    22
    33   This file is part of the LZO real-time data compression library.
    44
     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
    513   Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
    614   Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
    715   Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
    816   Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
    917   Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
     18   All Rights Reserved.
    1019
    1120   The LZO library is free software; you can redistribute it and/or
    1221   modify it under the terms of the GNU General Public License as
     
    2130   You should have received a copy of the GNU General Public License
    2231   along with the LZO library; see the file COPYING.
    2332   If not, write to the Free Software Foundation, Inc.,
    24    59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
     33   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
    2534
    2635   Markus F.X.J. Oberhumer
    27    <markus.oberhumer@jk.uni-linz.ac.at>
    28    http://wildsau.idv.uni-linz.ac.at/mfx/lzo.html
     36   <markus@oberhumer.com>
     37   http://www.oberhumer.com/opensource/lzo/
    2938 */
    3039
    3140/*
    3241 * NOTE:
    3342 *   the full LZO package can be found at
    34  *   http://wildsau.idv.uni-linz.ac.at/mfx/lzo.html
     43 *   http://www.oberhumer.com/opensource/lzo/
    3544 */
    3645
    3746#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
    3854
    3955#ifdef MINILZO_HAVE_CONFIG_H
    4056#  include <config.h>
    4157#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
    421829
    431830#undef LZO_HAVE_CONFIG_H
    441831#include "minilzo.h"
    451832
    46 #if !defined(MINILZO_VERSION) || (MINILZO_VERSION != 0x1070)
     1833#if !defined(MINILZO_VERSION) || (MINILZO_VERSION != 0x2030)
    471834#  error "version mismatch in miniLZO source files"
    481835#endif
    491836
     
    511838#  define LZO_HAVE_CONFIG_H
    521839#endif
    531840
    54 #if !defined(LZO_NO_SYS_TYPES_H)
    55 #  include <sys/types.h>
    56 #endif
    57 #include <stdio.h>
    58 
    591841#ifndef __LZO_CONF_H
    601842#define __LZO_CONF_H
    611843
    621844#if !defined(__LZO_IN_MINILZO)
    63 #  ifndef __LZOCONF_H
    64 #    include <lzoconf.h>
    65 #  endif
     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"
    661870#endif
    671871
    68 #if defined(__BOUNDS_CHECKING_ON)
    69 #  include <unchecked.h>
    70 #else
    71 #  define BOUNDS_CHECKING_OFF_DURING(stmt)      stmt
    72 #  define BOUNDS_CHECKING_OFF_IN_EXPR(expr)     (expr)
     1872#if (LZO_VERSION < 0x02000) || !defined(__LZOCONF_H_INCLUDED)
     1873#  error "version mismatch"
    731874#endif
    741875
    75 #if !defined(LZO_HAVE_CONFIG_H)
    76 #  include <stddef.h>
    77 #  include <string.h>
    78 #  if !defined(NO_STDLIB_H)
    79 #    include <stdlib.h>
    80 #  endif
    81 #  define HAVE_MEMCMP
    82 #  define HAVE_MEMCPY
    83 #  define HAVE_MEMMOVE
    84 #  define HAVE_MEMSET
    85 #else
    86 #  include <sys/types.h>
    87 #  if defined(STDC_HEADERS)
    88 #    include <string.h>
    89 #    include <stdlib.h>
    90 #  endif
    91 #  if defined(HAVE_STDDEF_H)
    92 #    include <stddef.h>
    93 #  endif
    94 #  if defined(HAVE_MEMORY_H)
    95 #    include <memory.h>
    96 #  endif
     1876#if (LZO_CC_BORLANDC && LZO_ARCH_I086)
     1877#  pragma option -h
    971878#endif
    981879
    99 #if defined(__LZO_DOS16) || defined(__LZO_WIN16)
    100 #  define HAVE_MALLOC_H
    101 #  define HAVE_HALLOC
     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)
    1021886#endif
    1031887
    104 #undef NDEBUG
    105 #if !defined(LZO_DEBUG)
    106 define NDEBUG
     1888#if (LZO_CC_SUNPROC)
     1889#  pragma error_messages(off,E_END_OF_LOOP_CODE_NOT_REACHED)
     1890pragma error_messages(off,E_LOOP_NOT_ENTERED_AT_TOP)
    1071891#endif
    108 #if defined(LZO_DEBUG) || !defined(NDEBUG)
    109 #  if !defined(NO_STDIO_H)
    110 #    include <stdio.h>
    111 #  endif
     1892
     1893#if defined(__LZO_MMODEL_HUGE) && (!LZO_HAVE_MM_HUGE_PTR)
     1894#  error "this should not happen - check defines for __huge"
    1121895#endif
    113 #include <assert.h>
    1141896
    115 #if !defined(LZO_UNUSED)
    116 #  define LZO_UNUSED(parm)  (parm = parm)
     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
    1171906#endif
    1181907
    119 #if !defined(__inline__) && !defined(__GNUC__)
    120 #  if defined(__cplusplus)
    121 #    define __inline__      inline
     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
    1221930#  else
    123 #    define __inline__
     1931#    define lzo_uintptr_t       size_t
    1241932#  endif
    1251933#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
    1261957
    127 #if defined(NO_MEMCMP)
     1958#if defined(LZO_CFG_FREESTANDING)
    1281959#  undef HAVE_MEMCMP
     1960#  undef HAVE_MEMCPY
     1961#  undef HAVE_MEMMOVE
     1962#  undef HAVE_MEMSET
    1291963#endif
    1301964
    1311965#if !defined(HAVE_MEMCMP)
    1321966#  undef memcmp
    133 #  define memcmp    lzo_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)
    1341970#endif
    1351971#if !defined(HAVE_MEMCPY)
    1361972#  undef memcpy
    137 #  define memcpy    lzo_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)
    1381976#endif
    1391977#if !defined(HAVE_MEMMOVE)
    1401978#  undef memmove
    141 #  define memmove   lzo_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)
    1421982#endif
    1431983#if !defined(HAVE_MEMSET)
    1441984#  undef memset
    145 #  define memset    lzo_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
    1462018#endif
    1472019
    1482020#if 1
     
    1502022#else
    1512023#  define LZO_BYTE(x)       ((unsigned char) ((x) & 0xff))
    1522024#endif
    153 #if 0
    154 #  define LZO_USHORT(x)     ((unsigned short) (x))
    155 #else
    156 #  define LZO_USHORT(x)     ((unsigned short) ((x) & 0xffff))
    157 #endif
    1582025
    1592026#define LZO_MAX(a,b)        ((a) >= (b) ? (a) : (b))
    1602027#define LZO_MIN(a,b)        ((a) <= (b) ? (a) : (b))
     
    1742041#define LZO_USIZE(bits)     ((lzo_uint) 1 << (bits))
    1752042#define LZO_UMASK(bits)     (LZO_USIZE(bits) - 1)
    1762043
    177 #define LZO_STYPE_MAX(b)    (((1l  << (8*(b)-2)) - 1l)  + (1l  << (8*(b)-2)))
    178 #define LZO_UTYPE_MAX(b)    (((1ul << (8*(b)-1)) - 1ul) + (1ul << (8*(b)-1)))
    179 
    180 #if !defined(SIZEOF_UNSIGNED)
    181 #  if (UINT_MAX == 0xffff)
    182 #    define SIZEOF_UNSIGNED         2
    183 #  elif (UINT_MAX == LZO_0xffffffffL)
    184 #    define SIZEOF_UNSIGNED         4
    185 #  elif (UINT_MAX >= LZO_0xffffffffL)
    186 #    define SIZEOF_UNSIGNED         8
    187 #  else
    188 #    error SIZEOF_UNSIGNED
    189 #  endif
    190 #endif
    191 
    192 #if !defined(SIZEOF_UNSIGNED_LONG)
    193 #  if (ULONG_MAX == LZO_0xffffffffL)
    194 #    define SIZEOF_UNSIGNED_LONG    4
    195 #  elif (ULONG_MAX >= LZO_0xffffffffL)
    196 #    define SIZEOF_UNSIGNED_LONG    8
    197 #  else
    198 #    error SIZEOF_UNSIGNED_LONG
    199 #  endif
    200 #endif
     2044#if !defined(DMUL)
     2045#if 0
    2012046
    202 #if !defined(SIZEOF_SIZE_T)
    203 #  define SIZEOF_SIZE_T             SIZEOF_UNSIGNED
     2047#  define DMUL(a,b) ((lzo_xint) ((lzo_uint32)(a) * (lzo_uint32)(b)))
     2048#else
     2049#  define DMUL(a,b) ((lzo_xint) ((a) * (b)))
    2042050#endif
    205 #if !defined(SIZE_T_MAX)
    206 #  define SIZE_T_MAX                LZO_UTYPE_MAX(SIZEOF_SIZE_T)
    2072051#endif
    2082052
    209 #if 1 && defined(__LZO_i386) && (UINT_MAX == LZO_0xffffffffL)
    210 #  if !defined(LZO_UNALIGNED_OK_2) && (USHRT_MAX == 0xffff)
     2053#if 1 && !defined(LZO_CFG_NO_UNALIGNED)
     2054#if 1 && (LZO_ARCH_AMD64 || LZO_ARCH_I386)
     2055#  if (LZO_SIZEOF_SHORT == 2)
    2112056#    define LZO_UNALIGNED_OK_2
    2122057#  endif
    213 #  if !defined(LZO_UNALIGNED_OK_4) && (LZO_UINT32_MAX == LZO_0xffffffffL)
     2058#  if (LZO_SIZEOF_INT == 4)
    2142059#    define LZO_UNALIGNED_OK_4
    2152060#  endif
    2162061#endif
    217 
    218 #if defined(LZO_UNALIGNED_OK_2) || defined(LZO_UNALIGNED_OK_4)
    219 #  if !defined(LZO_UNALIGNED_OK)
    220 #    define LZO_UNALIGNED_OK
    221 #  endif
    222 #endif
    223 
    224 #if defined(__LZO_NO_UNALIGNED)
    225 #  undef LZO_UNALIGNED_OK
    226 #  undef LZO_UNALIGNED_OK_2
    227 #  undef LZO_UNALIGNED_OK_4
    228 #endif
    229 
    230 #if defined(LZO_UNALIGNED_OK_2) && (USHRT_MAX != 0xffff)
    231 #  error "LZO_UNALIGNED_OK_2 must not be defined on this system"
    232 #endif
    233 #if defined(LZO_UNALIGNED_OK_4) && (LZO_UINT32_MAX != LZO_0xffffffffL)
    234 #  error "LZO_UNALIGNED_OK_4 must not be defined on this system"
    235 #endif
    236 
    237 #if defined(__LZO_NO_ALIGNED)
    238 #  undef LZO_ALIGNED_OK_4
    2392062#endif
    2402063
    241 #if defined(LZO_ALIGNED_OK_4) && (LZO_UINT32_MAX != LZO_0xffffffffL)
    242 #  error "LZO_ALIGNED_OK_4 must not be defined on this system"
    243 #endif
    244 
    245 #define LZO_LITTLE_ENDIAN       1234
    246 #define LZO_BIG_ENDIAN          4321
    247 #define LZO_PDP_ENDIAN          3412
    248 
    249 #if !defined(LZO_BYTE_ORDER)
    250 #  if defined(MFX_BYTE_ORDER)
    251 #    define LZO_BYTE_ORDER      MFX_BYTE_ORDER
    252 #  elif defined(__LZO_i386)
    253 #    define LZO_BYTE_ORDER      LZO_LITTLE_ENDIAN
    254 #  elif defined(BYTE_ORDER)
    255 #    define LZO_BYTE_ORDER      BYTE_ORDER
    256 #  elif defined(__BYTE_ORDER)
    257 #    define LZO_BYTE_ORDER      __BYTE_ORDER
    258 #  endif
     2064#if defined(LZO_UNALIGNED_OK_2)
     2065  LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(short) == 2)
    2592066#endif
    260 
    261 #if defined(LZO_BYTE_ORDER)
    262 #  if (LZO_BYTE_ORDER != LZO_LITTLE_ENDIAN) && \
    263       (LZO_BYTE_ORDER != LZO_BIG_ENDIAN)
    264 #    error "invalid LZO_BYTE_ORDER"
    265 #  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)
    2662071#endif
    2672072
    268 #if defined(LZO_UNALIGNED_OK) && !defined(LZO_BYTE_ORDER)
    269 #  error "LZO_BYTE_ORDER is not defined"
    270 #endif
     2073#define MEMCPY8_DS(dest,src,len) \
     2074    lzo_memcpy(dest,src,len); dest += len; src += len
    2712075
    272 #define LZO_OPTIMIZE_GNUC_i386_IS_BUGGY
     2076#define BZERO8_PTR(s,l,n) \
     2077    lzo_memset((lzo_voidp)(s),0,(lzo_uint)(l)*(n))
    2732078
    274 #if defined(NDEBUG) && !defined(LZO_DEBUG) && !defined(__LZO_CHECKER)
    275 #  if defined(__GNUC__) && defined(__i386__)
    276 #    if !defined(LZO_OPTIMIZE_GNUC_i386_IS_BUGGY)
    277 #      define LZO_OPTIMIZE_GNUC_i386
    278 #    endif
    279 #  endif
    280 #endif
     2079#define MEMCPY_DS(dest,src,len) \
     2080    do *dest++ = *src++; while (--len > 0)
    2812081
    2822082__LZO_EXTERN_C int __lzo_init_done;
    283 __LZO_EXTERN_C const lzo_byte __lzo_copyright[];
    284 LZO_EXTERN(const lzo_byte *) lzo_copyright(void);
    285 __LZO_EXTERN_C const lzo_uint32 _lzo_crc32_table[256];
    286 
    287 #define _LZO_STRINGIZE(x)           #x
    288 #define _LZO_MEXPAND(x)             _LZO_STRINGIZE(x)
    289 
    290 #define _LZO_CONCAT2(a,b)           a ## b
    291 #define _LZO_CONCAT3(a,b,c)         a ## b ## c
    292 #define _LZO_CONCAT4(a,b,c,d)       a ## b ## c ## d
    293 #define _LZO_CONCAT5(a,b,c,d,e)     a ## b ## c ## d ## e
    294 
    295 #define _LZO_ECONCAT2(a,b)          _LZO_CONCAT2(a,b)
    296 #define _LZO_ECONCAT3(a,b,c)        _LZO_CONCAT3(a,b,c)
    297 #define _LZO_ECONCAT4(a,b,c,d)      _LZO_CONCAT4(a,b,c,d)
    298 #define _LZO_ECONCAT5(a,b,c,d,e)    _LZO_CONCAT5(a,b,c,d,e)
    299 
    300 #if 0
    301 
    302 #define __LZO_IS_COMPRESS_QUERY(i,il,o,ol,w)    ((lzo_voidp)(o) == (w))
    303 #define __LZO_QUERY_COMPRESS(i,il,o,ol,w,n,s) \
    304                 (*ol = (n)*(s), LZO_E_OK)
    305 
    306 #define __LZO_IS_DECOMPRESS_QUERY(i,il,o,ol,w)  ((lzo_voidp)(o) == (w))
    307 #define __LZO_QUERY_DECOMPRESS(i,il,o,ol,w,n,s) \
    308                 (*ol = (n)*(s), LZO_E_OK)
    309 
    310 #define __LZO_IS_OPTIMIZE_QUERY(i,il,o,ol,w)    ((lzo_voidp)(o) == (w))
    311 #define __LZO_QUERY_OPTIMIZE(i,il,o,ol,w,n,s) \
    312                 (*ol = (n)*(s), LZO_E_OK)
    313 
    314 #endif
     2083__LZO_EXTERN_C const char __lzo_copyright[];
     2084LZO_EXTERN(const lzo_bytep) lzo_copyright(void);
    3152085
    3162086#ifndef __LZO_PTR_H
    3172087#define __LZO_PTR_H
     
    3202090extern "C" {
    3212091#endif
    3222092
    323 #if defined(__LZO_DOS16) || defined(__LZO_WIN16)
    324 #  include <dos.h>
    325 #  if 1 && defined(__WATCOMC__)
    326 #    include <i86.h>
    327      __LZO_EXTERN_C unsigned char _HShift;
    328 #    define __LZO_HShift    _HShift
    329 #  elif 1 && defined(_MSC_VER)
    330      __LZO_EXTERN_C unsigned short __near _AHSHIFT;
    331 #    define __LZO_HShift    ((unsigned) &_AHSHIFT)
    332 #  elif defined(__LZO_WIN16)
    333 #    define __LZO_HShift    3
     2093#if !defined(lzo_uintptr_t)
     2094#  if defined(__LZO_MMODEL_HUGE)
     2095#    define lzo_uintptr_t   unsigned long
    3342096#  else
    335 #    define __LZO_HShift    12
    336 #  endif
    337 #  if !defined(_FP_SEG) && defined(FP_SEG)
    338 #    define _FP_SEG         FP_SEG
    339 #  endif
    340 #  if !defined(_FP_OFF) && defined(FP_OFF)
    341 #    define _FP_OFF         FP_OFF
    342 #  endif
    343 #endif
    344 
    345 #if (UINT_MAX >= LZO_0xffffffffL)
    346    typedef ptrdiff_t            lzo_ptrdiff_t;
    347 #else
    348    typedef long                 lzo_ptrdiff_t;
    349 #endif
    350 
    351 #if !defined(__LZO_HAVE_PTR_T)
    352 #  if defined(lzo_ptr_t)
    353 #    define __LZO_HAVE_PTR_T
    354 #  endif
    355 #endif
    356 #if !defined(__LZO_HAVE_PTR_T)
    357 #  if defined(SIZEOF_CHAR_P) && defined(SIZEOF_UNSIGNED_LONG)
    358 #    if (SIZEOF_CHAR_P == SIZEOF_UNSIGNED_LONG)
    359        typedef unsigned long    lzo_ptr_t;
    360        typedef long             lzo_sptr_t;
    361 #      define __LZO_HAVE_PTR_T
     2097#    define lzo_uintptr_t   acc_uintptr_t
     2098#    ifdef __ACC_INTPTR_T_IS_POINTER
     2099#      define __LZO_UINTPTR_T_IS_POINTER 1
    3622100#    endif
    3632101#  endif
    3642102#endif
    365 #if !defined(__LZO_HAVE_PTR_T)
    366 #  if defined(SIZEOF_CHAR_P) && defined(SIZEOF_UNSIGNED)
    367 #    if (SIZEOF_CHAR_P == SIZEOF_UNSIGNED)
    368        typedef unsigned int     lzo_ptr_t;
    369        typedef int              lzo_sptr_t;
    370 #      define __LZO_HAVE_PTR_T
    371 #    endif
    372 #  endif
    373 #endif
    374 #if !defined(__LZO_HAVE_PTR_T)
    375 #  if defined(SIZEOF_CHAR_P) && defined(SIZEOF_UNSIGNED_SHORT)
    376 #    if (SIZEOF_CHAR_P == SIZEOF_UNSIGNED_SHORT)
    377        typedef unsigned short   lzo_ptr_t;
    378        typedef short            lzo_sptr_t;
    379 #      define __LZO_HAVE_PTR_T
    380 #    endif
    381 #  endif
    382 #endif
    383 #if !defined(__LZO_HAVE_PTR_T)
    384 #  if defined(LZO_HAVE_CONFIG_H) || defined(SIZEOF_CHAR_P)
    385 #    error "no suitable type for lzo_ptr_t"
    386 #  else
    387      typedef unsigned long      lzo_ptr_t;
    388      typedef long               lzo_sptr_t;
    389 #    define __LZO_HAVE_PTR_T
    390 #  endif
    391 #endif
    3922103
    393 #if defined(__LZO_DOS16) || defined(__LZO_WIN16)
     2104#if (LZO_ARCH_I086)
    3942105#define PTR(a)              ((lzo_bytep) (a))
    395 #define PTR_ALIGNED_4(a)    ((_FP_OFF(a) & 3) == 0)
    396 #define PTR_ALIGNED2_4(a,b) (((_FP_OFF(a) | _FP_OFF(b)) & 3) == 0)
     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)
    3972112#else
    398 #define PTR(a)              ((lzo_ptr_t) (a))
     2113#define PTR(a)              ((lzo_uintptr_t) (a))
    3992114#define PTR_LINEAR(a)       PTR(a)
    4002115#define PTR_ALIGNED_4(a)    ((PTR_LINEAR(a) & 3) == 0)
    4012116#define PTR_ALIGNED_8(a)    ((PTR_LINEAR(a) & 7) == 0)
     
    4052120
    4062121#define PTR_LT(a,b)         (PTR(a) < PTR(b))
    4072122#define PTR_GE(a,b)         (PTR(a) >= PTR(b))
    408 #define PTR_DIFF(a,b)       ((lzo_ptrdiff_t) (PTR(a) - PTR(b)))
     2123#define PTR_DIFF(a,b)       (PTR(a) - PTR(b))
     2124#define pd(a,b)             ((lzo_uint) ((a)-(b)))
    4092125
    410 LZO_EXTERN(lzo_ptr_t)
     2126LZO_EXTERN(lzo_uintptr_t)
    4112127__lzo_ptr_linear(const lzo_voidp ptr);
    4122128
    4132129typedef union
     
    4252141    lzo_int32       a_lzo_int32;
    4262142    lzo_uint32      a_lzo_uint32;
    4272143    ptrdiff_t       a_ptrdiff_t;
    428     lzo_ptrdiff_t   a_lzo_ptrdiff_t;
    429     lzo_ptr_t       a_lzo_ptr_t;
    430     char *          a_charp;
     2144    lzo_uintptr_t   a_lzo_uintptr_t;
     2145    lzo_voidp       a_lzo_voidp;
     2146    void *          a_void_p;
    4312147    lzo_bytep       a_lzo_bytep;
    4322148    lzo_bytepp      a_lzo_bytepp;
    433 }
    434 lzo_align_t;
    435 
    436 #ifdef __cplusplus
    437 }
    438 #endif
    439 
    440 #endif
    441 
    442 #define LZO_DETERMINISTIC
    443 
    444 #define LZO_DICT_USE_PTR
    445 #if defined(__LZO_DOS16) || defined(__LZO_WIN16) || defined(__LZO_STRICT_16BIT)
    446 #  undef LZO_DICT_USE_PTR
    447 #endif
    448 
    449 #if defined(LZO_DICT_USE_PTR)
    450 #  define lzo_dict_t    const lzo_bytep
    451 #  define lzo_dict_p    lzo_dict_t __LZO_MMODEL *
    452 #else
    453 #  define lzo_dict_t    lzo_uint
    454 #  define lzo_dict_p    lzo_dict_t __LZO_MMODEL *
    455 #endif
    456 
    457 #if !defined(lzo_moff_t)
    458 #define lzo_moff_t      lzo_uint
    459 #endif
    460 
    461 #endif
    462 
    463 LZO_PUBLIC(lzo_ptr_t)
    464 __lzo_ptr_linear(const lzo_voidp ptr)
    465 {
    466     lzo_ptr_t p;
    467 
    468 #if defined(__LZO_DOS16) || defined(__LZO_WIN16)
    469     p = (((lzo_ptr_t)(_FP_SEG(ptr))) << (16 - __LZO_HShift)) + (_FP_OFF(ptr));
    470 #else
    471     p = PTR_LINEAR(ptr);
    472 #endif
    473 
    474     return p;
    475 }
    476 
    477 LZO_PUBLIC(unsigned)
    478 __lzo_align_gap(const lzo_voidp ptr, lzo_uint size)
    479 {
    480     lzo_ptr_t p, s, n;
    481 
    482     assert(size > 0);
    483 
    484     p = __lzo_ptr_linear(ptr);
    485     s = (lzo_ptr_t) (size - 1);
    486 #if 0
    487     assert((size & (size - 1)) == 0);
    488     n = ((p + s) & ~s) - p;
    489 #else
    490     n = (((p + s) / size) * size) - p;
    491 #endif
    492 
    493     assert((long)n >= 0);
    494     assert(n <= s);
    495 
    496     return (unsigned)n;
    497 }
    498 
    499 #ifndef __LZO_UTIL_H
    500 #define __LZO_UTIL_H
    501 
    502 #ifndef __LZO_CONF_H
    503 #endif
    504 
    505 #ifdef __cplusplus
    506 extern "C" {
    507 #endif
    508 
    509 #if 1 && defined(HAVE_MEMCPY)
    510 #if !defined(__LZO_DOS16) && !defined(__LZO_WIN16)
    511 
    512 #define MEMCPY8_DS(dest,src,len) \
    513     memcpy(dest,src,len); \
    514     dest += len; \
    515     src += len
    516 
    517 #endif
    518 #endif
    519 
    520 #if 0 && !defined(MEMCPY8_DS)
    521 
    522 #define MEMCPY8_DS(dest,src,len) \
    523     { do { \
    524         *dest++ = *src++; \
    525         *dest++ = *src++; \
    526         *dest++ = *src++; \
    527         *dest++ = *src++; \
    528         *dest++ = *src++; \
    529         *dest++ = *src++; \
    530         *dest++ = *src++; \
    531         *dest++ = *src++; \
    532         len -= 8; \
    533     } while (len > 0); }
     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;
    5342157
     2158#ifdef __cplusplus
     2159}
    5352160#endif
    5362161
    537 #if !defined(MEMCPY8_DS)
    538 
    539 #define MEMCPY8_DS(dest,src,len) \
    540     { register lzo_uint __l = (len) / 8; \
    541     do { \
    542         *dest++ = *src++; \
    543         *dest++ = *src++; \
    544         *dest++ = *src++; \
    545         *dest++ = *src++; \
    546         *dest++ = *src++; \
    547         *dest++ = *src++; \
    548         *dest++ = *src++; \
    549         *dest++ = *src++; \
    550     } while (--__l > 0); }
    551 
    5522162#endif
    5532163
    554 #define MEMCPY_DS(dest,src,len) \
    555     do *dest++ = *src++; \
    556     while (--len > 0)
    557 
    558 #define MEMMOVE_DS(dest,src,len) \
    559     do *dest++ = *src++; \
    560     while (--len > 0)
    561 
    562 #if 0 && defined(LZO_OPTIMIZE_GNUC_i386)
    563 
    564 #define BZERO8_PTR(s,l,n) \
    565 __asm__ __volatile__( \
    566     "movl  %0,%%eax \n"             \
    567     "movl  %1,%%edi \n"             \
    568     "movl  %2,%%ecx \n"             \
    569     "cld \n"                        \
    570     "rep \n"                        \
    571     "stosl %%eax,(%%edi) \n"        \
    572     :               \
    573     :"g" (0),"g" (s),"g" (n)        \
    574     :"eax","edi","ecx", "memory", "cc" \
    575 )
    576 
    577 #elif (LZO_UINT_MAX <= SIZE_T_MAX) && defined(HAVE_MEMSET)
     2164#define LZO_DETERMINISTIC
    5782165
    579 #if 1
    580 #define BZERO8_PTR(s,l,n)   memset((s),0,(lzo_uint)(l)*(n))
    581 #else
    582 #define BZERO8_PTR(s,l,n)   memset((lzo_voidp)(s),0,(lzo_uint)(l)*(n))
     2166#define LZO_DICT_USE_PTR
     2167#if 0 && (LZO_ARCH_I086)
     2168#  undef LZO_DICT_USE_PTR
    5832169#endif
    5842170
     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 *
    5852174#else
    586 
    587 #define BZERO8_PTR(s,l,n) \
    588     lzo_memset((lzo_voidp)(s),0,(lzo_uint)(l)*(n))
     2175#  define lzo_dict_t    lzo_uint
     2176#  define lzo_dict_p    lzo_dict_t __LZO_MMODEL *
     2177#endif
    5892178
    5902179#endif
    5912180
    592 #if 0
    593 #if defined(__GNUC__) && defined(__i386__)
     2181#if !defined(MINILZO_CFG_SKIP_LZO_PTR)
    5942182
    595 unsigned char lzo_rotr8(unsigned char value, int shift);
    596 extern __inline__ unsigned char lzo_rotr8(unsigned char value, int shift)
     2183LZO_PUBLIC(lzo_uintptr_t)
     2184__lzo_ptr_linear(const lzo_voidp ptr)
    5972185{
    598     unsigned char result;
     2186    lzo_uintptr_t p;
    5992187
    600     __asm__ __volatile__ ("movb %b1, %b0; rorb %b2, %b0"
    601                         : "=a"(result) : "g"(value), "c"(shift));
    602     return result;
    603 }
    604 
    605 unsigned short lzo_rotr16(unsigned short value, int shift);
    606 extern __inline__ unsigned short lzo_rotr16(unsigned short value, int shift)
    607 {
    608     unsigned short result;
     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
    6092196
    610     __asm__ __volatile__ ("movw %b1, %b0; rorw %b2, %b0"
    611                         : "=a"(result) : "g"(value), "c"(shift));
    612     return result;
     2197    return p;
    6132198}
    6142199
    615 #endif
     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;
    6162210#endif
    6172211
    618 #ifdef __cplusplus
     2212    assert(size > 0);
     2213    assert((long)n >= 0);
     2214    assert(n <= size);
     2215    return (unsigned)n;
    6192216}
    620 #endif
    6212217
    6222218#endif
    6232219
    624 LZO_PUBLIC(lzo_bool)
    625 lzo_assert(int expr)
    626 {
    627     return (expr) ? 1 : 0;
    628 }
    629 
    630 /* If you use the LZO library in a product, you *must* keep this
    631  * copyright string in the executable of your product.
     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.
    6322222 */
    6332223
    634 const lzo_byte __lzo_copyright[] =
     2224const char __lzo_copyright[] =
    6352225#if !defined(__LZO_IN_MINLZO)
    6362226    LZO_VERSION_STRING;
    6372227#else
    638     "\n\n\n"
    639     "LZO real-time data compression library.\n"
    640     "Copyright (C) 1996, 1997, 1998, 1999, 2000 Markus Franz Xaver Johannes Oberhumer\n"
    641     "<markus.oberhumer@jk.uni-linz.ac.at>\n"
    642     "http://wildsau.idv.uni-linz.ac.at/mfx/lzo.html\n"
    643     "\n"
    644     "LZO version: v" LZO_VERSION_STRING ", " LZO_VERSION_DATE "\n"
    645     "LZO build date: " __DATE__ " " __TIME__ "\n\n"
    646     "LZO special compilation options:\n"
    647 #ifdef __cplusplus
    648     " __cplusplus\n"
    649 #endif
    650 #if defined(__PIC__)
    651     " __PIC__\n"
    652 #elif defined(__pic__)
    653     " __pic__\n"
    654 #endif
    655 #if (UINT_MAX < LZO_0xffffffffL)
    656     " 16BIT\n"
    657 #endif
    658 #if defined(__LZO_STRICT_16BIT)
    659     " __LZO_STRICT_16BIT\n"
    660 #endif
    661 #if (UINT_MAX > LZO_0xffffffffL)
    662     " UINT_MAX=" _LZO_MEXPAND(UINT_MAX) "\n"
    663 #endif
    664 #if (ULONG_MAX > LZO_0xffffffffL)
    665     " ULONG_MAX=" _LZO_MEXPAND(ULONG_MAX) "\n"
    666 #endif
    667 #if defined(LZO_BYTE_ORDER)
    668     " LZO_BYTE_ORDER=" _LZO_MEXPAND(LZO_BYTE_ORDER) "\n"
    669 #endif
    670 #if defined(LZO_UNALIGNED_OK_2)
    671     " LZO_UNALIGNED_OK_2\n"
    672 #endif
    673 #if defined(LZO_UNALIGNED_OK_4)
    674     " LZO_UNALIGNED_OK_4\n"
    675 #endif
    676 #if defined(LZO_ALIGNED_OK_4)
    677     " LZO_ALIGNED_OK_4\n"
    678 #endif
    679 #if defined(LZO_DICT_USE_PTR)
    680     " LZO_DICT_USE_PTR\n"
    681 #endif
    682 #if defined(__LZO_QUERY_COMPRESS)
    683     " __LZO_QUERY_COMPRESS\n"
    684 #endif
    685 #if defined(__LZO_QUERY_DECOMPRESS)
    686     " __LZO_QUERY_DECOMPRESS\n"
    687 #endif
    688 #if defined(__LZO_IN_MINILZO)
    689     " __LZO_IN_MINILZO\n"
    690 #endif
    691     "\n\n"
    692     "$Id: LZO " LZO_VERSION_STRING " built " __DATE__ " " __TIME__
    693 #if defined(__GNUC__) && defined(__VERSION__)
    694     " by gcc " __VERSION__
    695 #elif defined(__BORLANDC__)
    696     " by Borland C " _LZO_MEXPAND(__BORLANDC__)
    697 #elif defined(_MSC_VER)
    698     " by Microsoft C " _LZO_MEXPAND(_MSC_VER)
    699 #elif defined(__PUREC__)
    700     " by Pure C " _LZO_MEXPAND(__PUREC__)
    701 #elif defined(__SC__)
    702     " by Symantec C " _LZO_MEXPAND(__SC__)
    703 #elif defined(__TURBOC__)
    704     " by Turbo C " _LZO_MEXPAND(__TURBOC__)
    705 #elif defined(__WATCOMC__)
    706     " by Watcom C " _LZO_MEXPAND(__WATCOMC__)
    707 #endif
    708     " $\n"
    709     "$Copyright: LZO (C) 1996, 1997, 1998, 1999, 2000 Markus Franz Xaver Johannes Oberhumer $\n";
     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";
    7102236#endif
    7112237
    712 LZO_PUBLIC(const lzo_byte *)
     2238LZO_PUBLIC(const lzo_bytep)
    7132239lzo_copyright(void)
    7142240{
    715     return __lzo_copyright;
     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
    7162246}
    7172247
    7182248LZO_PUBLIC(unsigned)
     
    7482278#define LZO_BASE 65521u
    7492279#define LZO_NMAX 5552
    7502280
    751 #define LZO_DO1(buf,i)  {s1 += buf[i]; s2 += s1;}
     2281#define LZO_DO1(buf,i)  s1 += buf[i]; s2 += s1
    7522282#define LZO_DO2(buf,i)  LZO_DO1(buf,i); LZO_DO1(buf,i+1);
    7532283#define LZO_DO4(buf,i)  LZO_DO2(buf,i); LZO_DO2(buf,i+2);
    7542284#define LZO_DO8(buf,i)  LZO_DO4(buf,i); LZO_DO4(buf,i+4);
    7552285#define LZO_DO16(buf,i) LZO_DO8(buf,i); LZO_DO8(buf,i+8);
    7562286
    7572287LZO_PUBLIC(lzo_uint32)
    758 lzo_adler32(lzo_uint32 adler, const lzo_byte *buf, lzo_uint len)
     2288lzo_adler32(lzo_uint32 adler, const lzo_bytep buf, lzo_uint len)
    7592289{
    7602290    lzo_uint32 s1 = adler & 0xffff;
    7612291    lzo_uint32 s2 = (adler >> 16) & 0xffff;
    762     int k;
     2292    unsigned k;
    7632293
    7642294    if (buf == NULL)
    765         return 1;
     2295        return 1;
    7662296
    7672297    while (len > 0)
    7682298    {
    769         k = len < LZO_NMAX ? (int) len : LZO_NMAX;
    770         len -= k;
    771         if (k >= 16) do
    772         {
    773             LZO_DO16(buf,0);
    774             buf += 16;
    775             k -= 16;
    776         } while (k >= 16);
    777         if (k != 0) do
    778         {
    779             s1 += *buf++;
    780             s2 += s1;
    781         } while (--k > 0);
    782         s1 %= LZO_BASE;
    783         s2 %= LZO_BASE;
     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;
    7842314    }
    7852315    return (s2 << 16) | s1;
    7862316}
    7872317
    788 LZO_PUBLIC(int)
    789 lzo_memcmp(const lzo_voidp s1, const lzo_voidp s2, lzo_uint len)
     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)
    7902345{
    791 #if (LZO_UINT_MAX <= SIZE_T_MAX) && defined(HAVE_MEMCMP)
    792     return memcmp(s1,s2,len);
    793 #else
    794     const lzo_byte *p1 = (const lzo_byte *) s1;
    795     const lzo_byte *p2 = (const lzo_byte *) s2;
    796     int d;
    797 
    798     if (len > 0) do
     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
    7992350    {
    800         d = *p1 - *p2;
    801         if (d != 0)
    802             return d;
    803         p1++;
    804         p2++;
    805     }
    806     while (--len > 0);
     2351        int d = *p1 - *p2;
     2352        if (d != 0)
     2353            return d;
     2354        p1++; p2++;
     2355    } while __lzo_likely(--len > 0);
    8072356    return 0;
     2357#else
     2358    return memcmp(s1, s2, len);
    8082359#endif
    8092360}
    810 
    811 LZO_PUBLIC(lzo_voidp)
    812 lzo_memcpy(lzo_voidp dest, const lzo_voidp src, lzo_uint len)
     2361LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemcpy) (lzo_hvoid_p dest, const lzo_hvoid_p src, lzo_hsize_t len)
    8132362{
    814 #if (LZO_UINT_MAX <= SIZE_T_MAX) && defined(HAVE_MEMCPY)
    815     return memcpy(dest,src,len);
    816 #else
    817     lzo_byte *p1 = (lzo_byte *) dest;
    818     const lzo_byte *p2 = (const lzo_byte *) src;
    819 
    820     if (len <= 0 || p1 == p2)
    821         return dest;
     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;
    8222368    do
    823         *p1++ = *p2++;
    824     while (--len > 0);
     2369        *p1++ = *p2++;
     2370    while __lzo_likely(--len > 0);
    8252371    return dest;
     2372#else
     2373    return memcpy(dest, src, len);
    8262374#endif
    8272375}
    828 
    829 LZO_PUBLIC(lzo_voidp)
    830 lzo_memmove(lzo_voidp dest, const lzo_voidp src, lzo_uint len)
     2376LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemmove) (lzo_hvoid_p dest, const lzo_hvoid_p src, lzo_hsize_t len)
    8312377{
    832 #if (LZO_UINT_MAX <= SIZE_T_MAX) && defined(HAVE_MEMMOVE)
    833     return memmove(dest,src,len);
    834 #else
    835     lzo_byte *p1 = (lzo_byte *) dest;
    836     const lzo_byte *p2 = (const lzo_byte *) src;
    837 
    838     if (len <= 0 || p1 == p2)
    839         return dest;
    840 
     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;
    8412383    if (p1 < p2)
    8422384    {
    843         do
    844             *p1++ = *p2++;
    845         while (--len > 0);
     2385        do
     2386            *p1++ = *p2++;
     2387        while __lzo_likely(--len > 0);
    8462388    }
    8472389    else
    8482390    {
    849         p1 += len;
    850         p2 += len;
    851         do
    852             *--p1 = *--p2;
    853         while (--len > 0);
     2391        p1 += len;
     2392        p2 += len;
     2393        do
     2394            *--p1 = *--p2;
     2395        while __lzo_likely(--len > 0);
    8542396    }
    8552397    return dest;
    856 #endif
    857 }
    858 
    859 LZO_PUBLIC(lzo_voidp)
    860 lzo_memset(lzo_voidp s, int c, lzo_uint len)
    861 {
    862 #if (LZO_UINT_MAX <= SIZE_T_MAX) && defined(HAVE_MEMSET)
    863     return memset(s,c,len);
    8642398#else
    865     lzo_byte *p = (lzo_byte *) s;
    866 
    867     if (len > 0) do
    868         *p++ = LZO_BYTE(c);
    869     while (--len > 0);
    870     return s;
     2399    return memmove(dest, src, len);
    8712400#endif
    8722401}
    873 
    874 #include <stdio.h>
    875 
    876 #if 0
    877 #  define IS_SIGNED(type)       (((type) (1ul << (8 * sizeof(type) - 1))) < 0)
    878 #  define IS_UNSIGNED(type)     (((type) (1ul << (8 * sizeof(type) - 1))) > 0)
    879 #else
    880 #  define IS_SIGNED(type)       (((type) (-1)) < ((type) 0))
    881 #  define IS_UNSIGNED(type)     (((type) (-1)) > ((type) 0))
    882 #endif
    883 
    884 static lzo_bool schedule_insns_bug(void);
    885 static lzo_bool strength_reduce_bug(int *);
    886 
    887 #if 0 || defined(LZO_DEBUG)
    888 static lzo_bool __lzo_assert_fail(const char *s, unsigned line)
     2402LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemset) (lzo_hvoid_p s, int c, lzo_hsize_t len)
    8892403{
    890 #if defined(__palmos__)
    891     printf("LZO assertion failed in line %u: '%s'\n",line,s);
     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;
    8922410#else
    893     fprintf(stderr,"LZO assertion failed in line %u: '%s'\n",line,s);
     2411    return memset(s, c, len);
    8942412#endif
    895     return 0;
    8962413}
    897 #  define __lzo_assert(x)   ((x) ? 1 : __lzo_assert_fail(#x,__LINE__))
    898 #else
    899 #  define __lzo_assert(x)   ((x) ? 1 : 0)
    900 #endif
    901 
    902 static lzo_bool basic_integral_check(void)
    903 {
    904     lzo_bool r = 1;
    905     lzo_bool sanity;
    906 
    907     r &= __lzo_assert(CHAR_BIT == 8);
    908     r &= __lzo_assert(sizeof(char) == 1);
    909     r &= __lzo_assert(sizeof(short) >= 2);
    910     r &= __lzo_assert(sizeof(long) >= 4);
    911     r &= __lzo_assert(sizeof(int) >= sizeof(short));
    912     r &= __lzo_assert(sizeof(long) >= sizeof(int));
    913 
    914     r &= __lzo_assert(sizeof(lzo_uint32) >= 4);
    915     r &= __lzo_assert(sizeof(lzo_uint32) >= sizeof(unsigned));
    916 #if defined(__LZO_STRICT_16BIT)
    917     r &= __lzo_assert(sizeof(lzo_uint) == 2);
    918 #else
    919     r &= __lzo_assert(sizeof(lzo_uint) >= 4);
    920     r &= __lzo_assert(sizeof(lzo_uint) >= sizeof(unsigned));
    921 #endif
    922 
    923 #if defined(SIZEOF_UNSIGNED)
    924     r &= __lzo_assert(SIZEOF_UNSIGNED == sizeof(unsigned));
    925 #endif
    926 #if defined(SIZEOF_UNSIGNED_LONG)
    927     r &= __lzo_assert(SIZEOF_UNSIGNED_LONG == sizeof(unsigned long));
    928 #endif
    929 #if defined(SIZEOF_UNSIGNED_SHORT)
    930     r &= __lzo_assert(SIZEOF_UNSIGNED_SHORT == sizeof(unsigned short));
    931 #endif
    932 #if !defined(__LZO_IN_MINILZO)
    933 #if defined(SIZEOF_SIZE_T)
    934     r &= __lzo_assert(SIZEOF_SIZE_T == sizeof(size_t));
    935 #endif
     2414#undef LZOLIB_PUBLIC
    9362415#endif
    9372416
    938     sanity = IS_UNSIGNED(unsigned short) && IS_UNSIGNED(unsigned) &&
    939              IS_UNSIGNED(unsigned long) &&
    940              IS_SIGNED(short) && IS_SIGNED(int) && IS_SIGNED(long);
    941     if (sanity)
    942     {
    943         r &= __lzo_assert(IS_UNSIGNED(lzo_uint32));
    944         r &= __lzo_assert(IS_UNSIGNED(lzo_uint));
    945         r &= __lzo_assert(IS_SIGNED(lzo_int32));
    946         r &= __lzo_assert(IS_SIGNED(lzo_int));
    947 
    948         r &= __lzo_assert(INT_MAX    == LZO_STYPE_MAX(sizeof(int)));
    949         r &= __lzo_assert(UINT_MAX   == LZO_UTYPE_MAX(sizeof(unsigned)));
    950         r &= __lzo_assert(LONG_MAX   == LZO_STYPE_MAX(sizeof(long)));
    951         r &= __lzo_assert(ULONG_MAX  == LZO_UTYPE_MAX(sizeof(unsigned long)));
    952         r &= __lzo_assert(SHRT_MAX   == LZO_STYPE_MAX(sizeof(short)));
    953         r &= __lzo_assert(USHRT_MAX  == LZO_UTYPE_MAX(sizeof(unsigned short)));
    954         r &= __lzo_assert(LZO_UINT32_MAX == LZO_UTYPE_MAX(sizeof(lzo_uint32)));
    955         r &= __lzo_assert(LZO_UINT_MAX   == LZO_UTYPE_MAX(sizeof(lzo_uint)));
    9562417#if !defined(__LZO_IN_MINILZO)
    957         r &= __lzo_assert(SIZE_T_MAX     == LZO_UTYPE_MAX(sizeof(size_t)));
    958 #endif
    959     }
    960 
    961 #if 0
    962     r &= __lzo_assert(LZO_BYTE(257) == 1);
    963     r &= __lzo_assert(LZO_USHORT(65537L) == 1);
    964 #endif
    965 
    966     return r;
    967 }
    9682418
    969 static lzo_bool basic_ptr_check(void)
    970 {
    971     lzo_bool r = 1;
    972     lzo_bool sanity;
    973 
    974     r &= __lzo_assert(sizeof(char *) >= sizeof(int));
    975     r &= __lzo_assert(sizeof(lzo_byte *) >= sizeof(char *));
    976 
    977     r &= __lzo_assert(sizeof(lzo_voidp) == sizeof(lzo_byte *));
    978     r &= __lzo_assert(sizeof(lzo_voidp) == sizeof(lzo_voidpp));
    979     r &= __lzo_assert(sizeof(lzo_voidp) == sizeof(lzo_bytepp));
    980     r &= __lzo_assert(sizeof(lzo_voidp) >= sizeof(lzo_uint));
     2419#define ACC_WANT_ACC_CHK_CH 1
     2420#undef ACCCHK_ASSERT
    9812421
    982     r &= __lzo_assert(sizeof(lzo_ptr_t) == sizeof(lzo_voidp));
    983     r &= __lzo_assert(sizeof(lzo_ptr_t) >= sizeof(lzo_uint));
     2422    ACCCHK_ASSERT_IS_SIGNED_T(lzo_int)
     2423    ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uint)
    9842424
    985     r &= __lzo_assert(sizeof(lzo_ptrdiff_t) >= 4);
    986     r &= __lzo_assert(sizeof(lzo_ptrdiff_t) >= sizeof(ptrdiff_t));
     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)
    9872429
    988 #if defined(SIZEOF_CHAR_P)
    989     r &= __lzo_assert(SIZEOF_CHAR_P == sizeof(char *));
     2430#if !defined(__LZO_UINTPTR_T_IS_POINTER)
     2431    ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uintptr_t)
    9902432#endif
    991 #if defined(SIZEOF_PTRDIFF_T)
    992     r &= __lzo_assert(SIZEOF_PTRDIFF_T == sizeof(ptrdiff_t));
    993 #endif
    994 
    995     sanity = IS_UNSIGNED(unsigned short) && IS_UNSIGNED(unsigned) &&
    996              IS_UNSIGNED(unsigned long) &&
    997              IS_SIGNED(short) && IS_SIGNED(int) && IS_SIGNED(long);
    998     if (sanity)
    999     {
    1000         r &= __lzo_assert(IS_UNSIGNED(lzo_ptr_t));
    1001         r &= __lzo_assert(IS_UNSIGNED(lzo_moff_t));
    1002         r &= __lzo_assert(IS_SIGNED(lzo_ptrdiff_t));
    1003         r &= __lzo_assert(IS_SIGNED(lzo_sptr_t));
    1004     }
    1005 
    1006     return r;
    1007 }
    1008 
    1009 static lzo_bool ptr_check(void)
    1010 {
    1011     lzo_bool r = 1;
    1012     int i;
    1013     char _wrkmem[10 * sizeof(lzo_byte *) + sizeof(lzo_align_t)];
    1014     lzo_byte *wrkmem;
    1015     lzo_bytepp dict;
    1016     unsigned char x[4 * sizeof(lzo_align_t)];
    1017     long d;
    1018     lzo_align_t a;
    1019 
    1020     for (i = 0; i < (int) sizeof(x); i++)
    1021         x[i] = LZO_BYTE(i);
    1022 
    1023     wrkmem = LZO_PTR_ALIGN_UP((lzo_byte *)_wrkmem,sizeof(lzo_align_t));
    1024     dict = (lzo_bytepp) wrkmem;
    1025 
    1026     d = (long) ((const lzo_bytep) dict - (const lzo_bytep) _wrkmem);
    1027     r &= __lzo_assert(d >= 0);
    1028     r &= __lzo_assert(d < (long) sizeof(lzo_align_t));
    1029 
    1030     memset(&a,0xff,sizeof(a));
    1031     r &= __lzo_assert(a.a_ushort == USHRT_MAX);
    1032     r &= __lzo_assert(a.a_uint == UINT_MAX);
    1033     r &= __lzo_assert(a.a_ulong == ULONG_MAX);
    1034     r &= __lzo_assert(a.a_lzo_uint == LZO_UINT_MAX);
    1035 
    1036     if (r == 1)
    1037     {
    1038         for (i = 0; i < 8; i++)
    1039             r &= __lzo_assert((const lzo_voidp) (&dict[i]) == (const lzo_voidp) (&wrkmem[i * sizeof(lzo_byte *)]));
    1040     }
    1041 
    1042     memset(&a,0,sizeof(a));
    1043     r &= __lzo_assert(a.a_charp == NULL);
    1044     r &= __lzo_assert(a.a_lzo_bytep == NULL);
    1045     //r &= __lzo_assert(0 == NULL);
    1046     if (r == 1)
    1047     {
    1048         for (i = 0; i < 10; i++)
    1049             dict[i] = wrkmem;
    1050         BZERO8_PTR(dict+1,sizeof(dict[0]),8);
    1051         r &= __lzo_assert(dict[0] == wrkmem);
    1052         for (i = 1; i < 9; i++)
    1053             r &= __lzo_assert(dict[i] == NULL);
    1054         r &= __lzo_assert(dict[9] == wrkmem);
    1055     }
     2433    ACCCHK_ASSERT(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp))
    10562434
    1057     if (r == 1)
    1058     {
    1059         unsigned k = 1;
    1060         const unsigned n = (unsigned) sizeof(lzo_uint32);
    1061         lzo_byte *p0;
    1062         lzo_byte *p1;
    1063 
    1064         k += __lzo_align_gap(&x[k],n);
    1065         p0 = (lzo_bytep) &x[k];
    1066 #if defined(PTR_LINEAR)
    1067         r &= __lzo_assert((PTR_LINEAR(p0) & (n-1)) == 0);
    1068 #else
    1069         r &= __lzo_assert(n == 4);
    1070         r &= __lzo_assert(PTR_ALIGNED_4(p0));
    1071 #endif
    1072 
    1073         r &= __lzo_assert(k >= 1);
    1074         p1 = (lzo_bytep) &x[1];
    1075         r &= __lzo_assert(PTR_GE(p0,p1));
    1076 
    1077         r &= __lzo_assert(k < 1+n);
    1078         p1 = (lzo_bytep) &x[1+n];
    1079         r &= __lzo_assert(PTR_LT(p0,p1));
    1080 
    1081         if (r == 1)
    1082         {
    1083             lzo_uint32 v0 = * (lzo_uint32 *) &x[k];
    1084             lzo_uint32 v1 = * (lzo_uint32 *) &x[k+n];
    1085 
    1086             r &= __lzo_assert(v0 > 0);
    1087             r &= __lzo_assert(v1 > 0);
    1088         }
    1089     }
     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))
    10902439
    1091     return r;
    1092 }
     2440#endif
     2441#undef ACCCHK_ASSERT
    10932442
    10942443LZO_PUBLIC(int)
    10952444_lzo_config_check(void)
    10962445{
    10972446    lzo_bool r = 1;
    1098     int i;
    1099     union {
    1100         lzo_uint32 a;
    1101         unsigned short b;
    1102         lzo_uint32 aa[4];
    1103         unsigned char x[4*sizeof(lzo_align_t)];
    1104     } u;
    1105 
    1106 #if 0
    1107     r &= __lzo_assert((const void *)&u == (const void *)&u.a);
    1108     r &= __lzo_assert((const void *)&u == (const void *)&u.b);
    1109     r &= __lzo_assert((const void *)&u == (const void *)&u.x[0]);
    1110     r &= __lzo_assert((const void *)&u == (const void *)&u.aa[0]);
    1111 #endif
    1112 
    1113     r &= basic_integral_check();
    1114     r &= basic_ptr_check();
    1115     if (r != 1)
    1116         return LZO_E_ERROR;
    1117 
    1118     u.a = 0; u.b = 0;
    1119     for (i = 0; i < (int) sizeof(u.x); i++)
    1120         u.x[i] = LZO_BYTE(i);
    1121 
    1122 #if 0
    1123     r &= __lzo_assert( (int) (unsigned char) ((char) -1) == 255);
    1124 #endif
     2447    union { unsigned char c[2*sizeof(lzo_xint)]; lzo_xint l[2]; } u;
     2448    lzo_uintptr_t p;
    11252449
    1126 #if defined(LZO_BYTE_ORDER)
    1127     if (r == 1)
    1128     {
    1129 #  if (LZO_BYTE_ORDER == LZO_LITTLE_ENDIAN)
    1130         lzo_uint32 a = (lzo_uint32) (u.a & LZO_0xffffffffL);
    1131         unsigned short b = (unsigned short) (u.b & 0xffff);
    1132         r &= __lzo_assert(a == 0x03020100L);
    1133         r &= __lzo_assert(b == 0x0100);
    1134 #  elif (LZO_BYTE_ORDER == LZO_BIG_ENDIAN)
    1135         lzo_uint32 a = u.a >> (8 * sizeof(u.a) - 32);
    1136         unsigned short b = u.b >> (8 * sizeof(u.b) - 16);
    1137         r &= __lzo_assert(a == 0x00010203L);
    1138         r &= __lzo_assert(b == 0x0001);
    1139 #  else
    1140 #    error invalid LZO_BYTE_ORDER
    1141 #  endif
    1142     }
     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);
    11432458#endif
    1144 
    11452459#if defined(LZO_UNALIGNED_OK_2)
    1146     r &= __lzo_assert(sizeof(short) == 2);
    1147     if (r == 1)
    1148     {
    1149         unsigned short b[4];
    1150 
    1151         for (i = 0; i < 4; i++)
    1152             b[i] = * (const unsigned short *) &u.x[i];
    1153 
    1154 #  if (LZO_BYTE_ORDER == LZO_LITTLE_ENDIAN)
    1155         r &= __lzo_assert(b[0] == 0x0100);
    1156         r &= __lzo_assert(b[1] == 0x0201);
    1157         r &= __lzo_assert(b[2] == 0x0302);
    1158         r &= __lzo_assert(b[3] == 0x0403);
    1159 #  elif (LZO_BYTE_ORDER == LZO_BIG_ENDIAN)
    1160         r &= __lzo_assert(b[0] == 0x0001);
    1161         r &= __lzo_assert(b[1] == 0x0102);
    1162         r &= __lzo_assert(b[2] == 0x0203);
    1163         r &= __lzo_assert(b[3] == 0x0304);
    1164 #  endif
    1165     }
     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);
    11662463#endif
    1167 
    11682464#if defined(LZO_UNALIGNED_OK_4)
    1169     r &= __lzo_assert(sizeof(lzo_uint32) == 4);
    1170     if (r == 1)
    1171     {
    1172         lzo_uint32 a[4];
    1173 
    1174         for (i = 0; i < 4; i++)
    1175             a[i] = * (const lzo_uint32 *) &u.x[i];
    1176 
    1177 #  if (LZO_BYTE_ORDER == LZO_LITTLE_ENDIAN)
    1178         r &= __lzo_assert(a[0] == 0x03020100L);
    1179         r &= __lzo_assert(a[1] == 0x04030201L);
    1180         r &= __lzo_assert(a[2] == 0x05040302L);
    1181         r &= __lzo_assert(a[3] == 0x06050403L);
    1182 #  elif (LZO_BYTE_ORDER == LZO_BIG_ENDIAN)
    1183         r &= __lzo_assert(a[0] == 0x00010203L);
    1184         r &= __lzo_assert(a[1] == 0x01020304L);
    1185         r &= __lzo_assert(a[2] == 0x02030405L);
    1186         r &= __lzo_assert(a[3] == 0x03040506L);
    1187 #  endif
    1188     }
    1189 #endif
    1190 
    1191 #if defined(LZO_ALIGNED_OK_4)
    1192     r &= __lzo_assert(sizeof(lzo_uint32) == 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);
    11932468#endif
    1194 
    1195     r &= __lzo_assert(lzo_sizeof_dict_t == sizeof(lzo_dict_t));
    1196 
    1197 #if defined(__LZO_IN_MINLZO)
    1198     if (r == 1)
    1199     {
    1200         lzo_uint32 adler;
    1201         adler = lzo_adler32(0, NULL, 0);
    1202         adler = lzo_adler32(adler, lzo_copyright(), 200);
    1203         r &= __lzo_assert(adler == 0x7ea34377L);
    1204     }
    12052469#endif
    12062470
    1207     if (r == 1)
    1208     {
    1209         r &= __lzo_assert(!schedule_insns_bug());
    1210     }
    1211 
    1212     if (r == 1)
    1213     {
    1214         static int x[3];
    1215         static unsigned xn = 3;
    1216         register unsigned j;
    1217 
    1218         for (j = 0; j < xn; j++)
    1219             x[j] = (int)j - 3;
    1220         r &= __lzo_assert(!strength_reduce_bug(x));
    1221     }
    1222 
    1223     if (r == 1)
    1224     {
    1225         r &= ptr_check();
    1226     }
    1227 
     2471    LZO_UNUSED(u); LZO_UNUSED(p);
    12282472    return r == 1 ? LZO_E_OK : LZO_E_ERROR;
    12292473}
    12302474
    1231 static lzo_bool schedule_insns_bug(void)
    1232 {
    1233 #if defined(__LZO_CHECKER)
    1234     return 0;
    1235 #else
    1236     const int clone[] = {1, 2, 0};
    1237     const int *q;
    1238     q = clone;
    1239     return (*q) ? 0 : 1;
    1240 #endif
    1241 }
    1242 
    1243 static lzo_bool strength_reduce_bug(int *x)
    1244 {
    1245     return x[0] != -3 || x[1] != -2 || x[2] != -1;
    1246 }
    1247 
    12482475int __lzo_init_done = 0;
    12492476
    12502477LZO_PUBLIC(int)
    1251 __lzo_init2(unsigned v, int s1, int s2, int s3, int s4, int s5,
    1252                         int s6, int s7, int s8, int s9)
     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)
    12532480{
    12542481    int r;
    12552482
     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
    12562492    __lzo_init_done = 1;
    12572493
    12582494    if (v == 0)
    1259         return LZO_E_ERROR;
     2495        return LZO_E_ERROR;
    12602496
    12612497    r = (s1 == -1 || s1 == (int) sizeof(short)) &&
    1262         (s2 == -1 || s2 == (int) sizeof(int)) &&
    1263         (s3 == -1 || s3 == (int) sizeof(long)) &&
    1264         (s4 == -1 || s4 == (int) sizeof(lzo_uint32)) &&
    1265         (s5 == -1 || s5 == (int) sizeof(lzo_uint)) &&
    1266         (s6 == -1 || s6 == (int) lzo_sizeof_dict_t) &&
    1267         (s7 == -1 || s7 == (int) sizeof(char *)) &&
    1268         (s8 == -1 || s8 == (int) sizeof(lzo_voidp)) &&
    1269         (s9 == -1 || s9 == (int) sizeof(lzo_compress_t));
     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));
    12702506    if (!r)
    1271         return LZO_E_ERROR;
     2507        return LZO_E_ERROR;
    12722508
    12732509    r = _lzo_config_check();
    12742510    if (r != LZO_E_OK)
    1275         return r;
     2511        return r;
    12762512
    12772513    return r;
    12782514}
    12792515
    12802516#if !defined(__LZO_IN_MINILZO)
    12812517
    1282 LZO_EXTERN(int)
    1283 __lzo_init(unsigned v,int s1,int s2,int s3,int s4,int s5,int s6,int s7);
     2518#if (LZO_OS_WIN16 && LZO_CC_WATCOMC) && defined(__SW_BD)
    12842519
    1285 LZO_PUBLIC(int)
    1286 __lzo_init(unsigned v,int s1,int s2,int s3,int s4,int s5,int s6,int s7)
     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
    12872526{
    1288     if (v == 0 || v > 0x1010)
    1289         return LZO_E_ERROR;
    1290     return __lzo_init2(v,s1,s2,s3,s4,s5,-1,-1,s6,s7);
     2527    LZO_UNUSED(a); LZO_UNUSED(b); LZO_UNUSED(c); LZO_UNUSED(d);
     2528    return 1;
    12912529}
    12922530
    12932531#endif
    12942532
     2533#endif
     2534
    12952535#define do_compress         _lzo1x_1_do_compress
    12962536
     2537#if !defined(MINILZO_CFG_SKIP_LZO1X_1_COMPRESS)
     2538
    12972539#define LZO_NEED_DICT_H
    12982540#define D_BITS          14
    1299 #define D_INDEX1(d,p)       d = DM((0x21*DX3(p,5,5,6)) >> 5)
     2541#define D_INDEX1(d,p)       d = DM(DMUL(0x21,DX3(p,5,5,6)) >> 5)
    13002542#define D_INDEX2(d,p)       d = (d & (D_MASK & 0x7ff)) ^ (D_HIGH | 0x1f)
    13012543
    13022544#ifndef __LZO_CONFIG1X_H
     
    13072549#endif
    13082550
    13092551#if !defined(__LZO_IN_MINILZO)
    1310 #include <lzo1x.h>
     2552#include "lzo/lzo1x.h"
    13112553#endif
    13122554
    13132555#define LZO_EOF_CODE
     
    13602602#  define D_BITS        DBITS
    13612603#endif
    13622604#if !defined(D_BITS)
    1363 #  error D_BITS is not defined
     2605#  error "D_BITS is not defined"
    13642606#endif
    13652607#if (D_BITS < 16)
    13662608#  define D_SIZE        LZO_SIZE(D_BITS)
     
    13892631#endif
    13902632
    13912633#if (D_BITS != DL_BITS + DD_BITS)
    1392 #  error D_BITS does not match
     2634#  error "D_BITS does not match"
    13932635#endif
    13942636#if (D_BITS < 8 || D_BITS > 18)
    1395 #  error invalid D_BITS
     2637#  error "invalid D_BITS"
    13962638#endif
    13972639#if (DL_BITS < 8 || DL_BITS > 20)
    1398 #  error invalid DL_BITS
     2640#  error "invalid DL_BITS"
    13992641#endif
    14002642#if (DD_BITS < 0 || DD_BITS > 6)
    1401 #  error invalid DD_BITS
     2643#  error "invalid DD_BITS"
    14022644#endif
    14032645
    14042646#if !defined(DL_MIN_LEN)
     
    14142656#define LZO_HASH_LZO_INCREMENTAL_B      4
    14152657
    14162658#if !defined(LZO_HASH)
    1417 #  error choose a hashing strategy
     2659#  error "choose a hashing strategy"
    14182660#endif
    14192661
     2662#undef DM
     2663#undef DX
     2664
    14202665#if (DL_MIN_LEN == 3)
    14212666#  define _DV2_A(p,shift1,shift2) \
    1422         (((( (lzo_uint32)((p)[0]) << shift1) ^ (p)[1]) << shift2) ^ (p)[2])
     2667        (((( (lzo_xint)((p)[0]) << shift1) ^ (p)[1]) << shift2) ^ (p)[2])
    14232668#  define _DV2_B(p,shift1,shift2) \
    1424         (((( (lzo_uint32)((p)[2]) << shift1) ^ (p)[1]) << shift2) ^ (p)[0])
     2669        (((( (lzo_xint)((p)[2]) << shift1) ^ (p)[1]) << shift2) ^ (p)[0])
    14252670#  define _DV3_B(p,shift1,shift2,shift3) \
    1426         ((_DV2_B((p)+1,shift1,shift2) << (shift3)) ^ (p)[0])
     2671        ((_DV2_B((p)+1,shift1,shift2) << (shift3)) ^ (p)[0])
    14272672#elif (DL_MIN_LEN == 2)
    14282673#  define _DV2_A(p,shift1,shift2) \
    1429         (( (lzo_uint32)(p[0]) << shift1) ^ p[1])
     2674        (( (lzo_xint)(p[0]) << shift1) ^ p[1])
    14302675#  define _DV2_B(p,shift1,shift2) \
    1431         (( (lzo_uint32)(p[1]) << shift1) ^ p[2])
     2676        (( (lzo_xint)(p[1]) << shift1) ^ p[2])
    14322677#else
    1433 #  error invalid DL_MIN_LEN
     2678#  error "invalid DL_MIN_LEN"
    14342679#endif
    14352680#define _DV_A(p,shift)      _DV2_A(p,shift,shift)
    14362681#define _DV_B(p,shift)      _DV2_B(p,shift,shift)
    14372682#define DA2(p,s1,s2) \
    1438         (((((lzo_uint32)((p)[2]) << (s2)) + (p)[1]) << (s1)) + (p)[0])
     2683        (((((lzo_xint)((p)[2]) << (s2)) + (p)[1]) << (s1)) + (p)[0])
    14392684#define DS2(p,s1,s2) \
    1440         (((((lzo_uint32)((p)[2]) << (s2)) - (p)[1]) << (s1)) - (p)[0])
     2685        (((((lzo_xint)((p)[2]) << (s2)) - (p)[1]) << (s1)) - (p)[0])
    14412686#define DX2(p,s1,s2) \
    1442         (((((lzo_uint32)((p)[2]) << (s2)) ^ (p)[1]) << (s1)) ^ (p)[0])
     2687        (((((lzo_xint)((p)[2]) << (s2)) ^ (p)[1]) << (s1)) ^ (p)[0])
    14432688#define DA3(p,s1,s2,s3) ((DA2((p)+1,s2,s3) << (s1)) + (p)[0])
    14442689#define DS3(p,s1,s2,s3) ((DS2((p)+1,s2,s3) << (s1)) - (p)[0])
    14452690#define DX3(p,s1,s2,s3) ((DX2((p)+1,s2,s3) << (s1)) ^ (p)[0])
     
    14602705#  define __LZO_HASH_INCREMENTAL
    14612706#  define DVAL_FIRST(dv,p)  dv = _DV_A((p),5)
    14622707#  define DVAL_NEXT(dv,p) \
    1463                 dv ^= (lzo_uint32)(p[-1]) << (2*5); dv = (((dv) << 5) ^ p[2])
    1464 #  define _DINDEX(dv,p)     ((0x9f5f * (dv)) >> 5)
     2708                dv ^= (lzo_xint)(p[-1]) << (2*5); dv = (((dv) << 5) ^ p[2])
     2709#  define _DINDEX(dv,p)     ((DMUL(0x9f5f,dv)) >> 5)
    14652710#  define DVAL_LOOKAHEAD    DL_MIN_LEN
    14662711
    14672712#elif (LZO_HASH == LZO_HASH_LZO_INCREMENTAL_B)
    14682713#  define __LZO_HASH_INCREMENTAL
    14692714#  define DVAL_FIRST(dv,p)  dv = _DV_B((p),5)
    14702715#  define DVAL_NEXT(dv,p) \
    1471                 dv ^= p[-1]; dv = (((dv) >> 5) ^ ((lzo_uint32)(p[2]) << (2*5)))
    1472 #  define _DINDEX(dv,p)     ((0x9f5f * (dv)) >> 5)
     2716                dv ^= p[-1]; dv = (((dv) >> 5) ^ ((lzo_xint)(p[2]) << (2*5)))
     2717#  define _DINDEX(dv,p)     ((DMUL(0x9f5f,dv)) >> 5)
    14732718#  define DVAL_LOOKAHEAD    DL_MIN_LEN
    14742719
    14752720#else
    1476 #  error choose a hashing strategy
     2721#  error "choose a hashing strategy"
    14772722#endif
    14782723
    14792724#ifndef DINDEX
     
    14942739
    14952740#if !defined(DVAL_ASSERT)
    14962741#if defined(__LZO_HASH_INCREMENTAL) && !defined(NDEBUG)
    1497 static void DVAL_ASSERT(lzo_uint32 dv, const lzo_byte *p)
     2742static void DVAL_ASSERT(lzo_xint dv, const lzo_bytep p)
    14982743{
    1499     lzo_uint32 df;
     2744    lzo_xint df;
    15002745    DVAL_FIRST(df,(p));
    15012746    assert(DINDEX(dv,p) == DINDEX(df,p));
    15022747}
     
    15222767#else
    15232768
    15242769#  define UPDATE_D(dict,drun,dv,p,in)   \
    1525         dict[ DINDEX(dv,p) + drun++ ] = DENTRY(p,in); drun &= DD_MASK
     2770        dict[ DINDEX(dv,p) + drun++ ] = DENTRY(p,in); drun &= DD_MASK
    15262771#  define UPDATE_I(dict,drun,index,p,in)    \
    1527         dict[ (index) + drun++ ] = DENTRY(p,in); drun &= DD_MASK
     2772        dict[ (index) + drun++ ] = DENTRY(p,in); drun &= DD_MASK
    15282773#  define UPDATE_P(ptr,drun,p,in)   \
    1529         (ptr) [ drun++ ] = DENTRY(p,in); drun &= DD_MASK
     2774        (ptr) [ drun++ ] = DENTRY(p,in); drun &= DD_MASK
    15302775
    15312776#endif
    15322777
    15332778#if defined(LZO_DICT_USE_PTR)
    15342779
    15352780#define LZO_CHECK_MPOS_DET(m_pos,m_off,in,ip,max_offset) \
    1536         (m_pos == NULL || (m_off = (lzo_moff_t) (ip - m_pos)) > max_offset)
     2781        (m_pos == NULL || (m_off = pd(ip, m_pos)) > max_offset)
    15372782
    15382783#define LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,max_offset) \
    1539     (BOUNDS_CHECKING_OFF_IN_EXPR( \
    1540         (PTR_LT(m_pos,in) || \
    1541          (m_off = (lzo_moff_t) PTR_DIFF(ip,m_pos)) <= 0 || \
    1542           m_off > 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 )))
    15432789
    15442790#else
    15452791
    15462792#define LZO_CHECK_MPOS_DET(m_pos,m_off,in,ip,max_offset) \
    1547         (m_off == 0 || \
    1548          ((m_off = (lzo_moff_t) ((ip)-(in)) - m_off) > max_offset) || \
    1549         (m_pos = (ip) - (m_off), 0) )
     2793        (m_off == 0 || \
     2794         ((m_off = pd(ip, in) - m_off) > max_offset) || \
     2795        (m_pos = (ip) - (m_off), 0) )
    15502796
    15512797#define LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,max_offset) \
    1552         ((lzo_moff_t) ((ip)-(in)) <= m_off || \
    1553          ((m_off = (lzo_moff_t) ((ip)-(in)) - m_off) > max_offset) || \
    1554         (m_pos = (ip) - (m_off), 0) )
     2798        (pd(ip, in) <= m_off || \
     2799         ((m_off = pd(ip, in) - m_off) > max_offset) || \
     2800        (m_pos = (ip) - (m_off), 0) )
    15552801
    15562802#endif
    15572803
     
    15732819
    15742820#define DO_COMPRESS     lzo1x_1_compress
    15752821
    1576 static
    1577 lzo_uint do_compress     ( const lzo_byte *in , lzo_uint  in_len,
    1578                                  lzo_byte *out, lzo_uint *out_len,
    1579                                  lzo_voidp wrkmem )
    1580 {
    1581 #if 0 && defined(__GNUC__) && defined(__i386__)
    1582     register const lzo_byte *ip __asm__("%esi");
    1583 #else
    1584     register const lzo_byte *ip = NULL;
    1585 #endif
    1586     lzo_byte *op = NULL;
    1587     const lzo_byte * const in_end = in + in_len;
    1588     const lzo_byte * const ip_end = in + in_len - M2_MAX_LEN - 5;
    1589     const lzo_byte *ii = NULL;
     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;
    15902832    lzo_dict_p const dict = (lzo_dict_p) wrkmem;
    15912833
    15922834    op = out;
     
    15962838    ip += 4;
    15972839    for (;;)
    15982840    {
    1599 #if 0 && defined(__GNUC__) && defined(__i386__)
    1600         register const lzo_byte *m_pos __asm__("%edi");
    1601 #else
    1602         register const lzo_byte *m_pos = NULL;
    1603 #endif
    1604         lzo_moff_t m_off = 0;
    1605         lzo_uint m_len = 0;
    1606         lzo_uint dindex = 0;
    1607 
    1608         DINDEX1(dindex,ip);
    1609         GINDEX(m_pos,m_off,dict,dindex,in);
    1610         if (LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,M4_MAX_OFFSET))
    1611             goto literal;
     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;
    16122850#if 1
    1613         if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3])
    1614             goto try_match;
    1615         DINDEX2(dindex,ip);
    1616 #endif
    1617         GINDEX(m_pos,m_off,dict,dindex,in);
    1618         if (LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,M4_MAX_OFFSET))
    1619             goto literal;
    1620         if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3])
    1621             goto try_match;
    1622         goto literal;
     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;
    16232861
    16242862try_match:
    16252863#if 1 && defined(LZO_UNALIGNED_OK_2)
    1626         if (* (const lzo_ushortp) m_pos != * (const lzo_ushortp) ip)
     2864        if (* (const lzo_ushortp) m_pos != * (const lzo_ushortp) ip)
    16272865#else
    1628         if (m_pos[0] != ip[0] || m_pos[1] != ip[1])
     2866        if (m_pos[0] != ip[0] || m_pos[1] != ip[1])
    16292867#endif
    1630         {
    1631         }
    1632         else
    1633         {
    1634             if (m_pos[2] == ip[2])
    1635             {
     2868        {
     2869        }
     2870        else
     2871        {
     2872            if __lzo_likely(m_pos[2] == ip[2])
     2873            {
    16362874#if 0
    1637                 if (m_off <= M2_MAX_OFFSET)
    1638                     goto match;
    1639                 if (lit <= 3)
    1640                     goto match;
    1641                 if (lit == 3)
    1642                 {
    1643                     assert(op - 2 > out); op[-2] |= LZO_BYTE(3);
    1644                     *op++ = *ii++; *op++ = *ii++; *op++ = *ii++;
    1645                     goto code_match;
    1646                 }
    1647                 if (m_pos[3] == ip[3])
    1648 #endif
    1649                     goto match;
    1650             }
    1651             else
    1652             {
     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            {
    16532891#if 0
    16542892#if 0
    1655                 if (m_off <= M1_MAX_OFFSET && lit > 0 && lit <= 3)
     2893                if (m_off <= M1_MAX_OFFSET && lit > 0 && lit <= 3)
    16562894#else
    1657                 if (m_off <= M1_MAX_OFFSET && lit == 3)
     2895                if (m_off <= M1_MAX_OFFSET && lit == 3)
    16582896#endif
    1659                 {
    1660                     register lzo_uint t;
     2897                {
     2898                    register lzo_uint t;
    16612899
    1662                     t = lit;
    1663                     assert(op - 2 > out); op[-2] |= LZO_BYTE(t);
    1664                     do *op++ = *ii++; while (--t > 0);
    1665                     assert(ii == ip);
    1666                     m_off -= 1;
    1667                     *op++ = LZO_BYTE(M1_MARKER | ((m_off & 3) << 2));
    1668                     *op++ = LZO_BYTE(m_off >> 2);
    1669                     ip += 2;
    1670                     goto match_done;
    1671                 }
     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                }
    16722910#endif
    1673             }
    1674         }
     2911            }
     2912        }
    16752913
    16762914literal:
    1677         UPDATE_I(dict,0,dindex,ip,in);
    1678         ++ip;
    1679         if (ip >= ip_end)
    1680             break;
    1681         continue;
     2915        UPDATE_I(dict,0,dindex,ip,in);
     2916        ++ip;
     2917        if __lzo_unlikely(ip >= ip_end)
     2918            break;
     2919        continue;
    16822920
    16832921match:
    1684         UPDATE_I(dict,0,dindex,ip,in);
    1685         if (ip - ii > 0)
    1686         {
    1687             register lzo_uint t = ip - ii;
    1688 
    1689             if (t <= 3)
    1690             {
    1691                 assert(op - 2 > out);
    1692                 op[-2] |= LZO_BYTE(t);
    1693             }
    1694             else if (t <= 18)
    1695                 *op++ = LZO_BYTE(t - 3);
    1696             else
    1697             {
    1698                 register lzo_uint tt = t - 18;
    1699 
    1700                 *op++ = 0;
    1701                 while (tt > 255)
    1702                 {
    1703                     tt -= 255;
    1704                     *op++ = 0;
    1705                 }
    1706                 assert(tt > 0);
    1707                 *op++ = LZO_BYTE(tt);
    1708             }
    1709             do *op++ = *ii++; while (--t > 0);
    1710         }
    1711 
    1712         assert(ii == ip);
    1713         ip += 3;
    1714         if (m_pos[3] != *ip++ || m_pos[4] != *ip++ || m_pos[5] != *ip++ ||
    1715             m_pos[6] != *ip++ || m_pos[7] != *ip++ || m_pos[8] != *ip++
     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++
    17162954#ifdef LZO1Y
    1717             || m_pos[ 9] != *ip++ || m_pos[10] != *ip++ || m_pos[11] != *ip++
    1718             || m_pos[12] != *ip++ || m_pos[13] != *ip++ || m_pos[14] != *ip++
     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++
    17192957#endif
    1720            )
    1721         {
    1722             --ip;
    1723             m_len = ip - ii;
    1724             assert(m_len >= 3); assert(m_len <= M2_MAX_LEN);
    1725 
    1726             if (m_off <= M2_MAX_OFFSET)
    1727             {
    1728                 m_off -= 1;
     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;
    17292967#if defined(LZO1X)
    1730                 *op++ = LZO_BYTE(((m_len - 1) << 5) | ((m_off & 7) << 2));
    1731                 *op++ = LZO_BYTE(m_off >> 3);
     2968                *op++ = LZO_BYTE(((m_len - 1) << 5) | ((m_off & 7) << 2));
     2969                *op++ = LZO_BYTE(m_off >> 3);
    17322970#elif defined(LZO1Y)
    1733                 *op++ = LZO_BYTE(((m_len + 1) << 4) | ((m_off & 3) << 2));
    1734                 *op++ = LZO_BYTE(m_off >> 2);
     2971                *op++ = LZO_BYTE(((m_len + 1) << 4) | ((m_off & 3) << 2));
     2972                *op++ = LZO_BYTE(m_off >> 2);
    17352973#endif
    1736             }
    1737             else if (m_off <= M3_MAX_OFFSET)
    1738             {
    1739                 m_off -= 1;
    1740                 *op++ = LZO_BYTE(M3_MARKER | (m_len - 2));
    1741                 goto m3_m4_offset;
    1742             }
    1743             else
     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
    17442982#if defined(LZO1X)
    1745             {
    1746                 m_off -= 0x4000;
    1747                 assert(m_off > 0); assert(m_off <= 0x7fff);
    1748                 *op++ = LZO_BYTE(M4_MARKER |
    1749                                 ((m_off & 0x4000) >> 11) | (m_len - 2));
    1750                 goto m3_m4_offset;
    1751             }
     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            }
    17522990#elif defined(LZO1Y)
    1753                 goto m4_match;
     2991                goto m4_match;
    17542992#endif
    1755         }
    1756         else
    1757         {
    1758             {
    1759                 const lzo_byte *end = in_end;
    1760                 const lzo_byte *m = m_pos + M2_MAX_LEN + 1;
    1761                 while (ip < end && *m == *ip)
    1762                     m++, ip++;
    1763                 m_len = (ip - ii);
    1764             }
    1765             assert(m_len > M2_MAX_LEN);
    1766 
    1767             if (m_off <= M3_MAX_OFFSET)
    1768             {
    1769                 m_off -= 1;
    1770                 if (m_len <= 33)
    1771                     *op++ = LZO_BYTE(M3_MARKER | (m_len - 2));
    1772                 else
    1773                 {
    1774                     m_len -= 33;
    1775                     *op++ = M3_MARKER | 0;
    1776                     goto m3_m4_len;
    1777                 }
    1778             }
    1779             else
    1780             {
     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            {
    17813019#if defined(LZO1Y)
    17823020m4_match:
    17833021#endif
    1784                 m_off -= 0x4000;
    1785                 assert(m_off > 0); assert(m_off <= 0x7fff);
    1786                 if (m_len <= M4_MAX_LEN)
    1787                     *op++ = LZO_BYTE(M4_MARKER |
    1788                                      ((m_off & 0x4000) >> 11) | (m_len - 2));
    1789                 else
    1790                 {
    1791                     m_len -= M4_MAX_LEN;
    1792                     *op++ = LZO_BYTE(M4_MARKER | ((m_off & 0x4000) >> 11));
     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));
    17933031m3_m4_len:
    1794                     while (m_len > 255)
    1795                     {
    1796                         m_len -= 255;
    1797                         *op++ = 0;
    1798                     }
    1799                     assert(m_len > 0);
    1800                     *op++ = LZO_BYTE(m_len);
    1801                 }
    1802             }
     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            }
    18033041
    18043042m3_m4_offset:
    1805             *op++ = LZO_BYTE((m_off & 63) << 2);
    1806             *op++ = LZO_BYTE(m_off >> 6);
    1807         }
     3043            *op++ = LZO_BYTE((m_off & 63) << 2);
     3044            *op++ = LZO_BYTE(m_off >> 6);
     3045        }
    18083046
    18093047#if 0
    18103048match_done:
    18113049#endif
    1812         ii = ip;
    1813         if (ip >= ip_end)
    1814             break;
     3050        ii = ip;
     3051        if __lzo_unlikely(ip >= ip_end)
     3052            break;
    18153053    }
    18163054
    1817     *out_len = op - out;
    1818     return (lzo_uint) (in_end - ii);
     3055    *out_len = pd(op, out);
     3056    return pd(in_end,ii);
    18193057}
    18203058
    18213059LZO_PUBLIC(int)
    1822 DO_COMPRESS      ( const lzo_byte *in , lzo_uint  in_len,
    1823                          lzo_byte *out, lzo_uint *out_len,
    1824                         lzo_voidp wrkmem )
     3060DO_COMPRESS      ( const lzo_bytep in , lzo_uint  in_len,
     3061                         lzo_bytep out, lzo_uintp out_len,
     3062                        lzo_voidp wrkmem )
    18253063{
    1826     lzo_byte *op = out;
     3064    lzo_bytep op = out;
    18273065    lzo_uint t;
    18283066
    1829 #if defined(__LZO_QUERY_COMPRESS)
    1830     if (__LZO_IS_COMPRESS_QUERY(in,in_len,out,out_len,wrkmem))
    1831         return __LZO_QUERY_COMPRESS(in,in_len,out,out_len,wrkmem,D_SIZE,lzo_sizeof(lzo_dict_t));
    1832 #endif
    1833 
    1834     if (in_len <= M2_MAX_LEN + 5)
    1835         t = in_len;
     3067    if __lzo_unlikely(in_len <= M2_MAX_LEN + 5)
     3068        t = in_len;
    18363069    else
    18373070    {
    1838         t = do_compress(in,in_len,op,out_len,wrkmem);
    1839         op += *out_len;
     3071        t = do_compress(in,in_len,op,out_len,wrkmem);
     3072        op += *out_len;
    18403073    }
    18413074
    18423075    if (t > 0)
    18433076    {
    1844         const lzo_byte *ii = in + in_len - t;
     3077        const lzo_bytep ii = in + in_len - t;
    18453078
    1846         if (op == out && t <= 238)
    1847             *op++ = LZO_BYTE(17 + t);
    1848         else if (t <= 3)
    1849             op[-2] |= LZO_BYTE(t);
    1850         else if (t <= 18)
    1851             *op++ = LZO_BYTE(t - 3);
    1852         else
    1853         {
    1854             lzo_uint tt = t - 18;
    1855 
    1856             *op++ = 0;
    1857             while (tt > 255)
    1858             {
    1859                 tt -= 255;
    1860                 *op++ = 0;
    1861             }
    1862             assert(tt > 0);
    1863             *op++ = LZO_BYTE(tt);
    1864         }
    1865         do *op++ = *ii++; while (--t > 0);
     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);
    18663099    }
    18673100
    18683101    *op++ = M4_MARKER | 1;
    18693102    *op++ = 0;
    18703103    *op++ = 0;
    18713104
    1872     *out_len = op - out;
     3105    *out_len = pd(op, out);
    18733106    return LZO_E_OK;
    18743107}
    18753108
     3109#endif
     3110
    18763111#undef do_compress
    18773112#undef DO_COMPRESS
    18783113#undef LZO_HASH
    18793114
    1880 #undef LZO_TEST_DECOMPRESS_OVERRUN
    1881 #undef LZO_TEST_DECOMPRESS_OVERRUN_INPUT
    1882 #undef LZO_TEST_DECOMPRESS_OVERRUN_OUTPUT
    1883 #undef LZO_TEST_DECOMPRESS_OVERRUN_LOOKBEHIND
     3115#undef LZO_TEST_OVERRUN
    18843116#undef DO_DECOMPRESS
    18853117#define DO_DECOMPRESS       lzo1x_decompress
    18863118
    1887 #if defined(LZO_TEST_DECOMPRESS_OVERRUN)
    1888 #  if !defined(LZO_TEST_DECOMPRESS_OVERRUN_INPUT)
    1889 #    define LZO_TEST_DECOMPRESS_OVERRUN_INPUT       2
     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
    18903124#  endif
    1891 #  if !defined(LZO_TEST_DECOMPRESS_OVERRUN_OUTPUT)
    1892 #    define LZO_TEST_DECOMPRESS_OVERRUN_OUTPUT      2
     3125#  if !defined(LZO_TEST_OVERRUN_OUTPUT)
     3126#    define LZO_TEST_OVERRUN_OUTPUT      2
    18933127#  endif
    1894 #  if !defined(LZO_TEST_DECOMPRESS_OVERRUN_LOOKBEHIND)
    1895 #    define LZO_TEST_DECOMPRESS_OVERRUN_LOOKBEHIND
     3128#  if !defined(LZO_TEST_OVERRUN_LOOKBEHIND)
     3129#    define LZO_TEST_OVERRUN_LOOKBEHIND
    18963130#  endif
    18973131#endif
    18983132
    18993133#undef TEST_IP
    19003134#undef TEST_OP
    1901 #undef TEST_LOOKBEHIND
     3135#undef TEST_LB
     3136#undef TEST_LBO
    19023137#undef NEED_IP
    19033138#undef NEED_OP
    19043139#undef HAVE_TEST_IP
     
    19083143#undef HAVE_ANY_IP
    19093144#undef HAVE_ANY_OP
    19103145
    1911 #if defined(LZO_TEST_DECOMPRESS_OVERRUN_INPUT)
    1912 #  if (LZO_TEST_DECOMPRESS_OVERRUN_INPUT >= 1)
     3146#if defined(LZO_TEST_OVERRUN_INPUT)
     3147#  if (LZO_TEST_OVERRUN_INPUT >= 1)
    19133148#    define TEST_IP             (ip < ip_end)
    19143149#  endif
    1915 #  if (LZO_TEST_DECOMPRESS_OVERRUN_INPUT >= 2)
     3150#  if (LZO_TEST_OVERRUN_INPUT >= 2)
    19163151#    define NEED_IP(x) \
    1917             if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x))  goto input_overrun
     3152            if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x))  goto input_overrun
    19183153#  endif
    19193154#endif
    19203155
    1921 #if defined(LZO_TEST_DECOMPRESS_OVERRUN_OUTPUT)
    1922 #  if (LZO_TEST_DECOMPRESS_OVERRUN_OUTPUT >= 1)
     3156#if defined(LZO_TEST_OVERRUN_OUTPUT)
     3157#  if (LZO_TEST_OVERRUN_OUTPUT >= 1)
    19233158#    define TEST_OP             (op <= op_end)
    19243159#  endif
    1925 #  if (LZO_TEST_DECOMPRESS_OVERRUN_OUTPUT >= 2)
     3160#  if (LZO_TEST_OVERRUN_OUTPUT >= 2)
    19263161#    undef TEST_OP
    19273162#    define NEED_OP(x) \
    1928             if ((lzo_uint)(op_end - op) < (lzo_uint)(x))  goto output_overrun
     3163            if ((lzo_uint)(op_end - op) < (lzo_uint)(x))  goto output_overrun
    19293164#  endif
    19303165#endif
    19313166
    1932 #if defined(LZO_TEST_DECOMPRESS_OVERRUN_LOOKBEHIND)
    1933 #  define TEST_LOOKBEHIND(m_pos,out)    if (m_pos < out) goto lookbehind_overrun
     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
    19343170#else
    1935 #  define TEST_LOOKBEHIND(m_pos,op)     ((void) 0)
     3171#  define TEST_LB(m_pos)        ((void) 0)
     3172#  define TEST_LBO(m_pos,o)     ((void) 0)
    19363173#endif
    19373174
    19383175#if !defined(LZO_EOF_CODE) && !defined(TEST_IP)
     
    19683205#  define HAVE_ANY_OP
    19693206#endif
    19703207
     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
    19713218#if defined(DO_DECOMPRESS)
    19723219LZO_PUBLIC(int)
    1973 DO_DECOMPRESS  ( const lzo_byte *in , lzo_uint  in_len,
    1974                        lzo_byte *out, lzo_uint *out_len,
    1975                        lzo_voidp wrkmem )
     3220DO_DECOMPRESS  ( const lzo_bytep in , lzo_uint  in_len,
     3221                       lzo_bytep out, lzo_uintp out_len,
     3222                       lzo_voidp wrkmem )
    19763223#endif
    19773224{
    1978     register lzo_byte *op;
    1979     register const lzo_byte *ip;
     3225    register lzo_bytep op;
     3226    register const lzo_bytep ip;
    19803227    register lzo_uint t;
    19813228#if defined(COPY_DICT)
    19823229    lzo_uint m_off;
    1983     const lzo_byte *dict_end;
     3230    const lzo_bytep dict_end;
    19843231#else
    1985     register const lzo_byte *m_pos;
     3232    register const lzo_bytep m_pos;
    19863233#endif
    19873234
    1988     const lzo_byte * const ip_end = in + in_len;
     3235    const lzo_bytep const ip_end = in + in_len;
    19893236#if defined(HAVE_ANY_OP)
    1990     lzo_byte * const op_end = out + *out_len;
     3237    lzo_bytep const op_end = out + *out_len;
    19913238#endif
    19923239#if defined(LZO1Z)
    19933240    lzo_uint last_m_off = 0;
     
    19953242
    19963243    LZO_UNUSED(wrkmem);
    19973244
    1998 #if defined(__LZO_QUERY_DECOMPRESS)
    1999     if (__LZO_IS_DECOMPRESS_QUERY(in,in_len,out,out_len,wrkmem))
    2000         return __LZO_QUERY_DECOMPRESS(in,in_len,out,out_len,wrkmem,0,0);
    2001 #endif
    2002 
    20033245#if defined(COPY_DICT)
    20043246    if (dict)
    20053247    {
    2006         if (dict_len > M4_MAX_OFFSET)
    2007         {
    2008             dict += dict_len - M4_MAX_OFFSET;
    2009             dict_len = M4_MAX_OFFSET;
    2010         }
    2011         dict_end = dict + dict_len;
     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;
    20123254    }
    20133255    else
    20143256    {
    2015         dict_len = 0;
    2016         dict_end = NULL;
     3257        dict_len = 0;
     3258        dict_end = NULL;
    20173259    }
    20183260#endif
    20193261
     
    20243266
    20253267    if (*ip > 17)
    20263268    {
    2027         t = *ip++ - 17;
    2028         if (t < 4)
    2029             goto match_next;
    2030         assert(t > 0); NEED_OP(t); NEED_IP(t+1);
    2031         do *op++ = *ip++; while (--t > 0);
    2032         goto first_literal_run;
     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;
    20333275    }
    20343276
    20353277    while (TEST_IP && TEST_OP)
    20363278    {
    2037         t = *ip++;
    2038         if (t >= 16)
    2039             goto match;
    2040         if (t == 0)
    2041         {
    2042             NEED_IP(1);
    2043             while (*ip == 0)
    2044             {
    2045                 t += 255;
    2046                 ip++;
    2047                 NEED_IP(1);
    2048             }
    2049             t += 15 + *ip++;
    2050         }
    2051         assert(t > 0); NEED_OP(t+3); NEED_IP(t+4);
     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);
    20523294#if defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
    20533295#if !defined(LZO_UNALIGNED_OK_4)
    2054         if (PTR_ALIGNED2_4(op,ip))
    2055         {
     3296        if (PTR_ALIGNED2_4(op,ip))
     3297        {
    20563298#endif
    2057         * (lzo_uint32p) op = * (const lzo_uint32p) ip;
    2058         op += 4; ip += 4;
    2059         if (--t > 0)
    2060         {
    2061             if (t >= 4)
    2062             {
    2063                 do {
    2064                     * (lzo_uint32p) op = * (const lzo_uint32p) ip;
    2065                     op += 4; ip += 4; t -= 4;
    2066                 } while (t >= 4);
    2067                 if (t > 0) do *op++ = *ip++; while (--t > 0);
    2068             }
    2069             else
    2070                 do *op++ = *ip++; while (--t > 0);
    2071         }
     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        }
    20723314#if !defined(LZO_UNALIGNED_OK_4)
    2073         }
    2074         else
     3315        }
     3316        else
    20753317#endif
    20763318#endif
    20773319#if !defined(LZO_UNALIGNED_OK_4)
    2078         {
    2079             *op++ = *ip++; *op++ = *ip++; *op++ = *ip++;
    2080             do *op++ = *ip++; while (--t > 0);
    2081         }
     3320        {
     3321            *op++ = *ip++; *op++ = *ip++; *op++ = *ip++;
     3322            do *op++ = *ip++; while (--t > 0);
     3323        }
    20823324#endif
    20833325
    20843326first_literal_run:
    20853327
    2086         t = *ip++;
    2087         if (t >= 16)
    2088             goto match;
     3328        t = *ip++;
     3329        if (t >= 16)
     3330            goto match;
    20893331#if defined(COPY_DICT)
    20903332#if defined(LZO1Z)
    2091         m_off = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2);
    2092         last_m_off = m_off;
     3333        m_off = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2);
     3334        last_m_off = m_off;
    20933335#else
    2094         m_off = (1 + M2_MAX_OFFSET) + (t >> 2) + (*ip++ << 2);
     3336        m_off = (1 + M2_MAX_OFFSET) + (t >> 2) + (*ip++ << 2);
    20953337#endif
    2096         NEED_OP(3);
    2097         t = 3; COPY_DICT(t,m_off)
     3338        NEED_OP(3);
     3339        t = 3; COPY_DICT(t,m_off)
    20983340#else
    20993341#if defined(LZO1Z)
    2100         t = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2);
    2101         m_pos = op - t;
    2102         last_m_off = t;
     3342        t = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2);
     3343        m_pos = op - t;
     3344        last_m_off = t;
    21033345#else
    2104         m_pos = op - (1 + M2_MAX_OFFSET);
    2105         m_pos -= t >> 2;
    2106         m_pos -= *ip++ << 2;
     3346        m_pos = op - (1 + M2_MAX_OFFSET);
     3347        m_pos -= t >> 2;
     3348        m_pos -= *ip++ << 2;
    21073349#endif
    2108         TEST_LOOKBEHIND(m_pos,out); NEED_OP(3);
    2109         *op++ = *m_pos++; *op++ = *m_pos++; *op++ = *m_pos;
     3350        TEST_LB(m_pos); NEED_OP(3);
     3351        *op++ = *m_pos++; *op++ = *m_pos++; *op++ = *m_pos;
    21103352#endif
    2111         goto match_done;
     3353        goto match_done;
    21123354
    2113         while (TEST_IP && TEST_OP)
    2114         {
     3355        do {
    21153356match:
    2116             if (t >= 64)
    2117             {
     3357            if (t >= 64)
     3358            {
    21183359#if defined(COPY_DICT)
    21193360#if defined(LZO1X)
    2120                 m_off = 1 + ((t >> 2) & 7) + (*ip++ << 3);
    2121                 t = (t >> 5) - 1;
     3361                m_off = 1 + ((t >> 2) & 7) + (*ip++ << 3);
     3362                t = (t >> 5) - 1;
    21223363#elif defined(LZO1Y)
    2123                 m_off = 1 + ((t >> 2) & 3) + (*ip++ << 2);
    2124                 t = (t >> 4) - 3;
     3364                m_off = 1 + ((t >> 2) & 3) + (*ip++ << 2);
     3365                t = (t >> 4) - 3;
    21253366#elif defined(LZO1Z)
    2126                 m_off = t & 0x1f;
    2127                 if (m_off >= 0x1c)
    2128                     m_off = last_m_off;
    2129                 else
    2130                 {
    2131                     m_off = 1 + (m_off << 6) + (*ip++ >> 2);
    2132                     last_m_off = m_off;
    2133                 }
    2134                 t = (t >> 5) - 1;
     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;
    21353376#endif
    21363377#else
    21373378#if defined(LZO1X)
    2138                 m_pos = op - 1;
    2139                 m_pos -= (t >> 2) & 7;
    2140                 m_pos -= *ip++ << 3;
    2141                 t = (t >> 5) - 1;
     3379                m_pos = op - 1;
     3380                m_pos -= (t >> 2) & 7;
     3381                m_pos -= *ip++ << 3;
     3382                t = (t >> 5) - 1;
    21423383#elif defined(LZO1Y)
    2143                 m_pos = op - 1;
    2144                 m_pos -= (t >> 2) & 3;
    2145                 m_pos -= *ip++ << 2;
    2146                 t = (t >> 4) - 3;
     3384                m_pos = op - 1;
     3385                m_pos -= (t >> 2) & 3;
     3386                m_pos -= *ip++ << 2;
     3387                t = (t >> 4) - 3;
    21473388#elif defined(LZO1Z)
    2148                 {
    2149                     lzo_uint off = t & 0x1f;
    2150                     m_pos = op;
    2151                     if (off >= 0x1c)
    2152                     {
    2153                         assert(last_m_off > 0);
    2154                         m_pos -= last_m_off;
    2155                     }
    2156                     else
    2157                     {
    2158                         off = 1 + (off << 6) + (*ip++ >> 2);
    2159                         m_pos -= off;
    2160                         last_m_off = off;
    2161                     }
    2162                 }
    2163                 t = (t >> 5) - 1;
    2164 #endif
    2165                 TEST_LOOKBEHIND(m_pos,out); assert(t > 0); NEED_OP(t+3-1);
    2166                 goto copy_match;
    2167 #endif
    2168             }
    2169             else if (t >= 32)
    2170             {
    2171                 t &= 31;
    2172                 if (t == 0)
    2173                 {
    2174                     NEED_IP(1);
    2175                     while (*ip == 0)
    2176                     {
    2177                         t += 255;
    2178                         ip++;
    2179                         NEED_IP(1);
    2180                     }
    2181                     t += 31 + *ip++;
    2182                 }
     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                }
    21833424#if defined(COPY_DICT)
    21843425#if defined(LZO1Z)
    2185                 m_off = 1 + (ip[0] << 6) + (ip[1] >> 2);
    2186                 last_m_off = m_off;
     3426                m_off = 1 + (ip[0] << 6) + (ip[1] >> 2);
     3427                last_m_off = m_off;
    21873428#else
    2188                 m_off = 1 + (ip[0] >> 2) + (ip[1] << 6);
     3429                m_off = 1 + (ip[0] >> 2) + (ip[1] << 6);
    21893430#endif
    21903431#else
    21913432#if defined(LZO1Z)
    2192                 {
    2193                     lzo_uint off = 1 + (ip[0] << 6) + (ip[1] >> 2);
    2194                     m_pos = op - off;
    2195                     last_m_off = off;
    2196                 }
    2197 #elif defined(LZO_UNALIGNED_OK_2) && (LZO_BYTE_ORDER == LZO_LITTLE_ENDIAN)
    2198                 m_pos = op - 1;
    2199                 m_pos -= (* (const lzo_ushortp) ip) >> 2;
    2200 #else
    2201                 m_pos = op - 1;
    2202                 m_pos -= (ip[0] >> 2) + (ip[1] << 6);
    2203 #endif
    2204 #endif
    2205                 ip += 2;
    2206             }
    2207             else if (t >= 16)
    2208             {
     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            {
    22093450#if defined(COPY_DICT)
    2210                 m_off = (t & 8) << 11;
     3451                m_off = (t & 8) << 11;
    22113452#else
    2212                 m_pos = op;
    2213                 m_pos -= (t & 8) << 11;
     3453                m_pos = op;
     3454                m_pos -= (t & 8) << 11;
    22143455#endif
    2215                 t &= 7;
    2216                 if (t == 0)
    2217                 {
    2218                     NEED_IP(1);
    2219                     while (*ip == 0)
    2220                     {
    2221                         t += 255;
    2222                         ip++;
    2223                         NEED_IP(1);
    2224                     }
    2225                     t += 7 + *ip++;
    2226                 }
     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                }
    22273468#if defined(COPY_DICT)
    22283469#if defined(LZO1Z)
    2229                 m_off += (ip[0] << 6) + (ip[1] >> 2);
     3470                m_off += (ip[0] << 6) + (ip[1] >> 2);
    22303471#else
    2231                 m_off += (ip[0] >> 2) + (ip[1] << 6);
     3472                m_off += (ip[0] >> 2) + (ip[1] << 6);
    22323473#endif
    2233                 ip += 2;
    2234                 if (m_off == 0)
    2235                     goto eof_found;
    2236                 m_off += 0x4000;
     3474                ip += 2;
     3475                if (m_off == 0)
     3476                    goto eof_found;
     3477                m_off += 0x4000;
    22373478#if defined(LZO1Z)
    2238                 last_m_off = m_off;
     3479                last_m_off = m_off;
    22393480#endif
    22403481#else
    22413482#if defined(LZO1Z)
    2242                 m_pos -= (ip[0] << 6) + (ip[1] >> 2);
    2243 #elif defined(LZO_UNALIGNED_OK_2) && (LZO_BYTE_ORDER == LZO_LITTLE_ENDIAN)
    2244                 m_pos -= (* (const lzo_ushortp) ip) >> 2;
    2245 #else
    2246                 m_pos -= (ip[0] >> 2) + (ip[1] << 6);
    2247 #endif
    2248                 ip += 2;
    2249                 if (m_pos == op)
    2250                     goto eof_found;
    2251                 m_pos -= 0x4000;
     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;
    22523493#if defined(LZO1Z)
    2253                 last_m_off = op - m_pos;
     3494                last_m_off = pd((const lzo_bytep)op, m_pos);
    22543495#endif
    22553496#endif
    2256             }
    2257             else
    2258             {
     3497            }
     3498            else
     3499            {
    22593500#if defined(COPY_DICT)
    22603501#if defined(LZO1Z)
    2261                 m_off = 1 + (t << 6) + (*ip++ >> 2);
    2262                 last_m_off = m_off;
     3502                m_off = 1 + (t << 6) + (*ip++ >> 2);
     3503                last_m_off = m_off;
    22633504#else
    2264                 m_off = 1 + (t >> 2) + (*ip++ << 2);
     3505                m_off = 1 + (t >> 2) + (*ip++ << 2);
    22653506#endif
    2266                 NEED_OP(2);
    2267                 t = 2; COPY_DICT(t,m_off)
     3507                NEED_OP(2);
     3508                t = 2; COPY_DICT(t,m_off)
    22683509#else
    22693510#if defined(LZO1Z)
    2270                 t = 1 + (t << 6) + (*ip++ >> 2);
    2271                 m_pos = op - t;
    2272                 last_m_off = t;
    2273 #else
    2274                 m_pos = op - 1;
    2275                 m_pos -= t >> 2;
    2276                 m_pos -= *ip++ << 2;
     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;
    22773518#endif
    2278                 TEST_LOOKBEHIND(m_pos,out); NEED_OP(2);
    2279                 *op++ = *m_pos++; *op++ = *m_pos;
     3519                TEST_LB(m_pos); NEED_OP(2);
     3520                *op++ = *m_pos++; *op++ = *m_pos;
    22803521#endif
    2281                 goto match_done;
    2282             }
     3522                goto match_done;
     3523            }
    22833524
    22843525#if defined(COPY_DICT)
    22853526
    2286             NEED_OP(t+3-1);
    2287             t += 3-1; COPY_DICT(t,m_off)
     3527            NEED_OP(t+3-1);
     3528            t += 3-1; COPY_DICT(t,m_off)
    22883529
    22893530#else
    22903531
    2291             TEST_LOOKBEHIND(m_pos,out); assert(t > 0); NEED_OP(t+3-1);
     3532            TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1);
    22923533#if defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
    22933534#if !defined(LZO_UNALIGNED_OK_4)
    2294             if (t >= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op,m_pos))
    2295             {
    2296                 assert((op - m_pos) >= 4);
    2297 #else
    2298             if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4)
    2299             {
    2300 #endif
    2301                 * (lzo_uint32p) op = * (const lzo_uint32p) m_pos;
    2302                 op += 4; m_pos += 4; t -= 4 - (3 - 1);
    2303                 do {
    2304                     * (lzo_uint32p) op = * (const lzo_uint32p) m_pos;
    2305                     op += 4; m_pos += 4; t -= 4;
    2306                 } while (t >= 4);
    2307                 if (t > 0) do *op++ = *m_pos++; while (--t > 0);
    2308             }
    2309             else
     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
    23103551#endif
    2311             {
     3552            {
    23123553copy_match:
    2313                 *op++ = *m_pos++; *op++ = *m_pos++;
    2314                 do *op++ = *m_pos++; while (--t > 0);
    2315             }
     3554                *op++ = *m_pos++; *op++ = *m_pos++;
     3555                do *op++ = *m_pos++; while (--t > 0);
     3556            }
    23163557
    23173558#endif
    23183559
    23193560match_done:
    23203561#if defined(LZO1Z)
    2321             t = ip[-1] & 3;
     3562            t = ip[-1] & 3;
    23223563#else
    2323             t = ip[-2] & 3;
     3564            t = ip[-2] & 3;
    23243565#endif
    2325             if (t == 0)
    2326                 break;
     3566            if (t == 0)
     3567                break;
    23273568
    23283569match_next:
    2329             assert(t > 0); NEED_OP(t); NEED_IP(t+1);
    2330             do *op++ = *ip++; while (--t > 0);
    2331             t = *ip++;
    2332         }
     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);
    23333579    }
    23343580
    23353581#if defined(HAVE_TEST_IP) || defined(HAVE_TEST_OP)
    2336     *out_len = op - out;
     3582    *out_len = pd(op, out);
    23373583    return LZO_E_EOF_NOT_FOUND;
    23383584#endif
    23393585
    23403586eof_found:
    23413587    assert(t == 1);
    2342     *out_len = op - out;
     3588    *out_len = pd(op, out);
    23433589    return (ip == ip_end ? LZO_E_OK :
    2344            (ip < ip_end  ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN));
     3590           (ip < ip_end  ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN));
    23453591
    23463592#if defined(HAVE_NEED_IP)
    23473593input_overrun:
    2348     *out_len = op - out;
     3594    *out_len = pd(op, out);
    23493595    return LZO_E_INPUT_OVERRUN;
    23503596#endif
    23513597
    23523598#if defined(HAVE_NEED_OP)
    23533599output_overrun:
    2354     *out_len = op - out;
     3600    *out_len = pd(op, out);
    23553601    return LZO_E_OUTPUT_OVERRUN;
    23563602#endif
    23573603
    2358 #if defined(LZO_TEST_DECOMPRESS_OVERRUN_LOOKBEHIND)
     3604#if defined(LZO_TEST_OVERRUN_LOOKBEHIND)
    23593605lookbehind_overrun:
    2360     *out_len = op - out;
     3606    *out_len = pd(op, out);
    23613607    return LZO_E_LOOKBEHIND_OVERRUN;
    23623608#endif
    23633609}
    23643610
    2365 #define LZO_TEST_DECOMPRESS_OVERRUN
     3611#endif
     3612
     3613#define LZO_TEST_OVERRUN
    23663614#undef DO_DECOMPRESS
    23673615#define DO_DECOMPRESS       lzo1x_decompress_safe
    23683616
    2369 #if defined(LZO_TEST_DECOMPRESS_OVERRUN)
    2370 #  if !defined(LZO_TEST_DECOMPRESS_OVERRUN_INPUT)
    2371 #    define LZO_TEST_DECOMPRESS_OVERRUN_INPUT       2
     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
    23723622#  endif
    2373 #  if !defined(LZO_TEST_DECOMPRESS_OVERRUN_OUTPUT)
    2374 #    define LZO_TEST_DECOMPRESS_OVERRUN_OUTPUT      2
     3623#  if !defined(LZO_TEST_OVERRUN_OUTPUT)
     3624#    define LZO_TEST_OVERRUN_OUTPUT      2
    23753625#  endif
    2376 #  if !defined(LZO_TEST_DECOMPRESS_OVERRUN_LOOKBEHIND)
    2377 #    define LZO_TEST_DECOMPRESS_OVERRUN_LOOKBEHIND
     3626#  if !defined(LZO_TEST_OVERRUN_LOOKBEHIND)
     3627#    define LZO_TEST_OVERRUN_LOOKBEHIND
    23783628#  endif
    23793629#endif
    23803630
    23813631#undef TEST_IP
    23823632#undef TEST_OP
    2383 #undef TEST_LOOKBEHIND
     3633#undef TEST_LB
     3634#undef TEST_LBO
    23843635#undef NEED_IP
    23853636#undef NEED_OP
    23863637#undef HAVE_TEST_IP
     
    23903641#undef HAVE_ANY_IP
    23913642#undef HAVE_ANY_OP
    23923643
    2393 #if defined(LZO_TEST_DECOMPRESS_OVERRUN_INPUT)
    2394 #  if (LZO_TEST_DECOMPRESS_OVERRUN_INPUT >= 1)
     3644#if defined(LZO_TEST_OVERRUN_INPUT)
     3645#  if (LZO_TEST_OVERRUN_INPUT >= 1)
    23953646#    define TEST_IP             (ip < ip_end)
    23963647#  endif
    2397 #  if (LZO_TEST_DECOMPRESS_OVERRUN_INPUT >= 2)
     3648#  if (LZO_TEST_OVERRUN_INPUT >= 2)
    23983649#    define NEED_IP(x) \
    2399             if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x))  goto input_overrun
     3650            if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x))  goto input_overrun
    24003651#  endif
    24013652#endif
    24023653
    2403 #if defined(LZO_TEST_DECOMPRESS_OVERRUN_OUTPUT)
    2404 #  if (LZO_TEST_DECOMPRESS_OVERRUN_OUTPUT >= 1)
     3654#if defined(LZO_TEST_OVERRUN_OUTPUT)
     3655#  if (LZO_TEST_OVERRUN_OUTPUT >= 1)
    24053656#    define TEST_OP             (op <= op_end)
    24063657#  endif
    2407 #  if (LZO_TEST_DECOMPRESS_OVERRUN_OUTPUT >= 2)
     3658#  if (LZO_TEST_OVERRUN_OUTPUT >= 2)
    24083659#    undef TEST_OP
    24093660#    define NEED_OP(x) \
    2410             if ((lzo_uint)(op_end - op) < (lzo_uint)(x))  goto output_overrun
     3661            if ((lzo_uint)(op_end - op) < (lzo_uint)(x))  goto output_overrun
    24113662#  endif
    24123663#endif
    24133664
    2414 #if defined(LZO_TEST_DECOMPRESS_OVERRUN_LOOKBEHIND)
    2415 #  define TEST_LOOKBEHIND(m_pos,out)    if (m_pos < out) goto lookbehind_overrun
     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
    24163668#else
    2417 #  define TEST_LOOKBEHIND(m_pos,op)     ((void) 0)
     3669#  define TEST_LB(m_pos)        ((void) 0)
     3670#  define TEST_LBO(m_pos,o)     ((void) 0)
    24183671#endif
    24193672
    24203673#if !defined(LZO_EOF_CODE) && !defined(TEST_IP)
     
    24503703#  define HAVE_ANY_OP
    24513704#endif
    24523705
     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
    24533716#if defined(DO_DECOMPRESS)
    24543717LZO_PUBLIC(int)
    2455 DO_DECOMPRESS  ( const lzo_byte *in , lzo_uint  in_len,
    2456                        lzo_byte *out, lzo_uint *out_len,
    2457                        lzo_voidp wrkmem )
     3718DO_DECOMPRESS  ( const lzo_bytep in , lzo_uint  in_len,
     3719                       lzo_bytep out, lzo_uintp out_len,
     3720                       lzo_voidp wrkmem )
    24583721#endif
    24593722{
    2460     register lzo_byte *op;
    2461     register const lzo_byte *ip;
     3723    register lzo_bytep op;
     3724    register const lzo_bytep ip;
    24623725    register lzo_uint t;
    24633726#if defined(COPY_DICT)
    24643727    lzo_uint m_off;
    2465     const lzo_byte *dict_end;
     3728    const lzo_bytep dict_end;
    24663729#else
    2467     register const lzo_byte *m_pos;
     3730    register const lzo_bytep m_pos;
    24683731#endif
    24693732
    2470     const lzo_byte * const ip_end = in + in_len;
     3733    const lzo_bytep const ip_end = in + in_len;
    24713734#if defined(HAVE_ANY_OP)
    2472     lzo_byte * const op_end = out + *out_len;
     3735    lzo_bytep const op_end = out + *out_len;
    24733736#endif
    24743737#if defined(LZO1Z)
    24753738    lzo_uint last_m_off = 0;
     
    24773740
    24783741    LZO_UNUSED(wrkmem);
    24793742
    2480 #if defined(__LZO_QUERY_DECOMPRESS)
    2481     if (__LZO_IS_DECOMPRESS_QUERY(in,in_len,out,out_len,wrkmem))
    2482         return __LZO_QUERY_DECOMPRESS(in,in_len,out,out_len,wrkmem,0,0);
    2483 #endif
    2484 
    24853743#if defined(COPY_DICT)
    24863744    if (dict)
    24873745    {
    2488         if (dict_len > M4_MAX_OFFSET)
    2489         {
    2490             dict += dict_len - M4_MAX_OFFSET;
    2491             dict_len = M4_MAX_OFFSET;
    2492         }
    2493         dict_end = dict + dict_len;
     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;
    24943752    }
    24953753    else
    24963754    {
    2497         dict_len = 0;
    2498         dict_end = NULL;
     3755        dict_len = 0;
     3756        dict_end = NULL;
    24993757    }
    25003758#endif
    25013759
     
    25063764
    25073765    if (*ip > 17)
    25083766    {
    2509         t = *ip++ - 17;
    2510         if (t < 4)
    2511             goto match_next;
    2512         assert(t > 0); NEED_OP(t); NEED_IP(t+1);
    2513         do *op++ = *ip++; while (--t > 0);
    2514         goto first_literal_run;
     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;
    25153773    }
    25163774
    25173775    while (TEST_IP && TEST_OP)
    25183776    {
    2519         t = *ip++;
    2520         if (t >= 16)
    2521             goto match;
    2522         if (t == 0)
    2523         {
    2524             NEED_IP(1);
    2525             while (*ip == 0)
    2526             {
    2527                 t += 255;
    2528                 ip++;
    2529                 NEED_IP(1);
    2530             }
    2531             t += 15 + *ip++;
    2532         }
    2533         assert(t > 0); NEED_OP(t+3); NEED_IP(t+4);
     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);
    25343792#if defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
    25353793#if !defined(LZO_UNALIGNED_OK_4)
    2536         if (PTR_ALIGNED2_4(op,ip))
    2537         {
     3794        if (PTR_ALIGNED2_4(op,ip))
     3795        {
    25383796#endif
    2539         * (lzo_uint32p) op = * (const lzo_uint32p) ip;
    2540         op += 4; ip += 4;
    2541         if (--t > 0)
    2542         {
    2543             if (t >= 4)
    2544             {
    2545                 do {
    2546                     * (lzo_uint32p) op = * (const lzo_uint32p) ip;
    2547                     op += 4; ip += 4; t -= 4;
    2548                 } while (t >= 4);
    2549                 if (t > 0) do *op++ = *ip++; while (--t > 0);
    2550             }
    2551             else
    2552                 do *op++ = *ip++; while (--t > 0);
    2553         }
     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        }
    25543812#if !defined(LZO_UNALIGNED_OK_4)
    2555         }
    2556         else
     3813        }
     3814        else
    25573815#endif
    25583816#endif
    25593817#if !defined(LZO_UNALIGNED_OK_4)
    2560         {
    2561             *op++ = *ip++; *op++ = *ip++; *op++ = *ip++;
    2562             do *op++ = *ip++; while (--t > 0);
    2563         }
     3818        {
     3819            *op++ = *ip++; *op++ = *ip++; *op++ = *ip++;
     3820            do *op++ = *ip++; while (--t > 0);
     3821        }
    25643822#endif
    25653823
    25663824first_literal_run:
    25673825
    2568         t = *ip++;
    2569         if (t >= 16)
    2570             goto match;
     3826        t = *ip++;
     3827        if (t >= 16)
     3828            goto match;
    25713829#if defined(COPY_DICT)
    25723830#if defined(LZO1Z)
    2573         m_off = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2);
    2574         last_m_off = m_off;
     3831        m_off = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2);
     3832        last_m_off = m_off;
    25753833#else
    2576         m_off = (1 + M2_MAX_OFFSET) + (t >> 2) + (*ip++ << 2);
     3834        m_off = (1 + M2_MAX_OFFSET) + (t >> 2) + (*ip++ << 2);
    25773835#endif
    2578         NEED_OP(3);
    2579         t = 3; COPY_DICT(t,m_off)
     3836        NEED_OP(3);
     3837        t = 3; COPY_DICT(t,m_off)
    25803838#else
    25813839#if defined(LZO1Z)
    2582         t = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2);
    2583         m_pos = op - t;
    2584         last_m_off = t;
     3840        t = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2);
     3841        m_pos = op - t;
     3842        last_m_off = t;
    25853843#else
    2586         m_pos = op - (1 + M2_MAX_OFFSET);
    2587         m_pos -= t >> 2;
    2588         m_pos -= *ip++ << 2;
     3844        m_pos = op - (1 + M2_MAX_OFFSET);
     3845        m_pos -= t >> 2;
     3846        m_pos -= *ip++ << 2;
    25893847#endif
    2590         TEST_LOOKBEHIND(m_pos,out); NEED_OP(3);
    2591         *op++ = *m_pos++; *op++ = *m_pos++; *op++ = *m_pos;
     3848        TEST_LB(m_pos); NEED_OP(3);
     3849        *op++ = *m_pos++; *op++ = *m_pos++; *op++ = *m_pos;
    25923850#endif
    2593         goto match_done;
     3851        goto match_done;
    25943852
    2595         while (TEST_IP && TEST_OP)
    2596         {
     3853        do {
    25973854match:
    2598             if (t >= 64)
    2599             {
     3855            if (t >= 64)
     3856            {
    26003857#if defined(COPY_DICT)
    26013858#if defined(LZO1X)
    2602                 m_off = 1 + ((t >> 2) & 7) + (*ip++ << 3);
    2603                 t = (t >> 5) - 1;
     3859                m_off = 1 + ((t >> 2) & 7) + (*ip++ << 3);
     3860                t = (t >> 5) - 1;
    26043861#elif defined(LZO1Y)
    2605                 m_off = 1 + ((t >> 2) & 3) + (*ip++ << 2);
    2606                 t = (t >> 4) - 3;
     3862                m_off = 1 + ((t >> 2) & 3) + (*ip++ << 2);
     3863                t = (t >> 4) - 3;
    26073864#elif defined(LZO1Z)
    2608                 m_off = t & 0x1f;
    2609                 if (m_off >= 0x1c)
    2610                     m_off = last_m_off;
    2611                 else
    2612                 {
    2613                     m_off = 1 + (m_off << 6) + (*ip++ >> 2);
    2614                     last_m_off = m_off;
    2615                 }
    2616                 t = (t >> 5) - 1;
     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;
    26173874#endif
    26183875#else
    26193876#if defined(LZO1X)
    2620                 m_pos = op - 1;
    2621                 m_pos -= (t >> 2) & 7;
    2622                 m_pos -= *ip++ << 3;
    2623                 t = (t >> 5) - 1;
     3877                m_pos = op - 1;
     3878                m_pos -= (t >> 2) & 7;
     3879                m_pos -= *ip++ << 3;
     3880                t = (t >> 5) - 1;
    26243881#elif defined(LZO1Y)
    2625                 m_pos = op - 1;
    2626                 m_pos -= (t >> 2) & 3;
    2627                 m_pos -= *ip++ << 2;
    2628                 t = (t >> 4) - 3;
     3882                m_pos = op - 1;
     3883                m_pos -= (t >> 2) & 3;
     3884                m_pos -= *ip++ << 2;
     3885                t = (t >> 4) - 3;
    26293886#elif defined(LZO1Z)
    2630                 {
    2631                     lzo_uint off = t & 0x1f;
    2632                     m_pos = op;
    2633                     if (off >= 0x1c)
    2634                     {
    2635                         assert(last_m_off > 0);
    2636                         m_pos -= last_m_off;
    2637                     }
    2638                     else
    2639                     {
    2640                         off = 1 + (off << 6) + (*ip++ >> 2);
    2641                         m_pos -= off;
    2642                         last_m_off = off;
    2643                     }
    2644                 }
    2645                 t = (t >> 5) - 1;
    2646 #endif
    2647                 TEST_LOOKBEHIND(m_pos,out); assert(t > 0); NEED_OP(t+3-1);
    2648                 goto copy_match;
    2649 #endif
    2650             }
    2651             else if (t >= 32)
    2652             {
    2653                 t &= 31;
    2654                 if (t == 0)
    2655                 {
    2656                     NEED_IP(1);
    2657                     while (*ip == 0)
    2658                     {
    2659                         t += 255;
    2660                         ip++;
    2661                         NEED_IP(1);
    2662                     }
    2663                     t += 31 + *ip++;
    2664                 }
     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                }
    26653922#if defined(COPY_DICT)
    26663923#if defined(LZO1Z)
    2667                 m_off = 1 + (ip[0] << 6) + (ip[1] >> 2);
    2668                 last_m_off = m_off;
     3924                m_off = 1 + (ip[0] << 6) + (ip[1] >> 2);
     3925                last_m_off = m_off;
    26693926#else
    2670                 m_off = 1 + (ip[0] >> 2) + (ip[1] << 6);
     3927                m_off = 1 + (ip[0] >> 2) + (ip[1] << 6);
    26713928#endif
    26723929#else
    26733930#if defined(LZO1Z)
    2674                 {
    2675                     lzo_uint off = 1 + (ip[0] << 6) + (ip[1] >> 2);
    2676                     m_pos = op - off;
    2677                     last_m_off = off;
    2678                 }
    2679 #elif defined(LZO_UNALIGNED_OK_2) && (LZO_BYTE_ORDER == LZO_LITTLE_ENDIAN)
    2680                 m_pos = op - 1;
    2681                 m_pos -= (* (const lzo_ushortp) ip) >> 2;
    2682 #else
    2683                 m_pos = op - 1;
    2684                 m_pos -= (ip[0] >> 2) + (ip[1] << 6);
    2685 #endif
    2686 #endif
    2687                 ip += 2;
    2688             }
    2689             else if (t >= 16)
    2690             {
     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            {
    26913948#if defined(COPY_DICT)
    2692                 m_off = (t & 8) << 11;
     3949                m_off = (t & 8) << 11;
    26933950#else
    2694                 m_pos = op;
    2695                 m_pos -= (t & 8) << 11;
     3951                m_pos = op;
     3952                m_pos -= (t & 8) << 11;
    26963953#endif
    2697                 t &= 7;
    2698                 if (t == 0)
    2699                 {
    2700                     NEED_IP(1);
    2701                     while (*ip == 0)
    2702                     {
    2703                         t += 255;
    2704                         ip++;
    2705                         NEED_IP(1);
    2706                     }
    2707                     t += 7 + *ip++;
    2708                 }
     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                }
    27093966#if defined(COPY_DICT)
    27103967#if defined(LZO1Z)
    2711                 m_off += (ip[0] << 6) + (ip[1] >> 2);
     3968                m_off += (ip[0] << 6) + (ip[1] >> 2);
    27123969#else
    2713                 m_off += (ip[0] >> 2) + (ip[1] << 6);
     3970                m_off += (ip[0] >> 2) + (ip[1] << 6);
    27143971#endif
    2715                 ip += 2;
    2716                 if (m_off == 0)
    2717                     goto eof_found;
    2718                 m_off += 0x4000;
     3972                ip += 2;
     3973                if (m_off == 0)
     3974                    goto eof_found;
     3975                m_off += 0x4000;
    27193976#if defined(LZO1Z)
    2720                 last_m_off = m_off;
     3977                last_m_off = m_off;
    27213978#endif
    27223979#else
    27233980#if defined(LZO1Z)
    2724                 m_pos -= (ip[0] << 6) + (ip[1] >> 2);
    2725 #elif defined(LZO_UNALIGNED_OK_2) && (LZO_BYTE_ORDER == LZO_LITTLE_ENDIAN)
    2726                 m_pos -= (* (const lzo_ushortp) ip) >> 2;
    2727 #else
    2728                 m_pos -= (ip[0] >> 2) + (ip[1] << 6);
    2729 #endif
    2730                 ip += 2;
    2731                 if (m_pos == op)
    2732                     goto eof_found;
    2733                 m_pos -= 0x4000;
     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;
    27343991#if defined(LZO1Z)
    2735                 last_m_off = op - m_pos;
     3992                last_m_off = pd((const lzo_bytep)op, m_pos);
    27363993#endif
    27373994#endif
    2738             }
    2739             else
    2740             {
     3995            }
     3996            else
     3997            {
    27413998#if defined(COPY_DICT)
    27423999#if defined(LZO1Z)
    2743                 m_off = 1 + (t << 6) + (*ip++ >> 2);
    2744                 last_m_off = m_off;
     4000                m_off = 1 + (t << 6) + (*ip++ >> 2);
     4001                last_m_off = m_off;
    27454002#else
    2746                 m_off = 1 + (t >> 2) + (*ip++ << 2);
     4003                m_off = 1 + (t >> 2) + (*ip++ << 2);
    27474004#endif
    2748                 NEED_OP(2);
    2749                 t = 2; COPY_DICT(t,m_off)
     4005                NEED_OP(2);
     4006                t = 2; COPY_DICT(t,m_off)
    27504007#else
    27514008#if defined(LZO1Z)
    2752                 t = 1 + (t << 6) + (*ip++ >> 2);
    2753                 m_pos = op - t;
    2754                 last_m_off = t;
    2755 #else
    2756                 m_pos = op - 1;
    2757                 m_pos -= t >> 2;
    2758                 m_pos -= *ip++ << 2;
     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;
    27594016#endif
    2760                 TEST_LOOKBEHIND(m_pos,out); NEED_OP(2);
    2761                 *op++ = *m_pos++; *op++ = *m_pos;
     4017                TEST_LB(m_pos); NEED_OP(2);
     4018                *op++ = *m_pos++; *op++ = *m_pos;
    27624019#endif
    2763                 goto match_done;
    2764             }
     4020                goto match_done;
     4021            }
    27654022
    27664023#if defined(COPY_DICT)
    27674024
    2768             NEED_OP(t+3-1);
    2769             t += 3-1; COPY_DICT(t,m_off)
     4025            NEED_OP(t+3-1);
     4026            t += 3-1; COPY_DICT(t,m_off)
    27704027
    27714028#else
    27724029
    2773             TEST_LOOKBEHIND(m_pos,out); assert(t > 0); NEED_OP(t+3-1);
     4030            TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1);
    27744031#if defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
    27754032#if !defined(LZO_UNALIGNED_OK_4)
    2776             if (t >= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op,m_pos))
    2777             {
    2778                 assert((op - m_pos) >= 4);
    2779 #else
    2780             if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4)
    2781             {
    2782 #endif
    2783                 * (lzo_uint32p) op = * (const lzo_uint32p) m_pos;
    2784                 op += 4; m_pos += 4; t -= 4 - (3 - 1);
    2785                 do {
    2786                     * (lzo_uint32p) op = * (const lzo_uint32p) m_pos;
    2787                     op += 4; m_pos += 4; t -= 4;
    2788                 } while (t >= 4);
    2789                 if (t > 0) do *op++ = *m_pos++; while (--t > 0);
    2790             }
    2791             else
     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
    27924049#endif
    2793             {
     4050            {
    27944051copy_match:
    2795                 *op++ = *m_pos++; *op++ = *m_pos++;
    2796                 do *op++ = *m_pos++; while (--t > 0);
    2797             }
     4052                *op++ = *m_pos++; *op++ = *m_pos++;
     4053                do *op++ = *m_pos++; while (--t > 0);
     4054            }
    27984055
    27994056#endif
    28004057
    28014058match_done:
    28024059#if defined(LZO1Z)
    2803             t = ip[-1] & 3;
     4060            t = ip[-1] & 3;
    28044061#else
    2805             t = ip[-2] & 3;
     4062            t = ip[-2] & 3;
    28064063#endif
    2807             if (t == 0)
    2808                 break;
     4064            if (t == 0)
     4065                break;
    28094066
    28104067match_next:
    2811             assert(t > 0); NEED_OP(t); NEED_IP(t+1);
    2812             do *op++ = *ip++; while (--t > 0);
    2813             t = *ip++;
    2814         }
     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);
    28154077    }
    28164078
    28174079#if defined(HAVE_TEST_IP) || defined(HAVE_TEST_OP)
    2818     *out_len = op - out;
     4080    *out_len = pd(op, out);
    28194081    return LZO_E_EOF_NOT_FOUND;
    28204082#endif
    28214083
    28224084eof_found:
    28234085    assert(t == 1);
    2824     *out_len = op - out;
     4086    *out_len = pd(op, out);
    28254087    return (ip == ip_end ? LZO_E_OK :
    2826            (ip < ip_end  ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN));
     4088           (ip < ip_end  ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN));
    28274089
    28284090#if defined(HAVE_NEED_IP)
    28294091input_overrun:
    2830     *out_len = op - out;
     4092    *out_len = pd(op, out);
    28314093    return LZO_E_INPUT_OVERRUN;
    28324094#endif
    28334095
    28344096#if defined(HAVE_NEED_OP)
    28354097output_overrun:
    2836     *out_len = op - out;
     4098    *out_len = pd(op, out);
    28374099    return LZO_E_OUTPUT_OVERRUN;
    28384100#endif
    28394101
    2840 #if defined(LZO_TEST_DECOMPRESS_OVERRUN_LOOKBEHIND)
     4102#if defined(LZO_TEST_OVERRUN_LOOKBEHIND)
    28414103lookbehind_overrun:
    2842     *out_len = op - out;
     4104    *out_len = pd(op, out);
    28434105    return LZO_E_LOOKBEHIND_OVERRUN;
    28444106#endif
    28454107}
    28464108
     4109#endif
     4110
    28474111/***** End of minilzo.c *****/
    28484112
  • libs/libmythtv/minilzo.h

    diff -uNr mythtv-0.21-orig/libs/libmythtv/minilzo.h mythtv-0.21/libs/libmythtv/minilzo.h
    old new  
    22
    33   This file is part of the LZO real-time data compression library.
    44
     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
    513   Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
    614   Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
    715   Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
    816   Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
    917   Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
     18   All Rights Reserved.
    1019
    1120   The LZO library is free software; you can redistribute it and/or
    1221   modify it under the terms of the GNU General Public License as
     
    2130   You should have received a copy of the GNU General Public License
    2231   along with the LZO library; see the file COPYING.
    2332   If not, write to the Free Software Foundation, Inc.,
    24    59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
     33   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
    2534
    2635   Markus F.X.J. Oberhumer
    27    <markus.oberhumer@jk.uni-linz.ac.at>
    28    http://wildsau.idv.uni-linz.ac.at/mfx/lzo.html
     36   <markus@oberhumer.com>
     37   http://www.oberhumer.com/opensource/lzo/
    2938 */
    3039
    3140/*
    3241 * NOTE:
    3342 *   the full LZO package can be found at
    34  *   http://wildsau.idv.uni-linz.ac.at/mfx/lzo.html
     43 *   http://www.oberhumer.com/opensource/lzo/
    3544 */
    3645
    3746
    3847#ifndef __MINILZO_H
    3948#define __MINILZO_H
    4049
    41 #define MINILZO_VERSION         0x1070
     50#define MINILZO_VERSION         0x2030
    4251
    4352#ifdef __LZOCONF_H
    4453#  error "you cannot use both LZO and miniLZO"
     
    7281
    7382/* compression */
    7483LZO_EXTERN(int)
    75 lzo1x_1_compress        ( const lzo_byte *src, lzo_uint  src_len,
    76                                 lzo_byte *dst, lzo_uint *dst_len,
     84lzo1x_1_compress        ( const lzo_bytep src, lzo_uint  src_len,
     85                                lzo_bytep dst, lzo_uintp dst_len,
    7786                                lzo_voidp wrkmem );
    7887
    7988/* decompression */
    8089LZO_EXTERN(int)
    81 lzo1x_decompress        ( const lzo_byte *src, lzo_uint  src_len,
    82                                 lzo_byte *dst, lzo_uint *dst_len,
     90lzo1x_decompress        ( const lzo_bytep src, lzo_uint  src_len,
     91                                lzo_bytep dst, lzo_uintp dst_len,
    8392                                lzo_voidp wrkmem /* NOT USED */ );
    8493
    8594/* safe decompression with overrun testing */
    8695LZO_EXTERN(int)
    87 lzo1x_decompress_safe   ( const lzo_byte *src, lzo_uint  src_len,
    88                                 lzo_byte *dst, lzo_uint *dst_len,
     96lzo1x_decompress_safe   ( const lzo_bytep src, lzo_uint  src_len,
     97                                lzo_bytep dst, lzo_uintp dst_len,
    8998                                lzo_voidp wrkmem /* NOT USED */ );
    9099
    91100
  • libs/libmythtv/nuppeldecoder.cpp

    diff -uNr mythtv-0.21-orig/libs/libmythtv/nuppeldecoder.cpp mythtv-0.21/libs/libmythtv/nuppeldecoder.cpp
    old new  
    770770                                unsigned char *lstrm, VideoFrame *frame)
    771771{
    772772    int r;
    773     unsigned int out_len;
     773    lzo_uint out_len;
    774774    int compoff = 0;
    775775
    776776    unsigned char *outbuf = frame->buf;