1 /* minilzo.c -- mini subset of the LZO real-time data compression library
3 This file is part of the LZO real-time data compression library.
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
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.
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.
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.
35 Markus F.X.J. Oberhumer
36 <markus@oberhumer.com>
37 http://www.oberhumer.com/opensource/lzo/
42 * the full LZO package can be found at
43 * http://www.oberhumer.com/opensource/lzo/
46 #define __LZO_IN_MINILZO
49 #if defined(LZO_CFG_FREESTANDING)
50 # undef MINILZO_HAVE_CONFIG_H
51 # define LZO_LIBC_FREESTANDING 1
52 # define LZO_OS_FREESTANDING 1
55 #ifdef MINILZO_HAVE_CONFIG_H
60 #if defined(MINILZO_CFG_USE_INTERNAL_LZODEFS)
62 #ifndef __LZODEFS_H_INCLUDED
63 #define __LZODEFS_H_INCLUDED 1
65 #if defined(__CYGWIN32__) && !defined(__CYGWIN__)
66 # define __CYGWIN__ __CYGWIN32__
68 #if defined(__IBMCPP__) && !defined(__IBMC__)
69 # define __IBMC__ __IBMCPP__
71 #if defined(__ICL) && defined(_WIN32) && !defined(__INTEL_COMPILER)
72 # define __INTEL_COMPILER __ICL
74 #if 1 && defined(__INTERIX) && defined(__GNUC__) && !defined(_ALL_SOURCE)
75 # define _ALL_SOURCE 1
77 #if defined(__mips__) && defined(__R5900__)
78 # if !defined(__LONG_MAX__)
79 # define __LONG_MAX__ 9223372036854775807L
82 #if defined(__INTEL_COMPILER) && defined(__linux__)
83 # pragma warning(disable: 193)
85 #if defined(__KEIL__) && defined(__C166__)
86 # pragma warning disable = 322
87 #elif 0 && defined(__C251__)
88 # pragma warning disable = 322
90 #if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__)
91 # if (_MSC_VER >= 1300)
92 # pragma warning(disable: 4668)
95 #if 0 && defined(__WATCOMC__)
96 # if (__WATCOMC__ >= 1050) && (__WATCOMC__ < 1060)
97 # pragma warning 203 9
100 #if defined(__BORLANDC__) && defined(__MSDOS__) && !defined(__FLAT__)
104 #define LZO_0xffffL 0xfffful
105 #define LZO_0xffffffffL 0xfffffffful
107 #define LZO_0xffffL 65535ul
108 #define LZO_0xffffffffL 4294967295ul
110 #if (LZO_0xffffL == LZO_0xffffffffL)
111 # error "your preprocessor is broken 1"
113 #if (16ul * 16384ul != 262144ul)
114 # error "your preprocessor is broken 2"
117 #if (32767 >= 4294967295ul)
118 # error "your preprocessor is broken 3"
120 #if (65535u >= 4294967295ul)
121 # error "your preprocessor is broken 4"
124 #if (UINT_MAX == LZO_0xffffL)
125 #if defined(__ZTC__) && defined(__I86__) && !defined(__OS2__)
129 # if !defined(_MSDOS)
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
137 # if !defined(__DOS__)
143 #if defined(_MSC_VER) && defined(M_I86HM) && (UINT_MAX == LZO_0xffffL)
144 # define ptrdiff_t long
145 # define _PTRDIFF_T_DEFINED
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
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)
166 # if !defined(__near)
170 # if defined(__LZO_RENAME_A)
171 # if !defined(__cdecl)
172 # define __cdecl cdecl
177 # if !defined(__huge)
180 # if !defined(__near)
183 # if !defined(__pascal)
184 # define __pascal pascal
186 # if !defined(__huge)
189 # elif defined(__LZO_RENAME_B)
190 # if !defined(__cdecl)
191 # define __cdecl _cdecl
196 # if !defined(__huge)
197 # define __huge _huge
199 # if !defined(__near)
200 # define __near _near
202 # if !defined(__pascal)
203 # define __pascal _pascal
205 # elif (defined(__PUREC__) || defined(__TURBOC__)) && defined(__TOS__)
206 # if !defined(__cdecl)
207 # define __cdecl cdecl
209 # if !defined(__pascal)
210 # define __pascal pascal
213 # undef __LZO_RENAME_A
214 # undef __LZO_RENAME_B
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
223 # if (_MSC_VER < 700)
224 # define LZO_BROKEN_INTEGRAL_PROMOTION 1
225 # define LZO_BROKEN_SIZEOF 1
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
235 # if (__TURBOC__ < 0x0200)
236 # define LZO_BROKEN_SIZEOF 1
238 # if (__TURBOC__ < 0x0400) && defined(__cplusplus)
239 # define LZO_BROKEN_CDECL_ALT_SYNTAX 1
241 #elif (defined(__PUREC__) || defined(__TURBOC__)) && defined(__TOS__)
242 # define LZO_BROKEN_CDECL_ALT_SYNTAX 1
243 # define LZO_BROKEN_SIZEOF 1
246 #if defined(__WATCOMC__) && (__WATCOMC__ < 900)
247 # define LZO_BROKEN_INTEGRAL_CONSTANTS 1
249 #if defined(_CRAY) && defined(_CRAY1)
250 # define LZO_BROKEN_SIGNED_RIGHT_SHIFT 1
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)
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)
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
279 # if !defined(__STDC_LIMIT_MACROS)
280 # define __STDC_LIMIT_MACROS 1
283 #if defined(__cplusplus)
284 # define LZO_EXTERN_C extern "C"
286 # define LZO_EXTERN_C extern
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"
331 # error "check your limits.h header"
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"
350 # error "check your limits.h header"
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"
360 # error "check your limits.h header"
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"
373 # error "please specify a target using the -bt compiler option"
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"
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"
398 # define LZO_OS_POSIX 1
399 # define LZO_INFO_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"
440 # define LZO_OS_POSIX_SUNOS 1
441 # define LZO_INFO_OS_POSIX "sunos"
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"
450 # define LZO_OS_POSIX_UNKNOWN 1
451 # define LZO_INFO_OS_POSIX "unknown"
455 #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16)
456 # if (UINT_MAX != LZO_0xffffL)
457 # error "this should not happen"
459 # if (ULONG_MAX != LZO_0xffffffffL)
460 # error "this should not happen"
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"
467 # if (ULONG_MAX != LZO_0xffffffffL)
468 # error "this should not happen"
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__)
477 # define LZO_INFO_CCVER "unknown"
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
494 # define LZO_CC_SYNTAX_GNUC 1
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__)
504 # define LZO_CC_LLVM (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100)
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)
514 # define LZO_CC_GNUC (__GNUC__ * 0x10000L)
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__)
552 # define LZO_INFO_CCVER "unknown"
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__)
572 # define LZO_INFO_CCVER "unknown"
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)
580 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER)
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)
612 # define LZO_CC_SUNPROC 1
613 # define LZO_INFO_CCVER "unknown"
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)
621 # define LZO_CC_SUNPROC 1
622 # define LZO_INFO_CCVER "unknown"
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"
646 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__ZTC__)
649 # define LZO_CC_UNKNOWN 1
650 # define LZO_INFO_CC "unknown"
651 # define LZO_INFO_CCVER "unknown"
653 #if 0 && (LZO_CC_MSC && (_MSC_VER >= 1200)) && !defined(_MSC_FULL_VER)
654 # error "LZO_CC_MSC: _MSC_FULL_VER is not defined"
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
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"
693 # define LZO_INFO_ARCH "arm"
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"
787 # define LZO_ARCH_CRAY_T90 1
788 # define LZO_INFO_ARCH "cray_t90"
790 # define LZO_ARCH_CRAY_YMP 1
791 # define LZO_INFO_ARCH "cray_ymp"
793 # define LZO_ARCH_CRAY_XMP 1
794 # define LZO_INFO_ARCH "cray_xmp"
797 # define LZO_ARCH_UNKNOWN 1
798 # define LZO_INFO_ARCH "unknown"
801 #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_DOS32 || LZO_OS_OS2)
802 # error "FIXME - missing define for CPU architecture"
804 #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN32)
805 # error "FIXME - missing WIN32 define for CPU architecture"
807 #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN64)
808 # error "FIXME - missing WIN64 define for CPU architecture"
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
823 #if defined(LZO_ARCH_ARM_THUMB) && !defined(LZO_ARCH_ARM)
824 # error "this should not happen"
826 #if defined(LZO_ARCH_I086PM) && !defined(LZO_ARCH_I086)
827 # error "this should not happen"
830 # if (UINT_MAX != LZO_0xffffL)
831 # error "this should not happen"
833 # if (ULONG_MAX != LZO_0xffffffffL)
834 # error "this should not happen"
838 # if (UINT_MAX != LZO_0xffffL) && defined(__i386_int16__)
839 # error "this should not happen"
841 # if (UINT_MAX != LZO_0xffffffffL) && !defined(__i386_int16__)
842 # error "this should not happen"
844 # if (ULONG_MAX != LZO_0xffffffffL)
845 # error "this should not happen"
848 #if !defined(__LZO_MM_OVERRIDE)
850 #if (UINT_MAX != LZO_0xffffL)
851 # error "this should not happen"
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
873 # define LZO_MM_SMALL 1
875 #elif (LZO_CC_ZORTECHC && defined(__VCM__))
876 # define LZO_MM_LARGE 1
878 # error "unknown memory model"
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
884 # undef LZO_HAVE_MM_HUGE_ARRAY
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
896 #elif (LZO_CC_TURBOC && (__TURBOC__ < 0x0295))
897 # undef LZO_HAVE_MM_HUGE_ARRAY
899 #if (LZO_ARCH_I086PM) && !defined(LZO_HAVE_MM_HUGE_PTR)
901 # error "this should not happen"
902 # elif (LZO_CC_ZORTECHC)
904 # error "this should not happen"
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)
928 # error "FIXME - implement LZO_MM_AHSHIFT"
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
950 # error "FIXME - C166 __MODEL__"
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
966 # error "FIXME - MCS251 __MODEL__"
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
982 # error "FIXME - MCS51 __MODEL__"
984 #elif (LZO_ARCH_CRAY_PVP)
985 # define LZO_MM_PVP 1
987 # define LZO_MM_FLAT 1
990 # define LZO_INFO_MM "compact"
992 # define LZO_INFO_MM "flat"
994 # define LZO_INFO_MM "huge"
996 # define LZO_INFO_MM "large"
997 #elif (LZO_MM_MEDIUM)
998 # define LZO_INFO_MM "medium"
1000 # define LZO_INFO_MM "pvp"
1001 #elif (LZO_MM_SMALL)
1002 # define LZO_INFO_MM "small"
1004 # define LZO_INFO_MM "tiny"
1006 # error "unknown memory model"
1009 #if defined(SIZEOF_SHORT)
1010 # define LZO_SIZEOF_SHORT (SIZEOF_SHORT)
1012 #if defined(SIZEOF_INT)
1013 # define LZO_SIZEOF_INT (SIZEOF_INT)
1015 #if defined(SIZEOF_LONG)
1016 # define LZO_SIZEOF_LONG (SIZEOF_LONG)
1018 #if defined(SIZEOF_LONG_LONG)
1019 # define LZO_SIZEOF_LONG_LONG (SIZEOF_LONG_LONG)
1021 #if defined(SIZEOF___INT16)
1022 # define LZO_SIZEOF___INT16 (SIZEOF___INT16)
1024 #if defined(SIZEOF___INT32)
1025 # define LZO_SIZEOF___INT32 (SIZEOF___INT32)
1027 #if defined(SIZEOF___INT64)
1028 # define LZO_SIZEOF___INT64 (SIZEOF___INT64)
1030 #if defined(SIZEOF_VOID_P)
1031 # define LZO_SIZEOF_VOID_P (SIZEOF_VOID_P)
1033 #if defined(SIZEOF_SIZE_T)
1034 # define LZO_SIZEOF_SIZE_T (SIZEOF_SIZE_T)
1036 #if defined(SIZEOF_PTRDIFF_T)
1037 # define LZO_SIZEOF_PTRDIFF_T (SIZEOF_PTRDIFF_T)
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
1056 # error "LZO_SIZEOF_SHORT"
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
1077 # error "LZO_SIZEOF_INT"
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
1094 # error "LZO_SIZEOF_LONG"
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
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
1149 #if defined(__cplusplus) && defined(LZO_CC_GNUC)
1150 # if (LZO_CC_GNUC < 0x020800ul)
1151 # undef LZO_SIZEOF_LONG_LONG
1154 #if defined(LZO_CFG_NO_LONG_LONG) || defined(__NO_LONG_LONG)
1155 # undef LZO_SIZEOF_LONG_LONG
1157 #if !defined(LZO_SIZEOF_VOID_P)
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
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
1180 # define __LZO_WORDSIZE 2
1181 # define LZO_SIZEOF_VOID_P 2
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
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
1192 # define LZO_SIZEOF_VOID_P 2
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)
1215 # define __LZO_WORDSIZE 16
1217 # define LZO_SIZEOF_VOID_P 4
1219 # define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG
1222 #if !defined(LZO_WORDSIZE)
1223 # if defined(__LZO_WORDSIZE)
1224 # define LZO_WORDSIZE __LZO_WORDSIZE
1226 # define LZO_WORDSIZE LZO_SIZEOF_VOID_P
1229 #if !defined(LZO_SIZEOF_SIZE_T)
1230 #if (LZO_ARCH_I086 || LZO_ARCH_M16C)
1231 # define LZO_SIZEOF_SIZE_T 2
1233 # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_VOID_P
1236 #if !defined(LZO_SIZEOF_PTRDIFF_T)
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
1244 # define LZO_SIZEOF_PTRDIFF_T 2
1250 # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_SIZE_T
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
1267 # define LZO_ABI_BIG_ENDIAN 1
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
1283 #if defined(LZO_ABI_BIG_ENDIAN) && defined(LZO_ABI_LITTLE_ENDIAN)
1284 # error "this should not happen"
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"
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"
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__)
1336 # define LZO_LIBC_UCLIBC 0x00090bL
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"
1349 # define LZO_LIBC_DEFAULT 1
1350 # define LZO_INFO_LIBC "default"
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__
1359 # define __lzo_gnuc_extension__
1362 #if !defined(__lzo_ua_volatile)
1363 # define __lzo_ua_volatile volatile
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)
1374 #if defined(__lzo_alignof)
1375 # define __lzo_HAVE_alignof 1
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__))
1386 #if defined(__lzo_constructor)
1387 # define __lzo_HAVE_constructor 1
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__))
1398 #if defined(__lzo_destructor)
1399 # define __lzo_HAVE_destructor 1
1401 #if defined(__lzo_HAVE_destructor) && !defined(__lzo_HAVE_constructor)
1402 # error "this should not happen"
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__
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
1424 #if defined(__lzo_inline)
1425 # define __lzo_HAVE_inline 1
1427 # define __lzo_inline
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
1442 #if defined(__lzo_forceinline)
1443 # define __lzo_HAVE_forceinline 1
1445 # define __lzo_forceinline
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)
1463 # define __lzo_noinline __declspec(noinline)
1467 #if defined(__lzo_noinline)
1468 # define __lzo_HAVE_noinline 1
1470 # define __lzo_noinline
1472 #if (defined(__lzo_HAVE_forceinline) || defined(__lzo_HAVE_noinline)) && !defined(__lzo_HAVE_inline)
1473 # error "this should not happen"
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)
1488 #if defined(__lzo_noreturn)
1489 # define __lzo_HAVE_noreturn 1
1491 # define __lzo_noreturn
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)
1506 #if defined(__lzo_nothrow)
1507 # define __lzo_HAVE_nothrow 1
1509 # define __lzo_nothrow
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__
1517 # define __lzo_restrict __restrict__
1518 #elif (LZO_CC_MSC && (_MSC_VER >= 1400))
1519 # define __lzo_restrict __restrict
1522 #if defined(__lzo_restrict)
1523 # define __lzo_HAVE_restrict 1
1525 # define __lzo_restrict
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))
1539 #if defined(__lzo_likely)
1540 # define __lzo_HAVE_likely 1
1542 # define __lzo_likely(e) (e)
1544 #if defined(__lzo_unlikely)
1545 # define __lzo_HAVE_unlikely 1
1547 # define __lzo_unlikely(e) (e)
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)
1565 # define LZO_UNUSED(var) ((void) &var)
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
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)];}
1582 # define LZO_UNUSED_FUNC(func) ((void) func)
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
1591 # define LZO_UNUSED_LABEL(l) switch(0) case 1:goto l
1594 #if !defined(LZO_DEFINE_UNINITIALIZED_VAR)
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
1600 # define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = init
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)];
1611 # define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-2*!(e)];
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;
1624 # define LZO_COMPILE_TIME_ASSERT(e) {typedef int __lzo_cta_t[1-2*!(e)];}
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
1638 # define __lzo_cdecl_qsort __cdecl
1640 # elif (LZO_CC_WATCOMC)
1641 # define __lzo_cdecl __cdecl
1643 # define __lzo_cdecl __cdecl
1644 # define __lzo_cdecl_atexit __cdecl
1645 # define __lzo_cdecl_main __cdecl
1646 # define __lzo_cdecl_qsort __cdecl
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))
1657 # define __lzo_cdecl_sighandler _far _cdecl _loadds
1659 # define __lzo_cdecl_sighandler _far _cdecl
1661 # define __lzo_cdecl_sighandler _cdecl
1664 # define __lzo_cdecl_sighandler __cdecl
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
1671 #if !defined(__lzo_cdecl)
1672 # define __lzo_cdecl
1674 #if !defined(__lzo_cdecl_atexit)
1675 # define __lzo_cdecl_atexit
1677 #if !defined(__lzo_cdecl_main)
1678 # define __lzo_cdecl_main
1680 #if !defined(__lzo_cdecl_qsort)
1681 # define __lzo_cdecl_qsort
1683 #if !defined(__lzo_cdecl_sighandler)
1684 # define __lzo_cdecl_sighandler
1686 #if !defined(__lzo_cdecl_va)
1687 # define __lzo_cdecl_va __lzo_cdecl
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)))
1695 # define LZO_HAVE_WINDOWS_H 1
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
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
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
1746 # define LZO_OPT_PREFER_POSTINC 1
1747 # define LZO_OPT_PREFER_PREDEC 1
1749 #if !defined(LZO_CFG_NO_INLINE_ASM)
1750 #if defined(LZO_CC_LLVM)
1751 # define LZO_CFG_NO_INLINE_ASM 1
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
1759 #if defined(LZO_CFG_NO_UNALIGNED)
1760 # undef LZO_OPT_UNALIGNED16
1761 # undef LZO_OPT_UNALIGNED32
1762 # undef LZO_OPT_UNALIGNED64
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
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"
1779 # define __LZO_ASM_CLOBBER "cc", "memory"
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
1788 # define __LZO_INFOSTR_MM ""
1790 #if defined(__LZO_INFOSTR_PM)
1791 #elif defined(LZO_INFO_ABI_PM)
1792 # define __LZO_INFOSTR_PM "." LZO_INFO_ABI_PM
1794 # define __LZO_INFOSTR_PM ""
1796 #if defined(__LZO_INFOSTR_ENDIAN)
1797 #elif defined(LZO_INFO_ABI_ENDIAN)
1798 # define __LZO_INFOSTR_ENDIAN "." LZO_INFO_ABI_ENDIAN
1800 # define __LZO_INFOSTR_ENDIAN ""
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
1808 # define __LZO_INFOSTR_OSNAME LZO_INFO_OS
1810 #if defined(__LZO_INFOSTR_LIBC)
1811 #elif defined(LZO_INFO_LIBC)
1812 # define __LZO_INFOSTR_LIBC "." LZO_INFO_LIBC
1814 # define __LZO_INFOSTR_LIBC ""
1816 #if defined(__LZO_INFOSTR_CCVER)
1817 #elif defined(LZO_INFO_CCVER)
1818 # define __LZO_INFOSTR_CCVER " " LZO_INFO_CCVER
1820 # define __LZO_INFOSTR_CCVER ""
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
1830 #undef LZO_HAVE_CONFIG_H
1831 #include "minilzo.h"
1833 #if !defined(MINILZO_VERSION) || (MINILZO_VERSION != 0x2030)
1834 # error "version mismatch in miniLZO source files"
1837 #ifdef MINILZO_HAVE_CONFIG_H
1838 # define LZO_HAVE_CONFIG_H
1841 #ifndef __LZO_CONF_H
1842 #define __LZO_CONF_H
1844 #if !defined(__LZO_IN_MINILZO)
1845 #if defined(LZO_CFG_FREESTANDING)
1846 # define LZO_LIBC_FREESTANDING 1
1847 # define LZO_OS_FREESTANDING 1
1848 # define ACC_LIBC_FREESTANDING 1
1849 # define ACC_OS_FREESTANDING 1
1851 #if defined(LZO_CFG_NO_UNALIGNED)
1852 # define ACC_CFG_NO_UNALIGNED 1
1854 #if defined(LZO_ARCH_GENERIC)
1855 # define ACC_ARCH_GENERIC 1
1857 #if defined(LZO_ABI_NEUTRAL_ENDIAN)
1858 # define ACC_ABI_NEUTRAL_ENDIAN 1
1860 #if defined(LZO_HAVE_CONFIG_H)
1861 # define ACC_CONFIG_NO_HEADER 1
1863 #if defined(LZO_CFG_EXTRA_CONFIG_HEADER)
1864 # include LZO_CFG_EXTRA_CONFIG_HEADER
1866 #if defined(__LZOCONF_H) || defined(__LZOCONF_H_INCLUDED)
1867 # error "include this file first"
1869 #include "lzo/lzoconf.h"
1872 #if (LZO_VERSION < 0x02000) || !defined(__LZOCONF_H_INCLUDED)
1873 # error "version mismatch"
1876 #if (LZO_CC_BORLANDC && LZO_ARCH_I086)
1880 #if (LZO_CC_MSC && (_MSC_VER >= 1000))
1881 # pragma warning(disable: 4127 4701)
1883 #if (LZO_CC_MSC && (_MSC_VER >= 1300))
1884 # pragma warning(disable: 4820)
1885 # pragma warning(disable: 4514 4710 4711)
1888 #if (LZO_CC_SUNPROC)
1889 # pragma error_messages(off,E_END_OF_LOOP_CODE_NOT_REACHED)
1890 # pragma error_messages(off,E_LOOP_NOT_ENTERED_AT_TOP)
1893 #if defined(__LZO_MMODEL_HUGE) && (!LZO_HAVE_MM_HUGE_PTR)
1894 # error "this should not happen - check defines for __huge"
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
1903 # include <string.h>
1905 # define ACC_WANT_ACC_INCD_H 1
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)))
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
1931 # define lzo_uintptr_t size_t
1934 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uintptr_t
) >= sizeof(lzo_voidp
))
1936 #if 1 && !defined(LZO_CFG_FREESTANDING)
1937 #if 1 && !defined(HAVE_STRING_H)
1938 #define HAVE_STRING_H 1
1940 #if 1 && !defined(HAVE_MEMCMP)
1941 #define HAVE_MEMCMP 1
1943 #if 1 && !defined(HAVE_MEMCPY)
1944 #define HAVE_MEMCPY 1
1946 #if 1 && !defined(HAVE_MEMMOVE)
1947 #define HAVE_MEMMOVE 1
1949 #if 1 && !defined(HAVE_MEMSET)
1950 #define HAVE_MEMSET 1
1954 #if 1 && defined(HAVE_STRING_H)
1958 #if defined(LZO_CFG_FREESTANDING)
1961 # undef HAVE_MEMMOVE
1965 #if !defined(HAVE_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)
1971 #if !defined(HAVE_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)
1977 #if !defined(HAVE_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)
1983 #if !defined(HAVE_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)
1991 #if defined(LZO_CFG_FREESTANDING)
1995 # define assert(e) ((void)0)
1997 # if !defined(LZO_DEBUG)
2000 # define assert(e) ((void)0)
2003 #if 0 && defined(__BOUNDS_CHECKING_ON)
2004 # include <unchecked.h>
2006 # define BOUNDS_CHECKING_OFF_DURING(stmt) stmt
2007 # define BOUNDS_CHECKING_OFF_IN_EXPR(expr) (expr)
2010 #if !defined(__lzo_inline)
2011 # define __lzo_inline
2013 #if !defined(__lzo_forceinline)
2014 # define __lzo_forceinline
2016 #if !defined(__lzo_noinline)
2017 # define __lzo_noinline
2021 # define LZO_BYTE(x) ((unsigned char) (x))
2023 # define LZO_BYTE(x) ((unsigned char) ((x) & 0xff))
2026 #define LZO_MAX(a,b) ((a) >= (b) ? (a) : (b))
2027 #define LZO_MIN(a,b) ((a) <= (b) ? (a) : (b))
2028 #define LZO_MAX3(a,b,c) ((a) >= (b) ? LZO_MAX(a,c) : LZO_MAX(b,c))
2029 #define LZO_MIN3(a,b,c) ((a) <= (b) ? LZO_MIN(a,c) : LZO_MIN(b,c))
2031 #define lzo_sizeof(type) ((lzo_uint) (sizeof(type)))
2033 #define LZO_HIGH(array) ((lzo_uint) (sizeof(array)/sizeof(*(array))))
2035 #define LZO_SIZE(bits) (1u << (bits))
2036 #define LZO_MASK(bits) (LZO_SIZE(bits) - 1)
2038 #define LZO_LSIZE(bits) (1ul << (bits))
2039 #define LZO_LMASK(bits) (LZO_LSIZE(bits) - 1)
2041 #define LZO_USIZE(bits) ((lzo_uint) 1 << (bits))
2042 #define LZO_UMASK(bits) (LZO_USIZE(bits) - 1)
2047 # define DMUL(a,b) ((lzo_xint) ((lzo_uint32)(a) * (lzo_uint32)(b)))
2049 # define DMUL(a,b) ((lzo_xint) ((a) * (b)))
2053 #if 1 && !defined(LZO_CFG_NO_UNALIGNED)
2054 #if 1 && (LZO_ARCH_AMD64 || LZO_ARCH_I386)
2055 # if (LZO_SIZEOF_SHORT == 2)
2056 # define LZO_UNALIGNED_OK_2
2058 # if (LZO_SIZEOF_INT == 4)
2059 # define LZO_UNALIGNED_OK_4
2064 #if defined(LZO_UNALIGNED_OK_2)
2065 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(short) == 2)
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)
2073 #define MEMCPY8_DS(dest,src,len) \
2074 lzo_memcpy(dest,src,len); dest += len; src += len
2076 #define BZERO8_PTR(s,l,n) \
2077 lzo_memset((lzo_voidp)(s),0,(lzo_uint)(l)*(n))
2079 #define MEMCPY_DS(dest,src,len) \
2080 do *dest++ = *src++; while (--len > 0)
2082 __LZO_EXTERN_C
int __lzo_init_done
;
2083 __LZO_EXTERN_C
const char __lzo_copyright
[];
2084 LZO_EXTERN(const lzo_bytep
) lzo_copyright(void);
2093 #if !defined(lzo_uintptr_t)
2094 # if defined(__LZO_MMODEL_HUGE)
2095 # define lzo_uintptr_t unsigned long
2097 # define lzo_uintptr_t acc_uintptr_t
2098 # ifdef __ACC_INTPTR_T_IS_POINTER
2099 # define __LZO_UINTPTR_T_IS_POINTER 1
2105 #define PTR(a) ((lzo_bytep) (a))
2106 #define PTR_ALIGNED_4(a) ((ACC_PTR_FP_OFF(a) & 3) == 0)
2107 #define PTR_ALIGNED2_4(a,b) (((ACC_PTR_FP_OFF(a) | ACC_PTR_FP_OFF(b)) & 3) == 0)
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)
2113 #define PTR(a) ((lzo_uintptr_t) (a))
2114 #define PTR_LINEAR(a) PTR(a)
2115 #define PTR_ALIGNED_4(a) ((PTR_LINEAR(a) & 3) == 0)
2116 #define PTR_ALIGNED_8(a) ((PTR_LINEAR(a) & 7) == 0)
2117 #define PTR_ALIGNED2_4(a,b) (((PTR_LINEAR(a) | PTR_LINEAR(b)) & 3) == 0)
2118 #define PTR_ALIGNED2_8(a,b) (((PTR_LINEAR(a) | PTR_LINEAR(b)) & 7) == 0)
2121 #define PTR_LT(a,b) (PTR(a) < PTR(b))
2122 #define PTR_GE(a,b) (PTR(a) >= PTR(b))
2123 #define PTR_DIFF(a,b) (PTR(a) - PTR(b))
2124 #define pd(a,b) ((lzo_uint) ((a)-(b)))
2126 LZO_EXTERN(lzo_uintptr_t
)
2127 __lzo_ptr_linear(const lzo_voidp ptr
);
2132 unsigned char a_uchar
;
2134 unsigned short a_ushort
;
2136 unsigned int a_uint
;
2138 unsigned long a_ulong
;
2140 lzo_uint a_lzo_uint
;
2141 lzo_int32 a_lzo_int32
;
2142 lzo_uint32 a_lzo_uint32
;
2143 ptrdiff_t a_ptrdiff_t
;
2144 lzo_uintptr_t a_lzo_uintptr_t
;
2145 lzo_voidp a_lzo_voidp
;
2147 lzo_bytep a_lzo_bytep
;
2148 lzo_bytepp a_lzo_bytepp
;
2149 lzo_uintp a_lzo_uintp
;
2150 lzo_uint
* a_lzo_uint_p
;
2151 lzo_uint32p a_lzo_uint32p
;
2152 lzo_uint32
* a_lzo_uint32_p
;
2153 unsigned char * a_uchar_p
;
2164 #define LZO_DETERMINISTIC
2166 #define LZO_DICT_USE_PTR
2167 #if 0 && (LZO_ARCH_I086)
2168 # undef LZO_DICT_USE_PTR
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 *
2175 # define lzo_dict_t lzo_uint
2176 # define lzo_dict_p lzo_dict_t __LZO_MMODEL *
2181 #if !defined(MINILZO_CFG_SKIP_LZO_PTR)
2183 LZO_PUBLIC(lzo_uintptr_t
)
2184 __lzo_ptr_linear(const lzo_voidp ptr
)
2189 p
= (((lzo_uintptr_t
)(ACC_PTR_FP_SEG(ptr
))) << (16 - ACC_MM_AHSHIFT
)) + (ACC_PTR_FP_OFF(ptr
));
2191 p
= (lzo_uintptr_t
) (ptr
);
2192 p
= (p
<< 3) | (p
>> 61);
2194 p
= (lzo_uintptr_t
) PTR_LINEAR(ptr
);
2200 LZO_PUBLIC(unsigned)
2201 __lzo_align_gap(const lzo_voidp ptr
, lzo_uint size
)
2203 #if defined(__LZO_UINTPTR_T_IS_POINTER)
2204 size_t n
= (size_t) ptr
;
2205 n
= (((n
+ size
- 1) / size
) * size
) - n
;
2208 p
= __lzo_ptr_linear(ptr
);
2209 n
= (((p
+ size
- 1) / size
) * size
) - p
;
2213 assert((long)n
>= 0);
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.
2224 const char __lzo_copyright
[] =
2225 #if !defined(__LZO_IN_MINLZO)
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";
2238 LZO_PUBLIC(const lzo_bytep
)
2241 #if (LZO_OS_DOS16 && LZO_CC_TURBOC)
2242 return (lzo_voidp
) __lzo_copyright
;
2244 return (const lzo_bytep
) __lzo_copyright
;
2248 LZO_PUBLIC(unsigned)
2254 LZO_PUBLIC(const char *)
2255 lzo_version_string(void)
2257 return LZO_VERSION_STRING
;
2260 LZO_PUBLIC(const char *)
2261 lzo_version_date(void)
2263 return LZO_VERSION_DATE
;
2266 LZO_PUBLIC(const lzo_charp
)
2267 _lzo_version_string(void)
2269 return LZO_VERSION_STRING
;
2272 LZO_PUBLIC(const lzo_charp
)
2273 _lzo_version_date(void)
2275 return LZO_VERSION_DATE
;
2278 #define LZO_BASE 65521u
2279 #define LZO_NMAX 5552
2281 #define LZO_DO1(buf,i) s1 += buf[i]; s2 += s1
2282 #define LZO_DO2(buf,i) LZO_DO1(buf,i); LZO_DO1(buf,i+1);
2283 #define LZO_DO4(buf,i) LZO_DO2(buf,i); LZO_DO2(buf,i+2);
2284 #define LZO_DO8(buf,i) LZO_DO4(buf,i); LZO_DO4(buf,i+4);
2285 #define LZO_DO16(buf,i) LZO_DO8(buf,i); LZO_DO8(buf,i+8);
2287 LZO_PUBLIC(lzo_uint32
)
2288 lzo_adler32(lzo_uint32 adler
, const lzo_bytep buf
, lzo_uint len
)
2290 lzo_uint32 s1
= adler
& 0xffff;
2291 lzo_uint32 s2
= (adler
>> 16) & 0xffff;
2299 k
= len
< LZO_NMAX
? (unsigned) len
: LZO_NMAX
;
2315 return (s2
<< 16) | s1
;
2324 #if !defined(MINILZO_CFG_SKIP_LZO_STRING)
2329 #if !defined(__LZO_MMODEL_HUGE)
2330 # undef LZO_HAVE_MM_HUGE_PTR
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)
2344 LZOLIB_PUBLIC(int, lzo_hmemcmp
) (const lzo_hvoid_p s1
, const lzo_hvoid_p s2
, lzo_hsize_t len
)
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
2355 } while __lzo_likely(--len
> 0);
2358 return memcmp(s1
, s2
, len
);
2361 LZOLIB_PUBLIC(lzo_hvoid_p
, lzo_hmemcpy
) (lzo_hvoid_p dest
, const lzo_hvoid_p src
, lzo_hsize_t len
)
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
)
2370 while __lzo_likely(--len
> 0);
2373 return memcpy(dest
, src
, len
);
2376 LZOLIB_PUBLIC(lzo_hvoid_p
, lzo_hmemmove
) (lzo_hvoid_p dest
, const lzo_hvoid_p src
, lzo_hsize_t len
)
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
)
2387 while __lzo_likely(--len
> 0);
2395 while __lzo_likely(--len
> 0);
2399 return memmove(dest
, src
, len
);
2402 LZOLIB_PUBLIC(lzo_hvoid_p
, lzo_hmemset
) (lzo_hvoid_p s
, int c
, lzo_hsize_t len
)
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);
2411 return memset(s
, c
, len
);
2414 #undef LZOLIB_PUBLIC
2417 #if !defined(__LZO_IN_MINILZO)
2419 #define ACC_WANT_ACC_CHK_CH 1
2420 #undef ACCCHK_ASSERT
2422 ACCCHK_ASSERT_IS_SIGNED_T(lzo_int
)
2423 ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uint
)
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)
2430 #if !defined(__LZO_UINTPTR_T_IS_POINTER)
2431 ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uintptr_t
)
2433 ACCCHK_ASSERT(sizeof(lzo_uintptr_t
) >= sizeof(lzo_voidp
))
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
))
2441 #undef ACCCHK_ASSERT
2444 _lzo_config_check(void)
2447 union { unsigned char c
[2*sizeof(lzo_xint
)]; lzo_xint l
[2]; } u
;
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);
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);
2459 #if defined(LZO_UNALIGNED_OK_2)
2460 p
= (lzo_uintptr_t
) (const lzo_voidp
) &u
.c
[0];
2461 u
.l
[0] = u
.l
[1] = 0;
2462 r
&= ((* (const lzo_ushortp
) (p
+1)) == 0);
2464 #if defined(LZO_UNALIGNED_OK_4)
2465 p
= (lzo_uintptr_t
) (const lzo_voidp
) &u
.c
[0];
2466 u
.l
[0] = u
.l
[1] = 0;
2467 r
&= ((* (const lzo_uint32p
) (p
+1)) == 0);
2471 LZO_UNUSED(u
); LZO_UNUSED(p
);
2472 return r
== 1 ? LZO_E_OK
: LZO_E_ERROR
;
2475 int __lzo_init_done
= 0;
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
)
2483 #if defined(__LZO_IN_MINILZO)
2484 #elif (LZO_CC_MSC && ((_MSC_VER) < 700))
2486 #define ACC_WANT_ACC_CHK_CH 1
2487 #undef ACCCHK_ASSERT
2488 #define ACCCHK_ASSERT(expr) LZO_COMPILE_TIME_ASSERT(expr)
2490 #undef ACCCHK_ASSERT
2492 __lzo_init_done
= 1;
2497 r
= (s1
== -1 || s1
== (int) sizeof(short)) &&
2498 (s2
== -1 || s2
== (int) sizeof(int)) &&
2499 (s3
== -1 || s3
== (int) sizeof(long)) &&
2500 (s4
== -1 || s4
== (int) sizeof(lzo_uint32
)) &&
2501 (s5
== -1 || s5
== (int) sizeof(lzo_uint
)) &&
2502 (s6
== -1 || s6
== (int) lzo_sizeof_dict_t
) &&
2503 (s7
== -1 || s7
== (int) sizeof(char *)) &&
2504 (s8
== -1 || s8
== (int) sizeof(lzo_voidp
)) &&
2505 (s9
== -1 || s9
== (int) sizeof(lzo_callback_t
));
2509 r
= _lzo_config_check();
2516 #if !defined(__LZO_IN_MINILZO)
2518 #if (LZO_OS_WIN16 && LZO_CC_WATCOMC) && defined(__SW_BD)
2521 BOOL FAR PASCAL
LibMain ( HANDLE hInstance
, WORD wDataSegment
,
2522 WORD wHeapSize
, LPSTR lpszCmdLine
)
2524 int __far __pascal
LibMain ( int a
, short b
, short c
, long d
)
2527 LZO_UNUSED(a
); LZO_UNUSED(b
); LZO_UNUSED(c
); LZO_UNUSED(d
);
2535 #define do_compress _lzo1x_1_do_compress
2537 #if !defined(MINILZO_CFG_SKIP_LZO1X_1_COMPRESS)
2539 #define LZO_NEED_DICT_H
2541 #define D_INDEX1(d,p) d = DM(DMUL(0x21,DX3(p,5,5,6)) >> 5)
2542 #define D_INDEX2(d,p) d = (d & (D_MASK & 0x7ff)) ^ (D_HIGH | 0x1f)
2544 #ifndef __LZO_CONFIG1X_H
2545 #define __LZO_CONFIG1X_H
2547 #if !defined(LZO1X) && !defined(LZO1Y) && !defined(LZO1Z)
2551 #if !defined(__LZO_IN_MINILZO)
2552 #include "lzo/lzo1x.h"
2555 #define LZO_EOF_CODE
2556 #undef LZO_DETERMINISTIC
2558 #define M1_MAX_OFFSET 0x0400
2559 #ifndef M2_MAX_OFFSET
2560 #define M2_MAX_OFFSET 0x0800
2562 #define M3_MAX_OFFSET 0x4000
2563 #define M4_MAX_OFFSET 0xbfff
2565 #define MX_MAX_OFFSET (M1_MAX_OFFSET + M2_MAX_OFFSET)
2567 #define M1_MIN_LEN 2
2568 #define M1_MAX_LEN 2
2569 #define M2_MIN_LEN 3
2571 #define M2_MAX_LEN 8
2573 #define M3_MIN_LEN 3
2574 #define M3_MAX_LEN 33
2575 #define M4_MIN_LEN 3
2576 #define M4_MAX_LEN 9
2579 #define M2_MARKER 64
2580 #define M3_MARKER 32
2581 #define M4_MARKER 16
2583 #ifndef MIN_LOOKAHEAD
2584 #define MIN_LOOKAHEAD (M2_MAX_LEN + 1)
2587 #if defined(LZO_NEED_DICT_H)
2590 #define LZO_HASH LZO_HASH_LZO_INCREMENTAL_B
2592 #define DL_MIN_LEN M2_MIN_LEN
2594 #ifndef __LZO_DICT_H
2595 #define __LZO_DICT_H
2601 #if !defined(D_BITS) && defined(DBITS)
2602 # define D_BITS DBITS
2604 #if !defined(D_BITS)
2605 # error "D_BITS is not defined"
2608 # define D_SIZE LZO_SIZE(D_BITS)
2609 # define D_MASK LZO_MASK(D_BITS)
2611 # define D_SIZE LZO_USIZE(D_BITS)
2612 # define D_MASK LZO_UMASK(D_BITS)
2614 #define D_HIGH ((D_MASK >> 1) + 1)
2616 #if !defined(DD_BITS)
2619 #define DD_SIZE LZO_SIZE(DD_BITS)
2620 #define DD_MASK LZO_MASK(DD_BITS)
2622 #if !defined(DL_BITS)
2623 # define DL_BITS (D_BITS - DD_BITS)
2626 # define DL_SIZE LZO_SIZE(DL_BITS)
2627 # define DL_MASK LZO_MASK(DL_BITS)
2629 # define DL_SIZE LZO_USIZE(DL_BITS)
2630 # define DL_MASK LZO_UMASK(DL_BITS)
2633 #if (D_BITS != DL_BITS + DD_BITS)
2634 # error "D_BITS does not match"
2636 #if (D_BITS < 8 || D_BITS > 18)
2637 # error "invalid D_BITS"
2639 #if (DL_BITS < 8 || DL_BITS > 20)
2640 # error "invalid DL_BITS"
2642 #if (DD_BITS < 0 || DD_BITS > 6)
2643 # error "invalid DD_BITS"
2646 #if !defined(DL_MIN_LEN)
2647 # define DL_MIN_LEN 3
2649 #if !defined(DL_SHIFT)
2650 # define DL_SHIFT ((DL_BITS + (DL_MIN_LEN - 1)) / DL_MIN_LEN)
2653 #define LZO_HASH_GZIP 1
2654 #define LZO_HASH_GZIP_INCREMENTAL 2
2655 #define LZO_HASH_LZO_INCREMENTAL_A 3
2656 #define LZO_HASH_LZO_INCREMENTAL_B 4
2658 #if !defined(LZO_HASH)
2659 # error "choose a hashing strategy"
2665 #if (DL_MIN_LEN == 3)
2666 # define _DV2_A(p,shift1,shift2) \
2667 (((( (lzo_xint)((p)[0]) << shift1) ^ (p)[1]) << shift2) ^ (p)[2])
2668 # define _DV2_B(p,shift1,shift2) \
2669 (((( (lzo_xint)((p)[2]) << shift1) ^ (p)[1]) << shift2) ^ (p)[0])
2670 # define _DV3_B(p,shift1,shift2,shift3) \
2671 ((_DV2_B((p)+1,shift1,shift2) << (shift3)) ^ (p)[0])
2672 #elif (DL_MIN_LEN == 2)
2673 # define _DV2_A(p,shift1,shift2) \
2674 (( (lzo_xint)(p[0]) << shift1) ^ p[1])
2675 # define _DV2_B(p,shift1,shift2) \
2676 (( (lzo_xint)(p[1]) << shift1) ^ p[2])
2678 # error "invalid DL_MIN_LEN"
2680 #define _DV_A(p,shift) _DV2_A(p,shift,shift)
2681 #define _DV_B(p,shift) _DV2_B(p,shift,shift)
2682 #define DA2(p,s1,s2) \
2683 (((((lzo_xint)((p)[2]) << (s2)) + (p)[1]) << (s1)) + (p)[0])
2684 #define DS2(p,s1,s2) \
2685 (((((lzo_xint)((p)[2]) << (s2)) - (p)[1]) << (s1)) - (p)[0])
2686 #define DX2(p,s1,s2) \
2687 (((((lzo_xint)((p)[2]) << (s2)) ^ (p)[1]) << (s1)) ^ (p)[0])
2688 #define DA3(p,s1,s2,s3) ((DA2((p)+1,s2,s3) << (s1)) + (p)[0])
2689 #define DS3(p,s1,s2,s3) ((DS2((p)+1,s2,s3) << (s1)) - (p)[0])
2690 #define DX3(p,s1,s2,s3) ((DX2((p)+1,s2,s3) << (s1)) ^ (p)[0])
2691 #define DMS(v,s) ((lzo_uint) (((v) & (D_MASK >> (s))) << (s)))
2692 #define DM(v) DMS(v,0)
2694 #if (LZO_HASH == LZO_HASH_GZIP)
2695 # define _DINDEX(dv,p) (_DV_A((p),DL_SHIFT))
2697 #elif (LZO_HASH == LZO_HASH_GZIP_INCREMENTAL)
2698 # define __LZO_HASH_INCREMENTAL
2699 # define DVAL_FIRST(dv,p) dv = _DV_A((p),DL_SHIFT)
2700 # define DVAL_NEXT(dv,p) dv = (((dv) << DL_SHIFT) ^ p[2])
2701 # define _DINDEX(dv,p) (dv)
2702 # define DVAL_LOOKAHEAD DL_MIN_LEN
2704 #elif (LZO_HASH == LZO_HASH_LZO_INCREMENTAL_A)
2705 # define __LZO_HASH_INCREMENTAL
2706 # define DVAL_FIRST(dv,p) dv = _DV_A((p),5)
2707 # define DVAL_NEXT(dv,p) \
2708 dv ^= (lzo_xint)(p[-1]) << (2*5); dv = (((dv) << 5) ^ p[2])
2709 # define _DINDEX(dv,p) ((DMUL(0x9f5f,dv)) >> 5)
2710 # define DVAL_LOOKAHEAD DL_MIN_LEN
2712 #elif (LZO_HASH == LZO_HASH_LZO_INCREMENTAL_B)
2713 # define __LZO_HASH_INCREMENTAL
2714 # define DVAL_FIRST(dv,p) dv = _DV_B((p),5)
2715 # define DVAL_NEXT(dv,p) \
2716 dv ^= p[-1]; dv = (((dv) >> 5) ^ ((lzo_xint)(p[2]) << (2*5)))
2717 # define _DINDEX(dv,p) ((DMUL(0x9f5f,dv)) >> 5)
2718 # define DVAL_LOOKAHEAD DL_MIN_LEN
2721 # error "choose a hashing strategy"
2725 #define DINDEX(dv,p) ((lzo_uint)((_DINDEX(dv,p)) & DL_MASK) << DD_BITS)
2727 #if !defined(DINDEX1) && defined(D_INDEX1)
2728 #define DINDEX1 D_INDEX1
2730 #if !defined(DINDEX2) && defined(D_INDEX2)
2731 #define DINDEX2 D_INDEX2
2734 #if !defined(__LZO_HASH_INCREMENTAL)
2735 # define DVAL_FIRST(dv,p) ((void) 0)
2736 # define DVAL_NEXT(dv,p) ((void) 0)
2737 # define DVAL_LOOKAHEAD 0
2740 #if !defined(DVAL_ASSERT)
2741 #if defined(__LZO_HASH_INCREMENTAL) && !defined(NDEBUG)
2742 static void DVAL_ASSERT(lzo_xint dv
, const lzo_bytep p
)
2746 assert(DINDEX(dv
,p
) == DINDEX(df
,p
));
2749 # define DVAL_ASSERT(dv,p) ((void) 0)
2753 #if defined(LZO_DICT_USE_PTR)
2754 # define DENTRY(p,in) (p)
2755 # define GINDEX(m_pos,m_off,dict,dindex,in) m_pos = dict[dindex]
2757 # define DENTRY(p,in) ((lzo_uint) ((p)-(in)))
2758 # define GINDEX(m_pos,m_off,dict,dindex,in) m_off = dict[dindex]
2763 # define UPDATE_D(dict,drun,dv,p,in) dict[ DINDEX(dv,p) ] = DENTRY(p,in)
2764 # define UPDATE_I(dict,drun,index,p,in) dict[index] = DENTRY(p,in)
2765 # define UPDATE_P(ptr,drun,p,in) (ptr)[0] = DENTRY(p,in)
2769 # define UPDATE_D(dict,drun,dv,p,in) \
2770 dict[ DINDEX(dv,p) + drun++ ] = DENTRY(p,in); drun &= DD_MASK
2771 # define UPDATE_I(dict,drun,index,p,in) \
2772 dict[ (index) + drun++ ] = DENTRY(p,in); drun &= DD_MASK
2773 # define UPDATE_P(ptr,drun,p,in) \
2774 (ptr) [ drun++ ] = DENTRY(p,in); drun &= DD_MASK
2778 #if defined(LZO_DICT_USE_PTR)
2780 #define LZO_CHECK_MPOS_DET(m_pos,m_off,in,ip,max_offset) \
2781 (m_pos == NULL || (m_off = pd(ip, m_pos)) > max_offset)
2783 #define LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,max_offset) \
2784 (BOUNDS_CHECKING_OFF_IN_EXPR(( \
2785 m_pos = ip - (lzo_uint) PTR_DIFF(ip,m_pos), \
2786 PTR_LT(m_pos,in) || \
2787 (m_off = (lzo_uint) PTR_DIFF(ip,m_pos)) <= 0 || \
2788 m_off > max_offset )))
2792 #define LZO_CHECK_MPOS_DET(m_pos,m_off,in,ip,max_offset) \
2794 ((m_off = pd(ip, in) - m_off) > max_offset) || \
2795 (m_pos = (ip) - (m_off), 0) )
2797 #define LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,max_offset) \
2798 (pd(ip, in) <= m_off || \
2799 ((m_off = pd(ip, in) - m_off) > max_offset) || \
2800 (m_pos = (ip) - (m_off), 0) )
2804 #if defined(LZO_DETERMINISTIC)
2805 # define LZO_CHECK_MPOS LZO_CHECK_MPOS_DET
2807 # define LZO_CHECK_MPOS LZO_CHECK_MPOS_NON_DET
2820 #define DO_COMPRESS lzo1x_1_compress
2822 static __lzo_noinline lzo_uint
2823 do_compress ( const lzo_bytep in
, lzo_uint in_len
,
2824 lzo_bytep out
, lzo_uintp out_len
,
2827 register const lzo_bytep ip
;
2829 const lzo_bytep
const in_end
= in
+ in_len
;
2830 const lzo_bytep
const ip_end
= in
+ in_len
- M2_MAX_LEN
- 5;
2832 lzo_dict_p
const dict
= (lzo_dict_p
) wrkmem
;
2841 register const lzo_bytep m_pos
;
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
))
2851 if (m_off
<= M2_MAX_OFFSET
|| m_pos
[3] == ip
[3])
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
))
2858 if (m_off
<= M2_MAX_OFFSET
|| m_pos
[3] == ip
[3])
2863 #if 1 && defined(LZO_UNALIGNED_OK_2)
2864 if (* (const lzo_ushortp
) m_pos
!= * (const lzo_ushortp
) ip
)
2866 if (m_pos
[0] != ip
[0] || m_pos
[1] != ip
[1])
2872 if __lzo_likely(m_pos
[2] == ip
[2])
2875 if (m_off
<= M2_MAX_OFFSET
)
2881 assert(op
- 2 > out
); op
[-2] |= LZO_BYTE(3);
2882 *op
++ = *ii
++; *op
++ = *ii
++; *op
++ = *ii
++;
2885 if (m_pos
[3] == ip
[3])
2893 if (m_off
<= M1_MAX_OFFSET
&& lit
> 0 && lit
<= 3)
2895 if (m_off
<= M1_MAX_OFFSET
&& lit
== 3)
2898 register lzo_uint t
;
2901 assert(op
- 2 > out
); op
[-2] |= LZO_BYTE(t
);
2902 do *op
++ = *ii
++; while (--t
> 0);
2905 *op
++ = LZO_BYTE(M1_MARKER
| ((m_off
& 3) << 2));
2906 *op
++ = LZO_BYTE(m_off
>> 2);
2915 UPDATE_I(dict
,0,dindex
,ip
,in
);
2917 if __lzo_unlikely(ip
>= ip_end
)
2922 UPDATE_I(dict
,0,dindex
,ip
,in
);
2925 register lzo_uint t
= pd(ip
,ii
);
2929 assert(op
- 2 > out
);
2930 op
[-2] |= LZO_BYTE(t
);
2933 *op
++ = LZO_BYTE(t
- 3);
2936 register lzo_uint tt
= t
- 18;
2945 *op
++ = LZO_BYTE(tt
);
2947 do *op
++ = *ii
++; while (--t
> 0);
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
++
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
++
2962 assert(m_len
>= 3); assert(m_len
<= M2_MAX_LEN
);
2964 if (m_off
<= M2_MAX_OFFSET
)
2968 *op
++ = LZO_BYTE(((m_len
- 1) << 5) | ((m_off
& 7) << 2));
2969 *op
++ = LZO_BYTE(m_off
>> 3);
2970 #elif defined(LZO1Y)
2971 *op
++ = LZO_BYTE(((m_len
+ 1) << 4) | ((m_off
& 3) << 2));
2972 *op
++ = LZO_BYTE(m_off
>> 2);
2975 else if (m_off
<= M3_MAX_OFFSET
)
2978 *op
++ = LZO_BYTE(M3_MARKER
| (m_len
- 2));
2985 assert(m_off
> 0); assert(m_off
<= 0x7fff);
2986 *op
++ = LZO_BYTE(M4_MARKER
|
2987 ((m_off
& 0x4000) >> 11) | (m_len
- 2));
2990 #elif defined(LZO1Y)
2997 const lzo_bytep end
= in_end
;
2998 const lzo_bytep m
= m_pos
+ M2_MAX_LEN
+ 1;
2999 while (ip
< end
&& *m
== *ip
)
3003 assert(m_len
> M2_MAX_LEN
);
3005 if (m_off
<= M3_MAX_OFFSET
)
3009 *op
++ = LZO_BYTE(M3_MARKER
| (m_len
- 2));
3013 *op
++ = M3_MARKER
| 0;
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));
3029 m_len
-= M4_MAX_LEN
;
3030 *op
++ = LZO_BYTE(M4_MARKER
| ((m_off
& 0x4000) >> 11));
3038 *op
++ = LZO_BYTE(m_len
);
3043 *op
++ = LZO_BYTE((m_off
& 63) << 2);
3044 *op
++ = LZO_BYTE(m_off
>> 6);
3051 if __lzo_unlikely(ip
>= ip_end
)
3055 *out_len
= pd(op
, out
);
3056 return pd(in_end
,ii
);
3060 DO_COMPRESS ( const lzo_bytep in
, lzo_uint in_len
,
3061 lzo_bytep out
, lzo_uintp out_len
,
3067 if __lzo_unlikely(in_len
<= M2_MAX_LEN
+ 5)
3071 t
= do_compress(in
,in_len
,op
,out_len
,wrkmem
);
3077 const lzo_bytep ii
= in
+ in_len
- t
;
3079 if (op
== out
&& t
<= 238)
3080 *op
++ = LZO_BYTE(17 + t
);
3082 op
[-2] |= LZO_BYTE(t
);
3084 *op
++ = LZO_BYTE(t
- 3);
3087 lzo_uint tt
= t
- 18;
3096 *op
++ = LZO_BYTE(tt
);
3098 do *op
++ = *ii
++; while (--t
> 0);
3101 *op
++ = M4_MARKER
| 1;
3105 *out_len
= pd(op
, out
);
3115 #undef LZO_TEST_OVERRUN
3116 #undef DO_DECOMPRESS
3117 #define DO_DECOMPRESS lzo1x_decompress
3119 #if !defined(MINILZO_CFG_SKIP_LZO1X_DECOMPRESS)
3121 #if defined(LZO_TEST_OVERRUN)
3122 # if !defined(LZO_TEST_OVERRUN_INPUT)
3123 # define LZO_TEST_OVERRUN_INPUT 2
3125 # if !defined(LZO_TEST_OVERRUN_OUTPUT)
3126 # define LZO_TEST_OVERRUN_OUTPUT 2
3128 # if !defined(LZO_TEST_OVERRUN_LOOKBEHIND)
3129 # define LZO_TEST_OVERRUN_LOOKBEHIND
3146 #if defined(LZO_TEST_OVERRUN_INPUT)
3147 # if (LZO_TEST_OVERRUN_INPUT >= 1)
3148 # define TEST_IP (ip < ip_end)
3150 # if (LZO_TEST_OVERRUN_INPUT >= 2)
3151 # define NEED_IP(x) \
3152 if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x)) goto input_overrun
3156 #if defined(LZO_TEST_OVERRUN_OUTPUT)
3157 # if (LZO_TEST_OVERRUN_OUTPUT >= 1)
3158 # define TEST_OP (op <= op_end)
3160 # if (LZO_TEST_OVERRUN_OUTPUT >= 2)
3162 # define NEED_OP(x) \
3163 if ((lzo_uint)(op_end - op) < (lzo_uint)(x)) goto output_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
3171 # define TEST_LB(m_pos) ((void) 0)
3172 # define TEST_LBO(m_pos,o) ((void) 0)
3175 #if !defined(LZO_EOF_CODE) && !defined(TEST_IP)
3176 # define TEST_IP (ip < ip_end)
3179 #if defined(TEST_IP)
3180 # define HAVE_TEST_IP
3184 #if defined(TEST_OP)
3185 # define HAVE_TEST_OP
3190 #if defined(NEED_IP)
3191 # define HAVE_NEED_IP
3193 # define NEED_IP(x) ((void) 0)
3195 #if defined(NEED_OP)
3196 # define HAVE_NEED_OP
3198 # define NEED_OP(x) ((void) 0)
3201 #if defined(HAVE_TEST_IP) || defined(HAVE_NEED_IP)
3202 # define HAVE_ANY_IP
3204 #if defined(HAVE_TEST_OP) || defined(HAVE_NEED_OP)
3205 # define HAVE_ANY_OP
3209 #define __COPY4(dst,src) * (lzo_uint32p)(dst) = * (const lzo_uint32p)(src)
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))
3218 #if defined(DO_DECOMPRESS)
3220 DO_DECOMPRESS ( const lzo_bytep in
, lzo_uint in_len
,
3221 lzo_bytep out
, lzo_uintp out_len
,
3225 register lzo_bytep op
;
3226 register const lzo_bytep ip
;
3227 register lzo_uint t
;
3228 #if defined(COPY_DICT)
3230 const lzo_bytep dict_end
;
3232 register const lzo_bytep m_pos
;
3235 const lzo_bytep
const ip_end
= in
+ in_len
;
3236 #if defined(HAVE_ANY_OP)
3237 lzo_bytep
const op_end
= out
+ *out_len
;
3240 lzo_uint last_m_off
= 0;
3245 #if defined(COPY_DICT)
3248 if (dict_len
> M4_MAX_OFFSET
)
3250 dict
+= dict_len
- M4_MAX_OFFSET
;
3251 dict_len
= M4_MAX_OFFSET
;
3253 dict_end
= dict
+ dict_len
;
3272 assert(t
> 0); NEED_OP(t
); NEED_IP(t
+1);
3273 do *op
++ = *ip
++; while (--t
> 0);
3274 goto first_literal_run
;
3277 while (TEST_IP
&& TEST_OP
)
3293 assert(t
> 0); NEED_OP(t
+3); NEED_IP(t
+4);
3294 #if defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
3295 #if !defined(LZO_UNALIGNED_OK_4)
3296 if (PTR_ALIGNED2_4(op
,ip
))
3307 op
+= 4; ip
+= 4; t
-= 4;
3309 if (t
> 0) do *op
++ = *ip
++; while (--t
> 0);
3312 do *op
++ = *ip
++; while (--t
> 0);
3314 #if !defined(LZO_UNALIGNED_OK_4)
3319 #if !defined(LZO_UNALIGNED_OK_4)
3321 *op
++ = *ip
++; *op
++ = *ip
++; *op
++ = *ip
++;
3322 do *op
++ = *ip
++; while (--t
> 0);
3331 #if defined(COPY_DICT)
3333 m_off
= (1 + M2_MAX_OFFSET
) + (t
<< 6) + (*ip
++ >> 2);
3336 m_off
= (1 + M2_MAX_OFFSET
) + (t
>> 2) + (*ip
++ << 2);
3339 t
= 3; COPY_DICT(t
,m_off
)
3342 t
= (1 + M2_MAX_OFFSET
) + (t
<< 6) + (*ip
++ >> 2);
3346 m_pos
= op
- (1 + M2_MAX_OFFSET
);
3348 m_pos
-= *ip
++ << 2;
3350 TEST_LB(m_pos
); NEED_OP(3);
3351 *op
++ = *m_pos
++; *op
++ = *m_pos
++; *op
++ = *m_pos
;
3359 #if defined(COPY_DICT)
3361 m_off
= 1 + ((t
>> 2) & 7) + (*ip
++ << 3);
3363 #elif defined(LZO1Y)
3364 m_off
= 1 + ((t
>> 2) & 3) + (*ip
++ << 2);
3366 #elif defined(LZO1Z)
3372 m_off
= 1 + (m_off
<< 6) + (*ip
++ >> 2);
3380 m_pos
-= (t
>> 2) & 7;
3381 m_pos
-= *ip
++ << 3;
3383 #elif defined(LZO1Y)
3385 m_pos
-= (t
>> 2) & 3;
3386 m_pos
-= *ip
++ << 2;
3388 #elif defined(LZO1Z)
3390 lzo_uint off
= t
& 0x1f;
3394 assert(last_m_off
> 0);
3395 m_pos
-= last_m_off
;
3399 off
= 1 + (off
<< 6) + (*ip
++ >> 2);
3406 TEST_LB(m_pos
); assert(t
> 0); NEED_OP(t
+3-1);
3424 #if defined(COPY_DICT)
3426 m_off
= 1 + (ip
[0] << 6) + (ip
[1] >> 2);
3429 m_off
= 1 + (ip
[0] >> 2) + (ip
[1] << 6);
3434 lzo_uint off
= 1 + (ip
[0] << 6) + (ip
[1] >> 2);
3438 #elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN)
3440 m_pos
-= (* (const lzo_ushortp
) ip
) >> 2;
3443 m_pos
-= (ip
[0] >> 2) + (ip
[1] << 6);
3450 #if defined(COPY_DICT)
3451 m_off
= (t
& 8) << 11;
3454 m_pos
-= (t
& 8) << 11;
3468 #if defined(COPY_DICT)
3470 m_off
+= (ip
[0] << 6) + (ip
[1] >> 2);
3472 m_off
+= (ip
[0] >> 2) + (ip
[1] << 6);
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;
3487 m_pos
-= (ip
[0] >> 2) + (ip
[1] << 6);
3494 last_m_off
= pd((const lzo_bytep
)op
, m_pos
);
3500 #if defined(COPY_DICT)
3502 m_off
= 1 + (t
<< 6) + (*ip
++ >> 2);
3505 m_off
= 1 + (t
>> 2) + (*ip
++ << 2);
3508 t
= 2; COPY_DICT(t
,m_off
)
3511 t
= 1 + (t
<< 6) + (*ip
++ >> 2);
3517 m_pos
-= *ip
++ << 2;
3519 TEST_LB(m_pos
); NEED_OP(2);
3520 *op
++ = *m_pos
++; *op
++ = *m_pos
;
3525 #if defined(COPY_DICT)
3528 t
+= 3-1; COPY_DICT(t
,m_off
)
3532 TEST_LB(m_pos
); assert(t
> 0); NEED_OP(t
+3-1);
3533 #if defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
3534 #if !defined(LZO_UNALIGNED_OK_4)
3535 if (t
>= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op
,m_pos
))
3537 assert((op
- m_pos
) >= 4);
3539 if (t
>= 2 * 4 - (3 - 1) && (op
- m_pos
) >= 4)
3543 op
+= 4; m_pos
+= 4; t
-= 4 - (3 - 1);
3546 op
+= 4; m_pos
+= 4; t
-= 4;
3548 if (t
> 0) do *op
++ = *m_pos
++; while (--t
> 0);
3554 *op
++ = *m_pos
++; *op
++ = *m_pos
++;
3555 do *op
++ = *m_pos
++; while (--t
> 0);
3570 assert(t
> 0); assert(t
< 4); NEED_OP(t
); NEED_IP(t
+1);
3572 do *op
++ = *ip
++; while (--t
> 0);
3575 if (t
> 1) { *op
++ = *ip
++; if (t
> 2) { *op
++ = *ip
++; } }
3578 } while (TEST_IP
&& TEST_OP
);
3581 #if defined(HAVE_TEST_IP) || defined(HAVE_TEST_OP)
3582 *out_len
= pd(op
, out
);
3583 return LZO_E_EOF_NOT_FOUND
;
3588 *out_len
= pd(op
, out
);
3589 return (ip
== ip_end
? LZO_E_OK
:
3590 (ip
< ip_end
? LZO_E_INPUT_NOT_CONSUMED
: LZO_E_INPUT_OVERRUN
));
3592 #if defined(HAVE_NEED_IP)
3594 *out_len
= pd(op
, out
);
3595 return LZO_E_INPUT_OVERRUN
;
3598 #if defined(HAVE_NEED_OP)
3600 *out_len
= pd(op
, out
);
3601 return LZO_E_OUTPUT_OVERRUN
;
3604 #if defined(LZO_TEST_OVERRUN_LOOKBEHIND)
3606 *out_len
= pd(op
, out
);
3607 return LZO_E_LOOKBEHIND_OVERRUN
;
3613 #define LZO_TEST_OVERRUN
3614 #undef DO_DECOMPRESS
3615 #define DO_DECOMPRESS lzo1x_decompress_safe
3617 #if !defined(MINILZO_CFG_SKIP_LZO1X_DECOMPRESS_SAFE)
3619 #if defined(LZO_TEST_OVERRUN)
3620 # if !defined(LZO_TEST_OVERRUN_INPUT)
3621 # define LZO_TEST_OVERRUN_INPUT 2
3623 # if !defined(LZO_TEST_OVERRUN_OUTPUT)
3624 # define LZO_TEST_OVERRUN_OUTPUT 2
3626 # if !defined(LZO_TEST_OVERRUN_LOOKBEHIND)
3627 # define LZO_TEST_OVERRUN_LOOKBEHIND
3644 #if defined(LZO_TEST_OVERRUN_INPUT)
3645 # if (LZO_TEST_OVERRUN_INPUT >= 1)
3646 # define TEST_IP (ip < ip_end)
3648 # if (LZO_TEST_OVERRUN_INPUT >= 2)
3649 # define NEED_IP(x) \
3650 if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x)) goto input_overrun
3654 #if defined(LZO_TEST_OVERRUN_OUTPUT)
3655 # if (LZO_TEST_OVERRUN_OUTPUT >= 1)
3656 # define TEST_OP (op <= op_end)
3658 # if (LZO_TEST_OVERRUN_OUTPUT >= 2)
3660 # define NEED_OP(x) \
3661 if ((lzo_uint)(op_end - op) < (lzo_uint)(x)) goto output_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
3669 # define TEST_LB(m_pos) ((void) 0)
3670 # define TEST_LBO(m_pos,o) ((void) 0)
3673 #if !defined(LZO_EOF_CODE) && !defined(TEST_IP)
3674 # define TEST_IP (ip < ip_end)
3677 #if defined(TEST_IP)
3678 # define HAVE_TEST_IP
3682 #if defined(TEST_OP)
3683 # define HAVE_TEST_OP
3688 #if defined(NEED_IP)
3689 # define HAVE_NEED_IP
3691 # define NEED_IP(x) ((void) 0)
3693 #if defined(NEED_OP)
3694 # define HAVE_NEED_OP
3696 # define NEED_OP(x) ((void) 0)
3699 #if defined(HAVE_TEST_IP) || defined(HAVE_NEED_IP)
3700 # define HAVE_ANY_IP
3702 #if defined(HAVE_TEST_OP) || defined(HAVE_NEED_OP)
3703 # define HAVE_ANY_OP
3707 #define __COPY4(dst,src) * (lzo_uint32p)(dst) = * (const lzo_uint32p)(src)
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))
3716 #if defined(DO_DECOMPRESS)
3718 DO_DECOMPRESS ( const lzo_bytep in
, lzo_uint in_len
,
3719 lzo_bytep out
, lzo_uintp out_len
,
3723 register lzo_bytep op
;
3724 register const lzo_bytep ip
;
3725 register lzo_uint t
;
3726 #if defined(COPY_DICT)
3728 const lzo_bytep dict_end
;
3730 register const lzo_bytep m_pos
;
3733 const lzo_bytep
const ip_end
= in
+ in_len
;
3734 #if defined(HAVE_ANY_OP)
3735 lzo_bytep
const op_end
= out
+ *out_len
;
3738 lzo_uint last_m_off
= 0;
3743 #if defined(COPY_DICT)
3746 if (dict_len
> M4_MAX_OFFSET
)
3748 dict
+= dict_len
- M4_MAX_OFFSET
;
3749 dict_len
= M4_MAX_OFFSET
;
3751 dict_end
= dict
+ dict_len
;
3770 assert(t
> 0); NEED_OP(t
); NEED_IP(t
+1);
3771 do *op
++ = *ip
++; while (--t
> 0);
3772 goto first_literal_run
;
3775 while (TEST_IP
&& TEST_OP
)
3791 assert(t
> 0); NEED_OP(t
+3); NEED_IP(t
+4);
3792 #if defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
3793 #if !defined(LZO_UNALIGNED_OK_4)
3794 if (PTR_ALIGNED2_4(op
,ip
))
3805 op
+= 4; ip
+= 4; t
-= 4;
3807 if (t
> 0) do *op
++ = *ip
++; while (--t
> 0);
3810 do *op
++ = *ip
++; while (--t
> 0);
3812 #if !defined(LZO_UNALIGNED_OK_4)
3817 #if !defined(LZO_UNALIGNED_OK_4)
3819 *op
++ = *ip
++; *op
++ = *ip
++; *op
++ = *ip
++;
3820 do *op
++ = *ip
++; while (--t
> 0);
3829 #if defined(COPY_DICT)
3831 m_off
= (1 + M2_MAX_OFFSET
) + (t
<< 6) + (*ip
++ >> 2);
3834 m_off
= (1 + M2_MAX_OFFSET
) + (t
>> 2) + (*ip
++ << 2);
3837 t
= 3; COPY_DICT(t
,m_off
)
3840 t
= (1 + M2_MAX_OFFSET
) + (t
<< 6) + (*ip
++ >> 2);
3844 m_pos
= op
- (1 + M2_MAX_OFFSET
);
3846 m_pos
-= *ip
++ << 2;
3848 TEST_LB(m_pos
); NEED_OP(3);
3849 *op
++ = *m_pos
++; *op
++ = *m_pos
++; *op
++ = *m_pos
;
3857 #if defined(COPY_DICT)
3859 m_off
= 1 + ((t
>> 2) & 7) + (*ip
++ << 3);
3861 #elif defined(LZO1Y)
3862 m_off
= 1 + ((t
>> 2) & 3) + (*ip
++ << 2);
3864 #elif defined(LZO1Z)
3870 m_off
= 1 + (m_off
<< 6) + (*ip
++ >> 2);
3878 m_pos
-= (t
>> 2) & 7;
3879 m_pos
-= *ip
++ << 3;
3881 #elif defined(LZO1Y)
3883 m_pos
-= (t
>> 2) & 3;
3884 m_pos
-= *ip
++ << 2;
3886 #elif defined(LZO1Z)
3888 lzo_uint off
= t
& 0x1f;
3892 assert(last_m_off
> 0);
3893 m_pos
-= last_m_off
;
3897 off
= 1 + (off
<< 6) + (*ip
++ >> 2);
3904 TEST_LB(m_pos
); assert(t
> 0); NEED_OP(t
+3-1);
3922 #if defined(COPY_DICT)
3924 m_off
= 1 + (ip
[0] << 6) + (ip
[1] >> 2);
3927 m_off
= 1 + (ip
[0] >> 2) + (ip
[1] << 6);
3932 lzo_uint off
= 1 + (ip
[0] << 6) + (ip
[1] >> 2);
3936 #elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN)
3938 m_pos
-= (* (const lzo_ushortp
) ip
) >> 2;
3941 m_pos
-= (ip
[0] >> 2) + (ip
[1] << 6);
3948 #if defined(COPY_DICT)
3949 m_off
= (t
& 8) << 11;
3952 m_pos
-= (t
& 8) << 11;
3966 #if defined(COPY_DICT)
3968 m_off
+= (ip
[0] << 6) + (ip
[1] >> 2);
3970 m_off
+= (ip
[0] >> 2) + (ip
[1] << 6);
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;
3985 m_pos
-= (ip
[0] >> 2) + (ip
[1] << 6);
3992 last_m_off
= pd((const lzo_bytep
)op
, m_pos
);
3998 #if defined(COPY_DICT)
4000 m_off
= 1 + (t
<< 6) + (*ip
++ >> 2);
4003 m_off
= 1 + (t
>> 2) + (*ip
++ << 2);
4006 t
= 2; COPY_DICT(t
,m_off
)
4009 t
= 1 + (t
<< 6) + (*ip
++ >> 2);
4015 m_pos
-= *ip
++ << 2;
4017 TEST_LB(m_pos
); NEED_OP(2);
4018 *op
++ = *m_pos
++; *op
++ = *m_pos
;
4023 #if defined(COPY_DICT)
4026 t
+= 3-1; COPY_DICT(t
,m_off
)
4030 TEST_LB(m_pos
); assert(t
> 0); NEED_OP(t
+3-1);
4031 #if defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
4032 #if !defined(LZO_UNALIGNED_OK_4)
4033 if (t
>= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op
,m_pos
))
4035 assert((op
- m_pos
) >= 4);
4037 if (t
>= 2 * 4 - (3 - 1) && (op
- m_pos
) >= 4)
4041 op
+= 4; m_pos
+= 4; t
-= 4 - (3 - 1);
4044 op
+= 4; m_pos
+= 4; t
-= 4;
4046 if (t
> 0) do *op
++ = *m_pos
++; while (--t
> 0);
4052 *op
++ = *m_pos
++; *op
++ = *m_pos
++;
4053 do *op
++ = *m_pos
++; while (--t
> 0);
4068 assert(t
> 0); assert(t
< 4); NEED_OP(t
); NEED_IP(t
+1);
4070 do *op
++ = *ip
++; while (--t
> 0);
4073 if (t
> 1) { *op
++ = *ip
++; if (t
> 2) { *op
++ = *ip
++; } }
4076 } while (TEST_IP
&& TEST_OP
);
4079 #if defined(HAVE_TEST_IP) || defined(HAVE_TEST_OP)
4080 *out_len
= pd(op
, out
);
4081 return LZO_E_EOF_NOT_FOUND
;
4086 *out_len
= pd(op
, out
);
4087 return (ip
== ip_end
? LZO_E_OK
:
4088 (ip
< ip_end
? LZO_E_INPUT_NOT_CONSUMED
: LZO_E_INPUT_OVERRUN
));
4090 #if defined(HAVE_NEED_IP)
4092 *out_len
= pd(op
, out
);
4093 return LZO_E_INPUT_OVERRUN
;
4096 #if defined(HAVE_NEED_OP)
4098 *out_len
= pd(op
, out
);
4099 return LZO_E_OUTPUT_OVERRUN
;
4102 #if defined(LZO_TEST_OVERRUN_LOOKBEHIND)
4104 *out_len
= pd(op
, out
);
4105 return LZO_E_LOOKBEHIND_OVERRUN
;
4111 /***** End of minilzo.c *****/