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) 2011 Markus Franz Xaver Johannes Oberhumer
6 Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer
7 Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer
8 Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer
9 Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer
10 Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer
11 Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer
12 Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer
13 Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer
14 Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
15 Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
16 Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
17 Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
18 Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
19 Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
20 Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
23 The LZO library is free software; you can redistribute it and/or
24 modify it under the terms of the GNU General Public License as
25 published by the Free Software Foundation; either version 2 of
26 the License, or (at your option) any later version.
28 The LZO library is distributed in the hope that it will be useful,
29 but WITHOUT ANY WARRANTY; without even the implied warranty of
30 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 GNU General Public License for more details.
33 You should have received a copy of the GNU General Public License
34 along with the LZO library; see the file COPYING.
35 If not, write to the Free Software Foundation, Inc.,
36 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
38 Markus F.X.J. Oberhumer
39 <markus@oberhumer.com>
40 http://www.oberhumer.com/opensource/lzo/
45 * the full LZO package can be found at
46 * http://www.oberhumer.com/opensource/lzo/
50 #define LZO_CFG_FREESTANDING 1
53 #define __LZO_IN_MINILZO 1
55 #if defined(LZO_CFG_FREESTANDING)
56 # undef MINILZO_HAVE_CONFIG_H
57 # define LZO_LIBC_FREESTANDING 1
58 # define LZO_OS_FREESTANDING 1
61 #ifdef MINILZO_HAVE_CONFIG_H
66 #if defined(MINILZO_CFG_USE_INTERNAL_LZODEFS)
68 #ifndef __LZODEFS_H_INCLUDED
69 #define __LZODEFS_H_INCLUDED 1
71 #if defined(__CYGWIN32__) && !defined(__CYGWIN__)
72 # define __CYGWIN__ __CYGWIN32__
74 #if defined(__IBMCPP__) && !defined(__IBMC__)
75 # define __IBMC__ __IBMCPP__
77 #if defined(__ICL) && defined(_WIN32) && !defined(__INTEL_COMPILER)
78 # define __INTEL_COMPILER __ICL
80 #if 1 && defined(__INTERIX) && defined(__GNUC__) && !defined(_ALL_SOURCE)
81 # define _ALL_SOURCE 1
83 #if defined(__mips__) && defined(__R5900__)
84 # if !defined(__LONG_MAX__)
85 # define __LONG_MAX__ 9223372036854775807L
88 #if defined(__INTEL_COMPILER) && defined(__linux__)
89 # pragma warning(disable: 193)
91 #if defined(__KEIL__) && defined(__C166__)
92 # pragma warning disable = 322
93 #elif 0 && defined(__C251__)
94 # pragma warning disable = 322
96 #if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__)
97 # if (_MSC_VER >= 1300)
98 # pragma warning(disable: 4668)
101 #if 0 && defined(__WATCOMC__)
102 # if (__WATCOMC__ >= 1050) && (__WATCOMC__ < 1060)
103 # pragma warning 203 9
106 #if defined(__BORLANDC__) && defined(__MSDOS__) && !defined(__FLAT__)
110 #define LZO_0xffffL 0xfffful
111 #define LZO_0xffffffffL 0xfffffffful
113 #define LZO_0xffffL 65535ul
114 #define LZO_0xffffffffL 4294967295ul
116 #if (LZO_0xffffL == LZO_0xffffffffL)
117 # error "your preprocessor is broken 1"
119 #if (16ul * 16384ul != 262144ul)
120 # error "your preprocessor is broken 2"
123 #if (32767 >= 4294967295ul)
124 # error "your preprocessor is broken 3"
126 #if (65535u >= 4294967295ul)
127 # error "your preprocessor is broken 4"
130 #if (UINT_MAX == LZO_0xffffL)
131 #if defined(__ZTC__) && defined(__I86__) && !defined(__OS2__)
135 # if !defined(_MSDOS)
138 #elif 0 && defined(__VERSION) && defined(MB_LEN_MAX)
139 # if (__VERSION == 520) && (MB_LEN_MAX == 1)
140 # if !defined(__AZTEC_C__)
141 # define __AZTEC_C__ __VERSION
143 # if !defined(__DOS__)
149 #if defined(_MSC_VER) && defined(M_I86HM) && (UINT_MAX == LZO_0xffffL)
150 # define ptrdiff_t long
151 # define _PTRDIFF_T_DEFINED 1
153 #if (UINT_MAX == LZO_0xffffL)
154 # undef __LZO_RENAME_A
155 # undef __LZO_RENAME_B
156 # if defined(__AZTEC_C__) && defined(__DOS__)
157 # define __LZO_RENAME_A 1
158 # elif defined(_MSC_VER) && defined(MSDOS)
159 # if (_MSC_VER < 600)
160 # define __LZO_RENAME_A 1
161 # elif (_MSC_VER < 700)
162 # define __LZO_RENAME_B 1
164 # elif defined(__TSC__) && defined(__OS2__)
165 # define __LZO_RENAME_A 1
166 # elif defined(__MSDOS__) && defined(__TURBOC__) && (__TURBOC__ < 0x0410)
167 # define __LZO_RENAME_A 1
168 # elif defined(__PACIFIC__) && defined(DOS)
172 # if !defined(__near)
176 # if defined(__LZO_RENAME_A)
177 # if !defined(__cdecl)
178 # define __cdecl cdecl
183 # if !defined(__huge)
186 # if !defined(__near)
189 # if !defined(__pascal)
190 # define __pascal pascal
192 # if !defined(__huge)
195 # elif defined(__LZO_RENAME_B)
196 # if !defined(__cdecl)
197 # define __cdecl _cdecl
202 # if !defined(__huge)
203 # define __huge _huge
205 # if !defined(__near)
206 # define __near _near
208 # if !defined(__pascal)
209 # define __pascal _pascal
211 # elif (defined(__PUREC__) || defined(__TURBOC__)) && defined(__TOS__)
212 # if !defined(__cdecl)
213 # define __cdecl cdecl
215 # if !defined(__pascal)
216 # define __pascal pascal
219 # undef __LZO_RENAME_A
220 # undef __LZO_RENAME_B
222 #if (UINT_MAX == LZO_0xffffL)
223 #if defined(__AZTEC_C__) && defined(__DOS__)
224 # define LZO_BROKEN_CDECL_ALT_SYNTAX 1
225 #elif defined(_MSC_VER) && defined(MSDOS)
226 # if (_MSC_VER < 600)
227 # define LZO_BROKEN_INTEGRAL_CONSTANTS 1
229 # if (_MSC_VER < 700)
230 # define LZO_BROKEN_INTEGRAL_PROMOTION 1
231 # define LZO_BROKEN_SIZEOF 1
233 #elif defined(__PACIFIC__) && defined(DOS)
234 # define LZO_BROKEN_INTEGRAL_CONSTANTS 1
235 #elif defined(__TURBOC__) && defined(__MSDOS__)
236 # if (__TURBOC__ < 0x0150)
237 # define LZO_BROKEN_CDECL_ALT_SYNTAX 1
238 # define LZO_BROKEN_INTEGRAL_CONSTANTS 1
239 # define LZO_BROKEN_INTEGRAL_PROMOTION 1
241 # if (__TURBOC__ < 0x0200)
242 # define LZO_BROKEN_SIZEOF 1
244 # if (__TURBOC__ < 0x0400) && defined(__cplusplus)
245 # define LZO_BROKEN_CDECL_ALT_SYNTAX 1
247 #elif (defined(__PUREC__) || defined(__TURBOC__)) && defined(__TOS__)
248 # define LZO_BROKEN_CDECL_ALT_SYNTAX 1
249 # define LZO_BROKEN_SIZEOF 1
252 #if defined(__WATCOMC__) && (__WATCOMC__ < 900)
253 # define LZO_BROKEN_INTEGRAL_CONSTANTS 1
255 #if defined(_CRAY) && defined(_CRAY1)
256 # define LZO_BROKEN_SIGNED_RIGHT_SHIFT 1
258 #define LZO_PP_STRINGIZE(x) #x
259 #define LZO_PP_MACRO_EXPAND(x) LZO_PP_STRINGIZE(x)
260 #define LZO_PP_CONCAT2(a,b) a ## b
261 #define LZO_PP_CONCAT3(a,b,c) a ## b ## c
262 #define LZO_PP_CONCAT4(a,b,c,d) a ## b ## c ## d
263 #define LZO_PP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e
264 #define LZO_PP_ECONCAT2(a,b) LZO_PP_CONCAT2(a,b)
265 #define LZO_PP_ECONCAT3(a,b,c) LZO_PP_CONCAT3(a,b,c)
266 #define LZO_PP_ECONCAT4(a,b,c,d) LZO_PP_CONCAT4(a,b,c,d)
267 #define LZO_PP_ECONCAT5(a,b,c,d,e) LZO_PP_CONCAT5(a,b,c,d,e)
269 #define LZO_CPP_STRINGIZE(x) #x
270 #define LZO_CPP_MACRO_EXPAND(x) LZO_CPP_STRINGIZE(x)
271 #define LZO_CPP_CONCAT2(a,b) a ## b
272 #define LZO_CPP_CONCAT3(a,b,c) a ## b ## c
273 #define LZO_CPP_CONCAT4(a,b,c,d) a ## b ## c ## d
274 #define LZO_CPP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e
275 #define LZO_CPP_ECONCAT2(a,b) LZO_CPP_CONCAT2(a,b)
276 #define LZO_CPP_ECONCAT3(a,b,c) LZO_CPP_CONCAT3(a,b,c)
277 #define LZO_CPP_ECONCAT4(a,b,c,d) LZO_CPP_CONCAT4(a,b,c,d)
278 #define LZO_CPP_ECONCAT5(a,b,c,d,e) LZO_CPP_CONCAT5(a,b,c,d,e)
280 #define __LZO_MASK_GEN(o,b) (((((o) << ((b)-1)) - (o)) << 1) + (o))
281 #if 1 && defined(__cplusplus)
282 # if !defined(__STDC_CONSTANT_MACROS)
283 # define __STDC_CONSTANT_MACROS 1
285 # if !defined(__STDC_LIMIT_MACROS)
286 # define __STDC_LIMIT_MACROS 1
289 #if defined(__cplusplus)
290 # define LZO_EXTERN_C extern "C"
292 # define LZO_EXTERN_C extern
294 #if !defined(__LZO_OS_OVERRIDE)
295 #if (LZO_OS_FREESTANDING)
296 # define LZO_INFO_OS "freestanding"
297 #elif (LZO_OS_EMBEDDED)
298 # define LZO_INFO_OS "embedded"
299 #elif 1 && defined(__IAR_SYSTEMS_ICC__)
300 # define LZO_OS_EMBEDDED 1
301 # define LZO_INFO_OS "embedded"
302 #elif defined(__CYGWIN__) && defined(__GNUC__)
303 # define LZO_OS_CYGWIN 1
304 # define LZO_INFO_OS "cygwin"
305 #elif defined(__EMX__) && defined(__GNUC__)
306 # define LZO_OS_EMX 1
307 # define LZO_INFO_OS "emx"
308 #elif defined(__BEOS__)
309 # define LZO_OS_BEOS 1
310 # define LZO_INFO_OS "beos"
311 #elif defined(__Lynx__)
312 # define LZO_OS_LYNXOS 1
313 # define LZO_INFO_OS "lynxos"
314 #elif defined(__OS400__)
315 # define LZO_OS_OS400 1
316 # define LZO_INFO_OS "os400"
317 #elif defined(__QNX__)
318 # define LZO_OS_QNX 1
319 # define LZO_INFO_OS "qnx"
320 #elif defined(__BORLANDC__) && defined(__DPMI32__) && (__BORLANDC__ >= 0x0460)
321 # define LZO_OS_DOS32 1
322 # define LZO_INFO_OS "dos32"
323 #elif defined(__BORLANDC__) && defined(__DPMI16__)
324 # define LZO_OS_DOS16 1
325 # define LZO_INFO_OS "dos16"
326 #elif defined(__ZTC__) && defined(DOS386)
327 # define LZO_OS_DOS32 1
328 # define LZO_INFO_OS "dos32"
329 #elif defined(__OS2__) || defined(__OS2V2__)
330 # if (UINT_MAX == LZO_0xffffL)
331 # define LZO_OS_OS216 1
332 # define LZO_INFO_OS "os216"
333 # elif (UINT_MAX == LZO_0xffffffffL)
334 # define LZO_OS_OS2 1
335 # define LZO_INFO_OS "os2"
337 # error "check your limits.h header"
339 #elif defined(__WIN64__) || defined(_WIN64) || defined(WIN64)
340 # define LZO_OS_WIN64 1
341 # define LZO_INFO_OS "win64"
342 #elif defined(__WIN32__) || defined(_WIN32) || defined(WIN32) || defined(__WINDOWS_386__)
343 # define LZO_OS_WIN32 1
344 # define LZO_INFO_OS "win32"
345 #elif defined(__MWERKS__) && defined(__INTEL__)
346 # define LZO_OS_WIN32 1
347 # define LZO_INFO_OS "win32"
348 #elif defined(__WINDOWS__) || defined(_WINDOWS) || defined(_Windows)
349 # if (UINT_MAX == LZO_0xffffL)
350 # define LZO_OS_WIN16 1
351 # define LZO_INFO_OS "win16"
352 # elif (UINT_MAX == LZO_0xffffffffL)
353 # define LZO_OS_WIN32 1
354 # define LZO_INFO_OS "win32"
356 # error "check your limits.h header"
358 #elif defined(__DOS__) || defined(__MSDOS__) || defined(_MSDOS) || defined(MSDOS) || (defined(__PACIFIC__) && defined(DOS))
359 # if (UINT_MAX == LZO_0xffffL)
360 # define LZO_OS_DOS16 1
361 # define LZO_INFO_OS "dos16"
362 # elif (UINT_MAX == LZO_0xffffffffL)
363 # define LZO_OS_DOS32 1
364 # define LZO_INFO_OS "dos32"
366 # error "check your limits.h header"
368 #elif defined(__WATCOMC__)
369 # if defined(__NT__) && (UINT_MAX == LZO_0xffffL)
370 # define LZO_OS_DOS16 1
371 # define LZO_INFO_OS "dos16"
372 # elif defined(__NT__) && (__WATCOMC__ < 1100)
373 # define LZO_OS_WIN32 1
374 # define LZO_INFO_OS "win32"
375 # elif defined(__linux__) || defined(__LINUX__)
376 # define LZO_OS_POSIX 1
377 # define LZO_INFO_OS "posix"
379 # error "please specify a target using the -bt compiler option"
381 #elif defined(__palmos__)
382 # define LZO_OS_PALMOS 1
383 # define LZO_INFO_OS "palmos"
384 #elif defined(__TOS__) || defined(__atarist__)
385 # define LZO_OS_TOS 1
386 # define LZO_INFO_OS "tos"
387 #elif defined(macintosh) && !defined(__ppc__)
388 # define LZO_OS_MACCLASSIC 1
389 # define LZO_INFO_OS "macclassic"
391 # define LZO_OS_VMS 1
392 # define LZO_INFO_OS "vms"
393 #elif ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__))
394 # define LZO_OS_CONSOLE 1
395 # define LZO_OS_CONSOLE_PS2 1
396 # define LZO_INFO_OS "console"
397 # define LZO_INFO_OS_CONSOLE "ps2"
398 #elif (defined(__mips__) && defined(__psp__))
399 # define LZO_OS_CONSOLE 1
400 # define LZO_OS_CONSOLE_PSP 1
401 # define LZO_INFO_OS "console"
402 # define LZO_INFO_OS_CONSOLE "psp"
404 # define LZO_OS_POSIX 1
405 # define LZO_INFO_OS "posix"
408 # if defined(_AIX) || defined(__AIX__) || defined(__aix__)
409 # define LZO_OS_POSIX_AIX 1
410 # define LZO_INFO_OS_POSIX "aix"
411 # elif defined(__FreeBSD__)
412 # define LZO_OS_POSIX_FREEBSD 1
413 # define LZO_INFO_OS_POSIX "freebsd"
414 # elif defined(__hpux__) || defined(__hpux)
415 # define LZO_OS_POSIX_HPUX 1
416 # define LZO_INFO_OS_POSIX "hpux"
417 # elif defined(__INTERIX)
418 # define LZO_OS_POSIX_INTERIX 1
419 # define LZO_INFO_OS_POSIX "interix"
420 # elif defined(__IRIX__) || defined(__irix__)
421 # define LZO_OS_POSIX_IRIX 1
422 # define LZO_INFO_OS_POSIX "irix"
423 # elif defined(__linux__) || defined(__linux) || defined(__LINUX__)
424 # define LZO_OS_POSIX_LINUX 1
425 # define LZO_INFO_OS_POSIX "linux"
426 # elif defined(__APPLE__) || defined(__MACOS__)
427 # define LZO_OS_POSIX_MACOSX 1
428 # define LZO_INFO_OS_POSIX "macosx"
429 # elif defined(__minix__) || defined(__minix)
430 # define LZO_OS_POSIX_MINIX 1
431 # define LZO_INFO_OS_POSIX "minix"
432 # elif defined(__NetBSD__)
433 # define LZO_OS_POSIX_NETBSD 1
434 # define LZO_INFO_OS_POSIX "netbsd"
435 # elif defined(__OpenBSD__)
436 # define LZO_OS_POSIX_OPENBSD 1
437 # define LZO_INFO_OS_POSIX "openbsd"
438 # elif defined(__osf__)
439 # define LZO_OS_POSIX_OSF 1
440 # define LZO_INFO_OS_POSIX "osf"
441 # elif defined(__solaris__) || defined(__sun)
442 # if defined(__SVR4) || defined(__svr4__)
443 # define LZO_OS_POSIX_SOLARIS 1
444 # define LZO_INFO_OS_POSIX "solaris"
446 # define LZO_OS_POSIX_SUNOS 1
447 # define LZO_INFO_OS_POSIX "sunos"
449 # elif defined(__ultrix__) || defined(__ultrix)
450 # define LZO_OS_POSIX_ULTRIX 1
451 # define LZO_INFO_OS_POSIX "ultrix"
452 # elif defined(_UNICOS)
453 # define LZO_OS_POSIX_UNICOS 1
454 # define LZO_INFO_OS_POSIX "unicos"
456 # define LZO_OS_POSIX_UNKNOWN 1
457 # define LZO_INFO_OS_POSIX "unknown"
461 #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16)
462 # if (UINT_MAX != LZO_0xffffL)
463 # error "this should not happen"
465 # if (ULONG_MAX != LZO_0xffffffffL)
466 # error "this should not happen"
469 #if (LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_WIN32 || LZO_OS_WIN64)
470 # if (UINT_MAX != LZO_0xffffffffL)
471 # error "this should not happen"
473 # if (ULONG_MAX != LZO_0xffffffffL)
474 # error "this should not happen"
477 #if defined(CIL) && defined(_GNUCC) && defined(__GNUC__)
478 # define LZO_CC_CILLY 1
479 # define LZO_INFO_CC "Cilly"
480 # if defined(__CILLY__)
481 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__CILLY__)
483 # define LZO_INFO_CCVER "unknown"
485 #elif 0 && defined(SDCC) && defined(__VERSION__) && !defined(__GNUC__)
486 # define LZO_CC_SDCC 1
487 # define LZO_INFO_CC "sdcc"
488 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(SDCC)
489 #elif defined(__PATHSCALE__) && defined(__PATHCC_PATCHLEVEL__)
490 # define LZO_CC_PATHSCALE (__PATHCC__ * 0x10000L + __PATHCC_MINOR__ * 0x100 + __PATHCC_PATCHLEVEL__)
491 # define LZO_INFO_CC "Pathscale C"
492 # define LZO_INFO_CCVER __PATHSCALE__
493 #elif defined(__INTEL_COMPILER)
494 # define LZO_CC_INTELC 1
495 # define LZO_INFO_CC "Intel C"
496 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__INTEL_COMPILER)
497 # if defined(_WIN32) || defined(_WIN64)
498 # define LZO_CC_SYNTAX_MSC 1
500 # define LZO_CC_SYNTAX_GNUC 1
502 #elif defined(__POCC__) && defined(_WIN32)
503 # define LZO_CC_PELLESC 1
504 # define LZO_INFO_CC "Pelles C"
505 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__POCC__)
506 #elif defined(__clang__) && defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__)
507 # if defined(__GNUC_PATCHLEVEL__)
508 # define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__)
510 # define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100)
512 # if defined(__clang_major__) && defined(__clang_minor__) && defined(__clang_patchlevel__)
513 # define LZO_CC_CLANG_CLANG (__clang_major__ * 0x10000L + __clang_minor__ * 0x100 + __clang_patchlevel__)
515 # define LZO_CC_CLANG_CLANG 0x010000L
517 # define LZO_CC_CLANG LZO_CC_CLANG_GNUC
518 # define LZO_INFO_CC "clang"
519 # define LZO_INFO_CCVER __VERSION__
520 #elif defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__)
521 # if defined(__GNUC_PATCHLEVEL__)
522 # define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__)
524 # define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100)
526 # define LZO_CC_LLVM LZO_CC_LLVM_GNUC
527 # define LZO_INFO_CC "llvm-gcc"
528 # define LZO_INFO_CCVER __VERSION__
529 #elif defined(__GNUC__) && defined(__VERSION__)
530 # if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
531 # define LZO_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__)
532 # elif defined(__GNUC_MINOR__)
533 # define LZO_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100)
535 # define LZO_CC_GNUC (__GNUC__ * 0x10000L)
537 # define LZO_INFO_CC "gcc"
538 # define LZO_INFO_CCVER __VERSION__
539 #elif defined(__ACK__) && defined(_ACK)
540 # define LZO_CC_ACK 1
541 # define LZO_INFO_CC "Amsterdam Compiler Kit C"
542 # define LZO_INFO_CCVER "unknown"
543 #elif defined(__AZTEC_C__)
544 # define LZO_CC_AZTECC 1
545 # define LZO_INFO_CC "Aztec C"
546 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__AZTEC_C__)
547 #elif defined(__CODEGEARC__)
548 # define LZO_CC_CODEGEARC 1
549 # define LZO_INFO_CC "CodeGear C"
550 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__CODEGEARC__)
551 #elif defined(__BORLANDC__)
552 # define LZO_CC_BORLANDC 1
553 # define LZO_INFO_CC "Borland C"
554 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__BORLANDC__)
555 #elif defined(_CRAYC) && defined(_RELEASE)
556 # define LZO_CC_CRAYC 1
557 # define LZO_INFO_CC "Cray C"
558 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_RELEASE)
559 #elif defined(__DMC__) && defined(__SC__)
560 # define LZO_CC_DMC 1
561 # define LZO_INFO_CC "Digital Mars C"
562 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__DMC__)
563 #elif defined(__DECC)
564 # define LZO_CC_DECC 1
565 # define LZO_INFO_CC "DEC C"
566 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__DECC)
567 #elif defined(__HIGHC__)
568 # define LZO_CC_HIGHC 1
569 # define LZO_INFO_CC "MetaWare High C"
570 # define LZO_INFO_CCVER "unknown"
571 #elif defined(__IAR_SYSTEMS_ICC__)
572 # define LZO_CC_IARC 1
573 # define LZO_INFO_CC "IAR C"
574 # if defined(__VER__)
575 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__VER__)
577 # define LZO_INFO_CCVER "unknown"
579 #elif defined(__IBMC__)
580 # define LZO_CC_IBMC 1
581 # define LZO_INFO_CC "IBM C"
582 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__IBMC__)
583 #elif defined(__KEIL__) && defined(__C166__)
584 # define LZO_CC_KEILC 1
585 # define LZO_INFO_CC "Keil C"
586 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__C166__)
587 #elif defined(__LCC__) && defined(_WIN32) && defined(__LCCOPTIMLEVEL)
588 # define LZO_CC_LCCWIN32 1
589 # define LZO_INFO_CC "lcc-win32"
590 # define LZO_INFO_CCVER "unknown"
591 #elif defined(__LCC__)
592 # define LZO_CC_LCC 1
593 # define LZO_INFO_CC "lcc"
594 # if defined(__LCC_VERSION__)
595 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__LCC_VERSION__)
597 # define LZO_INFO_CCVER "unknown"
599 #elif defined(_MSC_VER)
600 # define LZO_CC_MSC 1
601 # define LZO_INFO_CC "Microsoft C"
602 # if defined(_MSC_FULL_VER)
603 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) "." LZO_PP_MACRO_EXPAND(_MSC_FULL_VER)
605 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER)
607 #elif defined(__MWERKS__)
608 # define LZO_CC_MWERKS 1
609 # define LZO_INFO_CC "Metrowerks C"
610 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__MWERKS__)
611 #elif (defined(__NDPC__) || defined(__NDPX__)) && defined(__i386)
612 # define LZO_CC_NDPC 1
613 # define LZO_INFO_CC "Microway NDP C"
614 # define LZO_INFO_CCVER "unknown"
615 #elif defined(__PACIFIC__)
616 # define LZO_CC_PACIFICC 1
617 # define LZO_INFO_CC "Pacific C"
618 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PACIFIC__)
619 #elif defined(__PGI) && (defined(__linux__) || defined(__WIN32__))
620 # define LZO_CC_PGI 1
621 # define LZO_INFO_CC "Portland Group PGI C"
622 # define LZO_INFO_CCVER "unknown"
623 #elif defined(__PUREC__) && defined(__TOS__)
624 # define LZO_CC_PUREC 1
625 # define LZO_INFO_CC "Pure C"
626 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PUREC__)
627 #elif defined(__SC__) && defined(__ZTC__)
628 # define LZO_CC_SYMANTECC 1
629 # define LZO_INFO_CC "Symantec C"
630 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SC__)
631 #elif defined(__SUNPRO_C)
632 # define LZO_INFO_CC "SunPro C"
633 # if ((__SUNPRO_C)+0 > 0)
634 # define LZO_CC_SUNPROC __SUNPRO_C
635 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_C)
637 # define LZO_CC_SUNPROC 1
638 # define LZO_INFO_CCVER "unknown"
640 #elif defined(__SUNPRO_CC)
641 # define LZO_INFO_CC "SunPro C"
642 # if ((__SUNPRO_CC)+0 > 0)
643 # define LZO_CC_SUNPROC __SUNPRO_CC
644 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_CC)
646 # define LZO_CC_SUNPROC 1
647 # define LZO_INFO_CCVER "unknown"
649 #elif defined(__TINYC__)
650 # define LZO_CC_TINYC 1
651 # define LZO_INFO_CC "Tiny C"
652 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TINYC__)
653 #elif defined(__TSC__)
654 # define LZO_CC_TOPSPEEDC 1
655 # define LZO_INFO_CC "TopSpeed C"
656 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TSC__)
657 #elif defined(__WATCOMC__)
658 # define LZO_CC_WATCOMC 1
659 # define LZO_INFO_CC "Watcom C"
660 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__WATCOMC__)
661 #elif defined(__TURBOC__)
662 # define LZO_CC_TURBOC 1
663 # define LZO_INFO_CC "Turbo C"
664 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TURBOC__)
665 #elif defined(__ZTC__)
666 # define LZO_CC_ZORTECHC 1
667 # define LZO_INFO_CC "Zortech C"
668 # if (__ZTC__ == 0x310)
669 # define LZO_INFO_CCVER "0x310"
671 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__ZTC__)
674 # define LZO_CC_UNKNOWN 1
675 # define LZO_INFO_CC "unknown"
676 # define LZO_INFO_CCVER "unknown"
678 #if 0 && (LZO_CC_MSC && (_MSC_VER >= 1200)) && !defined(_MSC_FULL_VER)
679 # error "LZO_CC_MSC: _MSC_FULL_VER is not defined"
681 #if !defined(__LZO_ARCH_OVERRIDE) && !(LZO_ARCH_GENERIC) && defined(_CRAY)
682 # if (UINT_MAX > LZO_0xffffffffL) && defined(_CRAY)
683 # if defined(_CRAYMPP) || defined(_CRAYT3D) || defined(_CRAYT3E)
684 # define LZO_ARCH_CRAY_MPP 1
685 # elif defined(_CRAY1)
686 # define LZO_ARCH_CRAY_PVP 1
690 #if !defined(__LZO_ARCH_OVERRIDE)
691 #if (LZO_ARCH_GENERIC)
692 # define LZO_INFO_ARCH "generic"
693 #elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16)
694 # define LZO_ARCH_I086 1
695 # define LZO_ARCH_IA16 1
696 # define LZO_INFO_ARCH "i086"
697 #elif defined(__alpha__) || defined(__alpha) || defined(_M_ALPHA)
698 # define LZO_ARCH_ALPHA 1
699 # define LZO_INFO_ARCH "alpha"
700 #elif (LZO_ARCH_CRAY_MPP) && (defined(_CRAYT3D) || defined(_CRAYT3E))
701 # define LZO_ARCH_ALPHA 1
702 # define LZO_INFO_ARCH "alpha"
703 #elif defined(__amd64__) || defined(__x86_64__) || defined(_M_AMD64)
704 # define LZO_ARCH_AMD64 1
705 # define LZO_INFO_ARCH "amd64"
706 #elif defined(__thumb__) || (defined(_M_ARM) && defined(_M_THUMB))
707 # define LZO_ARCH_ARM 1
708 # define LZO_ARCH_ARM_THUMB 1
709 # define LZO_INFO_ARCH "arm_thumb"
710 #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCARM__)
711 # define LZO_ARCH_ARM 1
712 # if defined(__CPU_MODE__) && ((__CPU_MODE__)+0 == 1)
713 # define LZO_ARCH_ARM_THUMB 1
714 # define LZO_INFO_ARCH "arm_thumb"
715 # elif defined(__CPU_MODE__) && ((__CPU_MODE__)+0 == 2)
716 # define LZO_INFO_ARCH "arm"
718 # define LZO_INFO_ARCH "arm"
720 #elif defined(__arm__) || defined(_M_ARM)
721 # define LZO_ARCH_ARM 1
722 # define LZO_INFO_ARCH "arm"
723 #elif (UINT_MAX <= LZO_0xffffL) && defined(__AVR__)
724 # define LZO_ARCH_AVR 1
725 # define LZO_INFO_ARCH "avr"
726 #elif defined(__avr32__) || defined(__AVR32__)
727 # define LZO_ARCH_AVR32 1
728 # define LZO_INFO_ARCH "avr32"
729 #elif defined(__bfin__)
730 # define LZO_ARCH_BLACKFIN 1
731 # define LZO_INFO_ARCH "blackfin"
732 #elif (UINT_MAX == LZO_0xffffL) && defined(__C166__)
733 # define LZO_ARCH_C166 1
734 # define LZO_INFO_ARCH "c166"
735 #elif defined(__cris__)
736 # define LZO_ARCH_CRIS 1
737 # define LZO_INFO_ARCH "cris"
738 #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCEZ80__)
739 # define LZO_ARCH_EZ80 1
740 # define LZO_INFO_ARCH "ez80"
741 #elif defined(__H8300__) || defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__)
742 # define LZO_ARCH_H8300 1
743 # define LZO_INFO_ARCH "h8300"
744 #elif defined(__hppa__) || defined(__hppa)
745 # define LZO_ARCH_HPPA 1
746 # define LZO_INFO_ARCH "hppa"
747 #elif defined(__386__) || defined(__i386__) || defined(__i386) || defined(_M_IX86) || defined(_M_I386)
748 # define LZO_ARCH_I386 1
749 # define LZO_ARCH_IA32 1
750 # define LZO_INFO_ARCH "i386"
751 #elif (LZO_CC_ZORTECHC && defined(__I86__))
752 # define LZO_ARCH_I386 1
753 # define LZO_ARCH_IA32 1
754 # define LZO_INFO_ARCH "i386"
755 #elif (LZO_OS_DOS32 && LZO_CC_HIGHC) && defined(_I386)
756 # define LZO_ARCH_I386 1
757 # define LZO_ARCH_IA32 1
758 # define LZO_INFO_ARCH "i386"
759 #elif defined(__ia64__) || defined(__ia64) || defined(_M_IA64)
760 # define LZO_ARCH_IA64 1
761 # define LZO_INFO_ARCH "ia64"
762 #elif (UINT_MAX == LZO_0xffffL) && defined(__m32c__)
763 # define LZO_ARCH_M16C 1
764 # define LZO_INFO_ARCH "m16c"
765 #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCM16C__)
766 # define LZO_ARCH_M16C 1
767 # define LZO_INFO_ARCH "m16c"
768 #elif defined(__m32r__)
769 # define LZO_ARCH_M32R 1
770 # define LZO_INFO_ARCH "m32r"
771 #elif (LZO_OS_TOS) || defined(__m68k__) || defined(__m68000__) || defined(__mc68000__) || defined(__mc68020__) || defined(_M_M68K)
772 # define LZO_ARCH_M68K 1
773 # define LZO_INFO_ARCH "m68k"
774 #elif (UINT_MAX == LZO_0xffffL) && defined(__C251__)
775 # define LZO_ARCH_MCS251 1
776 # define LZO_INFO_ARCH "mcs251"
777 #elif (UINT_MAX == LZO_0xffffL) && defined(__C51__)
778 # define LZO_ARCH_MCS51 1
779 # define LZO_INFO_ARCH "mcs51"
780 #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICC8051__)
781 # define LZO_ARCH_MCS51 1
782 # define LZO_INFO_ARCH "mcs51"
783 #elif defined(__mips__) || defined(__mips) || defined(_MIPS_ARCH) || defined(_M_MRX000)
784 # define LZO_ARCH_MIPS 1
785 # define LZO_INFO_ARCH "mips"
786 #elif (UINT_MAX == LZO_0xffffL) && defined(__MSP430__)
787 # define LZO_ARCH_MSP430 1
788 # define LZO_INFO_ARCH "msp430"
789 #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICC430__)
790 # define LZO_ARCH_MSP430 1
791 # define LZO_INFO_ARCH "msp430"
792 #elif defined(__powerpc__) || defined(__powerpc) || defined(__ppc__) || defined(__PPC__) || defined(_M_PPC) || defined(_ARCH_PPC) || defined(_ARCH_PWR)
793 # define LZO_ARCH_POWERPC 1
794 # define LZO_INFO_ARCH "powerpc"
795 #elif defined(__s390__) || defined(__s390) || defined(__s390x__) || defined(__s390x)
796 # define LZO_ARCH_S390 1
797 # define LZO_INFO_ARCH "s390"
798 #elif defined(__sh__) || defined(_M_SH)
799 # define LZO_ARCH_SH 1
800 # define LZO_INFO_ARCH "sh"
801 #elif defined(__sparc__) || defined(__sparc) || defined(__sparcv8)
802 # define LZO_ARCH_SPARC 1
803 # define LZO_INFO_ARCH "sparc"
804 #elif defined(__SPU__)
805 # define LZO_ARCH_SPU 1
806 # define LZO_INFO_ARCH "spu"
807 #elif (UINT_MAX == LZO_0xffffL) && defined(__z80)
808 # define LZO_ARCH_Z80 1
809 # define LZO_INFO_ARCH "z80"
810 #elif (LZO_ARCH_CRAY_PVP)
811 # if defined(_CRAYSV1)
812 # define LZO_ARCH_CRAY_SV1 1
813 # define LZO_INFO_ARCH "cray_sv1"
815 # define LZO_ARCH_CRAY_T90 1
816 # define LZO_INFO_ARCH "cray_t90"
818 # define LZO_ARCH_CRAY_YMP 1
819 # define LZO_INFO_ARCH "cray_ymp"
821 # define LZO_ARCH_CRAY_XMP 1
822 # define LZO_INFO_ARCH "cray_xmp"
825 # define LZO_ARCH_UNKNOWN 1
826 # define LZO_INFO_ARCH "unknown"
829 #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_DOS32 || LZO_OS_OS2)
830 # error "FIXME - missing define for CPU architecture"
832 #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN32)
833 # error "FIXME - missing WIN32 define for CPU architecture"
835 #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN64)
836 # error "FIXME - missing WIN64 define for CPU architecture"
838 #if (LZO_OS_OS216 || LZO_OS_WIN16)
839 # define LZO_ARCH_I086PM 1
840 # define LZO_ARCH_IA16PM 1
841 #elif 1 && (LZO_OS_DOS16 && defined(BLX286))
842 # define LZO_ARCH_I086PM 1
843 # define LZO_ARCH_IA16PM 1
844 #elif 1 && (LZO_OS_DOS16 && defined(DOSX286))
845 # define LZO_ARCH_I086PM 1
846 # define LZO_ARCH_IA16PM 1
847 #elif 1 && (LZO_OS_DOS16 && LZO_CC_BORLANDC && defined(__DPMI16__))
848 # define LZO_ARCH_I086PM 1
849 # define LZO_ARCH_IA16PM 1
851 #if (LZO_ARCH_ARM_THUMB) && !(LZO_ARCH_ARM)
852 # error "this should not happen"
854 #if (LZO_ARCH_I086PM) && !(LZO_ARCH_I086)
855 # error "this should not happen"
858 # if (UINT_MAX != LZO_0xffffL)
859 # error "this should not happen"
861 # if (ULONG_MAX != LZO_0xffffffffL)
862 # error "this should not happen"
866 # if (UINT_MAX != LZO_0xffffL) && defined(__i386_int16__)
867 # error "this should not happen"
869 # if (UINT_MAX != LZO_0xffffffffL) && !defined(__i386_int16__)
870 # error "this should not happen"
872 # if (ULONG_MAX != LZO_0xffffffffL)
873 # error "this should not happen"
876 #if !defined(__LZO_MM_OVERRIDE)
878 #if (UINT_MAX != LZO_0xffffL)
879 # error "this should not happen"
881 #if defined(__TINY__) || defined(M_I86TM) || defined(_M_I86TM)
882 # define LZO_MM_TINY 1
883 #elif defined(__HUGE__) || defined(_HUGE_) || defined(M_I86HM) || defined(_M_I86HM)
884 # define LZO_MM_HUGE 1
885 #elif defined(__SMALL__) || defined(M_I86SM) || defined(_M_I86SM) || defined(SMALL_MODEL)
886 # define LZO_MM_SMALL 1
887 #elif defined(__MEDIUM__) || defined(M_I86MM) || defined(_M_I86MM)
888 # define LZO_MM_MEDIUM 1
889 #elif defined(__COMPACT__) || defined(M_I86CM) || defined(_M_I86CM)
890 # define LZO_MM_COMPACT 1
891 #elif defined(__LARGE__) || defined(M_I86LM) || defined(_M_I86LM) || defined(LARGE_MODEL)
892 # define LZO_MM_LARGE 1
893 #elif (LZO_CC_AZTECC)
894 # if defined(_LARGE_CODE) && defined(_LARGE_DATA)
895 # define LZO_MM_LARGE 1
896 # elif defined(_LARGE_CODE)
897 # define LZO_MM_MEDIUM 1
898 # elif defined(_LARGE_DATA)
899 # define LZO_MM_COMPACT 1
901 # define LZO_MM_SMALL 1
903 #elif (LZO_CC_ZORTECHC && defined(__VCM__))
904 # define LZO_MM_LARGE 1
906 # error "unknown memory model"
908 #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16)
909 #define LZO_HAVE_MM_HUGE_PTR 1
910 #define LZO_HAVE_MM_HUGE_ARRAY 1
912 # undef LZO_HAVE_MM_HUGE_ARRAY
914 #if (LZO_CC_AZTECC || LZO_CC_PACIFICC || LZO_CC_ZORTECHC)
915 # undef LZO_HAVE_MM_HUGE_PTR
916 # undef LZO_HAVE_MM_HUGE_ARRAY
917 #elif (LZO_CC_DMC || LZO_CC_SYMANTECC)
918 # undef LZO_HAVE_MM_HUGE_ARRAY
919 #elif (LZO_CC_MSC && defined(_QC))
920 # undef LZO_HAVE_MM_HUGE_ARRAY
921 # if (_MSC_VER < 600)
922 # undef LZO_HAVE_MM_HUGE_PTR
924 #elif (LZO_CC_TURBOC && (__TURBOC__ < 0x0295))
925 # undef LZO_HAVE_MM_HUGE_ARRAY
927 #if (LZO_ARCH_I086PM) && !(LZO_HAVE_MM_HUGE_PTR)
929 # error "this should not happen"
930 # elif (LZO_CC_ZORTECHC)
932 # error "this should not happen"
938 #if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0200))
939 extern void __near __cdecl
_AHSHIFT(void);
940 # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT)
941 #elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC)
942 extern void __near __cdecl
_AHSHIFT(void);
943 # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT)
944 #elif (LZO_CC_MSC || LZO_CC_TOPSPEEDC)
945 extern void __near __cdecl
_AHSHIFT(void);
946 # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT)
947 #elif (LZO_CC_TURBOC && (__TURBOC__ >= 0x0295))
948 extern void __near __cdecl
_AHSHIFT(void);
949 # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT)
950 #elif ((LZO_CC_AZTECC || LZO_CC_PACIFICC || LZO_CC_TURBOC) && LZO_OS_DOS16)
951 # define LZO_MM_AHSHIFT 12
952 #elif (LZO_CC_WATCOMC)
953 extern unsigned char _HShift
;
954 # define LZO_MM_AHSHIFT ((unsigned) _HShift)
956 # error "FIXME - implement LZO_MM_AHSHIFT"
962 #elif (LZO_ARCH_C166)
963 #if !defined(__MODEL__)
964 # error "FIXME - C166 __MODEL__"
965 #elif ((__MODEL__) == 0)
966 # define LZO_MM_SMALL 1
967 #elif ((__MODEL__) == 1)
968 # define LZO_MM_SMALL 1
969 #elif ((__MODEL__) == 2)
970 # define LZO_MM_LARGE 1
971 #elif ((__MODEL__) == 3)
972 # define LZO_MM_TINY 1
973 #elif ((__MODEL__) == 4)
974 # define LZO_MM_XTINY 1
975 #elif ((__MODEL__) == 5)
976 # define LZO_MM_XSMALL 1
978 # error "FIXME - C166 __MODEL__"
980 #elif (LZO_ARCH_MCS251)
981 #if !defined(__MODEL__)
982 # error "FIXME - MCS251 __MODEL__"
983 #elif ((__MODEL__) == 0)
984 # define LZO_MM_SMALL 1
985 #elif ((__MODEL__) == 2)
986 # define LZO_MM_LARGE 1
987 #elif ((__MODEL__) == 3)
988 # define LZO_MM_TINY 1
989 #elif ((__MODEL__) == 4)
990 # define LZO_MM_XTINY 1
991 #elif ((__MODEL__) == 5)
992 # define LZO_MM_XSMALL 1
994 # error "FIXME - MCS251 __MODEL__"
996 #elif (LZO_ARCH_MCS51)
997 #if !defined(__MODEL__)
998 # error "FIXME - MCS51 __MODEL__"
999 #elif ((__MODEL__) == 1)
1000 # define LZO_MM_SMALL 1
1001 #elif ((__MODEL__) == 2)
1002 # define LZO_MM_LARGE 1
1003 #elif ((__MODEL__) == 3)
1004 # define LZO_MM_TINY 1
1005 #elif ((__MODEL__) == 4)
1006 # define LZO_MM_XTINY 1
1007 #elif ((__MODEL__) == 5)
1008 # define LZO_MM_XSMALL 1
1010 # error "FIXME - MCS51 __MODEL__"
1012 #elif (LZO_ARCH_CRAY_PVP)
1013 # define LZO_MM_PVP 1
1015 # define LZO_MM_FLAT 1
1017 #if (LZO_MM_COMPACT)
1018 # define LZO_INFO_MM "compact"
1020 # define LZO_INFO_MM "flat"
1022 # define LZO_INFO_MM "huge"
1023 #elif (LZO_MM_LARGE)
1024 # define LZO_INFO_MM "large"
1025 #elif (LZO_MM_MEDIUM)
1026 # define LZO_INFO_MM "medium"
1028 # define LZO_INFO_MM "pvp"
1029 #elif (LZO_MM_SMALL)
1030 # define LZO_INFO_MM "small"
1032 # define LZO_INFO_MM "tiny"
1034 # error "unknown memory model"
1037 #if defined(SIZEOF_SHORT)
1038 # define LZO_SIZEOF_SHORT (SIZEOF_SHORT)
1040 #if defined(SIZEOF_INT)
1041 # define LZO_SIZEOF_INT (SIZEOF_INT)
1043 #if defined(SIZEOF_LONG)
1044 # define LZO_SIZEOF_LONG (SIZEOF_LONG)
1046 #if defined(SIZEOF_LONG_LONG)
1047 # define LZO_SIZEOF_LONG_LONG (SIZEOF_LONG_LONG)
1049 #if defined(SIZEOF___INT16)
1050 # define LZO_SIZEOF___INT16 (SIZEOF___INT16)
1052 #if defined(SIZEOF___INT32)
1053 # define LZO_SIZEOF___INT32 (SIZEOF___INT32)
1055 #if defined(SIZEOF___INT64)
1056 # define LZO_SIZEOF___INT64 (SIZEOF___INT64)
1058 #if defined(SIZEOF_VOID_P)
1059 # define LZO_SIZEOF_VOID_P (SIZEOF_VOID_P)
1061 #if defined(SIZEOF_SIZE_T)
1062 # define LZO_SIZEOF_SIZE_T (SIZEOF_SIZE_T)
1064 #if defined(SIZEOF_PTRDIFF_T)
1065 # define LZO_SIZEOF_PTRDIFF_T (SIZEOF_PTRDIFF_T)
1067 #define __LZO_LSR(x,b) (((x)+0ul) >> (b))
1068 #if !defined(LZO_SIZEOF_SHORT)
1069 # if (LZO_ARCH_CRAY_PVP)
1070 # define LZO_SIZEOF_SHORT 8
1071 # elif (USHRT_MAX == LZO_0xffffL)
1072 # define LZO_SIZEOF_SHORT 2
1073 # elif (__LZO_LSR(USHRT_MAX,7) == 1)
1074 # define LZO_SIZEOF_SHORT 1
1075 # elif (__LZO_LSR(USHRT_MAX,15) == 1)
1076 # define LZO_SIZEOF_SHORT 2
1077 # elif (__LZO_LSR(USHRT_MAX,31) == 1)
1078 # define LZO_SIZEOF_SHORT 4
1079 # elif (__LZO_LSR(USHRT_MAX,63) == 1)
1080 # define LZO_SIZEOF_SHORT 8
1081 # elif (__LZO_LSR(USHRT_MAX,127) == 1)
1082 # define LZO_SIZEOF_SHORT 16
1084 # error "LZO_SIZEOF_SHORT"
1087 #if !defined(LZO_SIZEOF_INT)
1088 # if (LZO_ARCH_CRAY_PVP)
1089 # define LZO_SIZEOF_INT 8
1090 # elif (UINT_MAX == LZO_0xffffL)
1091 # define LZO_SIZEOF_INT 2
1092 # elif (UINT_MAX == LZO_0xffffffffL)
1093 # define LZO_SIZEOF_INT 4
1094 # elif (__LZO_LSR(UINT_MAX,7) == 1)
1095 # define LZO_SIZEOF_INT 1
1096 # elif (__LZO_LSR(UINT_MAX,15) == 1)
1097 # define LZO_SIZEOF_INT 2
1098 # elif (__LZO_LSR(UINT_MAX,31) == 1)
1099 # define LZO_SIZEOF_INT 4
1100 # elif (__LZO_LSR(UINT_MAX,63) == 1)
1101 # define LZO_SIZEOF_INT 8
1102 # elif (__LZO_LSR(UINT_MAX,127) == 1)
1103 # define LZO_SIZEOF_INT 16
1105 # error "LZO_SIZEOF_INT"
1108 #if !defined(LZO_SIZEOF_LONG)
1109 # if (ULONG_MAX == LZO_0xffffffffL)
1110 # define LZO_SIZEOF_LONG 4
1111 # elif (__LZO_LSR(ULONG_MAX,7) == 1)
1112 # define LZO_SIZEOF_LONG 1
1113 # elif (__LZO_LSR(ULONG_MAX,15) == 1)
1114 # define LZO_SIZEOF_LONG 2
1115 # elif (__LZO_LSR(ULONG_MAX,31) == 1)
1116 # define LZO_SIZEOF_LONG 4
1117 # elif (__LZO_LSR(ULONG_MAX,63) == 1)
1118 # define LZO_SIZEOF_LONG 8
1119 # elif (__LZO_LSR(ULONG_MAX,127) == 1)
1120 # define LZO_SIZEOF_LONG 16
1122 # error "LZO_SIZEOF_LONG"
1125 #if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64)
1126 #if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8)
1127 # if defined(__LONG_MAX__) && defined(__LONG_LONG_MAX__)
1128 # if (LZO_CC_GNUC >= 0x030300ul)
1129 # if ((__LONG_MAX__)+0 == (__LONG_LONG_MAX__)+0)
1130 # define LZO_SIZEOF_LONG_LONG LZO_SIZEOF_LONG
1131 # elif (__LZO_LSR(__LONG_LONG_MAX__,30) == 1)
1132 # define LZO_SIZEOF_LONG_LONG 4
1138 #if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64)
1139 #if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8)
1140 #if (LZO_ARCH_I086 && LZO_CC_DMC)
1141 #elif (LZO_CC_CILLY) && defined(__GNUC__)
1142 # define LZO_SIZEOF_LONG_LONG 8
1143 #elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE)
1144 # define LZO_SIZEOF_LONG_LONG 8
1145 #elif ((LZO_OS_WIN32 || LZO_OS_WIN64 || defined(_WIN32)) && LZO_CC_MSC && (_MSC_VER >= 1400))
1146 # define LZO_SIZEOF_LONG_LONG 8
1147 #elif (LZO_OS_WIN64 || defined(_WIN64))
1148 # define LZO_SIZEOF___INT64 8
1149 #elif (LZO_ARCH_I386 && (LZO_CC_DMC))
1150 # define LZO_SIZEOF_LONG_LONG 8
1151 #elif (LZO_ARCH_I386 && (LZO_CC_SYMANTECC && (__SC__ >= 0x700)))
1152 # define LZO_SIZEOF_LONG_LONG 8
1153 #elif (LZO_ARCH_I386 && (LZO_CC_INTELC && defined(__linux__)))
1154 # define LZO_SIZEOF_LONG_LONG 8
1155 #elif (LZO_ARCH_I386 && (LZO_CC_MWERKS || LZO_CC_PELLESC || LZO_CC_PGI || LZO_CC_SUNPROC))
1156 # define LZO_SIZEOF_LONG_LONG 8
1157 #elif (LZO_ARCH_I386 && (LZO_CC_INTELC || LZO_CC_MSC))
1158 # define LZO_SIZEOF___INT64 8
1159 #elif ((LZO_OS_WIN32 || defined(_WIN32)) && (LZO_CC_MSC))
1160 # define LZO_SIZEOF___INT64 8
1161 #elif (LZO_ARCH_I386 && (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0520)))
1162 # define LZO_SIZEOF___INT64 8
1163 #elif (LZO_ARCH_I386 && (LZO_CC_WATCOMC && (__WATCOMC__ >= 1100)))
1164 # define LZO_SIZEOF___INT64 8
1165 #elif (LZO_CC_WATCOMC && defined(_INTEGRAL_MAX_BITS) && (_INTEGRAL_MAX_BITS == 64))
1166 # define LZO_SIZEOF___INT64 8
1167 #elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__)
1168 # define LZO_SIZEOF_LONG_LONG 8
1169 #elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64)
1170 # define LZO_SIZEOF_LONG_LONG 8
1171 #elif (LZO_CC_SDCC) && (LZO_SIZEOF_INT == 2)
1172 #elif 1 && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
1173 # define LZO_SIZEOF_LONG_LONG 8
1177 #if defined(__cplusplus) && (LZO_CC_GNUC)
1178 # if (LZO_CC_GNUC < 0x020800ul)
1179 # undef LZO_SIZEOF_LONG_LONG
1182 #if (LZO_CFG_NO_LONG_LONG) || defined(__NO_LONG_LONG)
1183 # undef LZO_SIZEOF_LONG_LONG
1185 #if !defined(LZO_SIZEOF_VOID_P)
1187 # define __LZO_WORDSIZE 2
1188 # if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM)
1189 # define LZO_SIZEOF_VOID_P 2
1190 # elif (LZO_MM_COMPACT || LZO_MM_LARGE || LZO_MM_HUGE)
1191 # define LZO_SIZEOF_VOID_P 4
1195 #elif (LZO_ARCH_AVR || LZO_ARCH_Z80)
1196 # define __LZO_WORDSIZE 1
1197 # define LZO_SIZEOF_VOID_P 2
1198 #elif (LZO_ARCH_C166 || LZO_ARCH_MCS51 || LZO_ARCH_MCS251 || LZO_ARCH_MSP430)
1199 # define LZO_SIZEOF_VOID_P 2
1200 #elif (LZO_ARCH_H8300)
1201 # if defined(__NORMAL_MODE__)
1202 # define __LZO_WORDSIZE 4
1203 # define LZO_SIZEOF_VOID_P 2
1204 # elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__)
1205 # define __LZO_WORDSIZE 4
1206 # define LZO_SIZEOF_VOID_P 4
1208 # define __LZO_WORDSIZE 2
1209 # define LZO_SIZEOF_VOID_P 2
1211 # if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_SIZEOF_INT == 4)
1212 # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_INT
1213 # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_INT
1215 #elif (LZO_ARCH_M16C)
1216 # define __LZO_WORDSIZE 2
1217 # if defined(__m32c_cpu__) || defined(__m32cm_cpu__)
1218 # define LZO_SIZEOF_VOID_P 4
1220 # define LZO_SIZEOF_VOID_P 2
1222 #elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__))
1223 # define __LZO_WORDSIZE 8
1224 # define LZO_SIZEOF_VOID_P 4
1225 #elif defined(__LLP64__) || defined(__LLP64) || defined(_LLP64) || defined(_WIN64)
1226 # define __LZO_WORDSIZE 8
1227 # define LZO_SIZEOF_VOID_P 8
1228 #elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__)
1229 # define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG
1230 # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG
1231 # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG
1232 #elif (LZO_OS_OS400 || defined(__OS400__))
1233 # define __LZO_WORDSIZE LZO_SIZEOF_LONG
1234 # define LZO_SIZEOF_VOID_P 16
1235 # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG
1236 # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG
1237 #elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64)
1238 # define LZO_SIZEOF_VOID_P 8
1239 # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG
1240 # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG
1241 #elif (LZO_ARCH_SPU)
1243 # define __LZO_WORDSIZE 16
1245 # define LZO_SIZEOF_VOID_P 4
1247 # define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG
1250 #if !defined(LZO_WORDSIZE)
1251 # if defined(__LZO_WORDSIZE)
1252 # define LZO_WORDSIZE __LZO_WORDSIZE
1254 # define LZO_WORDSIZE LZO_SIZEOF_VOID_P
1257 #if !defined(LZO_SIZEOF_SIZE_T)
1258 #if (LZO_ARCH_I086 || LZO_ARCH_M16C)
1259 # define LZO_SIZEOF_SIZE_T 2
1261 # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_VOID_P
1264 #if !defined(LZO_SIZEOF_PTRDIFF_T)
1266 # if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM || LZO_MM_HUGE)
1267 # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_VOID_P
1268 # elif (LZO_MM_COMPACT || LZO_MM_LARGE)
1269 # if (LZO_CC_BORLANDC || LZO_CC_TURBOC)
1270 # define LZO_SIZEOF_PTRDIFF_T 4
1272 # define LZO_SIZEOF_PTRDIFF_T 2
1278 # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_SIZE_T
1281 #if (LZO_ABI_NEUTRAL_ENDIAN)
1282 # undef LZO_ABI_BIG_ENDIAN
1283 # undef LZO_ABI_LITTLE_ENDIAN
1284 #elif !(LZO_ABI_BIG_ENDIAN) && !(LZO_ABI_LITTLE_ENDIAN)
1285 #if (LZO_ARCH_ALPHA) && (LZO_ARCH_CRAY_MPP)
1286 # define LZO_ABI_BIG_ENDIAN 1
1287 #elif (LZO_ARCH_IA64) && (LZO_OS_POSIX_LINUX || LZO_OS_WIN64)
1288 # define LZO_ABI_LITTLE_ENDIAN 1
1289 #elif (LZO_ARCH_ALPHA || LZO_ARCH_AMD64 || LZO_ARCH_BLACKFIN || LZO_ARCH_CRIS || LZO_ARCH_I086 || LZO_ARCH_I386 || LZO_ARCH_MSP430)
1290 # define LZO_ABI_LITTLE_ENDIAN 1
1291 #elif (LZO_ARCH_AVR32 || LZO_ARCH_M68K || LZO_ARCH_S390)
1292 # define LZO_ABI_BIG_ENDIAN 1
1293 #elif 1 && defined(__IAR_SYSTEMS_ICC__) && defined(__LITTLE_ENDIAN__)
1294 # if (__LITTLE_ENDIAN__ == 1)
1295 # define LZO_ABI_LITTLE_ENDIAN 1
1297 # define LZO_ABI_BIG_ENDIAN 1
1299 #elif 1 && defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__)
1300 # define LZO_ABI_BIG_ENDIAN 1
1301 #elif 1 && defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)
1302 # define LZO_ABI_LITTLE_ENDIAN 1
1303 #elif 1 && (LZO_ARCH_ARM) && defined(__ARMEB__) && !defined(__ARMEL__)
1304 # define LZO_ABI_BIG_ENDIAN 1
1305 #elif 1 && (LZO_ARCH_ARM) && defined(__ARMEL__) && !defined(__ARMEB__)
1306 # define LZO_ABI_LITTLE_ENDIAN 1
1307 #elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEB__) && !defined(__MIPSEL__)
1308 # define LZO_ABI_BIG_ENDIAN 1
1309 #elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEL__) && !defined(__MIPSEB__)
1310 # define LZO_ABI_LITTLE_ENDIAN 1
1313 #if (LZO_ABI_BIG_ENDIAN) && (LZO_ABI_LITTLE_ENDIAN)
1314 # error "this should not happen"
1316 #if (LZO_ABI_BIG_ENDIAN)
1317 # define LZO_INFO_ABI_ENDIAN "be"
1318 #elif (LZO_ABI_LITTLE_ENDIAN)
1319 # define LZO_INFO_ABI_ENDIAN "le"
1320 #elif (LZO_ABI_NEUTRAL_ENDIAN)
1321 # define LZO_INFO_ABI_ENDIAN "neutral"
1323 #if (LZO_SIZEOF_INT == 1 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2)
1324 # define LZO_ABI_I8LP16 1
1325 # define LZO_INFO_ABI_PM "i8lp16"
1326 #elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2)
1327 # define LZO_ABI_ILP16 1
1328 # define LZO_INFO_ABI_PM "ilp16"
1329 #elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4)
1330 # define LZO_ABI_ILP32 1
1331 # define LZO_INFO_ABI_PM "ilp32"
1332 #elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 8 && LZO_SIZEOF_SIZE_T == 8)
1333 # define LZO_ABI_LLP64 1
1334 # define LZO_INFO_ABI_PM "llp64"
1335 #elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8)
1336 # define LZO_ABI_LP64 1
1337 # define LZO_INFO_ABI_PM "lp64"
1338 #elif (LZO_SIZEOF_INT == 8 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8)
1339 # define LZO_ABI_ILP64 1
1340 # define LZO_INFO_ABI_PM "ilp64"
1341 #elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 4)
1342 # define LZO_ABI_IP32L64 1
1343 # define LZO_INFO_ABI_PM "ip32l64"
1345 #if !defined(__LZO_LIBC_OVERRIDE)
1346 #if (LZO_LIBC_NAKED)
1347 # define LZO_INFO_LIBC "naked"
1348 #elif (LZO_LIBC_FREESTANDING)
1349 # define LZO_INFO_LIBC "freestanding"
1350 #elif (LZO_LIBC_MOSTLY_FREESTANDING)
1351 # define LZO_INFO_LIBC "mfreestanding"
1352 #elif (LZO_LIBC_ISOC90)
1353 # define LZO_INFO_LIBC "isoc90"
1354 #elif (LZO_LIBC_ISOC99)
1355 # define LZO_INFO_LIBC "isoc99"
1356 #elif defined(__dietlibc__)
1357 # define LZO_LIBC_DIETLIBC 1
1358 # define LZO_INFO_LIBC "dietlibc"
1359 #elif defined(_NEWLIB_VERSION)
1360 # define LZO_LIBC_NEWLIB 1
1361 # define LZO_INFO_LIBC "newlib"
1362 #elif defined(__UCLIBC__) && defined(__UCLIBC_MAJOR__) && defined(__UCLIBC_MINOR__)
1363 # if defined(__UCLIBC_SUBLEVEL__)
1364 # define LZO_LIBC_UCLIBC (__UCLIBC_MAJOR__ * 0x10000L + __UCLIBC_MINOR__ * 0x100 + __UCLIBC_SUBLEVEL__)
1366 # define LZO_LIBC_UCLIBC 0x00090bL
1368 # define LZO_INFO_LIBC "uclibc"
1369 #elif defined(__GLIBC__) && defined(__GLIBC_MINOR__)
1370 # define LZO_LIBC_GLIBC (__GLIBC__ * 0x10000L + __GLIBC_MINOR__ * 0x100)
1371 # define LZO_INFO_LIBC "glibc"
1372 #elif (LZO_CC_MWERKS) && defined(__MSL__)
1373 # define LZO_LIBC_MSL __MSL__
1374 # define LZO_INFO_LIBC "msl"
1375 #elif 1 && defined(__IAR_SYSTEMS_ICC__)
1376 # define LZO_LIBC_ISOC90 1
1377 # define LZO_INFO_LIBC "isoc90"
1379 # define LZO_LIBC_DEFAULT 1
1380 # define LZO_INFO_LIBC "default"
1383 #if !defined(__lzo_gnuc_extension__)
1384 #if (LZO_CC_GNUC >= 0x020800ul)
1385 # define __lzo_gnuc_extension__ __extension__
1386 #elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
1387 # define __lzo_gnuc_extension__ __extension__
1389 # define __lzo_gnuc_extension__ /*empty*/
1392 #if !defined(__lzo_ua_volatile)
1393 # define __lzo_ua_volatile volatile
1395 #if !defined(__lzo_alignof)
1396 #if (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI)
1397 # define __lzo_alignof(e) __alignof__(e)
1398 #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 700))
1399 # define __lzo_alignof(e) __alignof__(e)
1400 #elif (LZO_CC_MSC && (_MSC_VER >= 1300))
1401 # define __lzo_alignof(e) __alignof(e)
1402 #elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100))
1403 # define __lzo_alignof(e) __alignof__(e)
1406 #if defined(__lzo_alignof)
1407 # define __lzo_HAVE_alignof 1
1409 #if !defined(__lzo_constructor)
1410 #if (LZO_CC_GNUC >= 0x030400ul)
1411 # define __lzo_constructor __attribute__((__constructor__,__used__))
1412 #elif (LZO_CC_GNUC >= 0x020700ul)
1413 # define __lzo_constructor __attribute__((__constructor__))
1414 #elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
1415 # define __lzo_constructor __attribute__((__constructor__))
1418 #if defined(__lzo_constructor)
1419 # define __lzo_HAVE_constructor 1
1421 #if !defined(__lzo_destructor)
1422 #if (LZO_CC_GNUC >= 0x030400ul)
1423 # define __lzo_destructor __attribute__((__destructor__,__used__))
1424 #elif (LZO_CC_GNUC >= 0x020700ul)
1425 # define __lzo_destructor __attribute__((__destructor__))
1426 #elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
1427 # define __lzo_destructor __attribute__((__destructor__))
1430 #if defined(__lzo_destructor)
1431 # define __lzo_HAVE_destructor 1
1433 #if (__lzo_HAVE_destructor) && !(__lzo_HAVE_constructor)
1434 # error "this should not happen"
1436 #if !defined(__lzo_inline)
1437 #if (LZO_CC_TURBOC && (__TURBOC__ <= 0x0295))
1438 #elif defined(__cplusplus)
1439 # define __lzo_inline inline
1440 #elif (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0550))
1441 # define __lzo_inline __inline
1442 #elif (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI)
1443 # define __lzo_inline __inline__
1445 # define __lzo_inline __inline
1446 #elif (LZO_CC_INTELC)
1447 # define __lzo_inline __inline
1448 #elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x2405))
1449 # define __lzo_inline __inline
1450 #elif (LZO_CC_MSC && (_MSC_VER >= 900))
1451 # define __lzo_inline __inline
1452 #elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100))
1453 # define __lzo_inline __inline__
1454 #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
1455 # define __lzo_inline inline
1458 #if defined(__lzo_inline)
1459 # define __lzo_HAVE_inline 1
1461 # define __lzo_inline /*empty*/
1463 #if !defined(__lzo_forceinline)
1464 #if (LZO_CC_GNUC >= 0x030200ul)
1465 # define __lzo_forceinline __inline__ __attribute__((__always_inline__))
1466 #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC)
1467 # define __lzo_forceinline __forceinline
1468 #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC)
1469 # define __lzo_forceinline __inline__ __attribute__((__always_inline__))
1470 #elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
1471 # define __lzo_forceinline __inline__ __attribute__((__always_inline__))
1472 #elif (LZO_CC_MSC && (_MSC_VER >= 1200))
1473 # define __lzo_forceinline __forceinline
1474 #elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100))
1475 # define __lzo_forceinline __inline__ __attribute__((__always_inline__))
1478 #if defined(__lzo_forceinline)
1479 # define __lzo_HAVE_forceinline 1
1481 # define __lzo_forceinline /*empty*/
1483 #if !defined(__lzo_noinline)
1484 #if 1 && (LZO_ARCH_I386) && (LZO_CC_GNUC >= 0x040000ul) && (LZO_CC_GNUC < 0x040003ul)
1485 # define __lzo_noinline __attribute__((__noinline__,__used__))
1486 #elif (LZO_CC_GNUC >= 0x030200ul)
1487 # define __lzo_noinline __attribute__((__noinline__))
1488 #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_MSC)
1489 # define __lzo_noinline __declspec(noinline)
1490 #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC)
1491 # define __lzo_noinline __attribute__((__noinline__))
1492 #elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
1493 # define __lzo_noinline __attribute__((__noinline__))
1494 #elif (LZO_CC_MSC && (_MSC_VER >= 1300))
1495 # define __lzo_noinline __declspec(noinline)
1496 #elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x3200) && (LZO_OS_WIN32 || LZO_OS_WIN64))
1497 # if defined(__cplusplus)
1499 # define __lzo_noinline __declspec(noinline)
1501 #elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100))
1502 # define __lzo_noinline __attribute__((__noinline__))
1505 #if defined(__lzo_noinline)
1506 # define __lzo_HAVE_noinline 1
1508 # define __lzo_noinline /*empty*/
1510 #if (__lzo_HAVE_forceinline || __lzo_HAVE_noinline) && !(__lzo_HAVE_inline)
1511 # error "this should not happen"
1513 #if !defined(__lzo_noreturn)
1514 #if (LZO_CC_GNUC >= 0x020700ul)
1515 # define __lzo_noreturn __attribute__((__noreturn__))
1516 #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC)
1517 # define __lzo_noreturn __declspec(noreturn)
1518 #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_GNUC)
1519 # define __lzo_noreturn __attribute__((__noreturn__))
1520 #elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
1521 # define __lzo_noreturn __attribute__((__noreturn__))
1522 #elif (LZO_CC_MSC && (_MSC_VER >= 1200))
1523 # define __lzo_noreturn __declspec(noreturn)
1526 #if defined(__lzo_noreturn)
1527 # define __lzo_HAVE_noreturn 1
1529 # define __lzo_noreturn /*empty*/
1531 #if !defined(__lzo_nothrow)
1532 #if (LZO_CC_GNUC >= 0x030300ul)
1533 # define __lzo_nothrow __attribute__((__nothrow__))
1534 #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) && defined(__cplusplus)
1535 # define __lzo_nothrow __declspec(nothrow)
1536 #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 900) && LZO_CC_SYNTAX_GNUC)
1537 # define __lzo_nothrow __attribute__((__nothrow__))
1538 #elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
1539 # define __lzo_nothrow __attribute__((__nothrow__))
1540 #elif (LZO_CC_MSC && (_MSC_VER >= 1200)) && defined(__cplusplus)
1541 # define __lzo_nothrow __declspec(nothrow)
1544 #if defined(__lzo_nothrow)
1545 # define __lzo_HAVE_nothrow 1
1547 # define __lzo_nothrow /*empty*/
1549 #if !defined(__lzo_restrict)
1550 #if (LZO_CC_GNUC >= 0x030400ul)
1551 # define __lzo_restrict __restrict__
1552 #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_GNUC)
1553 # define __lzo_restrict __restrict__
1554 #elif (LZO_CC_CLANG || LZO_CC_LLVM)
1555 # define __lzo_restrict __restrict__
1556 #elif (LZO_CC_MSC && (_MSC_VER >= 1400))
1557 # define __lzo_restrict __restrict
1560 #if defined(__lzo_restrict)
1561 # define __lzo_HAVE_restrict 1
1563 # define __lzo_restrict /*empty*/
1565 #if !defined(__lzo_likely) && !defined(__lzo_unlikely)
1566 #if (LZO_CC_GNUC >= 0x030200ul)
1567 # define __lzo_likely(e) (__builtin_expect(!!(e),1))
1568 # define __lzo_unlikely(e) (__builtin_expect(!!(e),0))
1569 #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800))
1570 # define __lzo_likely(e) (__builtin_expect(!!(e),1))
1571 # define __lzo_unlikely(e) (__builtin_expect(!!(e),0))
1572 #elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
1573 # define __lzo_likely(e) (__builtin_expect(!!(e),1))
1574 # define __lzo_unlikely(e) (__builtin_expect(!!(e),0))
1577 #if defined(__lzo_likely)
1578 # define __lzo_HAVE_likely 1
1580 # define __lzo_likely(e) (e)
1582 #if defined(__lzo_unlikely)
1583 # define __lzo_HAVE_unlikely 1
1585 # define __lzo_unlikely(e) (e)
1587 #if !defined(LZO_UNUSED)
1588 # if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600))
1589 # define LZO_UNUSED(var) ((void) &var)
1590 # elif (LZO_CC_BORLANDC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PELLESC || LZO_CC_TURBOC)
1591 # define LZO_UNUSED(var) if (&var) ; else
1592 # elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE)
1593 # define LZO_UNUSED(var) ((void) var)
1594 # elif (LZO_CC_MSC && (_MSC_VER < 900))
1595 # define LZO_UNUSED(var) if (&var) ; else
1596 # elif (LZO_CC_KEILC)
1597 # define LZO_UNUSED(var) {extern int __lzo_unused[1-2*!(sizeof(var)>0)];}
1598 # elif (LZO_CC_PACIFICC)
1599 # define LZO_UNUSED(var) ((void) sizeof(var))
1600 # elif (LZO_CC_WATCOMC) && defined(__cplusplus)
1601 # define LZO_UNUSED(var) ((void) var)
1603 # define LZO_UNUSED(var) ((void) &var)
1606 #if !defined(LZO_UNUSED_FUNC)
1607 # if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600))
1608 # define LZO_UNUSED_FUNC(func) ((void) func)
1609 # elif (LZO_CC_BORLANDC || LZO_CC_NDPC || LZO_CC_TURBOC)
1610 # define LZO_UNUSED_FUNC(func) if (func) ; else
1611 # elif (LZO_CC_CLANG || LZO_CC_LLVM)
1612 # define LZO_UNUSED_FUNC(func) ((void) &func)
1613 # elif (LZO_CC_MSC && (_MSC_VER < 900))
1614 # define LZO_UNUSED_FUNC(func) if (func) ; else
1616 # define LZO_UNUSED_FUNC(func) ((void) &func)
1617 # elif (LZO_CC_KEILC || LZO_CC_PELLESC)
1618 # define LZO_UNUSED_FUNC(func) {extern int __lzo_unused[1-2*!(sizeof((int)func)>0)];}
1620 # define LZO_UNUSED_FUNC(func) ((void) func)
1623 #if !defined(LZO_UNUSED_LABEL)
1624 # if (LZO_CC_WATCOMC) && defined(__cplusplus)
1625 # define LZO_UNUSED_LABEL(l) switch(0) case 1:goto l
1626 # elif (LZO_CC_CLANG || LZO_CC_INTELC || LZO_CC_WATCOMC)
1627 # define LZO_UNUSED_LABEL(l) if (0) goto l
1629 # define LZO_UNUSED_LABEL(l) switch(0) case 1:goto l
1632 #if !defined(LZO_DEFINE_UNINITIALIZED_VAR)
1634 # define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var
1635 # elif 0 && (LZO_CC_GNUC)
1636 # define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = var
1638 # define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = init
1641 #if !defined(LZO_UNCONST_CAST)
1642 # if 0 && defined(__cplusplus)
1643 # define LZO_UNCONST_CAST(t,e) (const_cast<t> (e))
1644 # elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE)
1645 # define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((char *) ((lzo_uintptr_t) ((const void *) (e))))))
1647 # define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((char *) ((const void *) (e)))))
1650 #if !defined(LZO_COMPILE_TIME_ASSERT_HEADER)
1651 # if (LZO_CC_AZTECC || LZO_CC_ZORTECHC)
1652 # define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-!(e)];
1653 # elif (LZO_CC_DMC || LZO_CC_SYMANTECC)
1654 # define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1u-2*!(e)];
1655 # elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295))
1656 # define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-!(e)];
1658 # define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-2*!(e)];
1661 #if !defined(LZO_COMPILE_TIME_ASSERT)
1662 # if (LZO_CC_AZTECC)
1663 # define LZO_COMPILE_TIME_ASSERT(e) {typedef int __lzo_cta_t[1-!(e)];}
1664 # elif (LZO_CC_DMC || LZO_CC_PACIFICC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC)
1665 # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break;
1666 # elif (LZO_CC_MSC && (_MSC_VER < 900))
1667 # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break;
1668 # elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295))
1669 # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break;
1671 # define LZO_COMPILE_TIME_ASSERT(e) {typedef int __lzo_cta_t[1-2*!(e)];}
1674 #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)
1675 # if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC)
1676 # elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC)
1677 # define __lzo_cdecl __cdecl
1678 # define __lzo_cdecl_atexit /*empty*/
1679 # define __lzo_cdecl_main __cdecl
1680 # if (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC))
1681 # define __lzo_cdecl_qsort __pascal
1682 # elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC))
1683 # define __lzo_cdecl_qsort _stdcall
1685 # define __lzo_cdecl_qsort __cdecl
1687 # elif (LZO_CC_WATCOMC)
1688 # define __lzo_cdecl __cdecl
1690 # define __lzo_cdecl __cdecl
1691 # define __lzo_cdecl_atexit __cdecl
1692 # define __lzo_cdecl_main __cdecl
1693 # define __lzo_cdecl_qsort __cdecl
1695 # if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC || LZO_CC_WATCOMC)
1696 # elif (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC))
1697 # define __lzo_cdecl_sighandler __pascal
1698 # elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC))
1699 # define __lzo_cdecl_sighandler _stdcall
1700 # elif (LZO_CC_MSC && (_MSC_VER >= 1400)) && defined(_M_CEE_PURE)
1701 # define __lzo_cdecl_sighandler __clrcall
1702 # elif (LZO_CC_MSC && (_MSC_VER >= 600 && _MSC_VER < 700))
1704 # define __lzo_cdecl_sighandler _far _cdecl _loadds
1706 # define __lzo_cdecl_sighandler _far _cdecl
1708 # define __lzo_cdecl_sighandler _cdecl
1711 # define __lzo_cdecl_sighandler __cdecl
1713 #elif (LZO_ARCH_I386) && (LZO_CC_WATCOMC)
1714 # define __lzo_cdecl __cdecl
1715 #elif (LZO_ARCH_M68K && LZO_OS_TOS && (LZO_CC_PUREC || LZO_CC_TURBOC))
1716 # define __lzo_cdecl cdecl
1718 #if !defined(__lzo_cdecl)
1719 # define __lzo_cdecl /*empty*/
1721 #if !defined(__lzo_cdecl_atexit)
1722 # define __lzo_cdecl_atexit /*empty*/
1724 #if !defined(__lzo_cdecl_main)
1725 # define __lzo_cdecl_main /*empty*/
1727 #if !defined(__lzo_cdecl_qsort)
1728 # define __lzo_cdecl_qsort /*empty*/
1730 #if !defined(__lzo_cdecl_sighandler)
1731 # define __lzo_cdecl_sighandler /*empty*/
1733 #if !defined(__lzo_cdecl_va)
1734 # define __lzo_cdecl_va __lzo_cdecl
1736 #if !(LZO_CFG_NO_WINDOWS_H)
1737 #if (LZO_OS_CYGWIN || (LZO_OS_EMX && defined(__RSXNT__)) || LZO_OS_WIN32 || LZO_OS_WIN64)
1738 # if (LZO_CC_WATCOMC && (__WATCOMC__ < 1000))
1739 # elif (LZO_OS_WIN32 && LZO_CC_GNUC) && defined(__PW32__)
1740 # elif ((LZO_OS_CYGWIN || defined(__MINGW32__)) && (LZO_CC_GNUC && (LZO_CC_GNUC < 0x025f00ul)))
1742 # define LZO_HAVE_WINDOWS_H 1
1746 #if (LZO_ARCH_ALPHA)
1747 # define LZO_OPT_AVOID_UINT_INDEX 1
1748 # define LZO_OPT_AVOID_SHORT 1
1749 # define LZO_OPT_AVOID_USHORT 1
1750 #elif (LZO_ARCH_AMD64)
1751 # define LZO_OPT_AVOID_INT_INDEX 1
1752 # define LZO_OPT_AVOID_UINT_INDEX 1
1753 # define LZO_OPT_UNALIGNED16 1
1754 # define LZO_OPT_UNALIGNED32 1
1755 # define LZO_OPT_UNALIGNED64 1
1756 #elif (LZO_ARCH_ARM && LZO_ARCH_ARM_THUMB)
1757 #elif (LZO_ARCH_ARM)
1758 # define LZO_OPT_AVOID_SHORT 1
1759 # define LZO_OPT_AVOID_USHORT 1
1760 #elif (LZO_ARCH_CRIS)
1761 # define LZO_OPT_UNALIGNED16 1
1762 # define LZO_OPT_UNALIGNED32 1
1763 #elif (LZO_ARCH_I386)
1764 # define LZO_OPT_UNALIGNED16 1
1765 # define LZO_OPT_UNALIGNED32 1
1766 #elif (LZO_ARCH_IA64)
1767 # define LZO_OPT_AVOID_INT_INDEX 1
1768 # define LZO_OPT_AVOID_UINT_INDEX 1
1769 # define LZO_OPT_PREFER_POSTINC 1
1770 #elif (LZO_ARCH_M68K)
1771 # define LZO_OPT_PREFER_POSTINC 1
1772 # define LZO_OPT_PREFER_PREDEC 1
1773 # if defined(__mc68020__) && !defined(__mcoldfire__)
1774 # define LZO_OPT_UNALIGNED16 1
1775 # define LZO_OPT_UNALIGNED32 1
1777 #elif (LZO_ARCH_MIPS)
1778 # define LZO_OPT_AVOID_UINT_INDEX 1
1779 #elif (LZO_ARCH_POWERPC)
1780 # define LZO_OPT_PREFER_PREINC 1
1781 # define LZO_OPT_PREFER_PREDEC 1
1782 # if (LZO_ABI_BIG_ENDIAN)
1783 # define LZO_OPT_UNALIGNED16 1
1784 # define LZO_OPT_UNALIGNED32 1
1786 #elif (LZO_ARCH_S390)
1787 # define LZO_OPT_UNALIGNED16 1
1788 # define LZO_OPT_UNALIGNED32 1
1789 # if (LZO_SIZEOF_SIZE_T == 8)
1790 # define LZO_OPT_UNALIGNED64 1
1793 # define LZO_OPT_PREFER_POSTINC 1
1794 # define LZO_OPT_PREFER_PREDEC 1
1796 #ifndef LZO_CFG_NO_INLINE_ASM
1798 # define LZO_CFG_NO_INLINE_ASM 1
1801 #ifndef LZO_CFG_NO_UNALIGNED
1802 #if (LZO_ABI_NEUTRAL_ENDIAN) || (LZO_ARCH_GENERIC)
1803 # define LZO_CFG_NO_UNALIGNED 1
1806 #if (LZO_CFG_NO_UNALIGNED)
1807 # undef LZO_OPT_UNALIGNED16
1808 # undef LZO_OPT_UNALIGNED32
1809 # undef LZO_OPT_UNALIGNED64
1811 #if (LZO_CFG_NO_INLINE_ASM)
1812 #elif (LZO_ARCH_I386 && (LZO_OS_DOS32 || LZO_OS_WIN32) && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC))
1813 # define LZO_ASM_SYNTAX_MSC 1
1814 #elif (LZO_OS_WIN64 && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC))
1815 #elif (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC == 0x011f00ul))
1816 #elif (LZO_ARCH_I386 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE))
1817 # define LZO_ASM_SYNTAX_GNUC 1
1818 #elif (LZO_ARCH_AMD64 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE))
1819 # define LZO_ASM_SYNTAX_GNUC 1
1821 #if (LZO_ASM_SYNTAX_GNUC)
1822 #if (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC < 0x020000ul))
1823 # define __LZO_ASM_CLOBBER "ax"
1824 #elif (LZO_CC_INTELC)
1825 # define __LZO_ASM_CLOBBER "memory"
1827 # define __LZO_ASM_CLOBBER "cc", "memory"
1830 #if defined(__LZO_INFOSTR_MM)
1831 #elif (LZO_MM_FLAT) && (defined(__LZO_INFOSTR_PM) || defined(LZO_INFO_ABI_PM))
1832 # define __LZO_INFOSTR_MM ""
1833 #elif defined(LZO_INFO_MM)
1834 # define __LZO_INFOSTR_MM "." LZO_INFO_MM
1836 # define __LZO_INFOSTR_MM ""
1838 #if defined(__LZO_INFOSTR_PM)
1839 #elif defined(LZO_INFO_ABI_PM)
1840 # define __LZO_INFOSTR_PM "." LZO_INFO_ABI_PM
1842 # define __LZO_INFOSTR_PM ""
1844 #if defined(__LZO_INFOSTR_ENDIAN)
1845 #elif defined(LZO_INFO_ABI_ENDIAN)
1846 # define __LZO_INFOSTR_ENDIAN "." LZO_INFO_ABI_ENDIAN
1848 # define __LZO_INFOSTR_ENDIAN ""
1850 #if defined(__LZO_INFOSTR_OSNAME)
1851 #elif defined(LZO_INFO_OS_CONSOLE)
1852 # define __LZO_INFOSTR_OSNAME LZO_INFO_OS "." LZO_INFO_OS_CONSOLE
1853 #elif defined(LZO_INFO_OS_POSIX)
1854 # define __LZO_INFOSTR_OSNAME LZO_INFO_OS "." LZO_INFO_OS_POSIX
1856 # define __LZO_INFOSTR_OSNAME LZO_INFO_OS
1858 #if defined(__LZO_INFOSTR_LIBC)
1859 #elif defined(LZO_INFO_LIBC)
1860 # define __LZO_INFOSTR_LIBC "." LZO_INFO_LIBC
1862 # define __LZO_INFOSTR_LIBC ""
1864 #if defined(__LZO_INFOSTR_CCVER)
1865 #elif defined(LZO_INFO_CCVER)
1866 # define __LZO_INFOSTR_CCVER " " LZO_INFO_CCVER
1868 # define __LZO_INFOSTR_CCVER ""
1870 #define LZO_INFO_STRING \
1871 LZO_INFO_ARCH __LZO_INFOSTR_MM __LZO_INFOSTR_PM __LZO_INFOSTR_ENDIAN \
1872 " " __LZO_INFOSTR_OSNAME __LZO_INFOSTR_LIBC " " LZO_INFO_CC __LZO_INFOSTR_CCVER
1878 #undef LZO_HAVE_CONFIG_H
1879 #include "minilzo.h"
1881 #if !defined(MINILZO_VERSION) || (MINILZO_VERSION != 0x2060)
1882 # error "version mismatch in miniLZO source files"
1885 #ifdef MINILZO_HAVE_CONFIG_H
1886 # define LZO_HAVE_CONFIG_H 1
1889 #ifndef __LZO_CONF_H
1890 #define __LZO_CONF_H 1
1892 #if !defined(__LZO_IN_MINILZO)
1893 #if (LZO_CFG_FREESTANDING)
1894 # define LZO_LIBC_FREESTANDING 1
1895 # define LZO_OS_FREESTANDING 1
1896 # define ACC_LIBC_FREESTANDING 1
1897 # define ACC_OS_FREESTANDING 1
1899 #if (LZO_CFG_NO_UNALIGNED)
1900 # define ACC_CFG_NO_UNALIGNED 1
1902 #if (LZO_ARCH_GENERIC)
1903 # define ACC_ARCH_GENERIC 1
1905 #if (LZO_ABI_NEUTRAL_ENDIAN)
1906 # define ACC_ABI_NEUTRAL_ENDIAN 1
1908 #if (LZO_HAVE_CONFIG_H)
1909 # define ACC_CONFIG_NO_HEADER 1
1911 #if defined(LZO_CFG_EXTRA_CONFIG_HEADER)
1912 # include LZO_CFG_EXTRA_CONFIG_HEADER
1914 #if defined(__LZOCONF_H) || defined(__LZOCONF_H_INCLUDED)
1915 # error "include this file first"
1917 #include "lzo/lzoconf.h"
1920 #if (LZO_VERSION < 0x02000) || !defined(__LZOCONF_H_INCLUDED)
1921 # error "version mismatch"
1924 #if (LZO_CC_BORLANDC && LZO_ARCH_I086)
1928 #if (LZO_CC_MSC && (_MSC_VER >= 1000))
1929 # pragma warning(disable: 4127 4701)
1931 #if (LZO_CC_MSC && (_MSC_VER >= 1300))
1932 # pragma warning(disable: 4820)
1933 # pragma warning(disable: 4514 4710 4711)
1936 #if (LZO_CC_SUNPROC)
1937 #if !defined(__cplusplus)
1938 # pragma error_messages(off,E_END_OF_LOOP_CODE_NOT_REACHED)
1939 # pragma error_messages(off,E_LOOP_NOT_ENTERED_AT_TOP)
1940 # pragma error_messages(off,E_STATEMENT_NOT_REACHED)
1944 #if (__LZO_MMODEL_HUGE) && !(LZO_HAVE_MM_HUGE_PTR)
1945 # error "this should not happen - check defines for __huge"
1948 #if defined(__LZO_IN_MINILZO) || defined(LZO_CFG_FREESTANDING)
1949 #elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16)
1950 # define ACC_WANT_ACC_INCD_H 1
1951 # define ACC_WANT_ACC_INCE_H 1
1952 # define ACC_WANT_ACC_INCI_H 1
1954 # include <string.h>
1956 # define ACC_WANT_ACC_INCD_H 1
1960 # define ACC_MM_AHSHIFT LZO_MM_AHSHIFT
1961 # define ACC_PTR_FP_OFF(x) (((const unsigned __far*)&(x))[0])
1962 # define ACC_PTR_FP_SEG(x) (((const unsigned __far*)&(x))[1])
1963 # define ACC_PTR_MK_FP(s,o) ((void __far*)(((unsigned long)(s)<<16)+(unsigned)(o)))
1966 #if !defined(lzo_uintptr_t)
1967 # if defined(__LZO_MMODEL_HUGE)
1968 # define lzo_uintptr_t unsigned long
1969 # elif 1 && defined(LZO_OS_OS400) && (LZO_SIZEOF_VOID_P == 16)
1970 # define __LZO_UINTPTR_T_IS_POINTER 1
1971 typedef char* lzo_uintptr_t
;
1972 # define lzo_uintptr_t lzo_uintptr_t
1973 # elif (LZO_SIZEOF_SIZE_T == LZO_SIZEOF_VOID_P)
1974 # define lzo_uintptr_t size_t
1975 # elif (LZO_SIZEOF_LONG == LZO_SIZEOF_VOID_P)
1976 # define lzo_uintptr_t unsigned long
1977 # elif (LZO_SIZEOF_INT == LZO_SIZEOF_VOID_P)
1978 # define lzo_uintptr_t unsigned int
1979 # elif (LZO_SIZEOF_LONG_LONG == LZO_SIZEOF_VOID_P)
1980 # define lzo_uintptr_t unsigned long long
1982 # define lzo_uintptr_t size_t
1985 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uintptr_t
) >= sizeof(lzo_voidp
))
1987 #if 1 && !defined(LZO_CFG_FREESTANDING)
1988 #if 1 && !defined(HAVE_STRING_H)
1989 #define HAVE_STRING_H 1
1991 #if 1 && !defined(HAVE_MEMCMP)
1992 #define HAVE_MEMCMP 1
1994 #if 1 && !defined(HAVE_MEMCPY)
1995 #define HAVE_MEMCPY 1
1997 #if 1 && !defined(HAVE_MEMMOVE)
1998 #define HAVE_MEMMOVE 1
2000 #if 1 && !defined(HAVE_MEMSET)
2001 #define HAVE_MEMSET 1
2005 #if 1 && defined(HAVE_STRING_H)
2009 #if (LZO_CFG_FREESTANDING)
2012 # undef HAVE_MEMMOVE
2018 # define memcmp(a,b,c) lzo_memcmp(a,b,c)
2019 #elif !(__LZO_MMODEL_HUGE)
2021 # define lzo_memcmp(a,b,c) memcmp(a,b,c)
2025 # define memcpy(a,b,c) lzo_memcpy(a,b,c)
2026 #elif !(__LZO_MMODEL_HUGE)
2028 # define lzo_memcpy(a,b,c) memcpy(a,b,c)
2032 # define memmove(a,b,c) lzo_memmove(a,b,c)
2033 #elif !(__LZO_MMODEL_HUGE)
2035 # define lzo_memmove(a,b,c) memmove(a,b,c)
2039 # define memset(a,b,c) lzo_memset(a,b,c)
2040 #elif !(__LZO_MMODEL_HUGE)
2042 # define lzo_memset(a,b,c) memset(a,b,c)
2046 #if (LZO_CFG_FREESTANDING)
2050 # define assert(e) ((void)0)
2052 # if !defined(LZO_DEBUG)
2055 # include <assert.h>
2058 #if 0 && defined(__BOUNDS_CHECKING_ON)
2059 # include <unchecked.h>
2061 # define BOUNDS_CHECKING_OFF_DURING(stmt) stmt
2062 # define BOUNDS_CHECKING_OFF_IN_EXPR(expr) (expr)
2065 #if !defined(__lzo_inline)
2066 # define __lzo_inline /*empty*/
2068 #if !defined(__lzo_forceinline)
2069 # define __lzo_forceinline /*empty*/
2071 #if !defined(__lzo_noinline)
2072 # define __lzo_noinline /*empty*/
2076 # undef __acc_likely
2077 # undef __acc_unlikely
2078 # undef __lzo_likely
2079 # undef __lzo_unlikely
2080 # define __acc_likely(e) (e)
2081 # define __acc_unlikely(e) (e)
2082 # define __lzo_likely(e) (e)
2083 # define __lzo_unlikely(e) (e)
2087 # define LZO_BYTE(x) ((unsigned char) (x))
2089 # define LZO_BYTE(x) ((unsigned char) ((x) & 0xff))
2092 #define LZO_MAX(a,b) ((a) >= (b) ? (a) : (b))
2093 #define LZO_MIN(a,b) ((a) <= (b) ? (a) : (b))
2094 #define LZO_MAX3(a,b,c) ((a) >= (b) ? LZO_MAX(a,c) : LZO_MAX(b,c))
2095 #define LZO_MIN3(a,b,c) ((a) <= (b) ? LZO_MIN(a,c) : LZO_MIN(b,c))
2097 #define lzo_sizeof(type) ((lzo_uint) (sizeof(type)))
2099 #define LZO_HIGH(array) ((lzo_uint) (sizeof(array)/sizeof(*(array))))
2101 #define LZO_SIZE(bits) (1u << (bits))
2102 #define LZO_MASK(bits) (LZO_SIZE(bits) - 1)
2104 #define LZO_LSIZE(bits) (1ul << (bits))
2105 #define LZO_LMASK(bits) (LZO_LSIZE(bits) - 1)
2107 #define LZO_USIZE(bits) ((lzo_uint) 1 << (bits))
2108 #define LZO_UMASK(bits) (LZO_USIZE(bits) - 1)
2113 # define DMUL(a,b) ((lzo_xint) ((lzo_uint32)(a) * (lzo_uint32)(b)))
2115 # define DMUL(a,b) ((lzo_xint) ((a) * (b)))
2119 #if 1 && (LZO_ARCH_AMD64 || LZO_ARCH_I386 || LZO_ARCH_POWERPC)
2120 # if (LZO_SIZEOF_SHORT == 2)
2121 # define LZO_UNALIGNED_OK_2 1
2123 # if (LZO_SIZEOF_INT == 4)
2124 # define LZO_UNALIGNED_OK_4 1
2127 #if 1 && (LZO_ARCH_AMD64)
2128 # if defined(LZO_UINT64_MAX)
2129 # define LZO_UNALIGNED_OK_8 1
2132 #if (LZO_CFG_NO_UNALIGNED)
2133 # undef LZO_UNALIGNED_OK_2
2134 # undef LZO_UNALIGNED_OK_4
2135 # undef LZO_UNALIGNED_OK_8
2147 #if defined(LZO_UNALIGNED_OK_2)
2148 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(unsigned short) == 2)
2149 # if 1 && defined(ACC_UA_COPY16)
2150 # define UA_GET16 ACC_UA_GET16
2151 # define UA_SET16 ACC_UA_SET16
2152 # define UA_COPY16 ACC_UA_COPY16
2154 # define UA_GET16(p) (* (__lzo_ua_volatile const lzo_ushortp) (__lzo_ua_volatile const lzo_voidp) (p))
2155 # define UA_SET16(p,v) ((* (__lzo_ua_volatile lzo_ushortp) (__lzo_ua_volatile lzo_voidp) (p)) = (unsigned short) (v))
2156 # define UA_COPY16(d,s) UA_SET16(d, UA_GET16(s))
2159 #if defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
2160 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint32
) == 4)
2161 # if 1 && defined(ACC_UA_COPY32)
2162 # define UA_GET32 ACC_UA_GET32
2163 # define UA_SET32 ACC_UA_SET32
2164 # define UA_COPY32 ACC_UA_COPY32
2166 # define UA_GET32(p) (* (__lzo_ua_volatile const lzo_uint32p) (__lzo_ua_volatile const lzo_voidp) (p))
2167 # define UA_SET32(p,v) ((* (__lzo_ua_volatile lzo_uint32p) (__lzo_ua_volatile lzo_voidp) (p)) = (lzo_uint32) (v))
2168 # define UA_COPY32(d,s) UA_SET32(d, UA_GET32(s))
2171 #if defined(LZO_UNALIGNED_OK_8)
2172 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint64
) == 8)
2173 # if 1 && defined(ACC_UA_COPY64)
2174 # define UA_GET64 ACC_UA_GET64
2175 # define UA_SET64 ACC_UA_SET64
2176 # define UA_COPY64 ACC_UA_COPY64
2178 # define UA_GET64(p) (* (__lzo_ua_volatile const lzo_uint64p) (__lzo_ua_volatile const lzo_voidp) (p))
2179 # define UA_SET64(p,v) ((* (__lzo_ua_volatile lzo_uint64p) (__lzo_ua_volatile lzo_voidp) (p)) = (lzo_uint64) (v))
2180 # define UA_COPY64(d,s) UA_SET64(d, UA_GET64(s))
2184 #define MEMCPY8_DS(dest,src,len) \
2185 lzo_memcpy(dest,src,len); dest += len; src += len
2187 #define BZERO8_PTR(s,l,n) \
2188 lzo_memset((lzo_voidp)(s),0,(lzo_uint)(l)*(n))
2190 #define MEMCPY_DS(dest,src,len) \
2191 do *dest++ = *src++; while (--len > 0)
2193 LZO_EXTERN(const lzo_bytep
) lzo_copyright(void);
2196 #define __LZO_PTR_H 1
2202 #if !defined(lzo_uintptr_t)
2203 # if (__LZO_MMODEL_HUGE)
2204 # define lzo_uintptr_t unsigned long
2206 # define lzo_uintptr_t acc_uintptr_t
2207 # ifdef __ACC_INTPTR_T_IS_POINTER
2208 # define __LZO_UINTPTR_T_IS_POINTER 1
2214 #define PTR(a) ((lzo_bytep) (a))
2215 #define PTR_ALIGNED_4(a) ((ACC_PTR_FP_OFF(a) & 3) == 0)
2216 #define PTR_ALIGNED2_4(a,b) (((ACC_PTR_FP_OFF(a) | ACC_PTR_FP_OFF(b)) & 3) == 0)
2218 #define PTR(a) ((lzo_bytep) (a))
2219 #define PTR_ALIGNED_8(a) ((((lzo_uintptr_t)(a)) >> 61) == 0)
2220 #define PTR_ALIGNED2_8(a,b) ((((lzo_uintptr_t)(a)|(lzo_uintptr_t)(b)) >> 61) == 0)
2222 #define PTR(a) ((lzo_uintptr_t) (a))
2223 #define PTR_LINEAR(a) PTR(a)
2224 #define PTR_ALIGNED_4(a) ((PTR_LINEAR(a) & 3) == 0)
2225 #define PTR_ALIGNED_8(a) ((PTR_LINEAR(a) & 7) == 0)
2226 #define PTR_ALIGNED2_4(a,b) (((PTR_LINEAR(a) | PTR_LINEAR(b)) & 3) == 0)
2227 #define PTR_ALIGNED2_8(a,b) (((PTR_LINEAR(a) | PTR_LINEAR(b)) & 7) == 0)
2230 #define PTR_LT(a,b) (PTR(a) < PTR(b))
2231 #define PTR_GE(a,b) (PTR(a) >= PTR(b))
2232 #define PTR_DIFF(a,b) (PTR(a) - PTR(b))
2233 #define pd(a,b) ((lzo_uint) ((a)-(b)))
2235 LZO_EXTERN(lzo_uintptr_t
)
2236 __lzo_ptr_linear(const lzo_voidp ptr
);
2241 unsigned char a_uchar
;
2243 unsigned short a_ushort
;
2245 unsigned int a_uint
;
2247 unsigned long a_ulong
;
2249 lzo_uint a_lzo_uint
;
2250 lzo_int32 a_lzo_int32
;
2251 lzo_uint32 a_lzo_uint32
;
2252 #if defined(LZO_UINT64_MAX)
2253 lzo_int64 a_lzo_int64
;
2254 lzo_uint64 a_lzo_uint64
;
2256 ptrdiff_t a_ptrdiff_t
;
2257 lzo_uintptr_t a_lzo_uintptr_t
;
2258 lzo_voidp a_lzo_voidp
;
2260 lzo_bytep a_lzo_bytep
;
2261 lzo_bytepp a_lzo_bytepp
;
2262 lzo_uintp a_lzo_uintp
;
2263 lzo_uint
* a_lzo_uint_p
;
2264 lzo_uint32p a_lzo_uint32p
;
2265 lzo_uint32
* a_lzo_uint32_p
;
2266 unsigned char * a_uchar_p
;
2277 #ifndef LZO_DETERMINISTIC
2278 #define LZO_DETERMINISTIC 1
2281 #ifndef LZO_DICT_USE_PTR
2282 #define LZO_DICT_USE_PTR 1
2283 #if 0 && (LZO_ARCH_I086)
2284 # undef LZO_DICT_USE_PTR
2285 # define LZO_DICT_USE_PTR 0
2289 #if (LZO_DICT_USE_PTR)
2290 # define lzo_dict_t const lzo_bytep
2291 # define lzo_dict_p lzo_dict_t __LZO_MMODEL *
2293 # define lzo_dict_t lzo_uint
2294 # define lzo_dict_p lzo_dict_t __LZO_MMODEL *
2299 #if !defined(MINILZO_CFG_SKIP_LZO_PTR)
2301 LZO_PUBLIC(lzo_uintptr_t
)
2302 __lzo_ptr_linear(const lzo_voidp ptr
)
2307 p
= (((lzo_uintptr_t
)(ACC_PTR_FP_SEG(ptr
))) << (16 - ACC_MM_AHSHIFT
)) + (ACC_PTR_FP_OFF(ptr
));
2309 p
= (lzo_uintptr_t
) (ptr
);
2310 p
= (p
<< 3) | (p
>> 61);
2312 p
= (lzo_uintptr_t
) PTR_LINEAR(ptr
);
2318 LZO_PUBLIC(unsigned)
2319 __lzo_align_gap(const lzo_voidp ptr
, lzo_uint size
)
2321 #if defined(__LZO_UINTPTR_T_IS_POINTER)
2322 size_t n
= (size_t) ptr
;
2323 n
= (((n
+ size
- 1) / size
) * size
) - n
;
2326 p
= __lzo_ptr_linear(ptr
);
2327 n
= (((p
+ size
- 1) / size
) * size
) - p
;
2331 assert((long)n
>= 0);
2337 #if !defined(MINILZO_CFG_SKIP_LZO_UTIL)
2339 /* If you use the LZO library in a product, I would appreciate that you
2340 * keep this copyright string in the executable of your product.
2343 static const char __lzo_copyright
[] =
2344 #if !defined(__LZO_IN_MINLZO)
2348 "LZO data compression library.\n"
2349 "$Copyright: LZO Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer\n"
2350 "<markus@oberhumer.com>\n"
2351 "http://www.oberhumer.com $\n\n"
2352 "$Id: LZO version: v" LZO_VERSION_STRING
", " LZO_VERSION_DATE
" $\n"
2353 "$Info: " LZO_INFO_STRING
" $\n";
2356 LZO_PUBLIC(const lzo_bytep
)
2359 #if (LZO_OS_DOS16 && LZO_CC_TURBOC)
2360 return (lzo_voidp
) __lzo_copyright
;
2362 return (const lzo_bytep
) __lzo_copyright
;
2366 LZO_PUBLIC(unsigned)
2372 LZO_PUBLIC(const char *)
2373 lzo_version_string(void)
2375 return LZO_VERSION_STRING
;
2378 LZO_PUBLIC(const char *)
2379 lzo_version_date(void)
2381 return LZO_VERSION_DATE
;
2384 LZO_PUBLIC(const lzo_charp
)
2385 _lzo_version_string(void)
2387 return LZO_VERSION_STRING
;
2390 LZO_PUBLIC(const lzo_charp
)
2391 _lzo_version_date(void)
2393 return LZO_VERSION_DATE
;
2396 #define LZO_BASE 65521u
2397 #define LZO_NMAX 5552
2399 #define LZO_DO1(buf,i) s1 += buf[i]; s2 += s1
2400 #define LZO_DO2(buf,i) LZO_DO1(buf,i); LZO_DO1(buf,i+1);
2401 #define LZO_DO4(buf,i) LZO_DO2(buf,i); LZO_DO2(buf,i+2);
2402 #define LZO_DO8(buf,i) LZO_DO4(buf,i); LZO_DO4(buf,i+4);
2403 #define LZO_DO16(buf,i) LZO_DO8(buf,i); LZO_DO8(buf,i+8);
2405 LZO_PUBLIC(lzo_uint32
)
2406 lzo_adler32(lzo_uint32 adler
, const lzo_bytep buf
, lzo_uint len
)
2408 lzo_uint32 s1
= adler
& 0xffff;
2409 lzo_uint32 s2
= (adler
>> 16) & 0xffff;
2417 k
= len
< LZO_NMAX
? (unsigned) len
: LZO_NMAX
;
2433 return (s2
<< 16) | s1
;
2443 #if !defined(MINILZO_CFG_SKIP_LZO_STRING)
2448 #if !defined(__LZO_MMODEL_HUGE)
2449 # undef LZO_HAVE_MM_HUGE_PTR
2451 #define lzo_hsize_t lzo_uint
2452 #define lzo_hvoid_p lzo_voidp
2453 #define lzo_hbyte_p lzo_bytep
2454 #define LZOLIB_PUBLIC(r,f) LZO_PUBLIC(r) f
2455 #define lzo_hmemcmp lzo_memcmp
2456 #define lzo_hmemcpy lzo_memcpy
2457 #define lzo_hmemmove lzo_memmove
2458 #define lzo_hmemset lzo_memset
2459 #define __LZOLIB_HMEMCPY_CH_INCLUDED 1
2460 #if !defined(LZOLIB_PUBLIC)
2461 # define LZOLIB_PUBLIC(r,f) r __LZOLIB_FUNCNAME(f)
2463 LZOLIB_PUBLIC(int, lzo_hmemcmp
) (const lzo_hvoid_p s1
, const lzo_hvoid_p s2
, lzo_hsize_t len
)
2465 #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMCMP)
2466 const lzo_hbyte_p p1
= (const lzo_hbyte_p
) s1
;
2467 const lzo_hbyte_p p2
= (const lzo_hbyte_p
) s2
;
2468 if __lzo_likely(len
> 0) do
2474 } while __lzo_likely(--len
> 0);
2477 return memcmp(s1
, s2
, len
);
2480 LZOLIB_PUBLIC(lzo_hvoid_p
, lzo_hmemcpy
) (lzo_hvoid_p dest
, const lzo_hvoid_p src
, lzo_hsize_t len
)
2482 #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMCPY)
2483 lzo_hbyte_p p1
= (lzo_hbyte_p
) dest
;
2484 const lzo_hbyte_p p2
= (const lzo_hbyte_p
) src
;
2485 if (!(len
> 0) || p1
== p2
)
2489 while __lzo_likely(--len
> 0);
2492 return memcpy(dest
, src
, len
);
2495 LZOLIB_PUBLIC(lzo_hvoid_p
, lzo_hmemmove
) (lzo_hvoid_p dest
, const lzo_hvoid_p src
, lzo_hsize_t len
)
2497 #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMMOVE)
2498 lzo_hbyte_p p1
= (lzo_hbyte_p
) dest
;
2499 const lzo_hbyte_p p2
= (const lzo_hbyte_p
) src
;
2500 if (!(len
> 0) || p1
== p2
)
2506 while __lzo_likely(--len
> 0);
2514 while __lzo_likely(--len
> 0);
2518 return memmove(dest
, src
, len
);
2521 LZOLIB_PUBLIC(lzo_hvoid_p
, lzo_hmemset
) (lzo_hvoid_p s
, int c
, lzo_hsize_t len
)
2523 #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMSET)
2524 lzo_hbyte_p p
= (lzo_hbyte_p
) s
;
2525 if __lzo_likely(len
> 0) do
2526 *p
++ = (unsigned char) c
;
2527 while __lzo_likely(--len
> 0);
2530 return memset(s
, c
, len
);
2533 #undef LZOLIB_PUBLIC
2535 #if !defined(MINILZO_CFG_SKIP_LZO_INIT)
2537 #if !defined(__LZO_IN_MINILZO)
2539 #define ACC_WANT_ACC_CHK_CH 1
2540 #undef ACCCHK_ASSERT
2542 ACCCHK_ASSERT_IS_SIGNED_T(lzo_int
)
2543 ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uint
)
2545 ACCCHK_ASSERT_IS_SIGNED_T(lzo_int32
)
2546 ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uint32
)
2547 ACCCHK_ASSERT((LZO_UINT32_C(1) << (int)(8*sizeof(LZO_UINT32_C(1))-1)) > 0)
2548 ACCCHK_ASSERT(sizeof(lzo_uint32
) >= 4)
2549 #if defined(LZO_UINT64_MAX)
2550 ACCCHK_ASSERT(sizeof(lzo_uint64
) == 8)
2551 ACCCHK_ASSERT_IS_SIGNED_T(lzo_int64
)
2552 ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uint64
)
2555 #if !defined(__LZO_UINTPTR_T_IS_POINTER)
2556 ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uintptr_t
)
2558 ACCCHK_ASSERT(sizeof(lzo_uintptr_t
) >= sizeof(lzo_voidp
))
2560 ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_xint
)
2561 ACCCHK_ASSERT(sizeof(lzo_xint
) >= sizeof(lzo_uint32
))
2562 ACCCHK_ASSERT(sizeof(lzo_xint
) >= sizeof(lzo_uint
))
2563 ACCCHK_ASSERT(sizeof(lzo_xint
) == sizeof(lzo_uint32
) || sizeof(lzo_xint
) == sizeof(lzo_uint
))
2566 #undef ACCCHK_ASSERT
2568 #define WANT_lzo_bitops_clz32 1
2569 #define WANT_lzo_bitops_clz64 1
2570 #define WANT_lzo_bitops_ctz32 1
2571 #define WANT_lzo_bitops_ctz64 1
2573 #if (defined(_WIN32) || defined(_WIN64)) && ((LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || (LZO_CC_MSC && (_MSC_VER >= 1400)))
2575 #if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32) && 0
2576 #pragma intrinsic(_BitScanReverse)
2577 static __lzo_inline
unsigned lzo_bitops_clz32(lzo_uint32 v
)
2580 (void) _BitScanReverse(&r
, v
);
2581 return (unsigned) r
;
2583 #define lzo_bitops_clz32 lzo_bitops_clz32
2585 #if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX) && 0
2586 #pragma intrinsic(_BitScanReverse64)
2587 static __lzo_inline
unsigned lzo_bitops_clz64(lzo_uint64 v
)
2590 (void) _BitScanReverse64(&r
, v
);
2591 return (unsigned) r
;
2593 #define lzo_bitops_clz64 lzo_bitops_clz64
2595 #if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32)
2596 #pragma intrinsic(_BitScanForward)
2597 static __lzo_inline
unsigned lzo_bitops_ctz32(lzo_uint32 v
)
2600 (void) _BitScanForward(&r
, v
);
2601 return (unsigned) r
;
2603 #define lzo_bitops_ctz32 lzo_bitops_ctz32
2605 #if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX)
2606 #pragma intrinsic(_BitScanForward64)
2607 static __lzo_inline
unsigned lzo_bitops_ctz64(lzo_uint64 v
)
2610 (void) _BitScanForward64(&r
, v
);
2611 return (unsigned) r
;
2613 #define lzo_bitops_ctz64 lzo_bitops_ctz64
2616 #elif (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x030400ul) || (LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || (LZO_CC_LLVM && (!defined(__llvm_tools_version__) || (__llvm_tools_version__+0 >= 0x010500ul))))
2617 #if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32)
2618 #define lzo_bitops_clz32(v) ((unsigned) __builtin_clz(v))
2620 #if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX)
2621 #define lzo_bitops_clz64(v) ((unsigned) __builtin_clzll(v))
2623 #if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32)
2624 #define lzo_bitops_ctz32(v) ((unsigned) __builtin_ctz(v))
2626 #if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX)
2627 #define lzo_bitops_ctz64(v) ((unsigned) __builtin_ctzll(v))
2629 #if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount32)
2630 #define lzo_bitops_popcount32(v) ((unsigned) __builtin_popcount(v))
2632 #if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount64) && defined(LZO_UINT64_MAX)
2633 #define lzo_bitops_popcount64(v) ((unsigned) __builtin_popcountll(v))
2638 #define u2p(ptr,off) ((lzo_voidp) (((lzo_bytep)(lzo_voidp)(ptr)) + (off)))
2640 static __lzo_noinline lzo_voidp
u2p(lzo_voidp ptr
, lzo_uint off
)
2642 return (lzo_voidp
) ((lzo_bytep
) ptr
+ off
);
2647 _lzo_config_check(void)
2651 lzo_xint a
[2]; unsigned char b
[2*LZO_MAX(8,sizeof(lzo_xint
))];
2652 #if defined(LZO_UNALIGNED_OK_8)
2655 unsigned short x
[2]; lzo_uint32 y
[2]; lzo_uint z
[2];
2659 u
.a
[0] = u
.a
[1] = 0;
2661 r
&= ((* (lzo_bytep
) p
) == 0);
2662 #if !defined(LZO_CFG_NO_CONFIG_CHECK)
2663 #if defined(LZO_ABI_BIG_ENDIAN)
2664 u
.a
[0] = u
.a
[1] = 0; u
.b
[sizeof(lzo_uint
) - 1] = 128;
2666 r
&= ((* (lzo_uintp
) p
) == 128);
2668 #if defined(LZO_ABI_LITTLE_ENDIAN)
2669 u
.a
[0] = u
.a
[1] = 0; u
.b
[0] = 128;
2671 r
&= ((* (lzo_uintp
) p
) == 128);
2673 #if defined(LZO_UNALIGNED_OK_2)
2674 u
.a
[0] = u
.a
[1] = 0;
2675 u
.b
[0] = 1; u
.b
[sizeof(unsigned short) + 1] = 2;
2677 r
&= ((* (lzo_ushortp
) p
) == 0);
2679 #if defined(LZO_UNALIGNED_OK_4)
2680 u
.a
[0] = u
.a
[1] = 0;
2681 u
.b
[0] = 3; u
.b
[sizeof(lzo_uint32
) + 1] = 4;
2683 r
&= ((* (lzo_uint32p
) p
) == 0);
2685 #if defined(LZO_UNALIGNED_OK_8)
2686 u
.c
[0] = u
.c
[1] = 0;
2687 u
.b
[0] = 5; u
.b
[sizeof(lzo_uint64
) + 1] = 6;
2689 r
&= ((* (lzo_uint64p
) p
) == 0);
2691 #if defined(lzo_bitops_clz32)
2692 { unsigned i
; lzo_uint32 v
= 1;
2693 for (i
= 0; i
< 32; i
++, v
<<= 1)
2694 r
&= lzo_bitops_clz32(v
) == 31 - i
;
2697 #if defined(lzo_bitops_clz64)
2698 { unsigned i
; lzo_uint64 v
= 1;
2699 for (i
= 0; i
< 64; i
++, v
<<= 1)
2700 r
&= lzo_bitops_clz64(v
) == 63 - i
;
2703 #if defined(lzo_bitops_ctz32)
2704 { unsigned i
; lzo_uint32 v
= 1;
2705 for (i
= 0; i
< 32; i
++, v
<<= 1)
2706 r
&= lzo_bitops_ctz32(v
) == i
;
2709 #if defined(lzo_bitops_ctz64)
2710 { unsigned i
; lzo_uint64 v
= 1;
2711 for (i
= 0; i
< 64; i
++, v
<<= 1)
2712 r
&= lzo_bitops_ctz64(v
) == i
;
2717 return r
== 1 ? LZO_E_OK
: LZO_E_ERROR
;
2721 __lzo_init_v2(unsigned v
, int s1
, int s2
, int s3
, int s4
, int s5
,
2722 int s6
, int s7
, int s8
, int s9
)
2726 #if defined(__LZO_IN_MINILZO)
2727 #elif (LZO_CC_MSC && ((_MSC_VER) < 700))
2729 #define ACC_WANT_ACC_CHK_CH 1
2730 #undef ACCCHK_ASSERT
2731 #define ACCCHK_ASSERT(expr) LZO_COMPILE_TIME_ASSERT(expr)
2733 #undef ACCCHK_ASSERT
2738 r
= (s1
== -1 || s1
== (int) sizeof(short)) &&
2739 (s2
== -1 || s2
== (int) sizeof(int)) &&
2740 (s3
== -1 || s3
== (int) sizeof(long)) &&
2741 (s4
== -1 || s4
== (int) sizeof(lzo_uint32
)) &&
2742 (s5
== -1 || s5
== (int) sizeof(lzo_uint
)) &&
2743 (s6
== -1 || s6
== (int) lzo_sizeof_dict_t
) &&
2744 (s7
== -1 || s7
== (int) sizeof(char *)) &&
2745 (s8
== -1 || s8
== (int) sizeof(lzo_voidp
)) &&
2746 (s9
== -1 || s9
== (int) sizeof(lzo_callback_t
));
2750 r
= _lzo_config_check();
2757 #if !defined(__LZO_IN_MINILZO)
2759 #if (LZO_OS_WIN16 && LZO_CC_WATCOMC) && defined(__SW_BD)
2762 BOOL FAR PASCAL
LibMain ( HANDLE hInstance
, WORD wDataSegment
,
2763 WORD wHeapSize
, LPSTR lpszCmdLine
)
2765 int __far __pascal
LibMain ( int a
, short b
, short c
, long d
)
2768 LZO_UNUSED(a
); LZO_UNUSED(b
); LZO_UNUSED(c
); LZO_UNUSED(d
);
2779 #define LZO_EOF_CODE 1
2780 #define M2_MAX_OFFSET 0x0800
2782 #if !defined(MINILZO_CFG_SKIP_LZO1X_1_COMPRESS)
2784 #if 1 && defined(UA_GET32)
2785 #undef LZO_DICT_USE_PTR
2786 #define LZO_DICT_USE_PTR 0
2788 #define lzo_dict_t unsigned short
2791 #define LZO_NEED_DICT_H 1
2795 #define D_INDEX1(d,p) d = DM(DMUL(0x21,DX3(p,5,5,6)) >> 5)
2796 #define D_INDEX2(d,p) d = (d & (D_MASK & 0x7ff)) ^ (D_HIGH | 0x1f)
2798 #define DINDEX(dv,p) DM(((DMUL(0x1824429d,dv)) >> (32-D_BITS)))
2800 #define DINDEX(dv,p) DM((dv) + ((dv) >> (32-D_BITS)))
2803 #ifndef __LZO_CONFIG1X_H
2804 #define __LZO_CONFIG1X_H 1
2806 #if !defined(LZO1X) && !defined(LZO1Y) && !defined(LZO1Z)
2810 #if !defined(__LZO_IN_MINILZO)
2811 #include "lzo/lzo1x.h"
2814 #ifndef LZO_EOF_CODE
2815 #define LZO_EOF_CODE 1
2817 #undef LZO_DETERMINISTIC
2819 #define M1_MAX_OFFSET 0x0400
2820 #ifndef M2_MAX_OFFSET
2821 #define M2_MAX_OFFSET 0x0800
2823 #define M3_MAX_OFFSET 0x4000
2824 #define M4_MAX_OFFSET 0xbfff
2826 #define MX_MAX_OFFSET (M1_MAX_OFFSET + M2_MAX_OFFSET)
2828 #define M1_MIN_LEN 2
2829 #define M1_MAX_LEN 2
2830 #define M2_MIN_LEN 3
2832 #define M2_MAX_LEN 8
2834 #define M3_MIN_LEN 3
2835 #define M3_MAX_LEN 33
2836 #define M4_MIN_LEN 3
2837 #define M4_MAX_LEN 9
2840 #define M2_MARKER 64
2841 #define M3_MARKER 32
2842 #define M4_MARKER 16
2844 #ifndef MIN_LOOKAHEAD
2845 #define MIN_LOOKAHEAD (M2_MAX_LEN + 1)
2848 #if defined(LZO_NEED_DICT_H)
2851 #define LZO_HASH LZO_HASH_LZO_INCREMENTAL_B
2853 #define DL_MIN_LEN M2_MIN_LEN
2855 #ifndef __LZO_DICT_H
2856 #define __LZO_DICT_H 1
2862 #if !defined(D_BITS) && defined(DBITS)
2863 # define D_BITS DBITS
2865 #if !defined(D_BITS)
2866 # error "D_BITS is not defined"
2869 # define D_SIZE LZO_SIZE(D_BITS)
2870 # define D_MASK LZO_MASK(D_BITS)
2872 # define D_SIZE LZO_USIZE(D_BITS)
2873 # define D_MASK LZO_UMASK(D_BITS)
2875 #define D_HIGH ((D_MASK >> 1) + 1)
2877 #if !defined(DD_BITS)
2880 #define DD_SIZE LZO_SIZE(DD_BITS)
2881 #define DD_MASK LZO_MASK(DD_BITS)
2883 #if !defined(DL_BITS)
2884 # define DL_BITS (D_BITS - DD_BITS)
2887 # define DL_SIZE LZO_SIZE(DL_BITS)
2888 # define DL_MASK LZO_MASK(DL_BITS)
2890 # define DL_SIZE LZO_USIZE(DL_BITS)
2891 # define DL_MASK LZO_UMASK(DL_BITS)
2894 #if (D_BITS != DL_BITS + DD_BITS)
2895 # error "D_BITS does not match"
2897 #if (D_BITS < 6 || D_BITS > 18)
2898 # error "invalid D_BITS"
2900 #if (DL_BITS < 6 || DL_BITS > 20)
2901 # error "invalid DL_BITS"
2903 #if (DD_BITS < 0 || DD_BITS > 6)
2904 # error "invalid DD_BITS"
2907 #if !defined(DL_MIN_LEN)
2908 # define DL_MIN_LEN 3
2910 #if !defined(DL_SHIFT)
2911 # define DL_SHIFT ((DL_BITS + (DL_MIN_LEN - 1)) / DL_MIN_LEN)
2914 #define LZO_HASH_GZIP 1
2915 #define LZO_HASH_GZIP_INCREMENTAL 2
2916 #define LZO_HASH_LZO_INCREMENTAL_A 3
2917 #define LZO_HASH_LZO_INCREMENTAL_B 4
2919 #if !defined(LZO_HASH)
2920 # error "choose a hashing strategy"
2926 #if (DL_MIN_LEN == 3)
2927 # define _DV2_A(p,shift1,shift2) \
2928 (((( (lzo_xint)((p)[0]) << shift1) ^ (p)[1]) << shift2) ^ (p)[2])
2929 # define _DV2_B(p,shift1,shift2) \
2930 (((( (lzo_xint)((p)[2]) << shift1) ^ (p)[1]) << shift2) ^ (p)[0])
2931 # define _DV3_B(p,shift1,shift2,shift3) \
2932 ((_DV2_B((p)+1,shift1,shift2) << (shift3)) ^ (p)[0])
2933 #elif (DL_MIN_LEN == 2)
2934 # define _DV2_A(p,shift1,shift2) \
2935 (( (lzo_xint)(p[0]) << shift1) ^ p[1])
2936 # define _DV2_B(p,shift1,shift2) \
2937 (( (lzo_xint)(p[1]) << shift1) ^ p[2])
2939 # error "invalid DL_MIN_LEN"
2941 #define _DV_A(p,shift) _DV2_A(p,shift,shift)
2942 #define _DV_B(p,shift) _DV2_B(p,shift,shift)
2943 #define DA2(p,s1,s2) \
2944 (((((lzo_xint)((p)[2]) << (s2)) + (p)[1]) << (s1)) + (p)[0])
2945 #define DS2(p,s1,s2) \
2946 (((((lzo_xint)((p)[2]) << (s2)) - (p)[1]) << (s1)) - (p)[0])
2947 #define DX2(p,s1,s2) \
2948 (((((lzo_xint)((p)[2]) << (s2)) ^ (p)[1]) << (s1)) ^ (p)[0])
2949 #define DA3(p,s1,s2,s3) ((DA2((p)+1,s2,s3) << (s1)) + (p)[0])
2950 #define DS3(p,s1,s2,s3) ((DS2((p)+1,s2,s3) << (s1)) - (p)[0])
2951 #define DX3(p,s1,s2,s3) ((DX2((p)+1,s2,s3) << (s1)) ^ (p)[0])
2952 #define DMS(v,s) ((lzo_uint) (((v) & (D_MASK >> (s))) << (s)))
2953 #define DM(v) DMS(v,0)
2955 #if (LZO_HASH == LZO_HASH_GZIP)
2956 # define _DINDEX(dv,p) (_DV_A((p),DL_SHIFT))
2958 #elif (LZO_HASH == LZO_HASH_GZIP_INCREMENTAL)
2959 # define __LZO_HASH_INCREMENTAL 1
2960 # define DVAL_FIRST(dv,p) dv = _DV_A((p),DL_SHIFT)
2961 # define DVAL_NEXT(dv,p) dv = (((dv) << DL_SHIFT) ^ p[2])
2962 # define _DINDEX(dv,p) (dv)
2963 # define DVAL_LOOKAHEAD DL_MIN_LEN
2965 #elif (LZO_HASH == LZO_HASH_LZO_INCREMENTAL_A)
2966 # define __LZO_HASH_INCREMENTAL 1
2967 # define DVAL_FIRST(dv,p) dv = _DV_A((p),5)
2968 # define DVAL_NEXT(dv,p) \
2969 dv ^= (lzo_xint)(p[-1]) << (2*5); dv = (((dv) << 5) ^ p[2])
2970 # define _DINDEX(dv,p) ((DMUL(0x9f5f,dv)) >> 5)
2971 # define DVAL_LOOKAHEAD DL_MIN_LEN
2973 #elif (LZO_HASH == LZO_HASH_LZO_INCREMENTAL_B)
2974 # define __LZO_HASH_INCREMENTAL 1
2975 # define DVAL_FIRST(dv,p) dv = _DV_B((p),5)
2976 # define DVAL_NEXT(dv,p) \
2977 dv ^= p[-1]; dv = (((dv) >> 5) ^ ((lzo_xint)(p[2]) << (2*5)))
2978 # define _DINDEX(dv,p) ((DMUL(0x9f5f,dv)) >> 5)
2979 # define DVAL_LOOKAHEAD DL_MIN_LEN
2982 # error "choose a hashing strategy"
2986 #define DINDEX(dv,p) ((lzo_uint)((_DINDEX(dv,p)) & DL_MASK) << DD_BITS)
2988 #if !defined(DINDEX1) && defined(D_INDEX1)
2989 #define DINDEX1 D_INDEX1
2991 #if !defined(DINDEX2) && defined(D_INDEX2)
2992 #define DINDEX2 D_INDEX2
2995 #if !defined(__LZO_HASH_INCREMENTAL)
2996 # define DVAL_FIRST(dv,p) ((void) 0)
2997 # define DVAL_NEXT(dv,p) ((void) 0)
2998 # define DVAL_LOOKAHEAD 0
3001 #if !defined(DVAL_ASSERT)
3002 #if defined(__LZO_HASH_INCREMENTAL) && !defined(NDEBUG)
3003 #if (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x020700ul) || LZO_CC_LLVM)
3004 static void __attribute__((__unused__
))
3008 DVAL_ASSERT(lzo_xint dv
, const lzo_bytep p
)
3012 assert(DINDEX(dv
,p
) == DINDEX(df
,p
));
3015 # define DVAL_ASSERT(dv,p) ((void) 0)
3019 #if (LZO_DICT_USE_PTR)
3020 # define DENTRY(p,in) (p)
3021 # define GINDEX(m_pos,m_off,dict,dindex,in) m_pos = dict[dindex]
3023 # define DENTRY(p,in) ((lzo_dict_t) pd(p, in))
3024 # define GINDEX(m_pos,m_off,dict,dindex,in) m_off = dict[dindex]
3029 # define UPDATE_D(dict,drun,dv,p,in) dict[ DINDEX(dv,p) ] = DENTRY(p,in)
3030 # define UPDATE_I(dict,drun,index,p,in) dict[index] = DENTRY(p,in)
3031 # define UPDATE_P(ptr,drun,p,in) (ptr)[0] = DENTRY(p,in)
3035 # define UPDATE_D(dict,drun,dv,p,in) \
3036 dict[ DINDEX(dv,p) + drun++ ] = DENTRY(p,in); drun &= DD_MASK
3037 # define UPDATE_I(dict,drun,index,p,in) \
3038 dict[ (index) + drun++ ] = DENTRY(p,in); drun &= DD_MASK
3039 # define UPDATE_P(ptr,drun,p,in) \
3040 (ptr) [ drun++ ] = DENTRY(p,in); drun &= DD_MASK
3044 #if (LZO_DICT_USE_PTR)
3046 #define LZO_CHECK_MPOS_DET(m_pos,m_off,in,ip,max_offset) \
3047 (m_pos == NULL || (m_off = pd(ip, m_pos)) > max_offset)
3049 #define LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,max_offset) \
3050 (BOUNDS_CHECKING_OFF_IN_EXPR(( \
3051 m_pos = ip - (lzo_uint) PTR_DIFF(ip,m_pos), \
3052 PTR_LT(m_pos,in) || \
3053 (m_off = (lzo_uint) PTR_DIFF(ip,m_pos)) == 0 || \
3054 m_off > max_offset )))
3058 #define LZO_CHECK_MPOS_DET(m_pos,m_off,in,ip,max_offset) \
3060 ((m_off = pd(ip, in) - m_off) > max_offset) || \
3061 (m_pos = (ip) - (m_off), 0) )
3063 #define LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,max_offset) \
3064 (pd(ip, in) <= m_off || \
3065 ((m_off = pd(ip, in) - m_off) > max_offset) || \
3066 (m_pos = (ip) - (m_off), 0) )
3070 #if (LZO_DETERMINISTIC)
3071 # define LZO_CHECK_MPOS LZO_CHECK_MPOS_DET
3073 # define LZO_CHECK_MPOS LZO_CHECK_MPOS_NON_DET
3086 #define LZO_DETERMINISTIC !(LZO_DICT_USE_PTR)
3089 #define DO_COMPRESS lzo1x_1_compress
3092 #if 1 && defined(DO_COMPRESS) && !defined(do_compress)
3093 # define do_compress LZO_CPP_ECONCAT2(DO_COMPRESS,_core)
3096 #if defined(UA_GET64) && (LZO_ABI_BIG_ENDIAN)
3097 # define WANT_lzo_bitops_clz64 1
3098 #elif defined(UA_GET64) && (LZO_ABI_LITTLE_ENDIAN)
3099 # define WANT_lzo_bitops_ctz64 1
3100 #elif defined(UA_GET32) && (LZO_ABI_BIG_ENDIAN)
3101 # define WANT_lzo_bitops_clz32 1
3102 #elif defined(UA_GET32) && (LZO_ABI_LITTLE_ENDIAN)
3103 # define WANT_lzo_bitops_ctz32 1
3106 #if (defined(_WIN32) || defined(_WIN64)) && ((LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || (LZO_CC_MSC && (_MSC_VER >= 1400)))
3108 #if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32) && 0
3109 #pragma intrinsic(_BitScanReverse)
3110 static __lzo_inline
unsigned lzo_bitops_clz32(lzo_uint32 v
)
3113 (void) _BitScanReverse(&r
, v
);
3114 return (unsigned) r
;
3116 #define lzo_bitops_clz32 lzo_bitops_clz32
3118 #if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX) && 0
3119 #pragma intrinsic(_BitScanReverse64)
3120 static __lzo_inline
unsigned lzo_bitops_clz64(lzo_uint64 v
)
3123 (void) _BitScanReverse64(&r
, v
);
3124 return (unsigned) r
;
3126 #define lzo_bitops_clz64 lzo_bitops_clz64
3128 #if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32)
3129 #pragma intrinsic(_BitScanForward)
3130 static __lzo_inline
unsigned lzo_bitops_ctz32(lzo_uint32 v
)
3133 (void) _BitScanForward(&r
, v
);
3134 return (unsigned) r
;
3136 #define lzo_bitops_ctz32 lzo_bitops_ctz32
3138 #if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX)
3139 #pragma intrinsic(_BitScanForward64)
3140 static __lzo_inline
unsigned lzo_bitops_ctz64(lzo_uint64 v
)
3143 (void) _BitScanForward64(&r
, v
);
3144 return (unsigned) r
;
3146 #define lzo_bitops_ctz64 lzo_bitops_ctz64
3149 #elif (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x030400ul) || (LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || (LZO_CC_LLVM && (!defined(__llvm_tools_version__) || (__llvm_tools_version__+0 >= 0x010500ul))))
3150 #if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32)
3151 #define lzo_bitops_clz32(v) ((unsigned) __builtin_clz(v))
3153 #if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX)
3154 #define lzo_bitops_clz64(v) ((unsigned) __builtin_clzll(v))
3156 #if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32)
3157 #define lzo_bitops_ctz32(v) ((unsigned) __builtin_ctz(v))
3159 #if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX)
3160 #define lzo_bitops_ctz64(v) ((unsigned) __builtin_ctzll(v))
3162 #if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount32)
3163 #define lzo_bitops_popcount32(v) ((unsigned) __builtin_popcount(v))
3165 #if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount64) && defined(LZO_UINT64_MAX)
3166 #define lzo_bitops_popcount64(v) ((unsigned) __builtin_popcountll(v))
3170 static __lzo_noinline lzo_uint
3171 do_compress ( const lzo_bytep in
, lzo_uint in_len
,
3172 lzo_bytep out
, lzo_uintp out_len
,
3173 lzo_uint ti
, lzo_voidp wrkmem
)
3175 register const lzo_bytep ip
;
3177 const lzo_bytep
const in_end
= in
+ in_len
;
3178 const lzo_bytep
const ip_end
= in
+ in_len
- 20;
3180 lzo_dict_p
const dict
= (lzo_dict_p
) wrkmem
;
3186 ip
+= ti
< 4 ? 4 - ti
: 0;
3189 const lzo_bytep m_pos
;
3190 #if !(LZO_DETERMINISTIC)
3191 LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint
, m_off
, 0);
3195 if __lzo_unlikely(ip
>= ip_end
)
3198 GINDEX(m_pos
,m_off
,dict
,dindex
,in
);
3199 if (LZO_CHECK_MPOS_NON_DET(m_pos
,m_off
,in
,ip
,M4_MAX_OFFSET
))
3202 if (m_off
<= M2_MAX_OFFSET
|| m_pos
[3] == ip
[3])
3206 GINDEX(m_pos
,m_off
,dict
,dindex
,in
);
3207 if (LZO_CHECK_MPOS_NON_DET(m_pos
,m_off
,in
,ip
,M4_MAX_OFFSET
))
3209 if (m_off
<= M2_MAX_OFFSET
|| m_pos
[3] == ip
[3])
3214 #if defined(UA_GET32)
3215 if (UA_GET32(m_pos
) != UA_GET32(ip
))
3217 if (m_pos
[0] != ip
[0] || m_pos
[1] != ip
[1] || m_pos
[2] != ip
[2] || m_pos
[3] != ip
[3])
3221 UPDATE_I(dict
,0,dindex
,ip
,in
);
3222 ip
+= 1 + ((ip
- ii
) >> 5);
3225 UPDATE_I(dict
,0,dindex
,ip
,in
);
3233 ip
+= 1 + ((ip
- ii
) >> 5);
3235 if __lzo_unlikely(ip
>= ip_end
)
3238 dindex
= DINDEX(dv
,ip
);
3239 GINDEX(m_off
,m_pos
,in
+dict
,dindex
,in
);
3240 UPDATE_I(dict
,0,dindex
,ip
,in
);
3241 if __lzo_unlikely(dv
!= UA_GET32(m_pos
))
3248 register lzo_uint t
= pd(ip
,ii
);
3253 op
[-2] |= LZO_BYTE(t
);
3254 #if defined(UA_COPY32)
3258 { do *op
++ = *ii
++; while (--t
> 0); }
3261 #if defined(UA_COPY32) || defined(UA_COPY64)
3264 *op
++ = LZO_BYTE(t
- 3);
3265 #if defined(UA_COPY64)
3267 UA_COPY64(op
+8, ii
+8);
3270 UA_COPY32(op
+4, ii
+4);
3271 UA_COPY32(op
+8, ii
+8);
3272 UA_COPY32(op
+12, ii
+12);
3280 *op
++ = LZO_BYTE(t
- 3);
3283 register lzo_uint tt
= t
- 18;
3285 while __lzo_unlikely(tt
> 255)
3288 #if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400))
3289 * (volatile unsigned char *) op
++ = 0;
3295 *op
++ = LZO_BYTE(tt
);
3297 #if defined(UA_COPY32) || defined(UA_COPY64)
3299 #if defined(UA_COPY64)
3301 UA_COPY64(op
+8, ii
+8);
3304 UA_COPY32(op
+4, ii
+4);
3305 UA_COPY32(op
+8, ii
+8);
3306 UA_COPY32(op
+12, ii
+12);
3308 op
+= 16; ii
+= 16; t
-= 16;
3309 } while (t
>= 16); if (t
> 0)
3311 { do *op
++ = *ii
++; while (--t
> 0); }
3317 #if defined(UA_GET64)
3319 v
= UA_GET64(ip
+ m_len
) ^ UA_GET64(m_pos
+ m_len
);
3320 if __lzo_unlikely(v
== 0) {
3323 v
= UA_GET64(ip
+ m_len
) ^ UA_GET64(m_pos
+ m_len
);
3324 if __lzo_unlikely(ip
+ m_len
>= ip_end
)
3328 #if (LZO_ABI_BIG_ENDIAN) && defined(lzo_bitops_clz64)
3329 m_len
+= lzo_bitops_clz64(v
) / CHAR_BIT
;
3330 #elif (LZO_ABI_BIG_ENDIAN)
3331 if ((v
>> (64 - CHAR_BIT
)) == 0) do {
3334 } while ((v
>> (64 - CHAR_BIT
)) == 0);
3335 #elif (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_ctz64)
3336 m_len
+= lzo_bitops_ctz64(v
) / CHAR_BIT
;
3337 #elif (LZO_ABI_LITTLE_ENDIAN)
3338 if ((v
& UCHAR_MAX
) == 0) do {
3341 } while ((v
& UCHAR_MAX
) == 0);
3343 if (ip
[m_len
] == m_pos
[m_len
]) do {
3345 } while (ip
[m_len
] == m_pos
[m_len
]);
3347 #elif defined(UA_GET32)
3349 v
= UA_GET32(ip
+ m_len
) ^ UA_GET32(m_pos
+ m_len
);
3350 if __lzo_unlikely(v
== 0) {
3353 v
= UA_GET32(ip
+ m_len
) ^ UA_GET32(m_pos
+ m_len
);
3354 if __lzo_unlikely(ip
+ m_len
>= ip_end
)
3358 #if (LZO_ABI_BIG_ENDIAN) && defined(lzo_bitops_clz32)
3359 m_len
+= lzo_bitops_clz32(v
) / CHAR_BIT
;
3360 #elif (LZO_ABI_BIG_ENDIAN)
3361 if ((v
>> (32 - CHAR_BIT
)) == 0) do {
3364 } while ((v
>> (32 - CHAR_BIT
)) == 0);
3365 #elif (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_ctz32)
3366 m_len
+= lzo_bitops_ctz32(v
) / CHAR_BIT
;
3367 #elif (LZO_ABI_LITTLE_ENDIAN)
3368 if ((v
& UCHAR_MAX
) == 0) do {
3371 } while ((v
& UCHAR_MAX
) == 0);
3373 if (ip
[m_len
] == m_pos
[m_len
]) do {
3375 } while (ip
[m_len
] == m_pos
[m_len
]);
3378 if __lzo_unlikely(ip
[m_len
] == m_pos
[m_len
]) {
3381 if __lzo_unlikely(ip
+ m_len
>= ip_end
)
3383 } while (ip
[m_len
] == m_pos
[m_len
]);
3388 m_off
= pd(ip
,m_pos
);
3391 if (m_len
<= M2_MAX_LEN
&& m_off
<= M2_MAX_OFFSET
)
3395 *op
++ = LZO_BYTE(((m_len
- 1) << 5) | ((m_off
& 7) << 2));
3396 *op
++ = LZO_BYTE(m_off
>> 3);
3397 #elif defined(LZO1Y)
3398 *op
++ = LZO_BYTE(((m_len
+ 1) << 4) | ((m_off
& 3) << 2));
3399 *op
++ = LZO_BYTE(m_off
>> 2);
3402 else if (m_off
<= M3_MAX_OFFSET
)
3405 if (m_len
<= M3_MAX_LEN
)
3406 *op
++ = LZO_BYTE(M3_MARKER
| (m_len
- 2));
3409 m_len
-= M3_MAX_LEN
;
3410 *op
++ = M3_MARKER
| 0;
3411 while __lzo_unlikely(m_len
> 255)
3414 #if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400))
3415 * (volatile unsigned char *) op
++ = 0;
3420 *op
++ = LZO_BYTE(m_len
);
3422 *op
++ = LZO_BYTE(m_off
<< 2);
3423 *op
++ = LZO_BYTE(m_off
>> 6);
3428 if (m_len
<= M4_MAX_LEN
)
3429 *op
++ = LZO_BYTE(M4_MARKER
| ((m_off
>> 11) & 8) | (m_len
- 2));
3432 m_len
-= M4_MAX_LEN
;
3433 *op
++ = LZO_BYTE(M4_MARKER
| ((m_off
>> 11) & 8));
3434 while __lzo_unlikely(m_len
> 255)
3437 #if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400))
3438 * (volatile unsigned char *) op
++ = 0;
3443 *op
++ = LZO_BYTE(m_len
);
3445 *op
++ = LZO_BYTE(m_off
<< 2);
3446 *op
++ = LZO_BYTE(m_off
>> 6);
3451 *out_len
= pd(op
, out
);
3452 return pd(in_end
,ii
-ti
);
3456 DO_COMPRESS ( const lzo_bytep in
, lzo_uint in_len
,
3457 lzo_bytep out
, lzo_uintp out_len
,
3460 const lzo_bytep ip
= in
;
3462 lzo_uint l
= in_len
;
3468 lzo_uintptr_t ll_end
;
3469 #if 0 || (LZO_DETERMINISTIC)
3470 ll
= LZO_MIN(ll
, 49152);
3472 ll_end
= (lzo_uintptr_t
)ip
+ ll
;
3473 if ((ll_end
+ ((t
+ ll
) >> 5)) <= ll_end
|| (const lzo_bytep
)(ll_end
+ ((t
+ ll
) >> 5)) <= ip
+ ll
)
3475 #if (LZO_DETERMINISTIC)
3476 lzo_memset(wrkmem
, 0, ((lzo_uint
)1 << D_BITS
) * sizeof(lzo_dict_t
));
3478 t
= do_compress(ip
,ll
,op
,out_len
,t
,wrkmem
);
3487 const lzo_bytep ii
= in
+ in_len
- t
;
3489 if (op
== out
&& t
<= 238)
3490 *op
++ = LZO_BYTE(17 + t
);
3492 op
[-2] |= LZO_BYTE(t
);
3494 *op
++ = LZO_BYTE(t
- 3);
3497 lzo_uint tt
= t
- 18;
3503 #if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400))
3505 * (volatile unsigned char *) op
++ = 0;
3511 *op
++ = LZO_BYTE(tt
);
3513 do *op
++ = *ii
++; while (--t
> 0);
3516 *op
++ = M4_MARKER
| 1;
3520 *out_len
= pd(op
, out
);
3530 #undef LZO_TEST_OVERRUN
3531 #undef DO_DECOMPRESS
3532 #define DO_DECOMPRESS lzo1x_decompress
3534 #if !defined(MINILZO_CFG_SKIP_LZO1X_DECOMPRESS)
3536 #if defined(LZO_TEST_OVERRUN)
3537 # if !defined(LZO_TEST_OVERRUN_INPUT)
3538 # define LZO_TEST_OVERRUN_INPUT 2
3540 # if !defined(LZO_TEST_OVERRUN_OUTPUT)
3541 # define LZO_TEST_OVERRUN_OUTPUT 2
3543 # if !defined(LZO_TEST_OVERRUN_LOOKBEHIND)
3544 # define LZO_TEST_OVERRUN_LOOKBEHIND 1
3561 #if defined(LZO_TEST_OVERRUN_INPUT)
3562 # if (LZO_TEST_OVERRUN_INPUT >= 1)
3563 # define TEST_IP (ip < ip_end)
3565 # if (LZO_TEST_OVERRUN_INPUT >= 2)
3566 # define NEED_IP(x) \
3567 if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x)) goto input_overrun
3571 #if defined(LZO_TEST_OVERRUN_OUTPUT)
3572 # if (LZO_TEST_OVERRUN_OUTPUT >= 1)
3573 # define TEST_OP (op <= op_end)
3575 # if (LZO_TEST_OVERRUN_OUTPUT >= 2)
3577 # define NEED_OP(x) \
3578 if ((lzo_uint)(op_end - op) < (lzo_uint)(x)) goto output_overrun
3582 #if defined(LZO_TEST_OVERRUN_LOOKBEHIND)
3583 # define TEST_LB(m_pos) if (m_pos < out || m_pos >= op) goto lookbehind_overrun
3584 # define TEST_LBO(m_pos,o) if (m_pos < out || m_pos >= op - (o)) goto lookbehind_overrun
3586 # define TEST_LB(m_pos) ((void) 0)
3587 # define TEST_LBO(m_pos,o) ((void) 0)
3590 #if !defined(LZO_EOF_CODE) && !defined(TEST_IP)
3591 # define TEST_IP (ip < ip_end)
3594 #if defined(TEST_IP)
3595 # define HAVE_TEST_IP 1
3599 #if defined(TEST_OP)
3600 # define HAVE_TEST_OP 1
3605 #if defined(NEED_IP)
3606 # define HAVE_NEED_IP 1
3608 # define NEED_IP(x) ((void) 0)
3610 #if defined(NEED_OP)
3611 # define HAVE_NEED_OP 1
3613 # define NEED_OP(x) ((void) 0)
3616 #if defined(HAVE_TEST_IP) || defined(HAVE_NEED_IP)
3617 # define HAVE_ANY_IP 1
3619 #if defined(HAVE_TEST_OP) || defined(HAVE_NEED_OP)
3620 # define HAVE_ANY_OP 1
3623 #if defined(DO_DECOMPRESS)
3625 DO_DECOMPRESS ( const lzo_bytep in
, lzo_uint in_len
,
3626 lzo_bytep out
, lzo_uintp out_len
,
3630 register lzo_bytep op
;
3631 register const lzo_bytep ip
;
3632 register lzo_uint t
;
3633 #if defined(COPY_DICT)
3635 const lzo_bytep dict_end
;
3637 register const lzo_bytep m_pos
;
3640 const lzo_bytep
const ip_end
= in
+ in_len
;
3641 #if defined(HAVE_ANY_OP)
3642 lzo_bytep
const op_end
= out
+ *out_len
;
3645 lzo_uint last_m_off
= 0;
3650 #if defined(COPY_DICT)
3653 if (dict_len
> M4_MAX_OFFSET
)
3655 dict
+= dict_len
- M4_MAX_OFFSET
;
3656 dict_len
= M4_MAX_OFFSET
;
3658 dict_end
= dict
+ dict_len
;
3677 assert(t
> 0); NEED_OP(t
); NEED_IP(t
+1);
3678 do *op
++ = *ip
++; while (--t
> 0);
3679 goto first_literal_run
;
3682 while (TEST_IP
&& TEST_OP
)
3698 assert(t
> 0); NEED_OP(t
+3); NEED_IP(t
+4);
3699 #if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4)
3704 op
+= 8; ip
+= 8; t
-= 8;
3709 op
+= 4; ip
+= 4; t
-= 4;
3714 if (t
> 1) { *op
++ = *ip
++; if (t
> 2) { *op
++ = *ip
++; } }
3716 #elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
3717 #if !defined(LZO_UNALIGNED_OK_4)
3718 if (PTR_ALIGNED2_4(op
,ip
))
3729 op
+= 4; ip
+= 4; t
-= 4;
3731 if (t
> 0) do *op
++ = *ip
++; while (--t
> 0);
3734 do *op
++ = *ip
++; while (--t
> 0);
3736 #if !defined(LZO_UNALIGNED_OK_4)
3741 #if !defined(LZO_UNALIGNED_OK_4) && !defined(LZO_UNALIGNED_OK_8)
3743 *op
++ = *ip
++; *op
++ = *ip
++; *op
++ = *ip
++;
3744 do *op
++ = *ip
++; while (--t
> 0);
3753 #if defined(COPY_DICT)
3755 m_off
= (1 + M2_MAX_OFFSET
) + (t
<< 6) + (*ip
++ >> 2);
3758 m_off
= (1 + M2_MAX_OFFSET
) + (t
>> 2) + (*ip
++ << 2);
3761 t
= 3; COPY_DICT(t
,m_off
)
3764 t
= (1 + M2_MAX_OFFSET
) + (t
<< 6) + (*ip
++ >> 2);
3768 m_pos
= op
- (1 + M2_MAX_OFFSET
);
3770 m_pos
-= *ip
++ << 2;
3772 TEST_LB(m_pos
); NEED_OP(3);
3773 *op
++ = *m_pos
++; *op
++ = *m_pos
++; *op
++ = *m_pos
;
3781 #if defined(COPY_DICT)
3783 m_off
= 1 + ((t
>> 2) & 7) + (*ip
++ << 3);
3785 #elif defined(LZO1Y)
3786 m_off
= 1 + ((t
>> 2) & 3) + (*ip
++ << 2);
3788 #elif defined(LZO1Z)
3794 m_off
= 1 + (m_off
<< 6) + (*ip
++ >> 2);
3802 m_pos
-= (t
>> 2) & 7;
3803 m_pos
-= *ip
++ << 3;
3805 #elif defined(LZO1Y)
3807 m_pos
-= (t
>> 2) & 3;
3808 m_pos
-= *ip
++ << 2;
3810 #elif defined(LZO1Z)
3812 lzo_uint off
= t
& 0x1f;
3816 assert(last_m_off
> 0);
3817 m_pos
-= last_m_off
;
3821 off
= 1 + (off
<< 6) + (*ip
++ >> 2);
3828 TEST_LB(m_pos
); assert(t
> 0); NEED_OP(t
+3-1);
3846 #if defined(COPY_DICT)
3848 m_off
= 1 + (ip
[0] << 6) + (ip
[1] >> 2);
3851 m_off
= 1 + (ip
[0] >> 2) + (ip
[1] << 6);
3856 lzo_uint off
= 1 + (ip
[0] << 6) + (ip
[1] >> 2);
3860 #elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN)
3862 m_pos
-= UA_GET16(ip
) >> 2;
3865 m_pos
-= (ip
[0] >> 2) + (ip
[1] << 6);
3872 #if defined(COPY_DICT)
3873 m_off
= (t
& 8) << 11;
3876 m_pos
-= (t
& 8) << 11;
3890 #if defined(COPY_DICT)
3892 m_off
+= (ip
[0] << 6) + (ip
[1] >> 2);
3894 m_off
+= (ip
[0] >> 2) + (ip
[1] << 6);
3905 m_pos
-= (ip
[0] << 6) + (ip
[1] >> 2);
3906 #elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN)
3907 m_pos
-= UA_GET16(ip
) >> 2;
3909 m_pos
-= (ip
[0] >> 2) + (ip
[1] << 6);
3916 last_m_off
= pd((const lzo_bytep
)op
, m_pos
);
3922 #if defined(COPY_DICT)
3924 m_off
= 1 + (t
<< 6) + (*ip
++ >> 2);
3927 m_off
= 1 + (t
>> 2) + (*ip
++ << 2);
3930 t
= 2; COPY_DICT(t
,m_off
)
3933 t
= 1 + (t
<< 6) + (*ip
++ >> 2);
3939 m_pos
-= *ip
++ << 2;
3941 TEST_LB(m_pos
); NEED_OP(2);
3942 *op
++ = *m_pos
++; *op
++ = *m_pos
;
3947 #if defined(COPY_DICT)
3950 t
+= 3-1; COPY_DICT(t
,m_off
)
3954 TEST_LB(m_pos
); assert(t
> 0); NEED_OP(t
+3-1);
3955 #if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4)
3956 if (op
- m_pos
>= 8)
3961 UA_COPY64(op
,m_pos
);
3962 op
+= 8; m_pos
+= 8; t
-= 8;
3966 UA_COPY32(op
,m_pos
);
3967 op
+= 4; m_pos
+= 4; t
-= 4;
3972 if (t
> 1) { *op
++ = m_pos
[1]; if (t
> 2) { *op
++ = m_pos
[2]; } }
3976 #elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
3977 #if !defined(LZO_UNALIGNED_OK_4)
3978 if (t
>= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op
,m_pos
))
3980 assert((op
- m_pos
) >= 4);
3982 if (t
>= 2 * 4 - (3 - 1) && (op
- m_pos
) >= 4)
3985 UA_COPY32(op
,m_pos
);
3986 op
+= 4; m_pos
+= 4; t
-= 4 - (3 - 1);
3988 UA_COPY32(op
,m_pos
);
3989 op
+= 4; m_pos
+= 4; t
-= 4;
3991 if (t
> 0) do *op
++ = *m_pos
++; while (--t
> 0);
3997 *op
++ = *m_pos
++; *op
++ = *m_pos
++;
3998 do *op
++ = *m_pos
++; while (--t
> 0);
4013 assert(t
> 0); assert(t
< 4); NEED_OP(t
); NEED_IP(t
+1);
4015 do *op
++ = *ip
++; while (--t
> 0);
4018 if (t
> 1) { *op
++ = *ip
++; if (t
> 2) { *op
++ = *ip
++; } }
4021 } while (TEST_IP
&& TEST_OP
);
4024 #if defined(HAVE_TEST_IP) || defined(HAVE_TEST_OP)
4025 *out_len
= pd(op
, out
);
4026 return LZO_E_EOF_NOT_FOUND
;
4031 *out_len
= pd(op
, out
);
4032 return (ip
== ip_end
? LZO_E_OK
:
4033 (ip
< ip_end
? LZO_E_INPUT_NOT_CONSUMED
: LZO_E_INPUT_OVERRUN
));
4035 #if defined(HAVE_NEED_IP)
4037 *out_len
= pd(op
, out
);
4038 return LZO_E_INPUT_OVERRUN
;
4041 #if defined(HAVE_NEED_OP)
4043 *out_len
= pd(op
, out
);
4044 return LZO_E_OUTPUT_OVERRUN
;
4047 #if defined(LZO_TEST_OVERRUN_LOOKBEHIND)
4049 *out_len
= pd(op
, out
);
4050 return LZO_E_LOOKBEHIND_OVERRUN
;
4056 #define LZO_TEST_OVERRUN 1
4057 #undef DO_DECOMPRESS
4058 #define DO_DECOMPRESS lzo1x_decompress_safe
4060 #if !defined(MINILZO_CFG_SKIP_LZO1X_DECOMPRESS_SAFE)
4062 #if defined(LZO_TEST_OVERRUN)
4063 # if !defined(LZO_TEST_OVERRUN_INPUT)
4064 # define LZO_TEST_OVERRUN_INPUT 2
4066 # if !defined(LZO_TEST_OVERRUN_OUTPUT)
4067 # define LZO_TEST_OVERRUN_OUTPUT 2
4069 # if !defined(LZO_TEST_OVERRUN_LOOKBEHIND)
4070 # define LZO_TEST_OVERRUN_LOOKBEHIND 1
4087 #if defined(LZO_TEST_OVERRUN_INPUT)
4088 # if (LZO_TEST_OVERRUN_INPUT >= 1)
4089 # define TEST_IP (ip < ip_end)
4091 # if (LZO_TEST_OVERRUN_INPUT >= 2)
4092 # define NEED_IP(x) \
4093 if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x)) goto input_overrun
4097 #if defined(LZO_TEST_OVERRUN_OUTPUT)
4098 # if (LZO_TEST_OVERRUN_OUTPUT >= 1)
4099 # define TEST_OP (op <= op_end)
4101 # if (LZO_TEST_OVERRUN_OUTPUT >= 2)
4103 # define NEED_OP(x) \
4104 if ((lzo_uint)(op_end - op) < (lzo_uint)(x)) goto output_overrun
4108 #if defined(LZO_TEST_OVERRUN_LOOKBEHIND)
4109 # define TEST_LB(m_pos) if (m_pos < out || m_pos >= op) goto lookbehind_overrun
4110 # define TEST_LBO(m_pos,o) if (m_pos < out || m_pos >= op - (o)) goto lookbehind_overrun
4112 # define TEST_LB(m_pos) ((void) 0)
4113 # define TEST_LBO(m_pos,o) ((void) 0)
4116 #if !defined(LZO_EOF_CODE) && !defined(TEST_IP)
4117 # define TEST_IP (ip < ip_end)
4120 #if defined(TEST_IP)
4121 # define HAVE_TEST_IP 1
4125 #if defined(TEST_OP)
4126 # define HAVE_TEST_OP 1
4131 #if defined(NEED_IP)
4132 # define HAVE_NEED_IP 1
4134 # define NEED_IP(x) ((void) 0)
4136 #if defined(NEED_OP)
4137 # define HAVE_NEED_OP 1
4139 # define NEED_OP(x) ((void) 0)
4142 #if defined(HAVE_TEST_IP) || defined(HAVE_NEED_IP)
4143 # define HAVE_ANY_IP 1
4145 #if defined(HAVE_TEST_OP) || defined(HAVE_NEED_OP)
4146 # define HAVE_ANY_OP 1
4149 #if defined(DO_DECOMPRESS)
4151 DO_DECOMPRESS ( const lzo_bytep in
, lzo_uint in_len
,
4152 lzo_bytep out
, lzo_uintp out_len
,
4156 register lzo_bytep op
;
4157 register const lzo_bytep ip
;
4158 register lzo_uint t
;
4159 #if defined(COPY_DICT)
4161 const lzo_bytep dict_end
;
4163 register const lzo_bytep m_pos
;
4166 const lzo_bytep
const ip_end
= in
+ in_len
;
4167 #if defined(HAVE_ANY_OP)
4168 lzo_bytep
const op_end
= out
+ *out_len
;
4171 lzo_uint last_m_off
= 0;
4176 #if defined(COPY_DICT)
4179 if (dict_len
> M4_MAX_OFFSET
)
4181 dict
+= dict_len
- M4_MAX_OFFSET
;
4182 dict_len
= M4_MAX_OFFSET
;
4184 dict_end
= dict
+ dict_len
;
4203 assert(t
> 0); NEED_OP(t
); NEED_IP(t
+1);
4204 do *op
++ = *ip
++; while (--t
> 0);
4205 goto first_literal_run
;
4208 while (TEST_IP
&& TEST_OP
)
4224 assert(t
> 0); NEED_OP(t
+3); NEED_IP(t
+4);
4225 #if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4)
4230 op
+= 8; ip
+= 8; t
-= 8;
4235 op
+= 4; ip
+= 4; t
-= 4;
4240 if (t
> 1) { *op
++ = *ip
++; if (t
> 2) { *op
++ = *ip
++; } }
4242 #elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
4243 #if !defined(LZO_UNALIGNED_OK_4)
4244 if (PTR_ALIGNED2_4(op
,ip
))
4255 op
+= 4; ip
+= 4; t
-= 4;
4257 if (t
> 0) do *op
++ = *ip
++; while (--t
> 0);
4260 do *op
++ = *ip
++; while (--t
> 0);
4262 #if !defined(LZO_UNALIGNED_OK_4)
4267 #if !defined(LZO_UNALIGNED_OK_4) && !defined(LZO_UNALIGNED_OK_8)
4269 *op
++ = *ip
++; *op
++ = *ip
++; *op
++ = *ip
++;
4270 do *op
++ = *ip
++; while (--t
> 0);
4279 #if defined(COPY_DICT)
4281 m_off
= (1 + M2_MAX_OFFSET
) + (t
<< 6) + (*ip
++ >> 2);
4284 m_off
= (1 + M2_MAX_OFFSET
) + (t
>> 2) + (*ip
++ << 2);
4287 t
= 3; COPY_DICT(t
,m_off
)
4290 t
= (1 + M2_MAX_OFFSET
) + (t
<< 6) + (*ip
++ >> 2);
4294 m_pos
= op
- (1 + M2_MAX_OFFSET
);
4296 m_pos
-= *ip
++ << 2;
4298 TEST_LB(m_pos
); NEED_OP(3);
4299 *op
++ = *m_pos
++; *op
++ = *m_pos
++; *op
++ = *m_pos
;
4307 #if defined(COPY_DICT)
4309 m_off
= 1 + ((t
>> 2) & 7) + (*ip
++ << 3);
4311 #elif defined(LZO1Y)
4312 m_off
= 1 + ((t
>> 2) & 3) + (*ip
++ << 2);
4314 #elif defined(LZO1Z)
4320 m_off
= 1 + (m_off
<< 6) + (*ip
++ >> 2);
4328 m_pos
-= (t
>> 2) & 7;
4329 m_pos
-= *ip
++ << 3;
4331 #elif defined(LZO1Y)
4333 m_pos
-= (t
>> 2) & 3;
4334 m_pos
-= *ip
++ << 2;
4336 #elif defined(LZO1Z)
4338 lzo_uint off
= t
& 0x1f;
4342 assert(last_m_off
> 0);
4343 m_pos
-= last_m_off
;
4347 off
= 1 + (off
<< 6) + (*ip
++ >> 2);
4354 TEST_LB(m_pos
); assert(t
> 0); NEED_OP(t
+3-1);
4372 #if defined(COPY_DICT)
4374 m_off
= 1 + (ip
[0] << 6) + (ip
[1] >> 2);
4377 m_off
= 1 + (ip
[0] >> 2) + (ip
[1] << 6);
4382 lzo_uint off
= 1 + (ip
[0] << 6) + (ip
[1] >> 2);
4386 #elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN)
4388 m_pos
-= UA_GET16(ip
) >> 2;
4391 m_pos
-= (ip
[0] >> 2) + (ip
[1] << 6);
4398 #if defined(COPY_DICT)
4399 m_off
= (t
& 8) << 11;
4402 m_pos
-= (t
& 8) << 11;
4416 #if defined(COPY_DICT)
4418 m_off
+= (ip
[0] << 6) + (ip
[1] >> 2);
4420 m_off
+= (ip
[0] >> 2) + (ip
[1] << 6);
4431 m_pos
-= (ip
[0] << 6) + (ip
[1] >> 2);
4432 #elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN)
4433 m_pos
-= UA_GET16(ip
) >> 2;
4435 m_pos
-= (ip
[0] >> 2) + (ip
[1] << 6);
4442 last_m_off
= pd((const lzo_bytep
)op
, m_pos
);
4448 #if defined(COPY_DICT)
4450 m_off
= 1 + (t
<< 6) + (*ip
++ >> 2);
4453 m_off
= 1 + (t
>> 2) + (*ip
++ << 2);
4456 t
= 2; COPY_DICT(t
,m_off
)
4459 t
= 1 + (t
<< 6) + (*ip
++ >> 2);
4465 m_pos
-= *ip
++ << 2;
4467 TEST_LB(m_pos
); NEED_OP(2);
4468 *op
++ = *m_pos
++; *op
++ = *m_pos
;
4473 #if defined(COPY_DICT)
4476 t
+= 3-1; COPY_DICT(t
,m_off
)
4480 TEST_LB(m_pos
); assert(t
> 0); NEED_OP(t
+3-1);
4481 #if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4)
4482 if (op
- m_pos
>= 8)
4487 UA_COPY64(op
,m_pos
);
4488 op
+= 8; m_pos
+= 8; t
-= 8;
4492 UA_COPY32(op
,m_pos
);
4493 op
+= 4; m_pos
+= 4; t
-= 4;
4498 if (t
> 1) { *op
++ = m_pos
[1]; if (t
> 2) { *op
++ = m_pos
[2]; } }
4502 #elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
4503 #if !defined(LZO_UNALIGNED_OK_4)
4504 if (t
>= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op
,m_pos
))
4506 assert((op
- m_pos
) >= 4);
4508 if (t
>= 2 * 4 - (3 - 1) && (op
- m_pos
) >= 4)
4511 UA_COPY32(op
,m_pos
);
4512 op
+= 4; m_pos
+= 4; t
-= 4 - (3 - 1);
4514 UA_COPY32(op
,m_pos
);
4515 op
+= 4; m_pos
+= 4; t
-= 4;
4517 if (t
> 0) do *op
++ = *m_pos
++; while (--t
> 0);
4523 *op
++ = *m_pos
++; *op
++ = *m_pos
++;
4524 do *op
++ = *m_pos
++; while (--t
> 0);
4539 assert(t
> 0); assert(t
< 4); NEED_OP(t
); NEED_IP(t
+1);
4541 do *op
++ = *ip
++; while (--t
> 0);
4544 if (t
> 1) { *op
++ = *ip
++; if (t
> 2) { *op
++ = *ip
++; } }
4547 } while (TEST_IP
&& TEST_OP
);
4550 #if defined(HAVE_TEST_IP) || defined(HAVE_TEST_OP)
4551 *out_len
= pd(op
, out
);
4552 return LZO_E_EOF_NOT_FOUND
;
4557 *out_len
= pd(op
, out
);
4558 return (ip
== ip_end
? LZO_E_OK
:
4559 (ip
< ip_end
? LZO_E_INPUT_NOT_CONSUMED
: LZO_E_INPUT_OVERRUN
));
4561 #if defined(HAVE_NEED_IP)
4563 *out_len
= pd(op
, out
);
4564 return LZO_E_INPUT_OVERRUN
;
4567 #if defined(HAVE_NEED_OP)
4569 *out_len
= pd(op
, out
);
4570 return LZO_E_OUTPUT_OVERRUN
;
4573 #if defined(LZO_TEST_OVERRUN_LOOKBEHIND)
4575 *out_len
= pd(op
, out
);
4576 return LZO_E_LOOKBEHIND_OVERRUN
;
4582 /***** End of minilzo.c *****/