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 #ifdef HAVE_HEADER_FEATURES_H
1879 #include <features.h>
1882 #undef LZO_HAVE_CONFIG_H
1883 #include "minilzo.h"
1885 #if !defined(MINILZO_VERSION) || (MINILZO_VERSION != 0x2060)
1886 # error "version mismatch in miniLZO source files"
1889 #ifdef MINILZO_HAVE_CONFIG_H
1890 # define LZO_HAVE_CONFIG_H 1
1893 #ifndef __LZO_CONF_H
1894 #define __LZO_CONF_H 1
1896 #if !defined(__LZO_IN_MINILZO)
1897 #if (LZO_CFG_FREESTANDING)
1898 # define LZO_LIBC_FREESTANDING 1
1899 # define LZO_OS_FREESTANDING 1
1900 # define ACC_LIBC_FREESTANDING 1
1901 # define ACC_OS_FREESTANDING 1
1903 #if (LZO_CFG_NO_UNALIGNED)
1904 # define ACC_CFG_NO_UNALIGNED 1
1906 #if (LZO_ARCH_GENERIC)
1907 # define ACC_ARCH_GENERIC 1
1909 #if (LZO_ABI_NEUTRAL_ENDIAN)
1910 # define ACC_ABI_NEUTRAL_ENDIAN 1
1912 #if (LZO_HAVE_CONFIG_H)
1913 # define ACC_CONFIG_NO_HEADER 1
1915 #if defined(LZO_CFG_EXTRA_CONFIG_HEADER)
1916 # include LZO_CFG_EXTRA_CONFIG_HEADER
1918 #if defined(__LZOCONF_H) || defined(__LZOCONF_H_INCLUDED)
1919 # error "include this file first"
1921 #include "lzo/lzoconf.h"
1924 #if (LZO_VERSION < 0x02000) || !defined(__LZOCONF_H_INCLUDED)
1925 # error "version mismatch"
1928 #if (LZO_CC_BORLANDC && LZO_ARCH_I086)
1932 #if (LZO_CC_MSC && (_MSC_VER >= 1000))
1933 # pragma warning(disable: 4127 4701)
1935 #if (LZO_CC_MSC && (_MSC_VER >= 1300))
1936 # pragma warning(disable: 4820)
1937 # pragma warning(disable: 4514 4710 4711)
1940 #if (LZO_CC_SUNPROC)
1941 #if !defined(__cplusplus)
1942 # pragma error_messages(off,E_END_OF_LOOP_CODE_NOT_REACHED)
1943 # pragma error_messages(off,E_LOOP_NOT_ENTERED_AT_TOP)
1944 # pragma error_messages(off,E_STATEMENT_NOT_REACHED)
1948 #if (__LZO_MMODEL_HUGE) && !(LZO_HAVE_MM_HUGE_PTR)
1949 # error "this should not happen - check defines for __huge"
1952 #if defined(__LZO_IN_MINILZO) || defined(LZO_CFG_FREESTANDING)
1953 #elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16)
1954 # define ACC_WANT_ACC_INCD_H 1
1955 # define ACC_WANT_ACC_INCE_H 1
1956 # define ACC_WANT_ACC_INCI_H 1
1958 # include <string.h>
1960 # define ACC_WANT_ACC_INCD_H 1
1964 # define ACC_MM_AHSHIFT LZO_MM_AHSHIFT
1965 # define ACC_PTR_FP_OFF(x) (((const unsigned __far*)&(x))[0])
1966 # define ACC_PTR_FP_SEG(x) (((const unsigned __far*)&(x))[1])
1967 # define ACC_PTR_MK_FP(s,o) ((void __far*)(((unsigned long)(s)<<16)+(unsigned)(o)))
1970 #if !defined(lzo_uintptr_t)
1971 # if defined(__LZO_MMODEL_HUGE)
1972 # define lzo_uintptr_t unsigned long
1973 # elif 1 && defined(LZO_OS_OS400) && (LZO_SIZEOF_VOID_P == 16)
1974 # define __LZO_UINTPTR_T_IS_POINTER 1
1975 typedef char* lzo_uintptr_t
;
1976 # define lzo_uintptr_t lzo_uintptr_t
1977 # elif (LZO_SIZEOF_SIZE_T == LZO_SIZEOF_VOID_P)
1978 # define lzo_uintptr_t size_t
1979 # elif (LZO_SIZEOF_LONG == LZO_SIZEOF_VOID_P)
1980 # define lzo_uintptr_t unsigned long
1981 # elif (LZO_SIZEOF_INT == LZO_SIZEOF_VOID_P)
1982 # define lzo_uintptr_t unsigned int
1983 # elif (LZO_SIZEOF_LONG_LONG == LZO_SIZEOF_VOID_P)
1984 # define lzo_uintptr_t unsigned long long
1986 # define lzo_uintptr_t size_t
1989 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uintptr_t
) >= sizeof(lzo_voidp
))
1991 #if 1 && !defined(LZO_CFG_FREESTANDING)
1992 #if 1 && !defined(HAVE_STRING_H)
1993 #define HAVE_STRING_H 1
1995 #if 1 && !defined(HAVE_MEMCMP)
1996 #define HAVE_MEMCMP 1
1998 #if 1 && !defined(HAVE_MEMCPY)
1999 #define HAVE_MEMCPY 1
2001 #if 1 && !defined(HAVE_MEMMOVE)
2002 #define HAVE_MEMMOVE 1
2004 #if 1 && !defined(HAVE_MEMSET)
2005 #define HAVE_MEMSET 1
2009 #if 1 && defined(HAVE_STRING_H)
2013 #if (LZO_CFG_FREESTANDING)
2016 # undef HAVE_MEMMOVE
2022 # define memcmp(a,b,c) lzo_memcmp(a,b,c)
2023 #elif !(__LZO_MMODEL_HUGE)
2025 # define lzo_memcmp(a,b,c) memcmp(a,b,c)
2029 # define memcpy(a,b,c) lzo_memcpy(a,b,c)
2030 #elif !(__LZO_MMODEL_HUGE)
2032 # define lzo_memcpy(a,b,c) memcpy(a,b,c)
2036 # define memmove(a,b,c) lzo_memmove(a,b,c)
2037 #elif !(__LZO_MMODEL_HUGE)
2039 # define lzo_memmove(a,b,c) memmove(a,b,c)
2043 # define memset(a,b,c) lzo_memset(a,b,c)
2044 #elif !(__LZO_MMODEL_HUGE)
2046 # define lzo_memset(a,b,c) memset(a,b,c)
2050 #if (LZO_CFG_FREESTANDING)
2054 # define assert(e) ((void)0)
2056 # if !defined(LZO_DEBUG)
2059 # include <assert.h>
2062 #if 0 && defined(__BOUNDS_CHECKING_ON)
2063 # include <unchecked.h>
2065 # define BOUNDS_CHECKING_OFF_DURING(stmt) stmt
2066 # define BOUNDS_CHECKING_OFF_IN_EXPR(expr) (expr)
2069 #if !defined(__lzo_inline)
2070 # define __lzo_inline /*empty*/
2072 #if !defined(__lzo_forceinline)
2073 # define __lzo_forceinline /*empty*/
2075 #if !defined(__lzo_noinline)
2076 # define __lzo_noinline /*empty*/
2080 # undef __acc_likely
2081 # undef __acc_unlikely
2082 # undef __lzo_likely
2083 # undef __lzo_unlikely
2084 # define __acc_likely(e) (e)
2085 # define __acc_unlikely(e) (e)
2086 # define __lzo_likely(e) (e)
2087 # define __lzo_unlikely(e) (e)
2091 # define LZO_BYTE(x) ((unsigned char) (x))
2093 # define LZO_BYTE(x) ((unsigned char) ((x) & 0xff))
2096 #define LZO_MAX(a,b) ((a) >= (b) ? (a) : (b))
2097 #define LZO_MIN(a,b) ((a) <= (b) ? (a) : (b))
2098 #define LZO_MAX3(a,b,c) ((a) >= (b) ? LZO_MAX(a,c) : LZO_MAX(b,c))
2099 #define LZO_MIN3(a,b,c) ((a) <= (b) ? LZO_MIN(a,c) : LZO_MIN(b,c))
2101 #define lzo_sizeof(type) ((lzo_uint) (sizeof(type)))
2103 #define LZO_HIGH(array) ((lzo_uint) (sizeof(array)/sizeof(*(array))))
2105 #define LZO_SIZE(bits) (1u << (bits))
2106 #define LZO_MASK(bits) (LZO_SIZE(bits) - 1)
2108 #define LZO_LSIZE(bits) (1ul << (bits))
2109 #define LZO_LMASK(bits) (LZO_LSIZE(bits) - 1)
2111 #define LZO_USIZE(bits) ((lzo_uint) 1 << (bits))
2112 #define LZO_UMASK(bits) (LZO_USIZE(bits) - 1)
2117 # define DMUL(a,b) ((lzo_xint) ((lzo_uint32)(a) * (lzo_uint32)(b)))
2119 # define DMUL(a,b) ((lzo_xint) ((a) * (b)))
2123 #if 1 && (LZO_ARCH_AMD64 || LZO_ARCH_I386 || LZO_ARCH_POWERPC)
2124 # if (LZO_SIZEOF_SHORT == 2)
2125 # define LZO_UNALIGNED_OK_2 1
2127 # if (LZO_SIZEOF_INT == 4)
2128 # define LZO_UNALIGNED_OK_4 1
2131 #if 1 && (LZO_ARCH_AMD64)
2132 # if defined(LZO_UINT64_MAX)
2133 # define LZO_UNALIGNED_OK_8 1
2136 #if (LZO_CFG_NO_UNALIGNED)
2137 # undef LZO_UNALIGNED_OK_2
2138 # undef LZO_UNALIGNED_OK_4
2139 # undef LZO_UNALIGNED_OK_8
2151 #if defined(LZO_UNALIGNED_OK_2)
2152 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(unsigned short) == 2)
2153 # if 1 && defined(ACC_UA_COPY16)
2154 # define UA_GET16 ACC_UA_GET16
2155 # define UA_SET16 ACC_UA_SET16
2156 # define UA_COPY16 ACC_UA_COPY16
2158 # define UA_GET16(p) (* (__lzo_ua_volatile const lzo_ushortp) (__lzo_ua_volatile const lzo_voidp) (p))
2159 # define UA_SET16(p,v) ((* (__lzo_ua_volatile lzo_ushortp) (__lzo_ua_volatile lzo_voidp) (p)) = (unsigned short) (v))
2160 # define UA_COPY16(d,s) UA_SET16(d, UA_GET16(s))
2163 #if defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
2164 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint32
) == 4)
2165 # if 1 && defined(ACC_UA_COPY32)
2166 # define UA_GET32 ACC_UA_GET32
2167 # define UA_SET32 ACC_UA_SET32
2168 # define UA_COPY32 ACC_UA_COPY32
2170 # define UA_GET32(p) (* (__lzo_ua_volatile const lzo_uint32p) (__lzo_ua_volatile const lzo_voidp) (p))
2171 # define UA_SET32(p,v) ((* (__lzo_ua_volatile lzo_uint32p) (__lzo_ua_volatile lzo_voidp) (p)) = (lzo_uint32) (v))
2172 # define UA_COPY32(d,s) UA_SET32(d, UA_GET32(s))
2175 #if defined(LZO_UNALIGNED_OK_8)
2176 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint64
) == 8)
2177 # if 1 && defined(ACC_UA_COPY64)
2178 # define UA_GET64 ACC_UA_GET64
2179 # define UA_SET64 ACC_UA_SET64
2180 # define UA_COPY64 ACC_UA_COPY64
2182 # define UA_GET64(p) (* (__lzo_ua_volatile const lzo_uint64p) (__lzo_ua_volatile const lzo_voidp) (p))
2183 # define UA_SET64(p,v) ((* (__lzo_ua_volatile lzo_uint64p) (__lzo_ua_volatile lzo_voidp) (p)) = (lzo_uint64) (v))
2184 # define UA_COPY64(d,s) UA_SET64(d, UA_GET64(s))
2188 #define MEMCPY8_DS(dest,src,len) \
2189 lzo_memcpy(dest,src,len); dest += len; src += len
2191 #define BZERO8_PTR(s,l,n) \
2192 lzo_memset((lzo_voidp)(s),0,(lzo_uint)(l)*(n))
2194 #define MEMCPY_DS(dest,src,len) \
2195 do *dest++ = *src++; while (--len > 0)
2197 LZO_EXTERN(const lzo_bytep
) lzo_copyright(void);
2200 #define __LZO_PTR_H 1
2206 #if !defined(lzo_uintptr_t)
2207 # if (__LZO_MMODEL_HUGE)
2208 # define lzo_uintptr_t unsigned long
2210 # define lzo_uintptr_t acc_uintptr_t
2211 # ifdef __ACC_INTPTR_T_IS_POINTER
2212 # define __LZO_UINTPTR_T_IS_POINTER 1
2218 #define PTR(a) ((lzo_bytep) (a))
2219 #define PTR_ALIGNED_4(a) ((ACC_PTR_FP_OFF(a) & 3) == 0)
2220 #define PTR_ALIGNED2_4(a,b) (((ACC_PTR_FP_OFF(a) | ACC_PTR_FP_OFF(b)) & 3) == 0)
2222 #define PTR(a) ((lzo_bytep) (a))
2223 #define PTR_ALIGNED_8(a) ((((lzo_uintptr_t)(a)) >> 61) == 0)
2224 #define PTR_ALIGNED2_8(a,b) ((((lzo_uintptr_t)(a)|(lzo_uintptr_t)(b)) >> 61) == 0)
2226 #define PTR(a) ((lzo_uintptr_t) (a))
2227 #define PTR_LINEAR(a) PTR(a)
2228 #define PTR_ALIGNED_4(a) ((PTR_LINEAR(a) & 3) == 0)
2229 #define PTR_ALIGNED_8(a) ((PTR_LINEAR(a) & 7) == 0)
2230 #define PTR_ALIGNED2_4(a,b) (((PTR_LINEAR(a) | PTR_LINEAR(b)) & 3) == 0)
2231 #define PTR_ALIGNED2_8(a,b) (((PTR_LINEAR(a) | PTR_LINEAR(b)) & 7) == 0)
2234 #define PTR_LT(a,b) (PTR(a) < PTR(b))
2235 #define PTR_GE(a,b) (PTR(a) >= PTR(b))
2236 #define PTR_DIFF(a,b) (PTR(a) - PTR(b))
2237 #define pd(a,b) ((lzo_uint) ((a)-(b)))
2239 LZO_EXTERN(lzo_uintptr_t
)
2240 __lzo_ptr_linear(const lzo_voidp ptr
);
2245 unsigned char a_uchar
;
2247 unsigned short a_ushort
;
2249 unsigned int a_uint
;
2251 unsigned long a_ulong
;
2253 lzo_uint a_lzo_uint
;
2254 lzo_int32 a_lzo_int32
;
2255 lzo_uint32 a_lzo_uint32
;
2256 #if defined(LZO_UINT64_MAX)
2257 lzo_int64 a_lzo_int64
;
2258 lzo_uint64 a_lzo_uint64
;
2260 ptrdiff_t a_ptrdiff_t
;
2261 lzo_uintptr_t a_lzo_uintptr_t
;
2262 lzo_voidp a_lzo_voidp
;
2264 lzo_bytep a_lzo_bytep
;
2265 lzo_bytepp a_lzo_bytepp
;
2266 lzo_uintp a_lzo_uintp
;
2267 lzo_uint
* a_lzo_uint_p
;
2268 lzo_uint32p a_lzo_uint32p
;
2269 lzo_uint32
* a_lzo_uint32_p
;
2270 unsigned char * a_uchar_p
;
2281 #ifndef LZO_DETERMINISTIC
2282 #define LZO_DETERMINISTIC 1
2285 #ifndef LZO_DICT_USE_PTR
2286 #define LZO_DICT_USE_PTR 1
2287 #if 0 && (LZO_ARCH_I086)
2288 # undef LZO_DICT_USE_PTR
2289 # define LZO_DICT_USE_PTR 0
2293 #if (LZO_DICT_USE_PTR)
2294 # define lzo_dict_t const lzo_bytep
2295 # define lzo_dict_p lzo_dict_t __LZO_MMODEL *
2297 # define lzo_dict_t lzo_uint
2298 # define lzo_dict_p lzo_dict_t __LZO_MMODEL *
2303 #if !defined(MINILZO_CFG_SKIP_LZO_PTR)
2305 LZO_PUBLIC(lzo_uintptr_t
)
2306 __lzo_ptr_linear(const lzo_voidp ptr
)
2311 p
= (((lzo_uintptr_t
)(ACC_PTR_FP_SEG(ptr
))) << (16 - ACC_MM_AHSHIFT
)) + (ACC_PTR_FP_OFF(ptr
));
2313 p
= (lzo_uintptr_t
) (ptr
);
2314 p
= (p
<< 3) | (p
>> 61);
2316 p
= (lzo_uintptr_t
) PTR_LINEAR(ptr
);
2322 LZO_PUBLIC(unsigned)
2323 __lzo_align_gap(const lzo_voidp ptr
, lzo_uint size
)
2325 #if defined(__LZO_UINTPTR_T_IS_POINTER)
2326 size_t n
= (size_t) ptr
;
2327 n
= (((n
+ size
- 1) / size
) * size
) - n
;
2330 p
= __lzo_ptr_linear(ptr
);
2331 n
= (((p
+ size
- 1) / size
) * size
) - p
;
2335 assert((long)n
>= 0);
2341 #if !defined(MINILZO_CFG_SKIP_LZO_UTIL)
2343 /* If you use the LZO library in a product, I would appreciate that you
2344 * keep this copyright string in the executable of your product.
2347 static const char __lzo_copyright
[] =
2348 #if !defined(__LZO_IN_MINLZO)
2352 "LZO data compression library.\n"
2353 "$Copyright: LZO Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer\n"
2354 "<markus@oberhumer.com>\n"
2355 "http://www.oberhumer.com $\n\n"
2356 "$Id: LZO version: v" LZO_VERSION_STRING
", " LZO_VERSION_DATE
" $\n"
2357 "$Info: " LZO_INFO_STRING
" $\n";
2360 LZO_PUBLIC(const lzo_bytep
)
2363 #if (LZO_OS_DOS16 && LZO_CC_TURBOC)
2364 return (lzo_voidp
) __lzo_copyright
;
2366 return (const lzo_bytep
) __lzo_copyright
;
2370 LZO_PUBLIC(unsigned)
2376 LZO_PUBLIC(const char *)
2377 lzo_version_string(void)
2379 return LZO_VERSION_STRING
;
2382 LZO_PUBLIC(const char *)
2383 lzo_version_date(void)
2385 return LZO_VERSION_DATE
;
2388 LZO_PUBLIC(const lzo_charp
)
2389 _lzo_version_string(void)
2391 return LZO_VERSION_STRING
;
2394 LZO_PUBLIC(const lzo_charp
)
2395 _lzo_version_date(void)
2397 return LZO_VERSION_DATE
;
2400 #define LZO_BASE 65521u
2401 #define LZO_NMAX 5552
2403 #define LZO_DO1(buf,i) s1 += buf[i]; s2 += s1
2404 #define LZO_DO2(buf,i) LZO_DO1(buf,i); LZO_DO1(buf,i+1);
2405 #define LZO_DO4(buf,i) LZO_DO2(buf,i); LZO_DO2(buf,i+2);
2406 #define LZO_DO8(buf,i) LZO_DO4(buf,i); LZO_DO4(buf,i+4);
2407 #define LZO_DO16(buf,i) LZO_DO8(buf,i); LZO_DO8(buf,i+8);
2409 LZO_PUBLIC(lzo_uint32
)
2410 lzo_adler32(lzo_uint32 adler
, const lzo_bytep buf
, lzo_uint len
)
2412 lzo_uint32 s1
= adler
& 0xffff;
2413 lzo_uint32 s2
= (adler
>> 16) & 0xffff;
2421 k
= len
< LZO_NMAX
? (unsigned) len
: LZO_NMAX
;
2437 return (s2
<< 16) | s1
;
2447 #if !defined(MINILZO_CFG_SKIP_LZO_STRING)
2452 #if !defined(__LZO_MMODEL_HUGE)
2453 # undef LZO_HAVE_MM_HUGE_PTR
2455 #define lzo_hsize_t lzo_uint
2456 #define lzo_hvoid_p lzo_voidp
2457 #define lzo_hbyte_p lzo_bytep
2458 #define LZOLIB_PUBLIC(r,f) LZO_PUBLIC(r) f
2459 #define lzo_hmemcmp lzo_memcmp
2460 #define lzo_hmemcpy lzo_memcpy
2461 #define lzo_hmemmove lzo_memmove
2462 #define lzo_hmemset lzo_memset
2463 #define __LZOLIB_HMEMCPY_CH_INCLUDED 1
2464 #if !defined(LZOLIB_PUBLIC)
2465 # define LZOLIB_PUBLIC(r,f) r __LZOLIB_FUNCNAME(f)
2467 LZOLIB_PUBLIC(int, lzo_hmemcmp
) (const lzo_hvoid_p s1
, const lzo_hvoid_p s2
, lzo_hsize_t len
)
2469 #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMCMP)
2470 const lzo_hbyte_p p1
= (const lzo_hbyte_p
) s1
;
2471 const lzo_hbyte_p p2
= (const lzo_hbyte_p
) s2
;
2472 if __lzo_likely(len
> 0) do
2478 } while __lzo_likely(--len
> 0);
2481 return memcmp(s1
, s2
, len
);
2484 LZOLIB_PUBLIC(lzo_hvoid_p
, lzo_hmemcpy
) (lzo_hvoid_p dest
, const lzo_hvoid_p src
, lzo_hsize_t len
)
2486 #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMCPY)
2487 lzo_hbyte_p p1
= (lzo_hbyte_p
) dest
;
2488 const lzo_hbyte_p p2
= (const lzo_hbyte_p
) src
;
2489 if (!(len
> 0) || p1
== p2
)
2493 while __lzo_likely(--len
> 0);
2496 return memcpy(dest
, src
, len
);
2499 LZOLIB_PUBLIC(lzo_hvoid_p
, lzo_hmemmove
) (lzo_hvoid_p dest
, const lzo_hvoid_p src
, lzo_hsize_t len
)
2501 #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMMOVE)
2502 lzo_hbyte_p p1
= (lzo_hbyte_p
) dest
;
2503 const lzo_hbyte_p p2
= (const lzo_hbyte_p
) src
;
2504 if (!(len
> 0) || p1
== p2
)
2510 while __lzo_likely(--len
> 0);
2518 while __lzo_likely(--len
> 0);
2522 return memmove(dest
, src
, len
);
2525 LZOLIB_PUBLIC(lzo_hvoid_p
, lzo_hmemset
) (lzo_hvoid_p s
, int c
, lzo_hsize_t len
)
2527 #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMSET)
2528 lzo_hbyte_p p
= (lzo_hbyte_p
) s
;
2529 if __lzo_likely(len
> 0) do
2530 *p
++ = (unsigned char) c
;
2531 while __lzo_likely(--len
> 0);
2534 return memset(s
, c
, len
);
2537 #undef LZOLIB_PUBLIC
2539 #if !defined(MINILZO_CFG_SKIP_LZO_INIT)
2541 #if !defined(__LZO_IN_MINILZO)
2543 #define ACC_WANT_ACC_CHK_CH 1
2544 #undef ACCCHK_ASSERT
2546 ACCCHK_ASSERT_IS_SIGNED_T(lzo_int
)
2547 ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uint
)
2549 ACCCHK_ASSERT_IS_SIGNED_T(lzo_int32
)
2550 ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uint32
)
2551 ACCCHK_ASSERT((LZO_UINT32_C(1) << (int)(8*sizeof(LZO_UINT32_C(1))-1)) > 0)
2552 ACCCHK_ASSERT(sizeof(lzo_uint32
) >= 4)
2553 #if defined(LZO_UINT64_MAX)
2554 ACCCHK_ASSERT(sizeof(lzo_uint64
) == 8)
2555 ACCCHK_ASSERT_IS_SIGNED_T(lzo_int64
)
2556 ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uint64
)
2559 #if !defined(__LZO_UINTPTR_T_IS_POINTER)
2560 ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uintptr_t
)
2562 ACCCHK_ASSERT(sizeof(lzo_uintptr_t
) >= sizeof(lzo_voidp
))
2564 ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_xint
)
2565 ACCCHK_ASSERT(sizeof(lzo_xint
) >= sizeof(lzo_uint32
))
2566 ACCCHK_ASSERT(sizeof(lzo_xint
) >= sizeof(lzo_uint
))
2567 ACCCHK_ASSERT(sizeof(lzo_xint
) == sizeof(lzo_uint32
) || sizeof(lzo_xint
) == sizeof(lzo_uint
))
2570 #undef ACCCHK_ASSERT
2572 #define WANT_lzo_bitops_clz32 1
2573 #define WANT_lzo_bitops_clz64 1
2574 #define WANT_lzo_bitops_ctz32 1
2575 #define WANT_lzo_bitops_ctz64 1
2577 #if (defined(_WIN32) || defined(_WIN64)) && ((LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || (LZO_CC_MSC && (_MSC_VER >= 1400)))
2579 #if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32) && 0
2580 #pragma intrinsic(_BitScanReverse)
2581 static __lzo_inline
unsigned lzo_bitops_clz32(lzo_uint32 v
)
2584 (void) _BitScanReverse(&r
, v
);
2585 return (unsigned) r
;
2587 #define lzo_bitops_clz32 lzo_bitops_clz32
2589 #if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX) && 0
2590 #pragma intrinsic(_BitScanReverse64)
2591 static __lzo_inline
unsigned lzo_bitops_clz64(lzo_uint64 v
)
2594 (void) _BitScanReverse64(&r
, v
);
2595 return (unsigned) r
;
2597 #define lzo_bitops_clz64 lzo_bitops_clz64
2599 #if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32)
2600 #pragma intrinsic(_BitScanForward)
2601 static __lzo_inline
unsigned lzo_bitops_ctz32(lzo_uint32 v
)
2604 (void) _BitScanForward(&r
, v
);
2605 return (unsigned) r
;
2607 #define lzo_bitops_ctz32 lzo_bitops_ctz32
2609 #if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX)
2610 #pragma intrinsic(_BitScanForward64)
2611 static __lzo_inline
unsigned lzo_bitops_ctz64(lzo_uint64 v
)
2614 (void) _BitScanForward64(&r
, v
);
2615 return (unsigned) r
;
2617 #define lzo_bitops_ctz64 lzo_bitops_ctz64
2620 #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))))
2621 #if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32)
2622 #define lzo_bitops_clz32(v) ((unsigned) __builtin_clz(v))
2624 #if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX)
2625 #define lzo_bitops_clz64(v) ((unsigned) __builtin_clzll(v))
2627 #if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32)
2628 #define lzo_bitops_ctz32(v) ((unsigned) __builtin_ctz(v))
2630 #if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX)
2631 #define lzo_bitops_ctz64(v) ((unsigned) __builtin_ctzll(v))
2633 #if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount32)
2634 #define lzo_bitops_popcount32(v) ((unsigned) __builtin_popcount(v))
2636 #if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount64) && defined(LZO_UINT64_MAX)
2637 #define lzo_bitops_popcount64(v) ((unsigned) __builtin_popcountll(v))
2642 #define u2p(ptr,off) ((lzo_voidp) (((lzo_bytep)(lzo_voidp)(ptr)) + (off)))
2644 static __lzo_noinline lzo_voidp
u2p(lzo_voidp ptr
, lzo_uint off
)
2646 return (lzo_voidp
) ((lzo_bytep
) ptr
+ off
);
2651 _lzo_config_check(void)
2655 lzo_xint a
[2]; unsigned char b
[2*LZO_MAX(8,sizeof(lzo_xint
))];
2656 #if defined(LZO_UNALIGNED_OK_8)
2659 unsigned short x
[2]; lzo_uint32 y
[2]; lzo_uint z
[2];
2663 u
.a
[0] = u
.a
[1] = 0;
2665 r
&= ((* (lzo_bytep
) p
) == 0);
2666 #if !defined(LZO_CFG_NO_CONFIG_CHECK)
2667 #if defined(LZO_ABI_BIG_ENDIAN)
2668 u
.a
[0] = u
.a
[1] = 0; u
.b
[sizeof(lzo_uint
) - 1] = 128;
2670 r
&= ((* (lzo_uintp
) p
) == 128);
2672 #if defined(LZO_ABI_LITTLE_ENDIAN)
2673 u
.a
[0] = u
.a
[1] = 0; u
.b
[0] = 128;
2675 r
&= ((* (lzo_uintp
) p
) == 128);
2677 #if defined(LZO_UNALIGNED_OK_2)
2678 u
.a
[0] = u
.a
[1] = 0;
2679 u
.b
[0] = 1; u
.b
[sizeof(unsigned short) + 1] = 2;
2681 r
&= ((* (lzo_ushortp
) p
) == 0);
2683 #if defined(LZO_UNALIGNED_OK_4)
2684 u
.a
[0] = u
.a
[1] = 0;
2685 u
.b
[0] = 3; u
.b
[sizeof(lzo_uint32
) + 1] = 4;
2687 r
&= ((* (lzo_uint32p
) p
) == 0);
2689 #if defined(LZO_UNALIGNED_OK_8)
2690 u
.c
[0] = u
.c
[1] = 0;
2691 u
.b
[0] = 5; u
.b
[sizeof(lzo_uint64
) + 1] = 6;
2693 r
&= ((* (lzo_uint64p
) p
) == 0);
2695 #if defined(lzo_bitops_clz32)
2696 { unsigned i
; lzo_uint32 v
= 1;
2697 for (i
= 0; i
< 32; i
++, v
<<= 1)
2698 r
&= lzo_bitops_clz32(v
) == 31 - i
;
2701 #if defined(lzo_bitops_clz64)
2702 { unsigned i
; lzo_uint64 v
= 1;
2703 for (i
= 0; i
< 64; i
++, v
<<= 1)
2704 r
&= lzo_bitops_clz64(v
) == 63 - i
;
2707 #if defined(lzo_bitops_ctz32)
2708 { unsigned i
; lzo_uint32 v
= 1;
2709 for (i
= 0; i
< 32; i
++, v
<<= 1)
2710 r
&= lzo_bitops_ctz32(v
) == i
;
2713 #if defined(lzo_bitops_ctz64)
2714 { unsigned i
; lzo_uint64 v
= 1;
2715 for (i
= 0; i
< 64; i
++, v
<<= 1)
2716 r
&= lzo_bitops_ctz64(v
) == i
;
2721 return r
== 1 ? LZO_E_OK
: LZO_E_ERROR
;
2725 __lzo_init_v2(unsigned v
, int s1
, int s2
, int s3
, int s4
, int s5
,
2726 int s6
, int s7
, int s8
, int s9
)
2730 #if defined(__LZO_IN_MINILZO)
2731 #elif (LZO_CC_MSC && ((_MSC_VER) < 700))
2733 #define ACC_WANT_ACC_CHK_CH 1
2734 #undef ACCCHK_ASSERT
2735 #define ACCCHK_ASSERT(expr) LZO_COMPILE_TIME_ASSERT(expr)
2737 #undef ACCCHK_ASSERT
2742 r
= (s1
== -1 || s1
== (int) sizeof(short)) &&
2743 (s2
== -1 || s2
== (int) sizeof(int)) &&
2744 (s3
== -1 || s3
== (int) sizeof(long)) &&
2745 (s4
== -1 || s4
== (int) sizeof(lzo_uint32
)) &&
2746 (s5
== -1 || s5
== (int) sizeof(lzo_uint
)) &&
2747 (s6
== -1 || s6
== (int) lzo_sizeof_dict_t
) &&
2748 (s7
== -1 || s7
== (int) sizeof(char *)) &&
2749 (s8
== -1 || s8
== (int) sizeof(lzo_voidp
)) &&
2750 (s9
== -1 || s9
== (int) sizeof(lzo_callback_t
));
2754 r
= _lzo_config_check();
2761 #if !defined(__LZO_IN_MINILZO)
2763 #if (LZO_OS_WIN16 && LZO_CC_WATCOMC) && defined(__SW_BD)
2766 BOOL FAR PASCAL
LibMain ( HANDLE hInstance
, WORD wDataSegment
,
2767 WORD wHeapSize
, LPSTR lpszCmdLine
)
2769 int __far __pascal
LibMain ( int a
, short b
, short c
, long d
)
2772 LZO_UNUSED(a
); LZO_UNUSED(b
); LZO_UNUSED(c
); LZO_UNUSED(d
);
2783 #define LZO_EOF_CODE 1
2784 #define M2_MAX_OFFSET 0x0800
2786 #if !defined(MINILZO_CFG_SKIP_LZO1X_1_COMPRESS)
2788 #if 1 && defined(UA_GET32)
2789 #undef LZO_DICT_USE_PTR
2790 #define LZO_DICT_USE_PTR 0
2792 #define lzo_dict_t unsigned short
2795 #define LZO_NEED_DICT_H 1
2799 #define D_INDEX1(d,p) d = DM(DMUL(0x21,DX3(p,5,5,6)) >> 5)
2800 #define D_INDEX2(d,p) d = (d & (D_MASK & 0x7ff)) ^ (D_HIGH | 0x1f)
2802 #define DINDEX(dv,p) DM(((DMUL(0x1824429d,dv)) >> (32-D_BITS)))
2804 #define DINDEX(dv,p) DM((dv) + ((dv) >> (32-D_BITS)))
2807 #ifndef __LZO_CONFIG1X_H
2808 #define __LZO_CONFIG1X_H 1
2810 #if !defined(LZO1X) && !defined(LZO1Y) && !defined(LZO1Z)
2814 #if !defined(__LZO_IN_MINILZO)
2815 #include "lzo/lzo1x.h"
2818 #ifndef LZO_EOF_CODE
2819 #define LZO_EOF_CODE 1
2821 #undef LZO_DETERMINISTIC
2823 #define M1_MAX_OFFSET 0x0400
2824 #ifndef M2_MAX_OFFSET
2825 #define M2_MAX_OFFSET 0x0800
2827 #define M3_MAX_OFFSET 0x4000
2828 #define M4_MAX_OFFSET 0xbfff
2830 #define MX_MAX_OFFSET (M1_MAX_OFFSET + M2_MAX_OFFSET)
2832 #define M1_MIN_LEN 2
2833 #define M1_MAX_LEN 2
2834 #define M2_MIN_LEN 3
2836 #define M2_MAX_LEN 8
2838 #define M3_MIN_LEN 3
2839 #define M3_MAX_LEN 33
2840 #define M4_MIN_LEN 3
2841 #define M4_MAX_LEN 9
2844 #define M2_MARKER 64
2845 #define M3_MARKER 32
2846 #define M4_MARKER 16
2848 #ifndef MIN_LOOKAHEAD
2849 #define MIN_LOOKAHEAD (M2_MAX_LEN + 1)
2852 #if defined(LZO_NEED_DICT_H)
2855 #define LZO_HASH LZO_HASH_LZO_INCREMENTAL_B
2857 #define DL_MIN_LEN M2_MIN_LEN
2859 #ifndef __LZO_DICT_H
2860 #define __LZO_DICT_H 1
2866 #if !defined(D_BITS) && defined(DBITS)
2867 # define D_BITS DBITS
2869 #if !defined(D_BITS)
2870 # error "D_BITS is not defined"
2873 # define D_SIZE LZO_SIZE(D_BITS)
2874 # define D_MASK LZO_MASK(D_BITS)
2876 # define D_SIZE LZO_USIZE(D_BITS)
2877 # define D_MASK LZO_UMASK(D_BITS)
2879 #define D_HIGH ((D_MASK >> 1) + 1)
2881 #if !defined(DD_BITS)
2884 #define DD_SIZE LZO_SIZE(DD_BITS)
2885 #define DD_MASK LZO_MASK(DD_BITS)
2887 #if !defined(DL_BITS)
2888 # define DL_BITS (D_BITS - DD_BITS)
2891 # define DL_SIZE LZO_SIZE(DL_BITS)
2892 # define DL_MASK LZO_MASK(DL_BITS)
2894 # define DL_SIZE LZO_USIZE(DL_BITS)
2895 # define DL_MASK LZO_UMASK(DL_BITS)
2898 #if (D_BITS != DL_BITS + DD_BITS)
2899 # error "D_BITS does not match"
2901 #if (D_BITS < 6 || D_BITS > 18)
2902 # error "invalid D_BITS"
2904 #if (DL_BITS < 6 || DL_BITS > 20)
2905 # error "invalid DL_BITS"
2907 #if (DD_BITS < 0 || DD_BITS > 6)
2908 # error "invalid DD_BITS"
2911 #if !defined(DL_MIN_LEN)
2912 # define DL_MIN_LEN 3
2914 #if !defined(DL_SHIFT)
2915 # define DL_SHIFT ((DL_BITS + (DL_MIN_LEN - 1)) / DL_MIN_LEN)
2918 #define LZO_HASH_GZIP 1
2919 #define LZO_HASH_GZIP_INCREMENTAL 2
2920 #define LZO_HASH_LZO_INCREMENTAL_A 3
2921 #define LZO_HASH_LZO_INCREMENTAL_B 4
2923 #if !defined(LZO_HASH)
2924 # error "choose a hashing strategy"
2930 #if (DL_MIN_LEN == 3)
2931 # define _DV2_A(p,shift1,shift2) \
2932 (((( (lzo_xint)((p)[0]) << shift1) ^ (p)[1]) << shift2) ^ (p)[2])
2933 # define _DV2_B(p,shift1,shift2) \
2934 (((( (lzo_xint)((p)[2]) << shift1) ^ (p)[1]) << shift2) ^ (p)[0])
2935 # define _DV3_B(p,shift1,shift2,shift3) \
2936 ((_DV2_B((p)+1,shift1,shift2) << (shift3)) ^ (p)[0])
2937 #elif (DL_MIN_LEN == 2)
2938 # define _DV2_A(p,shift1,shift2) \
2939 (( (lzo_xint)(p[0]) << shift1) ^ p[1])
2940 # define _DV2_B(p,shift1,shift2) \
2941 (( (lzo_xint)(p[1]) << shift1) ^ p[2])
2943 # error "invalid DL_MIN_LEN"
2945 #define _DV_A(p,shift) _DV2_A(p,shift,shift)
2946 #define _DV_B(p,shift) _DV2_B(p,shift,shift)
2947 #define DA2(p,s1,s2) \
2948 (((((lzo_xint)((p)[2]) << (s2)) + (p)[1]) << (s1)) + (p)[0])
2949 #define DS2(p,s1,s2) \
2950 (((((lzo_xint)((p)[2]) << (s2)) - (p)[1]) << (s1)) - (p)[0])
2951 #define DX2(p,s1,s2) \
2952 (((((lzo_xint)((p)[2]) << (s2)) ^ (p)[1]) << (s1)) ^ (p)[0])
2953 #define DA3(p,s1,s2,s3) ((DA2((p)+1,s2,s3) << (s1)) + (p)[0])
2954 #define DS3(p,s1,s2,s3) ((DS2((p)+1,s2,s3) << (s1)) - (p)[0])
2955 #define DX3(p,s1,s2,s3) ((DX2((p)+1,s2,s3) << (s1)) ^ (p)[0])
2956 #define DMS(v,s) ((lzo_uint) (((v) & (D_MASK >> (s))) << (s)))
2957 #define DM(v) DMS(v,0)
2959 #if (LZO_HASH == LZO_HASH_GZIP)
2960 # define _DINDEX(dv,p) (_DV_A((p),DL_SHIFT))
2962 #elif (LZO_HASH == LZO_HASH_GZIP_INCREMENTAL)
2963 # define __LZO_HASH_INCREMENTAL 1
2964 # define DVAL_FIRST(dv,p) dv = _DV_A((p),DL_SHIFT)
2965 # define DVAL_NEXT(dv,p) dv = (((dv) << DL_SHIFT) ^ p[2])
2966 # define _DINDEX(dv,p) (dv)
2967 # define DVAL_LOOKAHEAD DL_MIN_LEN
2969 #elif (LZO_HASH == LZO_HASH_LZO_INCREMENTAL_A)
2970 # define __LZO_HASH_INCREMENTAL 1
2971 # define DVAL_FIRST(dv,p) dv = _DV_A((p),5)
2972 # define DVAL_NEXT(dv,p) \
2973 dv ^= (lzo_xint)(p[-1]) << (2*5); dv = (((dv) << 5) ^ p[2])
2974 # define _DINDEX(dv,p) ((DMUL(0x9f5f,dv)) >> 5)
2975 # define DVAL_LOOKAHEAD DL_MIN_LEN
2977 #elif (LZO_HASH == LZO_HASH_LZO_INCREMENTAL_B)
2978 # define __LZO_HASH_INCREMENTAL 1
2979 # define DVAL_FIRST(dv,p) dv = _DV_B((p),5)
2980 # define DVAL_NEXT(dv,p) \
2981 dv ^= p[-1]; dv = (((dv) >> 5) ^ ((lzo_xint)(p[2]) << (2*5)))
2982 # define _DINDEX(dv,p) ((DMUL(0x9f5f,dv)) >> 5)
2983 # define DVAL_LOOKAHEAD DL_MIN_LEN
2986 # error "choose a hashing strategy"
2990 #define DINDEX(dv,p) ((lzo_uint)((_DINDEX(dv,p)) & DL_MASK) << DD_BITS)
2992 #if !defined(DINDEX1) && defined(D_INDEX1)
2993 #define DINDEX1 D_INDEX1
2995 #if !defined(DINDEX2) && defined(D_INDEX2)
2996 #define DINDEX2 D_INDEX2
2999 #if !defined(__LZO_HASH_INCREMENTAL)
3000 # define DVAL_FIRST(dv,p) ((void) 0)
3001 # define DVAL_NEXT(dv,p) ((void) 0)
3002 # define DVAL_LOOKAHEAD 0
3005 #if !defined(DVAL_ASSERT)
3006 #if defined(__LZO_HASH_INCREMENTAL) && !defined(NDEBUG)
3007 #if (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x020700ul) || LZO_CC_LLVM)
3008 static void __attribute__((__unused__
))
3012 DVAL_ASSERT(lzo_xint dv
, const lzo_bytep p
)
3016 assert(DINDEX(dv
,p
) == DINDEX(df
,p
));
3019 # define DVAL_ASSERT(dv,p) ((void) 0)
3023 #if (LZO_DICT_USE_PTR)
3024 # define DENTRY(p,in) (p)
3025 # define GINDEX(m_pos,m_off,dict,dindex,in) m_pos = dict[dindex]
3027 # define DENTRY(p,in) ((lzo_dict_t) pd(p, in))
3028 # define GINDEX(m_pos,m_off,dict,dindex,in) m_off = dict[dindex]
3033 # define UPDATE_D(dict,drun,dv,p,in) dict[ DINDEX(dv,p) ] = DENTRY(p,in)
3034 # define UPDATE_I(dict,drun,index,p,in) dict[index] = DENTRY(p,in)
3035 # define UPDATE_P(ptr,drun,p,in) (ptr)[0] = DENTRY(p,in)
3039 # define UPDATE_D(dict,drun,dv,p,in) \
3040 dict[ DINDEX(dv,p) + drun++ ] = DENTRY(p,in); drun &= DD_MASK
3041 # define UPDATE_I(dict,drun,index,p,in) \
3042 dict[ (index) + drun++ ] = DENTRY(p,in); drun &= DD_MASK
3043 # define UPDATE_P(ptr,drun,p,in) \
3044 (ptr) [ drun++ ] = DENTRY(p,in); drun &= DD_MASK
3048 #if (LZO_DICT_USE_PTR)
3050 #define LZO_CHECK_MPOS_DET(m_pos,m_off,in,ip,max_offset) \
3051 (m_pos == NULL || (m_off = pd(ip, m_pos)) > max_offset)
3053 #define LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,max_offset) \
3054 (BOUNDS_CHECKING_OFF_IN_EXPR(( \
3055 m_pos = ip - (lzo_uint) PTR_DIFF(ip,m_pos), \
3056 PTR_LT(m_pos,in) || \
3057 (m_off = (lzo_uint) PTR_DIFF(ip,m_pos)) == 0 || \
3058 m_off > max_offset )))
3062 #define LZO_CHECK_MPOS_DET(m_pos,m_off,in,ip,max_offset) \
3064 ((m_off = pd(ip, in) - m_off) > max_offset) || \
3065 (m_pos = (ip) - (m_off), 0) )
3067 #define LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,max_offset) \
3068 (pd(ip, in) <= m_off || \
3069 ((m_off = pd(ip, in) - m_off) > max_offset) || \
3070 (m_pos = (ip) - (m_off), 0) )
3074 #if (LZO_DETERMINISTIC)
3075 # define LZO_CHECK_MPOS LZO_CHECK_MPOS_DET
3077 # define LZO_CHECK_MPOS LZO_CHECK_MPOS_NON_DET
3090 #define LZO_DETERMINISTIC !(LZO_DICT_USE_PTR)
3093 #define DO_COMPRESS lzo1x_1_compress
3096 #if 1 && defined(DO_COMPRESS) && !defined(do_compress)
3097 # define do_compress LZO_CPP_ECONCAT2(DO_COMPRESS,_core)
3100 #if defined(UA_GET64) && (LZO_ABI_BIG_ENDIAN)
3101 # define WANT_lzo_bitops_clz64 1
3102 #elif defined(UA_GET64) && (LZO_ABI_LITTLE_ENDIAN)
3103 # define WANT_lzo_bitops_ctz64 1
3104 #elif defined(UA_GET32) && (LZO_ABI_BIG_ENDIAN)
3105 # define WANT_lzo_bitops_clz32 1
3106 #elif defined(UA_GET32) && (LZO_ABI_LITTLE_ENDIAN)
3107 # define WANT_lzo_bitops_ctz32 1
3110 #if (defined(_WIN32) || defined(_WIN64)) && ((LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || (LZO_CC_MSC && (_MSC_VER >= 1400)))
3112 #if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32) && 0
3113 #pragma intrinsic(_BitScanReverse)
3114 static __lzo_inline
unsigned lzo_bitops_clz32(lzo_uint32 v
)
3117 (void) _BitScanReverse(&r
, v
);
3118 return (unsigned) r
;
3120 #define lzo_bitops_clz32 lzo_bitops_clz32
3122 #if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX) && 0
3123 #pragma intrinsic(_BitScanReverse64)
3124 static __lzo_inline
unsigned lzo_bitops_clz64(lzo_uint64 v
)
3127 (void) _BitScanReverse64(&r
, v
);
3128 return (unsigned) r
;
3130 #define lzo_bitops_clz64 lzo_bitops_clz64
3132 #if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32)
3133 #pragma intrinsic(_BitScanForward)
3134 static __lzo_inline
unsigned lzo_bitops_ctz32(lzo_uint32 v
)
3137 (void) _BitScanForward(&r
, v
);
3138 return (unsigned) r
;
3140 #define lzo_bitops_ctz32 lzo_bitops_ctz32
3142 #if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX)
3143 #pragma intrinsic(_BitScanForward64)
3144 static __lzo_inline
unsigned lzo_bitops_ctz64(lzo_uint64 v
)
3147 (void) _BitScanForward64(&r
, v
);
3148 return (unsigned) r
;
3150 #define lzo_bitops_ctz64 lzo_bitops_ctz64
3153 #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))))
3154 #if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32)
3155 #define lzo_bitops_clz32(v) ((unsigned) __builtin_clz(v))
3157 #if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX)
3158 #define lzo_bitops_clz64(v) ((unsigned) __builtin_clzll(v))
3160 #if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32)
3161 #define lzo_bitops_ctz32(v) ((unsigned) __builtin_ctz(v))
3163 #if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX)
3164 #define lzo_bitops_ctz64(v) ((unsigned) __builtin_ctzll(v))
3166 #if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount32)
3167 #define lzo_bitops_popcount32(v) ((unsigned) __builtin_popcount(v))
3169 #if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount64) && defined(LZO_UINT64_MAX)
3170 #define lzo_bitops_popcount64(v) ((unsigned) __builtin_popcountll(v))
3174 static __lzo_noinline lzo_uint
3175 do_compress ( const lzo_bytep in
, lzo_uint in_len
,
3176 lzo_bytep out
, lzo_uintp out_len
,
3177 lzo_uint ti
, lzo_voidp wrkmem
)
3179 register const lzo_bytep ip
;
3181 const lzo_bytep
const in_end
= in
+ in_len
;
3182 const lzo_bytep
const ip_end
= in
+ in_len
- 20;
3184 lzo_dict_p
const dict
= (lzo_dict_p
) wrkmem
;
3190 ip
+= ti
< 4 ? 4 - ti
: 0;
3193 const lzo_bytep m_pos
;
3194 #if !(LZO_DETERMINISTIC)
3195 LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint
, m_off
, 0);
3199 if __lzo_unlikely(ip
>= ip_end
)
3202 GINDEX(m_pos
,m_off
,dict
,dindex
,in
);
3203 if (LZO_CHECK_MPOS_NON_DET(m_pos
,m_off
,in
,ip
,M4_MAX_OFFSET
))
3206 if (m_off
<= M2_MAX_OFFSET
|| m_pos
[3] == ip
[3])
3210 GINDEX(m_pos
,m_off
,dict
,dindex
,in
);
3211 if (LZO_CHECK_MPOS_NON_DET(m_pos
,m_off
,in
,ip
,M4_MAX_OFFSET
))
3213 if (m_off
<= M2_MAX_OFFSET
|| m_pos
[3] == ip
[3])
3218 #if defined(UA_GET32)
3219 if (UA_GET32(m_pos
) != UA_GET32(ip
))
3221 if (m_pos
[0] != ip
[0] || m_pos
[1] != ip
[1] || m_pos
[2] != ip
[2] || m_pos
[3] != ip
[3])
3225 UPDATE_I(dict
,0,dindex
,ip
,in
);
3226 ip
+= 1 + ((ip
- ii
) >> 5);
3229 UPDATE_I(dict
,0,dindex
,ip
,in
);
3237 ip
+= 1 + ((ip
- ii
) >> 5);
3239 if __lzo_unlikely(ip
>= ip_end
)
3242 dindex
= DINDEX(dv
,ip
);
3243 GINDEX(m_off
,m_pos
,in
+dict
,dindex
,in
);
3244 UPDATE_I(dict
,0,dindex
,ip
,in
);
3245 if __lzo_unlikely(dv
!= UA_GET32(m_pos
))
3252 register lzo_uint t
= pd(ip
,ii
);
3257 op
[-2] |= LZO_BYTE(t
);
3258 #if defined(UA_COPY32)
3262 { do *op
++ = *ii
++; while (--t
> 0); }
3265 #if defined(UA_COPY32) || defined(UA_COPY64)
3268 *op
++ = LZO_BYTE(t
- 3);
3269 #if defined(UA_COPY64)
3271 UA_COPY64(op
+8, ii
+8);
3274 UA_COPY32(op
+4, ii
+4);
3275 UA_COPY32(op
+8, ii
+8);
3276 UA_COPY32(op
+12, ii
+12);
3284 *op
++ = LZO_BYTE(t
- 3);
3287 register lzo_uint tt
= t
- 18;
3289 while __lzo_unlikely(tt
> 255)
3292 #if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400))
3293 * (volatile unsigned char *) op
++ = 0;
3299 *op
++ = LZO_BYTE(tt
);
3301 #if defined(UA_COPY32) || defined(UA_COPY64)
3303 #if defined(UA_COPY64)
3305 UA_COPY64(op
+8, ii
+8);
3308 UA_COPY32(op
+4, ii
+4);
3309 UA_COPY32(op
+8, ii
+8);
3310 UA_COPY32(op
+12, ii
+12);
3312 op
+= 16; ii
+= 16; t
-= 16;
3313 } while (t
>= 16); if (t
> 0)
3315 { do *op
++ = *ii
++; while (--t
> 0); }
3321 #if defined(UA_GET64)
3323 v
= UA_GET64(ip
+ m_len
) ^ UA_GET64(m_pos
+ m_len
);
3324 if __lzo_unlikely(v
== 0) {
3327 v
= UA_GET64(ip
+ m_len
) ^ UA_GET64(m_pos
+ m_len
);
3328 if __lzo_unlikely(ip
+ m_len
>= ip_end
)
3332 #if (LZO_ABI_BIG_ENDIAN) && defined(lzo_bitops_clz64)
3333 m_len
+= lzo_bitops_clz64(v
) / CHAR_BIT
;
3334 #elif (LZO_ABI_BIG_ENDIAN)
3335 if ((v
>> (64 - CHAR_BIT
)) == 0) do {
3338 } while ((v
>> (64 - CHAR_BIT
)) == 0);
3339 #elif (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_ctz64)
3340 m_len
+= lzo_bitops_ctz64(v
) / CHAR_BIT
;
3341 #elif (LZO_ABI_LITTLE_ENDIAN)
3342 if ((v
& UCHAR_MAX
) == 0) do {
3345 } while ((v
& UCHAR_MAX
) == 0);
3347 if (ip
[m_len
] == m_pos
[m_len
]) do {
3349 } while (ip
[m_len
] == m_pos
[m_len
]);
3351 #elif defined(UA_GET32)
3353 v
= UA_GET32(ip
+ m_len
) ^ UA_GET32(m_pos
+ m_len
);
3354 if __lzo_unlikely(v
== 0) {
3357 v
= UA_GET32(ip
+ m_len
) ^ UA_GET32(m_pos
+ m_len
);
3358 if __lzo_unlikely(ip
+ m_len
>= ip_end
)
3362 #if (LZO_ABI_BIG_ENDIAN) && defined(lzo_bitops_clz32)
3363 m_len
+= lzo_bitops_clz32(v
) / CHAR_BIT
;
3364 #elif (LZO_ABI_BIG_ENDIAN)
3365 if ((v
>> (32 - CHAR_BIT
)) == 0) do {
3368 } while ((v
>> (32 - CHAR_BIT
)) == 0);
3369 #elif (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_ctz32)
3370 m_len
+= lzo_bitops_ctz32(v
) / CHAR_BIT
;
3371 #elif (LZO_ABI_LITTLE_ENDIAN)
3372 if ((v
& UCHAR_MAX
) == 0) do {
3375 } while ((v
& UCHAR_MAX
) == 0);
3377 if (ip
[m_len
] == m_pos
[m_len
]) do {
3379 } while (ip
[m_len
] == m_pos
[m_len
]);
3382 if __lzo_unlikely(ip
[m_len
] == m_pos
[m_len
]) {
3385 if __lzo_unlikely(ip
+ m_len
>= ip_end
)
3387 } while (ip
[m_len
] == m_pos
[m_len
]);
3392 m_off
= pd(ip
,m_pos
);
3395 if (m_len
<= M2_MAX_LEN
&& m_off
<= M2_MAX_OFFSET
)
3399 *op
++ = LZO_BYTE(((m_len
- 1) << 5) | ((m_off
& 7) << 2));
3400 *op
++ = LZO_BYTE(m_off
>> 3);
3401 #elif defined(LZO1Y)
3402 *op
++ = LZO_BYTE(((m_len
+ 1) << 4) | ((m_off
& 3) << 2));
3403 *op
++ = LZO_BYTE(m_off
>> 2);
3406 else if (m_off
<= M3_MAX_OFFSET
)
3409 if (m_len
<= M3_MAX_LEN
)
3410 *op
++ = LZO_BYTE(M3_MARKER
| (m_len
- 2));
3413 m_len
-= M3_MAX_LEN
;
3414 *op
++ = M3_MARKER
| 0;
3415 while __lzo_unlikely(m_len
> 255)
3418 #if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400))
3419 * (volatile unsigned char *) op
++ = 0;
3424 *op
++ = LZO_BYTE(m_len
);
3426 *op
++ = LZO_BYTE(m_off
<< 2);
3427 *op
++ = LZO_BYTE(m_off
>> 6);
3432 if (m_len
<= M4_MAX_LEN
)
3433 *op
++ = LZO_BYTE(M4_MARKER
| ((m_off
>> 11) & 8) | (m_len
- 2));
3436 m_len
-= M4_MAX_LEN
;
3437 *op
++ = LZO_BYTE(M4_MARKER
| ((m_off
>> 11) & 8));
3438 while __lzo_unlikely(m_len
> 255)
3441 #if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400))
3442 * (volatile unsigned char *) op
++ = 0;
3447 *op
++ = LZO_BYTE(m_len
);
3449 *op
++ = LZO_BYTE(m_off
<< 2);
3450 *op
++ = LZO_BYTE(m_off
>> 6);
3455 *out_len
= pd(op
, out
);
3456 return pd(in_end
,ii
-ti
);
3460 DO_COMPRESS ( const lzo_bytep in
, lzo_uint in_len
,
3461 lzo_bytep out
, lzo_uintp out_len
,
3464 const lzo_bytep ip
= in
;
3466 lzo_uint l
= in_len
;
3472 lzo_uintptr_t ll_end
;
3473 #if 0 || (LZO_DETERMINISTIC)
3474 ll
= LZO_MIN(ll
, 49152);
3476 ll_end
= (lzo_uintptr_t
)ip
+ ll
;
3477 if ((ll_end
+ ((t
+ ll
) >> 5)) <= ll_end
|| (const lzo_bytep
)(ll_end
+ ((t
+ ll
) >> 5)) <= ip
+ ll
)
3479 #if (LZO_DETERMINISTIC)
3480 lzo_memset(wrkmem
, 0, ((lzo_uint
)1 << D_BITS
) * sizeof(lzo_dict_t
));
3482 t
= do_compress(ip
,ll
,op
,out_len
,t
,wrkmem
);
3491 const lzo_bytep ii
= in
+ in_len
- t
;
3493 if (op
== out
&& t
<= 238)
3494 *op
++ = LZO_BYTE(17 + t
);
3496 op
[-2] |= LZO_BYTE(t
);
3498 *op
++ = LZO_BYTE(t
- 3);
3501 lzo_uint tt
= t
- 18;
3507 #if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400))
3509 * (volatile unsigned char *) op
++ = 0;
3515 *op
++ = LZO_BYTE(tt
);
3517 do *op
++ = *ii
++; while (--t
> 0);
3520 *op
++ = M4_MARKER
| 1;
3524 *out_len
= pd(op
, out
);
3534 #undef LZO_TEST_OVERRUN
3535 #undef DO_DECOMPRESS
3536 #define DO_DECOMPRESS lzo1x_decompress
3538 #if !defined(MINILZO_CFG_SKIP_LZO1X_DECOMPRESS)
3540 #if defined(LZO_TEST_OVERRUN)
3541 # if !defined(LZO_TEST_OVERRUN_INPUT)
3542 # define LZO_TEST_OVERRUN_INPUT 2
3544 # if !defined(LZO_TEST_OVERRUN_OUTPUT)
3545 # define LZO_TEST_OVERRUN_OUTPUT 2
3547 # if !defined(LZO_TEST_OVERRUN_LOOKBEHIND)
3548 # define LZO_TEST_OVERRUN_LOOKBEHIND 1
3565 #if defined(LZO_TEST_OVERRUN_INPUT)
3566 # if (LZO_TEST_OVERRUN_INPUT >= 1)
3567 # define TEST_IP (ip < ip_end)
3569 # if (LZO_TEST_OVERRUN_INPUT >= 2)
3570 # define NEED_IP(x) \
3571 if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x)) goto input_overrun
3575 #if defined(LZO_TEST_OVERRUN_OUTPUT)
3576 # if (LZO_TEST_OVERRUN_OUTPUT >= 1)
3577 # define TEST_OP (op <= op_end)
3579 # if (LZO_TEST_OVERRUN_OUTPUT >= 2)
3581 # define NEED_OP(x) \
3582 if ((lzo_uint)(op_end - op) < (lzo_uint)(x)) goto output_overrun
3586 #if defined(LZO_TEST_OVERRUN_LOOKBEHIND)
3587 # define TEST_LB(m_pos) if (m_pos < out || m_pos >= op) goto lookbehind_overrun
3588 # define TEST_LBO(m_pos,o) if (m_pos < out || m_pos >= op - (o)) goto lookbehind_overrun
3590 # define TEST_LB(m_pos) ((void) 0)
3591 # define TEST_LBO(m_pos,o) ((void) 0)
3594 #if !defined(LZO_EOF_CODE) && !defined(TEST_IP)
3595 # define TEST_IP (ip < ip_end)
3598 #if defined(TEST_IP)
3599 # define HAVE_TEST_IP 1
3603 #if defined(TEST_OP)
3604 # define HAVE_TEST_OP 1
3609 #if defined(NEED_IP)
3610 # define HAVE_NEED_IP 1
3612 # define NEED_IP(x) ((void) 0)
3614 #if defined(NEED_OP)
3615 # define HAVE_NEED_OP 1
3617 # define NEED_OP(x) ((void) 0)
3620 #if defined(HAVE_TEST_IP) || defined(HAVE_NEED_IP)
3621 # define HAVE_ANY_IP 1
3623 #if defined(HAVE_TEST_OP) || defined(HAVE_NEED_OP)
3624 # define HAVE_ANY_OP 1
3627 #if defined(DO_DECOMPRESS)
3629 DO_DECOMPRESS ( const lzo_bytep in
, lzo_uint in_len
,
3630 lzo_bytep out
, lzo_uintp out_len
,
3634 register lzo_bytep op
;
3635 register const lzo_bytep ip
;
3636 register lzo_uint t
;
3637 #if defined(COPY_DICT)
3639 const lzo_bytep dict_end
;
3641 register const lzo_bytep m_pos
;
3644 const lzo_bytep
const ip_end
= in
+ in_len
;
3645 #if defined(HAVE_ANY_OP)
3646 lzo_bytep
const op_end
= out
+ *out_len
;
3649 lzo_uint last_m_off
= 0;
3654 #if defined(COPY_DICT)
3657 if (dict_len
> M4_MAX_OFFSET
)
3659 dict
+= dict_len
- M4_MAX_OFFSET
;
3660 dict_len
= M4_MAX_OFFSET
;
3662 dict_end
= dict
+ dict_len
;
3681 assert(t
> 0); NEED_OP(t
); NEED_IP(t
+1);
3682 do *op
++ = *ip
++; while (--t
> 0);
3683 goto first_literal_run
;
3686 while (TEST_IP
&& TEST_OP
)
3702 assert(t
> 0); NEED_OP(t
+3); NEED_IP(t
+4);
3703 #if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4)
3708 op
+= 8; ip
+= 8; t
-= 8;
3713 op
+= 4; ip
+= 4; t
-= 4;
3718 if (t
> 1) { *op
++ = *ip
++; if (t
> 2) { *op
++ = *ip
++; } }
3720 #elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
3721 #if !defined(LZO_UNALIGNED_OK_4)
3722 if (PTR_ALIGNED2_4(op
,ip
))
3733 op
+= 4; ip
+= 4; t
-= 4;
3735 if (t
> 0) do *op
++ = *ip
++; while (--t
> 0);
3738 do *op
++ = *ip
++; while (--t
> 0);
3740 #if !defined(LZO_UNALIGNED_OK_4)
3745 #if !defined(LZO_UNALIGNED_OK_4) && !defined(LZO_UNALIGNED_OK_8)
3747 *op
++ = *ip
++; *op
++ = *ip
++; *op
++ = *ip
++;
3748 do *op
++ = *ip
++; while (--t
> 0);
3757 #if defined(COPY_DICT)
3759 m_off
= (1 + M2_MAX_OFFSET
) + (t
<< 6) + (*ip
++ >> 2);
3762 m_off
= (1 + M2_MAX_OFFSET
) + (t
>> 2) + (*ip
++ << 2);
3765 t
= 3; COPY_DICT(t
,m_off
)
3768 t
= (1 + M2_MAX_OFFSET
) + (t
<< 6) + (*ip
++ >> 2);
3772 m_pos
= op
- (1 + M2_MAX_OFFSET
);
3774 m_pos
-= *ip
++ << 2;
3776 TEST_LB(m_pos
); NEED_OP(3);
3777 *op
++ = *m_pos
++; *op
++ = *m_pos
++; *op
++ = *m_pos
;
3785 #if defined(COPY_DICT)
3787 m_off
= 1 + ((t
>> 2) & 7) + (*ip
++ << 3);
3789 #elif defined(LZO1Y)
3790 m_off
= 1 + ((t
>> 2) & 3) + (*ip
++ << 2);
3792 #elif defined(LZO1Z)
3798 m_off
= 1 + (m_off
<< 6) + (*ip
++ >> 2);
3806 m_pos
-= (t
>> 2) & 7;
3807 m_pos
-= *ip
++ << 3;
3809 #elif defined(LZO1Y)
3811 m_pos
-= (t
>> 2) & 3;
3812 m_pos
-= *ip
++ << 2;
3814 #elif defined(LZO1Z)
3816 lzo_uint off
= t
& 0x1f;
3820 assert(last_m_off
> 0);
3821 m_pos
-= last_m_off
;
3825 off
= 1 + (off
<< 6) + (*ip
++ >> 2);
3832 TEST_LB(m_pos
); assert(t
> 0); NEED_OP(t
+3-1);
3850 #if defined(COPY_DICT)
3852 m_off
= 1 + (ip
[0] << 6) + (ip
[1] >> 2);
3855 m_off
= 1 + (ip
[0] >> 2) + (ip
[1] << 6);
3860 lzo_uint off
= 1 + (ip
[0] << 6) + (ip
[1] >> 2);
3864 #elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN)
3866 m_pos
-= UA_GET16(ip
) >> 2;
3869 m_pos
-= (ip
[0] >> 2) + (ip
[1] << 6);
3876 #if defined(COPY_DICT)
3877 m_off
= (t
& 8) << 11;
3880 m_pos
-= (t
& 8) << 11;
3894 #if defined(COPY_DICT)
3896 m_off
+= (ip
[0] << 6) + (ip
[1] >> 2);
3898 m_off
+= (ip
[0] >> 2) + (ip
[1] << 6);
3909 m_pos
-= (ip
[0] << 6) + (ip
[1] >> 2);
3910 #elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN)
3911 m_pos
-= UA_GET16(ip
) >> 2;
3913 m_pos
-= (ip
[0] >> 2) + (ip
[1] << 6);
3920 last_m_off
= pd((const lzo_bytep
)op
, m_pos
);
3926 #if defined(COPY_DICT)
3928 m_off
= 1 + (t
<< 6) + (*ip
++ >> 2);
3931 m_off
= 1 + (t
>> 2) + (*ip
++ << 2);
3934 t
= 2; COPY_DICT(t
,m_off
)
3937 t
= 1 + (t
<< 6) + (*ip
++ >> 2);
3943 m_pos
-= *ip
++ << 2;
3945 TEST_LB(m_pos
); NEED_OP(2);
3946 *op
++ = *m_pos
++; *op
++ = *m_pos
;
3951 #if defined(COPY_DICT)
3954 t
+= 3-1; COPY_DICT(t
,m_off
)
3958 TEST_LB(m_pos
); assert(t
> 0); NEED_OP(t
+3-1);
3959 #if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4)
3960 if (op
- m_pos
>= 8)
3965 UA_COPY64(op
,m_pos
);
3966 op
+= 8; m_pos
+= 8; t
-= 8;
3970 UA_COPY32(op
,m_pos
);
3971 op
+= 4; m_pos
+= 4; t
-= 4;
3976 if (t
> 1) { *op
++ = m_pos
[1]; if (t
> 2) { *op
++ = m_pos
[2]; } }
3980 #elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
3981 #if !defined(LZO_UNALIGNED_OK_4)
3982 if (t
>= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op
,m_pos
))
3984 assert((op
- m_pos
) >= 4);
3986 if (t
>= 2 * 4 - (3 - 1) && (op
- m_pos
) >= 4)
3989 UA_COPY32(op
,m_pos
);
3990 op
+= 4; m_pos
+= 4; t
-= 4 - (3 - 1);
3992 UA_COPY32(op
,m_pos
);
3993 op
+= 4; m_pos
+= 4; t
-= 4;
3995 if (t
> 0) do *op
++ = *m_pos
++; while (--t
> 0);
4001 *op
++ = *m_pos
++; *op
++ = *m_pos
++;
4002 do *op
++ = *m_pos
++; while (--t
> 0);
4017 assert(t
> 0); assert(t
< 4); NEED_OP(t
); NEED_IP(t
+1);
4019 do *op
++ = *ip
++; while (--t
> 0);
4022 if (t
> 1) { *op
++ = *ip
++; if (t
> 2) { *op
++ = *ip
++; } }
4025 } while (TEST_IP
&& TEST_OP
);
4028 #if defined(HAVE_TEST_IP) || defined(HAVE_TEST_OP)
4029 *out_len
= pd(op
, out
);
4030 return LZO_E_EOF_NOT_FOUND
;
4035 *out_len
= pd(op
, out
);
4036 return (ip
== ip_end
? LZO_E_OK
:
4037 (ip
< ip_end
? LZO_E_INPUT_NOT_CONSUMED
: LZO_E_INPUT_OVERRUN
));
4039 #if defined(HAVE_NEED_IP)
4041 *out_len
= pd(op
, out
);
4042 return LZO_E_INPUT_OVERRUN
;
4045 #if defined(HAVE_NEED_OP)
4047 *out_len
= pd(op
, out
);
4048 return LZO_E_OUTPUT_OVERRUN
;
4051 #if defined(LZO_TEST_OVERRUN_LOOKBEHIND)
4053 *out_len
= pd(op
, out
);
4054 return LZO_E_LOOKBEHIND_OVERRUN
;
4060 #define LZO_TEST_OVERRUN 1
4061 #undef DO_DECOMPRESS
4062 #define DO_DECOMPRESS lzo1x_decompress_safe
4064 #if !defined(MINILZO_CFG_SKIP_LZO1X_DECOMPRESS_SAFE)
4066 #if defined(LZO_TEST_OVERRUN)
4067 # if !defined(LZO_TEST_OVERRUN_INPUT)
4068 # define LZO_TEST_OVERRUN_INPUT 2
4070 # if !defined(LZO_TEST_OVERRUN_OUTPUT)
4071 # define LZO_TEST_OVERRUN_OUTPUT 2
4073 # if !defined(LZO_TEST_OVERRUN_LOOKBEHIND)
4074 # define LZO_TEST_OVERRUN_LOOKBEHIND 1
4091 #if defined(LZO_TEST_OVERRUN_INPUT)
4092 # if (LZO_TEST_OVERRUN_INPUT >= 1)
4093 # define TEST_IP (ip < ip_end)
4095 # if (LZO_TEST_OVERRUN_INPUT >= 2)
4096 # define NEED_IP(x) \
4097 if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x)) goto input_overrun
4101 #if defined(LZO_TEST_OVERRUN_OUTPUT)
4102 # if (LZO_TEST_OVERRUN_OUTPUT >= 1)
4103 # define TEST_OP (op <= op_end)
4105 # if (LZO_TEST_OVERRUN_OUTPUT >= 2)
4107 # define NEED_OP(x) \
4108 if ((lzo_uint)(op_end - op) < (lzo_uint)(x)) goto output_overrun
4112 #if defined(LZO_TEST_OVERRUN_LOOKBEHIND)
4113 # define TEST_LB(m_pos) if (m_pos < out || m_pos >= op) goto lookbehind_overrun
4114 # define TEST_LBO(m_pos,o) if (m_pos < out || m_pos >= op - (o)) goto lookbehind_overrun
4116 # define TEST_LB(m_pos) ((void) 0)
4117 # define TEST_LBO(m_pos,o) ((void) 0)
4120 #if !defined(LZO_EOF_CODE) && !defined(TEST_IP)
4121 # define TEST_IP (ip < ip_end)
4124 #if defined(TEST_IP)
4125 # define HAVE_TEST_IP 1
4129 #if defined(TEST_OP)
4130 # define HAVE_TEST_OP 1
4135 #if defined(NEED_IP)
4136 # define HAVE_NEED_IP 1
4138 # define NEED_IP(x) ((void) 0)
4140 #if defined(NEED_OP)
4141 # define HAVE_NEED_OP 1
4143 # define NEED_OP(x) ((void) 0)
4146 #if defined(HAVE_TEST_IP) || defined(HAVE_NEED_IP)
4147 # define HAVE_ANY_IP 1
4149 #if defined(HAVE_TEST_OP) || defined(HAVE_NEED_OP)
4150 # define HAVE_ANY_OP 1
4153 #if defined(DO_DECOMPRESS)
4155 DO_DECOMPRESS ( const lzo_bytep in
, lzo_uint in_len
,
4156 lzo_bytep out
, lzo_uintp out_len
,
4160 register lzo_bytep op
;
4161 register const lzo_bytep ip
;
4162 register lzo_uint t
;
4163 #if defined(COPY_DICT)
4165 const lzo_bytep dict_end
;
4167 register const lzo_bytep m_pos
;
4170 const lzo_bytep
const ip_end
= in
+ in_len
;
4171 #if defined(HAVE_ANY_OP)
4172 lzo_bytep
const op_end
= out
+ *out_len
;
4175 lzo_uint last_m_off
= 0;
4180 #if defined(COPY_DICT)
4183 if (dict_len
> M4_MAX_OFFSET
)
4185 dict
+= dict_len
- M4_MAX_OFFSET
;
4186 dict_len
= M4_MAX_OFFSET
;
4188 dict_end
= dict
+ dict_len
;
4207 assert(t
> 0); NEED_OP(t
); NEED_IP(t
+1);
4208 do *op
++ = *ip
++; while (--t
> 0);
4209 goto first_literal_run
;
4212 while (TEST_IP
&& TEST_OP
)
4228 assert(t
> 0); NEED_OP(t
+3); NEED_IP(t
+4);
4229 #if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4)
4234 op
+= 8; ip
+= 8; t
-= 8;
4239 op
+= 4; ip
+= 4; t
-= 4;
4244 if (t
> 1) { *op
++ = *ip
++; if (t
> 2) { *op
++ = *ip
++; } }
4246 #elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
4247 #if !defined(LZO_UNALIGNED_OK_4)
4248 if (PTR_ALIGNED2_4(op
,ip
))
4259 op
+= 4; ip
+= 4; t
-= 4;
4261 if (t
> 0) do *op
++ = *ip
++; while (--t
> 0);
4264 do *op
++ = *ip
++; while (--t
> 0);
4266 #if !defined(LZO_UNALIGNED_OK_4)
4271 #if !defined(LZO_UNALIGNED_OK_4) && !defined(LZO_UNALIGNED_OK_8)
4273 *op
++ = *ip
++; *op
++ = *ip
++; *op
++ = *ip
++;
4274 do *op
++ = *ip
++; while (--t
> 0);
4283 #if defined(COPY_DICT)
4285 m_off
= (1 + M2_MAX_OFFSET
) + (t
<< 6) + (*ip
++ >> 2);
4288 m_off
= (1 + M2_MAX_OFFSET
) + (t
>> 2) + (*ip
++ << 2);
4291 t
= 3; COPY_DICT(t
,m_off
)
4294 t
= (1 + M2_MAX_OFFSET
) + (t
<< 6) + (*ip
++ >> 2);
4298 m_pos
= op
- (1 + M2_MAX_OFFSET
);
4300 m_pos
-= *ip
++ << 2;
4302 TEST_LB(m_pos
); NEED_OP(3);
4303 *op
++ = *m_pos
++; *op
++ = *m_pos
++; *op
++ = *m_pos
;
4311 #if defined(COPY_DICT)
4313 m_off
= 1 + ((t
>> 2) & 7) + (*ip
++ << 3);
4315 #elif defined(LZO1Y)
4316 m_off
= 1 + ((t
>> 2) & 3) + (*ip
++ << 2);
4318 #elif defined(LZO1Z)
4324 m_off
= 1 + (m_off
<< 6) + (*ip
++ >> 2);
4332 m_pos
-= (t
>> 2) & 7;
4333 m_pos
-= *ip
++ << 3;
4335 #elif defined(LZO1Y)
4337 m_pos
-= (t
>> 2) & 3;
4338 m_pos
-= *ip
++ << 2;
4340 #elif defined(LZO1Z)
4342 lzo_uint off
= t
& 0x1f;
4346 assert(last_m_off
> 0);
4347 m_pos
-= last_m_off
;
4351 off
= 1 + (off
<< 6) + (*ip
++ >> 2);
4358 TEST_LB(m_pos
); assert(t
> 0); NEED_OP(t
+3-1);
4376 #if defined(COPY_DICT)
4378 m_off
= 1 + (ip
[0] << 6) + (ip
[1] >> 2);
4381 m_off
= 1 + (ip
[0] >> 2) + (ip
[1] << 6);
4386 lzo_uint off
= 1 + (ip
[0] << 6) + (ip
[1] >> 2);
4390 #elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN)
4392 m_pos
-= UA_GET16(ip
) >> 2;
4395 m_pos
-= (ip
[0] >> 2) + (ip
[1] << 6);
4402 #if defined(COPY_DICT)
4403 m_off
= (t
& 8) << 11;
4406 m_pos
-= (t
& 8) << 11;
4420 #if defined(COPY_DICT)
4422 m_off
+= (ip
[0] << 6) + (ip
[1] >> 2);
4424 m_off
+= (ip
[0] >> 2) + (ip
[1] << 6);
4435 m_pos
-= (ip
[0] << 6) + (ip
[1] >> 2);
4436 #elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN)
4437 m_pos
-= UA_GET16(ip
) >> 2;
4439 m_pos
-= (ip
[0] >> 2) + (ip
[1] << 6);
4446 last_m_off
= pd((const lzo_bytep
)op
, m_pos
);
4452 #if defined(COPY_DICT)
4454 m_off
= 1 + (t
<< 6) + (*ip
++ >> 2);
4457 m_off
= 1 + (t
>> 2) + (*ip
++ << 2);
4460 t
= 2; COPY_DICT(t
,m_off
)
4463 t
= 1 + (t
<< 6) + (*ip
++ >> 2);
4469 m_pos
-= *ip
++ << 2;
4471 TEST_LB(m_pos
); NEED_OP(2);
4472 *op
++ = *m_pos
++; *op
++ = *m_pos
;
4477 #if defined(COPY_DICT)
4480 t
+= 3-1; COPY_DICT(t
,m_off
)
4484 TEST_LB(m_pos
); assert(t
> 0); NEED_OP(t
+3-1);
4485 #if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4)
4486 if (op
- m_pos
>= 8)
4491 UA_COPY64(op
,m_pos
);
4492 op
+= 8; m_pos
+= 8; t
-= 8;
4496 UA_COPY32(op
,m_pos
);
4497 op
+= 4; m_pos
+= 4; t
-= 4;
4502 if (t
> 1) { *op
++ = m_pos
[1]; if (t
> 2) { *op
++ = m_pos
[2]; } }
4506 #elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
4507 #if !defined(LZO_UNALIGNED_OK_4)
4508 if (t
>= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op
,m_pos
))
4510 assert((op
- m_pos
) >= 4);
4512 if (t
>= 2 * 4 - (3 - 1) && (op
- m_pos
) >= 4)
4515 UA_COPY32(op
,m_pos
);
4516 op
+= 4; m_pos
+= 4; t
-= 4 - (3 - 1);
4518 UA_COPY32(op
,m_pos
);
4519 op
+= 4; m_pos
+= 4; t
-= 4;
4521 if (t
> 0) do *op
++ = *m_pos
++; while (--t
> 0);
4527 *op
++ = *m_pos
++; *op
++ = *m_pos
++;
4528 do *op
++ = *m_pos
++; while (--t
> 0);
4543 assert(t
> 0); assert(t
< 4); NEED_OP(t
); NEED_IP(t
+1);
4545 do *op
++ = *ip
++; while (--t
> 0);
4548 if (t
> 1) { *op
++ = *ip
++; if (t
> 2) { *op
++ = *ip
++; } }
4551 } while (TEST_IP
&& TEST_OP
);
4554 #if defined(HAVE_TEST_IP) || defined(HAVE_TEST_OP)
4555 *out_len
= pd(op
, out
);
4556 return LZO_E_EOF_NOT_FOUND
;
4561 *out_len
= pd(op
, out
);
4562 return (ip
== ip_end
? LZO_E_OK
:
4563 (ip
< ip_end
? LZO_E_INPUT_NOT_CONSUMED
: LZO_E_INPUT_OVERRUN
));
4565 #if defined(HAVE_NEED_IP)
4567 *out_len
= pd(op
, out
);
4568 return LZO_E_INPUT_OVERRUN
;
4571 #if defined(HAVE_NEED_OP)
4573 *out_len
= pd(op
, out
);
4574 return LZO_E_OUTPUT_OVERRUN
;
4577 #if defined(LZO_TEST_OVERRUN_LOOKBEHIND)
4579 *out_len
= pd(op
, out
);
4580 return LZO_E_LOOKBEHIND_OVERRUN
;
4586 /***** End of minilzo.c *****/