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/
49 #define __LZO_IN_MINILZO 1
51 #if defined(LZO_CFG_FREESTANDING)
52 # undef MINILZO_HAVE_CONFIG_H
53 # define LZO_LIBC_FREESTANDING 1
54 # define LZO_OS_FREESTANDING 1
57 #ifdef MINILZO_HAVE_CONFIG_H
62 #if defined(MINILZO_CFG_USE_INTERNAL_LZODEFS)
64 #ifndef __LZODEFS_H_INCLUDED
65 #define __LZODEFS_H_INCLUDED 1
67 #if defined(__CYGWIN32__) && !defined(__CYGWIN__)
68 # define __CYGWIN__ __CYGWIN32__
70 #if defined(__IBMCPP__) && !defined(__IBMC__)
71 # define __IBMC__ __IBMCPP__
73 #if defined(__ICL) && defined(_WIN32) && !defined(__INTEL_COMPILER)
74 # define __INTEL_COMPILER __ICL
76 #if 1 && defined(__INTERIX) && defined(__GNUC__) && !defined(_ALL_SOURCE)
77 # define _ALL_SOURCE 1
79 #if defined(__mips__) && defined(__R5900__)
80 # if !defined(__LONG_MAX__)
81 # define __LONG_MAX__ 9223372036854775807L
84 #if defined(__INTEL_COMPILER) && defined(__linux__)
85 # pragma warning(disable: 193)
87 #if defined(__KEIL__) && defined(__C166__)
88 # pragma warning disable = 322
89 #elif 0 && defined(__C251__)
90 # pragma warning disable = 322
92 #if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__)
93 # if (_MSC_VER >= 1300)
94 # pragma warning(disable: 4668)
97 #if 0 && defined(__WATCOMC__)
98 # if (__WATCOMC__ >= 1050) && (__WATCOMC__ < 1060)
99 # pragma warning 203 9
102 #if defined(__BORLANDC__) && defined(__MSDOS__) && !defined(__FLAT__)
106 #define LZO_0xffffL 0xfffful
107 #define LZO_0xffffffffL 0xfffffffful
109 #define LZO_0xffffL 65535ul
110 #define LZO_0xffffffffL 4294967295ul
112 #if (LZO_0xffffL == LZO_0xffffffffL)
113 # error "your preprocessor is broken 1"
115 #if (16ul * 16384ul != 262144ul)
116 # error "your preprocessor is broken 2"
119 #if (32767 >= 4294967295ul)
120 # error "your preprocessor is broken 3"
122 #if (65535u >= 4294967295ul)
123 # error "your preprocessor is broken 4"
126 #if (UINT_MAX == LZO_0xffffL)
127 #if defined(__ZTC__) && defined(__I86__) && !defined(__OS2__)
131 # if !defined(_MSDOS)
134 #elif 0 && defined(__VERSION) && defined(MB_LEN_MAX)
135 # if (__VERSION == 520) && (MB_LEN_MAX == 1)
136 # if !defined(__AZTEC_C__)
137 # define __AZTEC_C__ __VERSION
139 # if !defined(__DOS__)
145 #if defined(_MSC_VER) && defined(M_I86HM) && (UINT_MAX == LZO_0xffffL)
146 # define ptrdiff_t long
147 # define _PTRDIFF_T_DEFINED 1
149 #if (UINT_MAX == LZO_0xffffL)
150 # undef __LZO_RENAME_A
151 # undef __LZO_RENAME_B
152 # if defined(__AZTEC_C__) && defined(__DOS__)
153 # define __LZO_RENAME_A 1
154 # elif defined(_MSC_VER) && defined(MSDOS)
155 # if (_MSC_VER < 600)
156 # define __LZO_RENAME_A 1
157 # elif (_MSC_VER < 700)
158 # define __LZO_RENAME_B 1
160 # elif defined(__TSC__) && defined(__OS2__)
161 # define __LZO_RENAME_A 1
162 # elif defined(__MSDOS__) && defined(__TURBOC__) && (__TURBOC__ < 0x0410)
163 # define __LZO_RENAME_A 1
164 # elif defined(__PACIFIC__) && defined(DOS)
168 # if !defined(__near)
172 # if defined(__LZO_RENAME_A)
173 # if !defined(__cdecl)
174 # define __cdecl cdecl
179 # if !defined(__huge)
182 # if !defined(__near)
185 # if !defined(__pascal)
186 # define __pascal pascal
188 # if !defined(__huge)
191 # elif defined(__LZO_RENAME_B)
192 # if !defined(__cdecl)
193 # define __cdecl _cdecl
198 # if !defined(__huge)
199 # define __huge _huge
201 # if !defined(__near)
202 # define __near _near
204 # if !defined(__pascal)
205 # define __pascal _pascal
207 # elif (defined(__PUREC__) || defined(__TURBOC__)) && defined(__TOS__)
208 # if !defined(__cdecl)
209 # define __cdecl cdecl
211 # if !defined(__pascal)
212 # define __pascal pascal
215 # undef __LZO_RENAME_A
216 # undef __LZO_RENAME_B
218 #if (UINT_MAX == LZO_0xffffL)
219 #if defined(__AZTEC_C__) && defined(__DOS__)
220 # define LZO_BROKEN_CDECL_ALT_SYNTAX 1
221 #elif defined(_MSC_VER) && defined(MSDOS)
222 # if (_MSC_VER < 600)
223 # define LZO_BROKEN_INTEGRAL_CONSTANTS 1
225 # if (_MSC_VER < 700)
226 # define LZO_BROKEN_INTEGRAL_PROMOTION 1
227 # define LZO_BROKEN_SIZEOF 1
229 #elif defined(__PACIFIC__) && defined(DOS)
230 # define LZO_BROKEN_INTEGRAL_CONSTANTS 1
231 #elif defined(__TURBOC__) && defined(__MSDOS__)
232 # if (__TURBOC__ < 0x0150)
233 # define LZO_BROKEN_CDECL_ALT_SYNTAX 1
234 # define LZO_BROKEN_INTEGRAL_CONSTANTS 1
235 # define LZO_BROKEN_INTEGRAL_PROMOTION 1
237 # if (__TURBOC__ < 0x0200)
238 # define LZO_BROKEN_SIZEOF 1
240 # if (__TURBOC__ < 0x0400) && defined(__cplusplus)
241 # define LZO_BROKEN_CDECL_ALT_SYNTAX 1
243 #elif (defined(__PUREC__) || defined(__TURBOC__)) && defined(__TOS__)
244 # define LZO_BROKEN_CDECL_ALT_SYNTAX 1
245 # define LZO_BROKEN_SIZEOF 1
248 #if defined(__WATCOMC__) && (__WATCOMC__ < 900)
249 # define LZO_BROKEN_INTEGRAL_CONSTANTS 1
251 #if defined(_CRAY) && defined(_CRAY1)
252 # define LZO_BROKEN_SIGNED_RIGHT_SHIFT 1
254 #define LZO_PP_STRINGIZE(x) #x
255 #define LZO_PP_MACRO_EXPAND(x) LZO_PP_STRINGIZE(x)
256 #define LZO_PP_CONCAT2(a,b) a ## b
257 #define LZO_PP_CONCAT3(a,b,c) a ## b ## c
258 #define LZO_PP_CONCAT4(a,b,c,d) a ## b ## c ## d
259 #define LZO_PP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e
260 #define LZO_PP_ECONCAT2(a,b) LZO_PP_CONCAT2(a,b)
261 #define LZO_PP_ECONCAT3(a,b,c) LZO_PP_CONCAT3(a,b,c)
262 #define LZO_PP_ECONCAT4(a,b,c,d) LZO_PP_CONCAT4(a,b,c,d)
263 #define LZO_PP_ECONCAT5(a,b,c,d,e) LZO_PP_CONCAT5(a,b,c,d,e)
265 #define LZO_CPP_STRINGIZE(x) #x
266 #define LZO_CPP_MACRO_EXPAND(x) LZO_CPP_STRINGIZE(x)
267 #define LZO_CPP_CONCAT2(a,b) a ## b
268 #define LZO_CPP_CONCAT3(a,b,c) a ## b ## c
269 #define LZO_CPP_CONCAT4(a,b,c,d) a ## b ## c ## d
270 #define LZO_CPP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e
271 #define LZO_CPP_ECONCAT2(a,b) LZO_CPP_CONCAT2(a,b)
272 #define LZO_CPP_ECONCAT3(a,b,c) LZO_CPP_CONCAT3(a,b,c)
273 #define LZO_CPP_ECONCAT4(a,b,c,d) LZO_CPP_CONCAT4(a,b,c,d)
274 #define LZO_CPP_ECONCAT5(a,b,c,d,e) LZO_CPP_CONCAT5(a,b,c,d,e)
276 #define __LZO_MASK_GEN(o,b) (((((o) << ((b)-1)) - (o)) << 1) + (o))
277 #if 1 && defined(__cplusplus)
278 # if !defined(__STDC_CONSTANT_MACROS)
279 # define __STDC_CONSTANT_MACROS 1
281 # if !defined(__STDC_LIMIT_MACROS)
282 # define __STDC_LIMIT_MACROS 1
285 #if defined(__cplusplus)
286 # define LZO_EXTERN_C extern "C"
288 # define LZO_EXTERN_C extern
290 #if !defined(__LZO_OS_OVERRIDE)
291 #if (LZO_OS_FREESTANDING)
292 # define LZO_INFO_OS "freestanding"
293 #elif (LZO_OS_EMBEDDED)
294 # define LZO_INFO_OS "embedded"
295 #elif 1 && defined(__IAR_SYSTEMS_ICC__)
296 # define LZO_OS_EMBEDDED 1
297 # define LZO_INFO_OS "embedded"
298 #elif defined(__CYGWIN__) && defined(__GNUC__)
299 # define LZO_OS_CYGWIN 1
300 # define LZO_INFO_OS "cygwin"
301 #elif defined(__EMX__) && defined(__GNUC__)
302 # define LZO_OS_EMX 1
303 # define LZO_INFO_OS "emx"
304 #elif defined(__BEOS__)
305 # define LZO_OS_BEOS 1
306 # define LZO_INFO_OS "beos"
307 #elif defined(__Lynx__)
308 # define LZO_OS_LYNXOS 1
309 # define LZO_INFO_OS "lynxos"
310 #elif defined(__OS400__)
311 # define LZO_OS_OS400 1
312 # define LZO_INFO_OS "os400"
313 #elif defined(__QNX__)
314 # define LZO_OS_QNX 1
315 # define LZO_INFO_OS "qnx"
316 #elif defined(__BORLANDC__) && defined(__DPMI32__) && (__BORLANDC__ >= 0x0460)
317 # define LZO_OS_DOS32 1
318 # define LZO_INFO_OS "dos32"
319 #elif defined(__BORLANDC__) && defined(__DPMI16__)
320 # define LZO_OS_DOS16 1
321 # define LZO_INFO_OS "dos16"
322 #elif defined(__ZTC__) && defined(DOS386)
323 # define LZO_OS_DOS32 1
324 # define LZO_INFO_OS "dos32"
325 #elif defined(__OS2__) || defined(__OS2V2__)
326 # if (UINT_MAX == LZO_0xffffL)
327 # define LZO_OS_OS216 1
328 # define LZO_INFO_OS "os216"
329 # elif (UINT_MAX == LZO_0xffffffffL)
330 # define LZO_OS_OS2 1
331 # define LZO_INFO_OS "os2"
333 # error "check your limits.h header"
335 #elif defined(__WIN64__) || defined(_WIN64) || defined(WIN64)
336 # define LZO_OS_WIN64 1
337 # define LZO_INFO_OS "win64"
338 #elif defined(__WIN32__) || defined(_WIN32) || defined(WIN32) || defined(__WINDOWS_386__)
339 # define LZO_OS_WIN32 1
340 # define LZO_INFO_OS "win32"
341 #elif defined(__MWERKS__) && defined(__INTEL__)
342 # define LZO_OS_WIN32 1
343 # define LZO_INFO_OS "win32"
344 #elif defined(__WINDOWS__) || defined(_WINDOWS) || defined(_Windows)
345 # if (UINT_MAX == LZO_0xffffL)
346 # define LZO_OS_WIN16 1
347 # define LZO_INFO_OS "win16"
348 # elif (UINT_MAX == LZO_0xffffffffL)
349 # define LZO_OS_WIN32 1
350 # define LZO_INFO_OS "win32"
352 # error "check your limits.h header"
354 #elif defined(__DOS__) || defined(__MSDOS__) || defined(_MSDOS) || defined(MSDOS) || (defined(__PACIFIC__) && defined(DOS))
355 # if (UINT_MAX == LZO_0xffffL)
356 # define LZO_OS_DOS16 1
357 # define LZO_INFO_OS "dos16"
358 # elif (UINT_MAX == LZO_0xffffffffL)
359 # define LZO_OS_DOS32 1
360 # define LZO_INFO_OS "dos32"
362 # error "check your limits.h header"
364 #elif defined(__WATCOMC__)
365 # if defined(__NT__) && (UINT_MAX == LZO_0xffffL)
366 # define LZO_OS_DOS16 1
367 # define LZO_INFO_OS "dos16"
368 # elif defined(__NT__) && (__WATCOMC__ < 1100)
369 # define LZO_OS_WIN32 1
370 # define LZO_INFO_OS "win32"
371 # elif defined(__linux__) || defined(__LINUX__)
372 # define LZO_OS_POSIX 1
373 # define LZO_INFO_OS "posix"
375 # error "please specify a target using the -bt compiler option"
377 #elif defined(__palmos__)
378 # define LZO_OS_PALMOS 1
379 # define LZO_INFO_OS "palmos"
380 #elif defined(__TOS__) || defined(__atarist__)
381 # define LZO_OS_TOS 1
382 # define LZO_INFO_OS "tos"
383 #elif defined(macintosh) && !defined(__ppc__)
384 # define LZO_OS_MACCLASSIC 1
385 # define LZO_INFO_OS "macclassic"
387 # define LZO_OS_VMS 1
388 # define LZO_INFO_OS "vms"
389 #elif ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__))
390 # define LZO_OS_CONSOLE 1
391 # define LZO_OS_CONSOLE_PS2 1
392 # define LZO_INFO_OS "console"
393 # define LZO_INFO_OS_CONSOLE "ps2"
394 #elif (defined(__mips__) && defined(__psp__))
395 # define LZO_OS_CONSOLE 1
396 # define LZO_OS_CONSOLE_PSP 1
397 # define LZO_INFO_OS "console"
398 # define LZO_INFO_OS_CONSOLE "psp"
400 # define LZO_OS_POSIX 1
401 # define LZO_INFO_OS "posix"
404 # if defined(_AIX) || defined(__AIX__) || defined(__aix__)
405 # define LZO_OS_POSIX_AIX 1
406 # define LZO_INFO_OS_POSIX "aix"
407 # elif defined(__FreeBSD__)
408 # define LZO_OS_POSIX_FREEBSD 1
409 # define LZO_INFO_OS_POSIX "freebsd"
410 # elif defined(__hpux__) || defined(__hpux)
411 # define LZO_OS_POSIX_HPUX 1
412 # define LZO_INFO_OS_POSIX "hpux"
413 # elif defined(__INTERIX)
414 # define LZO_OS_POSIX_INTERIX 1
415 # define LZO_INFO_OS_POSIX "interix"
416 # elif defined(__IRIX__) || defined(__irix__)
417 # define LZO_OS_POSIX_IRIX 1
418 # define LZO_INFO_OS_POSIX "irix"
419 # elif defined(__linux__) || defined(__linux) || defined(__LINUX__)
420 # define LZO_OS_POSIX_LINUX 1
421 # define LZO_INFO_OS_POSIX "linux"
422 # elif defined(__APPLE__) || defined(__MACOS__)
423 # define LZO_OS_POSIX_MACOSX 1
424 # define LZO_INFO_OS_POSIX "macosx"
425 # elif defined(__minix__) || defined(__minix)
426 # define LZO_OS_POSIX_MINIX 1
427 # define LZO_INFO_OS_POSIX "minix"
428 # elif defined(__NetBSD__)
429 # define LZO_OS_POSIX_NETBSD 1
430 # define LZO_INFO_OS_POSIX "netbsd"
431 # elif defined(__OpenBSD__)
432 # define LZO_OS_POSIX_OPENBSD 1
433 # define LZO_INFO_OS_POSIX "openbsd"
434 # elif defined(__osf__)
435 # define LZO_OS_POSIX_OSF 1
436 # define LZO_INFO_OS_POSIX "osf"
437 # elif defined(__solaris__) || defined(__sun)
438 # if defined(__SVR4) || defined(__svr4__)
439 # define LZO_OS_POSIX_SOLARIS 1
440 # define LZO_INFO_OS_POSIX "solaris"
442 # define LZO_OS_POSIX_SUNOS 1
443 # define LZO_INFO_OS_POSIX "sunos"
445 # elif defined(__ultrix__) || defined(__ultrix)
446 # define LZO_OS_POSIX_ULTRIX 1
447 # define LZO_INFO_OS_POSIX "ultrix"
448 # elif defined(_UNICOS)
449 # define LZO_OS_POSIX_UNICOS 1
450 # define LZO_INFO_OS_POSIX "unicos"
452 # define LZO_OS_POSIX_UNKNOWN 1
453 # define LZO_INFO_OS_POSIX "unknown"
457 #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16)
458 # if (UINT_MAX != LZO_0xffffL)
459 # error "this should not happen"
461 # if (ULONG_MAX != LZO_0xffffffffL)
462 # error "this should not happen"
465 #if (LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_WIN32 || LZO_OS_WIN64)
466 # if (UINT_MAX != LZO_0xffffffffL)
467 # error "this should not happen"
469 # if (ULONG_MAX != LZO_0xffffffffL)
470 # error "this should not happen"
473 #if defined(CIL) && defined(_GNUCC) && defined(__GNUC__)
474 # define LZO_CC_CILLY 1
475 # define LZO_INFO_CC "Cilly"
476 # if defined(__CILLY__)
477 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__CILLY__)
479 # define LZO_INFO_CCVER "unknown"
481 #elif 0 && defined(SDCC) && defined(__VERSION__) && !defined(__GNUC__)
482 # define LZO_CC_SDCC 1
483 # define LZO_INFO_CC "sdcc"
484 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(SDCC)
485 #elif defined(__PATHSCALE__) && defined(__PATHCC_PATCHLEVEL__)
486 # define LZO_CC_PATHSCALE (__PATHCC__ * 0x10000L + __PATHCC_MINOR__ * 0x100 + __PATHCC_PATCHLEVEL__)
487 # define LZO_INFO_CC "Pathscale C"
488 # define LZO_INFO_CCVER __PATHSCALE__
489 #elif defined(__INTEL_COMPILER)
490 # define LZO_CC_INTELC 1
491 # define LZO_INFO_CC "Intel C"
492 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__INTEL_COMPILER)
493 # if defined(_WIN32) || defined(_WIN64)
494 # define LZO_CC_SYNTAX_MSC 1
496 # define LZO_CC_SYNTAX_GNUC 1
498 #elif defined(__POCC__) && defined(_WIN32)
499 # define LZO_CC_PELLESC 1
500 # define LZO_INFO_CC "Pelles C"
501 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__POCC__)
502 #elif defined(__clang__) && defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__)
503 # if defined(__GNUC_PATCHLEVEL__)
504 # define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__)
506 # define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100)
508 # if defined(__clang_major__) && defined(__clang_minor__) && defined(__clang_patchlevel__)
509 # define LZO_CC_CLANG_CLANG (__clang_major__ * 0x10000L + __clang_minor__ * 0x100 + __clang_patchlevel__)
511 # define LZO_CC_CLANG_CLANG 0x010000L
513 # define LZO_CC_CLANG LZO_CC_CLANG_GNUC
514 # define LZO_INFO_CC "clang"
515 # define LZO_INFO_CCVER __VERSION__
516 #elif defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__)
517 # if defined(__GNUC_PATCHLEVEL__)
518 # define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__)
520 # define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100)
522 # define LZO_CC_LLVM LZO_CC_LLVM_GNUC
523 # define LZO_INFO_CC "llvm-gcc"
524 # define LZO_INFO_CCVER __VERSION__
525 #elif defined(__GNUC__) && defined(__VERSION__)
526 # if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
527 # define LZO_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__)
528 # elif defined(__GNUC_MINOR__)
529 # define LZO_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100)
531 # define LZO_CC_GNUC (__GNUC__ * 0x10000L)
533 # define LZO_INFO_CC "gcc"
534 # define LZO_INFO_CCVER __VERSION__
535 #elif defined(__ACK__) && defined(_ACK)
536 # define LZO_CC_ACK 1
537 # define LZO_INFO_CC "Amsterdam Compiler Kit C"
538 # define LZO_INFO_CCVER "unknown"
539 #elif defined(__AZTEC_C__)
540 # define LZO_CC_AZTECC 1
541 # define LZO_INFO_CC "Aztec C"
542 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__AZTEC_C__)
543 #elif defined(__CODEGEARC__)
544 # define LZO_CC_CODEGEARC 1
545 # define LZO_INFO_CC "CodeGear C"
546 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__CODEGEARC__)
547 #elif defined(__BORLANDC__)
548 # define LZO_CC_BORLANDC 1
549 # define LZO_INFO_CC "Borland C"
550 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__BORLANDC__)
551 #elif defined(_CRAYC) && defined(_RELEASE)
552 # define LZO_CC_CRAYC 1
553 # define LZO_INFO_CC "Cray C"
554 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_RELEASE)
555 #elif defined(__DMC__) && defined(__SC__)
556 # define LZO_CC_DMC 1
557 # define LZO_INFO_CC "Digital Mars C"
558 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__DMC__)
559 #elif defined(__DECC)
560 # define LZO_CC_DECC 1
561 # define LZO_INFO_CC "DEC C"
562 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__DECC)
563 #elif defined(__HIGHC__)
564 # define LZO_CC_HIGHC 1
565 # define LZO_INFO_CC "MetaWare High C"
566 # define LZO_INFO_CCVER "unknown"
567 #elif defined(__IAR_SYSTEMS_ICC__)
568 # define LZO_CC_IARC 1
569 # define LZO_INFO_CC "IAR C"
570 # if defined(__VER__)
571 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__VER__)
573 # define LZO_INFO_CCVER "unknown"
575 #elif defined(__IBMC__)
576 # define LZO_CC_IBMC 1
577 # define LZO_INFO_CC "IBM C"
578 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__IBMC__)
579 #elif defined(__KEIL__) && defined(__C166__)
580 # define LZO_CC_KEILC 1
581 # define LZO_INFO_CC "Keil C"
582 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__C166__)
583 #elif defined(__LCC__) && defined(_WIN32) && defined(__LCCOPTIMLEVEL)
584 # define LZO_CC_LCCWIN32 1
585 # define LZO_INFO_CC "lcc-win32"
586 # define LZO_INFO_CCVER "unknown"
587 #elif defined(__LCC__)
588 # define LZO_CC_LCC 1
589 # define LZO_INFO_CC "lcc"
590 # if defined(__LCC_VERSION__)
591 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__LCC_VERSION__)
593 # define LZO_INFO_CCVER "unknown"
595 #elif defined(_MSC_VER)
596 # define LZO_CC_MSC 1
597 # define LZO_INFO_CC "Microsoft C"
598 # if defined(_MSC_FULL_VER)
599 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) "." LZO_PP_MACRO_EXPAND(_MSC_FULL_VER)
601 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER)
603 #elif defined(__MWERKS__)
604 # define LZO_CC_MWERKS 1
605 # define LZO_INFO_CC "Metrowerks C"
606 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__MWERKS__)
607 #elif (defined(__NDPC__) || defined(__NDPX__)) && defined(__i386)
608 # define LZO_CC_NDPC 1
609 # define LZO_INFO_CC "Microway NDP C"
610 # define LZO_INFO_CCVER "unknown"
611 #elif defined(__PACIFIC__)
612 # define LZO_CC_PACIFICC 1
613 # define LZO_INFO_CC "Pacific C"
614 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PACIFIC__)
615 #elif defined(__PGI) && (defined(__linux__) || defined(__WIN32__))
616 # define LZO_CC_PGI 1
617 # define LZO_INFO_CC "Portland Group PGI C"
618 # define LZO_INFO_CCVER "unknown"
619 #elif defined(__PUREC__) && defined(__TOS__)
620 # define LZO_CC_PUREC 1
621 # define LZO_INFO_CC "Pure C"
622 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PUREC__)
623 #elif defined(__SC__) && defined(__ZTC__)
624 # define LZO_CC_SYMANTECC 1
625 # define LZO_INFO_CC "Symantec C"
626 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SC__)
627 #elif defined(__SUNPRO_C)
628 # define LZO_INFO_CC "SunPro C"
629 # if ((__SUNPRO_C)+0 > 0)
630 # define LZO_CC_SUNPROC __SUNPRO_C
631 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_C)
633 # define LZO_CC_SUNPROC 1
634 # define LZO_INFO_CCVER "unknown"
636 #elif defined(__SUNPRO_CC)
637 # define LZO_INFO_CC "SunPro C"
638 # if ((__SUNPRO_CC)+0 > 0)
639 # define LZO_CC_SUNPROC __SUNPRO_CC
640 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_CC)
642 # define LZO_CC_SUNPROC 1
643 # define LZO_INFO_CCVER "unknown"
645 #elif defined(__TINYC__)
646 # define LZO_CC_TINYC 1
647 # define LZO_INFO_CC "Tiny C"
648 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TINYC__)
649 #elif defined(__TSC__)
650 # define LZO_CC_TOPSPEEDC 1
651 # define LZO_INFO_CC "TopSpeed C"
652 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TSC__)
653 #elif defined(__WATCOMC__)
654 # define LZO_CC_WATCOMC 1
655 # define LZO_INFO_CC "Watcom C"
656 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__WATCOMC__)
657 #elif defined(__TURBOC__)
658 # define LZO_CC_TURBOC 1
659 # define LZO_INFO_CC "Turbo C"
660 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TURBOC__)
661 #elif defined(__ZTC__)
662 # define LZO_CC_ZORTECHC 1
663 # define LZO_INFO_CC "Zortech C"
664 # if (__ZTC__ == 0x310)
665 # define LZO_INFO_CCVER "0x310"
667 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__ZTC__)
670 # define LZO_CC_UNKNOWN 1
671 # define LZO_INFO_CC "unknown"
672 # define LZO_INFO_CCVER "unknown"
674 #if 0 && (LZO_CC_MSC && (_MSC_VER >= 1200)) && !defined(_MSC_FULL_VER)
675 # error "LZO_CC_MSC: _MSC_FULL_VER is not defined"
677 #if !defined(__LZO_ARCH_OVERRIDE) && !(LZO_ARCH_GENERIC) && defined(_CRAY)
678 # if (UINT_MAX > LZO_0xffffffffL) && defined(_CRAY)
679 # if defined(_CRAYMPP) || defined(_CRAYT3D) || defined(_CRAYT3E)
680 # define LZO_ARCH_CRAY_MPP 1
681 # elif defined(_CRAY1)
682 # define LZO_ARCH_CRAY_PVP 1
686 #if !defined(__LZO_ARCH_OVERRIDE)
687 #if (LZO_ARCH_GENERIC)
688 # define LZO_INFO_ARCH "generic"
689 #elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16)
690 # define LZO_ARCH_I086 1
691 # define LZO_ARCH_IA16 1
692 # define LZO_INFO_ARCH "i086"
693 #elif defined(__alpha__) || defined(__alpha) || defined(_M_ALPHA)
694 # define LZO_ARCH_ALPHA 1
695 # define LZO_INFO_ARCH "alpha"
696 #elif (LZO_ARCH_CRAY_MPP) && (defined(_CRAYT3D) || defined(_CRAYT3E))
697 # define LZO_ARCH_ALPHA 1
698 # define LZO_INFO_ARCH "alpha"
699 #elif defined(__amd64__) || defined(__x86_64__) || defined(_M_AMD64)
700 # define LZO_ARCH_AMD64 1
701 # define LZO_INFO_ARCH "amd64"
702 #elif defined(__thumb__) || (defined(_M_ARM) && defined(_M_THUMB))
703 # define LZO_ARCH_ARM 1
704 # define LZO_ARCH_ARM_THUMB 1
705 # define LZO_INFO_ARCH "arm_thumb"
706 #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCARM__)
707 # define LZO_ARCH_ARM 1
708 # if defined(__CPU_MODE__) && ((__CPU_MODE__)+0 == 1)
709 # define LZO_ARCH_ARM_THUMB 1
710 # define LZO_INFO_ARCH "arm_thumb"
711 # elif defined(__CPU_MODE__) && ((__CPU_MODE__)+0 == 2)
712 # define LZO_INFO_ARCH "arm"
714 # define LZO_INFO_ARCH "arm"
716 #elif defined(__arm__) || defined(_M_ARM)
717 # define LZO_ARCH_ARM 1
718 # define LZO_INFO_ARCH "arm"
719 #elif (UINT_MAX <= LZO_0xffffL) && defined(__AVR__)
720 # define LZO_ARCH_AVR 1
721 # define LZO_INFO_ARCH "avr"
722 #elif defined(__avr32__) || defined(__AVR32__)
723 # define LZO_ARCH_AVR32 1
724 # define LZO_INFO_ARCH "avr32"
725 #elif defined(__bfin__)
726 # define LZO_ARCH_BLACKFIN 1
727 # define LZO_INFO_ARCH "blackfin"
728 #elif (UINT_MAX == LZO_0xffffL) && defined(__C166__)
729 # define LZO_ARCH_C166 1
730 # define LZO_INFO_ARCH "c166"
731 #elif defined(__cris__)
732 # define LZO_ARCH_CRIS 1
733 # define LZO_INFO_ARCH "cris"
734 #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCEZ80__)
735 # define LZO_ARCH_EZ80 1
736 # define LZO_INFO_ARCH "ez80"
737 #elif defined(__H8300__) || defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__)
738 # define LZO_ARCH_H8300 1
739 # define LZO_INFO_ARCH "h8300"
740 #elif defined(__hppa__) || defined(__hppa)
741 # define LZO_ARCH_HPPA 1
742 # define LZO_INFO_ARCH "hppa"
743 #elif defined(__386__) || defined(__i386__) || defined(__i386) || defined(_M_IX86) || defined(_M_I386)
744 # define LZO_ARCH_I386 1
745 # define LZO_ARCH_IA32 1
746 # define LZO_INFO_ARCH "i386"
747 #elif (LZO_CC_ZORTECHC && defined(__I86__))
748 # define LZO_ARCH_I386 1
749 # define LZO_ARCH_IA32 1
750 # define LZO_INFO_ARCH "i386"
751 #elif (LZO_OS_DOS32 && LZO_CC_HIGHC) && defined(_I386)
752 # define LZO_ARCH_I386 1
753 # define LZO_ARCH_IA32 1
754 # define LZO_INFO_ARCH "i386"
755 #elif defined(__ia64__) || defined(__ia64) || defined(_M_IA64)
756 # define LZO_ARCH_IA64 1
757 # define LZO_INFO_ARCH "ia64"
758 #elif (UINT_MAX == LZO_0xffffL) && defined(__m32c__)
759 # define LZO_ARCH_M16C 1
760 # define LZO_INFO_ARCH "m16c"
761 #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCM16C__)
762 # define LZO_ARCH_M16C 1
763 # define LZO_INFO_ARCH "m16c"
764 #elif defined(__m32r__)
765 # define LZO_ARCH_M32R 1
766 # define LZO_INFO_ARCH "m32r"
767 #elif (LZO_OS_TOS) || defined(__m68k__) || defined(__m68000__) || defined(__mc68000__) || defined(__mc68020__) || defined(_M_M68K)
768 # define LZO_ARCH_M68K 1
769 # define LZO_INFO_ARCH "m68k"
770 #elif (UINT_MAX == LZO_0xffffL) && defined(__C251__)
771 # define LZO_ARCH_MCS251 1
772 # define LZO_INFO_ARCH "mcs251"
773 #elif (UINT_MAX == LZO_0xffffL) && defined(__C51__)
774 # define LZO_ARCH_MCS51 1
775 # define LZO_INFO_ARCH "mcs51"
776 #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICC8051__)
777 # define LZO_ARCH_MCS51 1
778 # define LZO_INFO_ARCH "mcs51"
779 #elif defined(__mips__) || defined(__mips) || defined(_MIPS_ARCH) || defined(_M_MRX000)
780 # define LZO_ARCH_MIPS 1
781 # define LZO_INFO_ARCH "mips"
782 #elif (UINT_MAX == LZO_0xffffL) && defined(__MSP430__)
783 # define LZO_ARCH_MSP430 1
784 # define LZO_INFO_ARCH "msp430"
785 #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICC430__)
786 # define LZO_ARCH_MSP430 1
787 # define LZO_INFO_ARCH "msp430"
788 #elif defined(__powerpc__) || defined(__powerpc) || defined(__ppc__) || defined(__PPC__) || defined(_M_PPC) || defined(_ARCH_PPC) || defined(_ARCH_PWR)
789 # define LZO_ARCH_POWERPC 1
790 # define LZO_INFO_ARCH "powerpc"
791 #elif defined(__s390__) || defined(__s390) || defined(__s390x__) || defined(__s390x)
792 # define LZO_ARCH_S390 1
793 # define LZO_INFO_ARCH "s390"
794 #elif defined(__sh__) || defined(_M_SH)
795 # define LZO_ARCH_SH 1
796 # define LZO_INFO_ARCH "sh"
797 #elif defined(__sparc__) || defined(__sparc) || defined(__sparcv8)
798 # define LZO_ARCH_SPARC 1
799 # define LZO_INFO_ARCH "sparc"
800 #elif defined(__SPU__)
801 # define LZO_ARCH_SPU 1
802 # define LZO_INFO_ARCH "spu"
803 #elif (UINT_MAX == LZO_0xffffL) && defined(__z80)
804 # define LZO_ARCH_Z80 1
805 # define LZO_INFO_ARCH "z80"
806 #elif (LZO_ARCH_CRAY_PVP)
807 # if defined(_CRAYSV1)
808 # define LZO_ARCH_CRAY_SV1 1
809 # define LZO_INFO_ARCH "cray_sv1"
811 # define LZO_ARCH_CRAY_T90 1
812 # define LZO_INFO_ARCH "cray_t90"
814 # define LZO_ARCH_CRAY_YMP 1
815 # define LZO_INFO_ARCH "cray_ymp"
817 # define LZO_ARCH_CRAY_XMP 1
818 # define LZO_INFO_ARCH "cray_xmp"
821 # define LZO_ARCH_UNKNOWN 1
822 # define LZO_INFO_ARCH "unknown"
825 #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_DOS32 || LZO_OS_OS2)
826 # error "FIXME - missing define for CPU architecture"
828 #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN32)
829 # error "FIXME - missing WIN32 define for CPU architecture"
831 #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN64)
832 # error "FIXME - missing WIN64 define for CPU architecture"
834 #if (LZO_OS_OS216 || LZO_OS_WIN16)
835 # define LZO_ARCH_I086PM 1
836 # define LZO_ARCH_IA16PM 1
837 #elif 1 && (LZO_OS_DOS16 && defined(BLX286))
838 # define LZO_ARCH_I086PM 1
839 # define LZO_ARCH_IA16PM 1
840 #elif 1 && (LZO_OS_DOS16 && defined(DOSX286))
841 # define LZO_ARCH_I086PM 1
842 # define LZO_ARCH_IA16PM 1
843 #elif 1 && (LZO_OS_DOS16 && LZO_CC_BORLANDC && defined(__DPMI16__))
844 # define LZO_ARCH_I086PM 1
845 # define LZO_ARCH_IA16PM 1
847 #if (LZO_ARCH_ARM_THUMB) && !(LZO_ARCH_ARM)
848 # error "this should not happen"
850 #if (LZO_ARCH_I086PM) && !(LZO_ARCH_I086)
851 # error "this should not happen"
854 # if (UINT_MAX != LZO_0xffffL)
855 # error "this should not happen"
857 # if (ULONG_MAX != LZO_0xffffffffL)
858 # error "this should not happen"
862 # if (UINT_MAX != LZO_0xffffL) && defined(__i386_int16__)
863 # error "this should not happen"
865 # if (UINT_MAX != LZO_0xffffffffL) && !defined(__i386_int16__)
866 # error "this should not happen"
868 # if (ULONG_MAX != LZO_0xffffffffL)
869 # error "this should not happen"
872 #if !defined(__LZO_MM_OVERRIDE)
874 #if (UINT_MAX != LZO_0xffffL)
875 # error "this should not happen"
877 #if defined(__TINY__) || defined(M_I86TM) || defined(_M_I86TM)
878 # define LZO_MM_TINY 1
879 #elif defined(__HUGE__) || defined(_HUGE_) || defined(M_I86HM) || defined(_M_I86HM)
880 # define LZO_MM_HUGE 1
881 #elif defined(__SMALL__) || defined(M_I86SM) || defined(_M_I86SM) || defined(SMALL_MODEL)
882 # define LZO_MM_SMALL 1
883 #elif defined(__MEDIUM__) || defined(M_I86MM) || defined(_M_I86MM)
884 # define LZO_MM_MEDIUM 1
885 #elif defined(__COMPACT__) || defined(M_I86CM) || defined(_M_I86CM)
886 # define LZO_MM_COMPACT 1
887 #elif defined(__LARGE__) || defined(M_I86LM) || defined(_M_I86LM) || defined(LARGE_MODEL)
888 # define LZO_MM_LARGE 1
889 #elif (LZO_CC_AZTECC)
890 # if defined(_LARGE_CODE) && defined(_LARGE_DATA)
891 # define LZO_MM_LARGE 1
892 # elif defined(_LARGE_CODE)
893 # define LZO_MM_MEDIUM 1
894 # elif defined(_LARGE_DATA)
895 # define LZO_MM_COMPACT 1
897 # define LZO_MM_SMALL 1
899 #elif (LZO_CC_ZORTECHC && defined(__VCM__))
900 # define LZO_MM_LARGE 1
902 # error "unknown memory model"
904 #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16)
905 #define LZO_HAVE_MM_HUGE_PTR 1
906 #define LZO_HAVE_MM_HUGE_ARRAY 1
908 # undef LZO_HAVE_MM_HUGE_ARRAY
910 #if (LZO_CC_AZTECC || LZO_CC_PACIFICC || LZO_CC_ZORTECHC)
911 # undef LZO_HAVE_MM_HUGE_PTR
912 # undef LZO_HAVE_MM_HUGE_ARRAY
913 #elif (LZO_CC_DMC || LZO_CC_SYMANTECC)
914 # undef LZO_HAVE_MM_HUGE_ARRAY
915 #elif (LZO_CC_MSC && defined(_QC))
916 # undef LZO_HAVE_MM_HUGE_ARRAY
917 # if (_MSC_VER < 600)
918 # undef LZO_HAVE_MM_HUGE_PTR
920 #elif (LZO_CC_TURBOC && (__TURBOC__ < 0x0295))
921 # undef LZO_HAVE_MM_HUGE_ARRAY
923 #if (LZO_ARCH_I086PM) && !(LZO_HAVE_MM_HUGE_PTR)
925 # error "this should not happen"
926 # elif (LZO_CC_ZORTECHC)
928 # error "this should not happen"
934 #if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0200))
935 extern void __near __cdecl
_AHSHIFT(void);
936 # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT)
937 #elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC)
938 extern void __near __cdecl
_AHSHIFT(void);
939 # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT)
940 #elif (LZO_CC_MSC || LZO_CC_TOPSPEEDC)
941 extern void __near __cdecl
_AHSHIFT(void);
942 # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT)
943 #elif (LZO_CC_TURBOC && (__TURBOC__ >= 0x0295))
944 extern void __near __cdecl
_AHSHIFT(void);
945 # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT)
946 #elif ((LZO_CC_AZTECC || LZO_CC_PACIFICC || LZO_CC_TURBOC) && LZO_OS_DOS16)
947 # define LZO_MM_AHSHIFT 12
948 #elif (LZO_CC_WATCOMC)
949 extern unsigned char _HShift
;
950 # define LZO_MM_AHSHIFT ((unsigned) _HShift)
952 # error "FIXME - implement LZO_MM_AHSHIFT"
958 #elif (LZO_ARCH_C166)
959 #if !defined(__MODEL__)
960 # error "FIXME - C166 __MODEL__"
961 #elif ((__MODEL__) == 0)
962 # define LZO_MM_SMALL 1
963 #elif ((__MODEL__) == 1)
964 # define LZO_MM_SMALL 1
965 #elif ((__MODEL__) == 2)
966 # define LZO_MM_LARGE 1
967 #elif ((__MODEL__) == 3)
968 # define LZO_MM_TINY 1
969 #elif ((__MODEL__) == 4)
970 # define LZO_MM_XTINY 1
971 #elif ((__MODEL__) == 5)
972 # define LZO_MM_XSMALL 1
974 # error "FIXME - C166 __MODEL__"
976 #elif (LZO_ARCH_MCS251)
977 #if !defined(__MODEL__)
978 # error "FIXME - MCS251 __MODEL__"
979 #elif ((__MODEL__) == 0)
980 # define LZO_MM_SMALL 1
981 #elif ((__MODEL__) == 2)
982 # define LZO_MM_LARGE 1
983 #elif ((__MODEL__) == 3)
984 # define LZO_MM_TINY 1
985 #elif ((__MODEL__) == 4)
986 # define LZO_MM_XTINY 1
987 #elif ((__MODEL__) == 5)
988 # define LZO_MM_XSMALL 1
990 # error "FIXME - MCS251 __MODEL__"
992 #elif (LZO_ARCH_MCS51)
993 #if !defined(__MODEL__)
994 # error "FIXME - MCS51 __MODEL__"
995 #elif ((__MODEL__) == 1)
996 # define LZO_MM_SMALL 1
997 #elif ((__MODEL__) == 2)
998 # define LZO_MM_LARGE 1
999 #elif ((__MODEL__) == 3)
1000 # define LZO_MM_TINY 1
1001 #elif ((__MODEL__) == 4)
1002 # define LZO_MM_XTINY 1
1003 #elif ((__MODEL__) == 5)
1004 # define LZO_MM_XSMALL 1
1006 # error "FIXME - MCS51 __MODEL__"
1008 #elif (LZO_ARCH_CRAY_PVP)
1009 # define LZO_MM_PVP 1
1011 # define LZO_MM_FLAT 1
1013 #if (LZO_MM_COMPACT)
1014 # define LZO_INFO_MM "compact"
1016 # define LZO_INFO_MM "flat"
1018 # define LZO_INFO_MM "huge"
1019 #elif (LZO_MM_LARGE)
1020 # define LZO_INFO_MM "large"
1021 #elif (LZO_MM_MEDIUM)
1022 # define LZO_INFO_MM "medium"
1024 # define LZO_INFO_MM "pvp"
1025 #elif (LZO_MM_SMALL)
1026 # define LZO_INFO_MM "small"
1028 # define LZO_INFO_MM "tiny"
1030 # error "unknown memory model"
1033 #if defined(SIZEOF_SHORT)
1034 # define LZO_SIZEOF_SHORT (SIZEOF_SHORT)
1036 #if defined(SIZEOF_INT)
1037 # define LZO_SIZEOF_INT (SIZEOF_INT)
1039 #if defined(SIZEOF_LONG)
1040 # define LZO_SIZEOF_LONG (SIZEOF_LONG)
1042 #if defined(SIZEOF_LONG_LONG)
1043 # define LZO_SIZEOF_LONG_LONG (SIZEOF_LONG_LONG)
1045 #if defined(SIZEOF___INT16)
1046 # define LZO_SIZEOF___INT16 (SIZEOF___INT16)
1048 #if defined(SIZEOF___INT32)
1049 # define LZO_SIZEOF___INT32 (SIZEOF___INT32)
1051 #if defined(SIZEOF___INT64)
1052 # define LZO_SIZEOF___INT64 (SIZEOF___INT64)
1054 #if defined(SIZEOF_VOID_P)
1055 # define LZO_SIZEOF_VOID_P (SIZEOF_VOID_P)
1057 #if defined(SIZEOF_SIZE_T)
1058 # define LZO_SIZEOF_SIZE_T (SIZEOF_SIZE_T)
1060 #if defined(SIZEOF_PTRDIFF_T)
1061 # define LZO_SIZEOF_PTRDIFF_T (SIZEOF_PTRDIFF_T)
1063 #define __LZO_LSR(x,b) (((x)+0ul) >> (b))
1064 #if !defined(LZO_SIZEOF_SHORT)
1065 # if (LZO_ARCH_CRAY_PVP)
1066 # define LZO_SIZEOF_SHORT 8
1067 # elif (USHRT_MAX == LZO_0xffffL)
1068 # define LZO_SIZEOF_SHORT 2
1069 # elif (__LZO_LSR(USHRT_MAX,7) == 1)
1070 # define LZO_SIZEOF_SHORT 1
1071 # elif (__LZO_LSR(USHRT_MAX,15) == 1)
1072 # define LZO_SIZEOF_SHORT 2
1073 # elif (__LZO_LSR(USHRT_MAX,31) == 1)
1074 # define LZO_SIZEOF_SHORT 4
1075 # elif (__LZO_LSR(USHRT_MAX,63) == 1)
1076 # define LZO_SIZEOF_SHORT 8
1077 # elif (__LZO_LSR(USHRT_MAX,127) == 1)
1078 # define LZO_SIZEOF_SHORT 16
1080 # error "LZO_SIZEOF_SHORT"
1083 #if !defined(LZO_SIZEOF_INT)
1084 # if (LZO_ARCH_CRAY_PVP)
1085 # define LZO_SIZEOF_INT 8
1086 # elif (UINT_MAX == LZO_0xffffL)
1087 # define LZO_SIZEOF_INT 2
1088 # elif (UINT_MAX == LZO_0xffffffffL)
1089 # define LZO_SIZEOF_INT 4
1090 # elif (__LZO_LSR(UINT_MAX,7) == 1)
1091 # define LZO_SIZEOF_INT 1
1092 # elif (__LZO_LSR(UINT_MAX,15) == 1)
1093 # define LZO_SIZEOF_INT 2
1094 # elif (__LZO_LSR(UINT_MAX,31) == 1)
1095 # define LZO_SIZEOF_INT 4
1096 # elif (__LZO_LSR(UINT_MAX,63) == 1)
1097 # define LZO_SIZEOF_INT 8
1098 # elif (__LZO_LSR(UINT_MAX,127) == 1)
1099 # define LZO_SIZEOF_INT 16
1101 # error "LZO_SIZEOF_INT"
1104 #if !defined(LZO_SIZEOF_LONG)
1105 # if (ULONG_MAX == LZO_0xffffffffL)
1106 # define LZO_SIZEOF_LONG 4
1107 # elif (__LZO_LSR(ULONG_MAX,7) == 1)
1108 # define LZO_SIZEOF_LONG 1
1109 # elif (__LZO_LSR(ULONG_MAX,15) == 1)
1110 # define LZO_SIZEOF_LONG 2
1111 # elif (__LZO_LSR(ULONG_MAX,31) == 1)
1112 # define LZO_SIZEOF_LONG 4
1113 # elif (__LZO_LSR(ULONG_MAX,63) == 1)
1114 # define LZO_SIZEOF_LONG 8
1115 # elif (__LZO_LSR(ULONG_MAX,127) == 1)
1116 # define LZO_SIZEOF_LONG 16
1118 # error "LZO_SIZEOF_LONG"
1121 #if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64)
1122 #if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8)
1123 # if defined(__LONG_MAX__) && defined(__LONG_LONG_MAX__)
1124 # if (LZO_CC_GNUC >= 0x030300ul)
1125 # if ((__LONG_MAX__)+0 == (__LONG_LONG_MAX__)+0)
1126 # define LZO_SIZEOF_LONG_LONG LZO_SIZEOF_LONG
1127 # elif (__LZO_LSR(__LONG_LONG_MAX__,30) == 1)
1128 # define LZO_SIZEOF_LONG_LONG 4
1134 #if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64)
1135 #if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8)
1136 #if (LZO_ARCH_I086 && LZO_CC_DMC)
1137 #elif (LZO_CC_CILLY) && defined(__GNUC__)
1138 # define LZO_SIZEOF_LONG_LONG 8
1139 #elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE)
1140 # define LZO_SIZEOF_LONG_LONG 8
1141 #elif ((LZO_OS_WIN32 || LZO_OS_WIN64 || defined(_WIN32)) && LZO_CC_MSC && (_MSC_VER >= 1400))
1142 # define LZO_SIZEOF_LONG_LONG 8
1143 #elif (LZO_OS_WIN64 || defined(_WIN64))
1144 # define LZO_SIZEOF___INT64 8
1145 #elif (LZO_ARCH_I386 && (LZO_CC_DMC))
1146 # define LZO_SIZEOF_LONG_LONG 8
1147 #elif (LZO_ARCH_I386 && (LZO_CC_SYMANTECC && (__SC__ >= 0x700)))
1148 # define LZO_SIZEOF_LONG_LONG 8
1149 #elif (LZO_ARCH_I386 && (LZO_CC_INTELC && defined(__linux__)))
1150 # define LZO_SIZEOF_LONG_LONG 8
1151 #elif (LZO_ARCH_I386 && (LZO_CC_MWERKS || LZO_CC_PELLESC || LZO_CC_PGI || LZO_CC_SUNPROC))
1152 # define LZO_SIZEOF_LONG_LONG 8
1153 #elif (LZO_ARCH_I386 && (LZO_CC_INTELC || LZO_CC_MSC))
1154 # define LZO_SIZEOF___INT64 8
1155 #elif ((LZO_OS_WIN32 || defined(_WIN32)) && (LZO_CC_MSC))
1156 # define LZO_SIZEOF___INT64 8
1157 #elif (LZO_ARCH_I386 && (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0520)))
1158 # define LZO_SIZEOF___INT64 8
1159 #elif (LZO_ARCH_I386 && (LZO_CC_WATCOMC && (__WATCOMC__ >= 1100)))
1160 # define LZO_SIZEOF___INT64 8
1161 #elif (LZO_CC_WATCOMC && defined(_INTEGRAL_MAX_BITS) && (_INTEGRAL_MAX_BITS == 64))
1162 # define LZO_SIZEOF___INT64 8
1163 #elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__)
1164 # define LZO_SIZEOF_LONG_LONG 8
1165 #elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64)
1166 # define LZO_SIZEOF_LONG_LONG 8
1167 #elif (LZO_CC_SDCC) && (LZO_SIZEOF_INT == 2)
1168 #elif 1 && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
1169 # define LZO_SIZEOF_LONG_LONG 8
1173 #if defined(__cplusplus) && (LZO_CC_GNUC)
1174 # if (LZO_CC_GNUC < 0x020800ul)
1175 # undef LZO_SIZEOF_LONG_LONG
1178 #if (LZO_CFG_NO_LONG_LONG) || defined(__NO_LONG_LONG)
1179 # undef LZO_SIZEOF_LONG_LONG
1181 #if !defined(LZO_SIZEOF_VOID_P)
1183 # define __LZO_WORDSIZE 2
1184 # if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM)
1185 # define LZO_SIZEOF_VOID_P 2
1186 # elif (LZO_MM_COMPACT || LZO_MM_LARGE || LZO_MM_HUGE)
1187 # define LZO_SIZEOF_VOID_P 4
1191 #elif (LZO_ARCH_AVR || LZO_ARCH_Z80)
1192 # define __LZO_WORDSIZE 1
1193 # define LZO_SIZEOF_VOID_P 2
1194 #elif (LZO_ARCH_C166 || LZO_ARCH_MCS51 || LZO_ARCH_MCS251 || LZO_ARCH_MSP430)
1195 # define LZO_SIZEOF_VOID_P 2
1196 #elif (LZO_ARCH_H8300)
1197 # if defined(__NORMAL_MODE__)
1198 # define __LZO_WORDSIZE 4
1199 # define LZO_SIZEOF_VOID_P 2
1200 # elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__)
1201 # define __LZO_WORDSIZE 4
1202 # define LZO_SIZEOF_VOID_P 4
1204 # define __LZO_WORDSIZE 2
1205 # define LZO_SIZEOF_VOID_P 2
1207 # if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_SIZEOF_INT == 4)
1208 # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_INT
1209 # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_INT
1211 #elif (LZO_ARCH_M16C)
1212 # define __LZO_WORDSIZE 2
1213 # if defined(__m32c_cpu__) || defined(__m32cm_cpu__)
1214 # define LZO_SIZEOF_VOID_P 4
1216 # define LZO_SIZEOF_VOID_P 2
1218 #elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__))
1219 # define __LZO_WORDSIZE 8
1220 # define LZO_SIZEOF_VOID_P 4
1221 #elif defined(__LLP64__) || defined(__LLP64) || defined(_LLP64) || defined(_WIN64)
1222 # define __LZO_WORDSIZE 8
1223 # define LZO_SIZEOF_VOID_P 8
1224 #elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__)
1225 # define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG
1226 # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG
1227 # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG
1228 #elif (LZO_OS_OS400 || defined(__OS400__))
1229 # define __LZO_WORDSIZE LZO_SIZEOF_LONG
1230 # define LZO_SIZEOF_VOID_P 16
1231 # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG
1232 # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG
1233 #elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64)
1234 # define LZO_SIZEOF_VOID_P 8
1235 # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG
1236 # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG
1237 #elif (LZO_ARCH_SPU)
1239 # define __LZO_WORDSIZE 16
1241 # define LZO_SIZEOF_VOID_P 4
1243 # define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG
1246 #if !defined(LZO_WORDSIZE)
1247 # if defined(__LZO_WORDSIZE)
1248 # define LZO_WORDSIZE __LZO_WORDSIZE
1250 # define LZO_WORDSIZE LZO_SIZEOF_VOID_P
1253 #if !defined(LZO_SIZEOF_SIZE_T)
1254 #if (LZO_ARCH_I086 || LZO_ARCH_M16C)
1255 # define LZO_SIZEOF_SIZE_T 2
1257 # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_VOID_P
1260 #if !defined(LZO_SIZEOF_PTRDIFF_T)
1262 # if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM || LZO_MM_HUGE)
1263 # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_VOID_P
1264 # elif (LZO_MM_COMPACT || LZO_MM_LARGE)
1265 # if (LZO_CC_BORLANDC || LZO_CC_TURBOC)
1266 # define LZO_SIZEOF_PTRDIFF_T 4
1268 # define LZO_SIZEOF_PTRDIFF_T 2
1274 # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_SIZE_T
1277 #if (LZO_ABI_NEUTRAL_ENDIAN)
1278 # undef LZO_ABI_BIG_ENDIAN
1279 # undef LZO_ABI_LITTLE_ENDIAN
1280 #elif !(LZO_ABI_BIG_ENDIAN) && !(LZO_ABI_LITTLE_ENDIAN)
1281 #if (LZO_ARCH_ALPHA) && (LZO_ARCH_CRAY_MPP)
1282 # define LZO_ABI_BIG_ENDIAN 1
1283 #elif (LZO_ARCH_IA64) && (LZO_OS_POSIX_LINUX || LZO_OS_WIN64)
1284 # define LZO_ABI_LITTLE_ENDIAN 1
1285 #elif (LZO_ARCH_ALPHA || LZO_ARCH_AMD64 || LZO_ARCH_BLACKFIN || LZO_ARCH_CRIS || LZO_ARCH_I086 || LZO_ARCH_I386 || LZO_ARCH_MSP430)
1286 # define LZO_ABI_LITTLE_ENDIAN 1
1287 #elif (LZO_ARCH_AVR32 || LZO_ARCH_M68K || LZO_ARCH_S390)
1288 # define LZO_ABI_BIG_ENDIAN 1
1289 #elif 1 && defined(__IAR_SYSTEMS_ICC__) && defined(__LITTLE_ENDIAN__)
1290 # if (__LITTLE_ENDIAN__ == 1)
1291 # define LZO_ABI_LITTLE_ENDIAN 1
1293 # define LZO_ABI_BIG_ENDIAN 1
1295 #elif 1 && defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__)
1296 # define LZO_ABI_BIG_ENDIAN 1
1297 #elif 1 && defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)
1298 # define LZO_ABI_LITTLE_ENDIAN 1
1299 #elif 1 && (LZO_ARCH_ARM) && defined(__ARMEB__) && !defined(__ARMEL__)
1300 # define LZO_ABI_BIG_ENDIAN 1
1301 #elif 1 && (LZO_ARCH_ARM) && defined(__ARMEL__) && !defined(__ARMEB__)
1302 # define LZO_ABI_LITTLE_ENDIAN 1
1303 #elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEB__) && !defined(__MIPSEL__)
1304 # define LZO_ABI_BIG_ENDIAN 1
1305 #elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEL__) && !defined(__MIPSEB__)
1306 # define LZO_ABI_LITTLE_ENDIAN 1
1309 #if (LZO_ABI_BIG_ENDIAN) && (LZO_ABI_LITTLE_ENDIAN)
1310 # error "this should not happen"
1312 #if (LZO_ABI_BIG_ENDIAN)
1313 # define LZO_INFO_ABI_ENDIAN "be"
1314 #elif (LZO_ABI_LITTLE_ENDIAN)
1315 # define LZO_INFO_ABI_ENDIAN "le"
1316 #elif (LZO_ABI_NEUTRAL_ENDIAN)
1317 # define LZO_INFO_ABI_ENDIAN "neutral"
1319 #if (LZO_SIZEOF_INT == 1 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2)
1320 # define LZO_ABI_I8LP16 1
1321 # define LZO_INFO_ABI_PM "i8lp16"
1322 #elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2)
1323 # define LZO_ABI_ILP16 1
1324 # define LZO_INFO_ABI_PM "ilp16"
1325 #elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4)
1326 # define LZO_ABI_ILP32 1
1327 # define LZO_INFO_ABI_PM "ilp32"
1328 #elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 8 && LZO_SIZEOF_SIZE_T == 8)
1329 # define LZO_ABI_LLP64 1
1330 # define LZO_INFO_ABI_PM "llp64"
1331 #elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8)
1332 # define LZO_ABI_LP64 1
1333 # define LZO_INFO_ABI_PM "lp64"
1334 #elif (LZO_SIZEOF_INT == 8 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8)
1335 # define LZO_ABI_ILP64 1
1336 # define LZO_INFO_ABI_PM "ilp64"
1337 #elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 4)
1338 # define LZO_ABI_IP32L64 1
1339 # define LZO_INFO_ABI_PM "ip32l64"
1341 #if !defined(__LZO_LIBC_OVERRIDE)
1342 #if (LZO_LIBC_NAKED)
1343 # define LZO_INFO_LIBC "naked"
1344 #elif (LZO_LIBC_FREESTANDING)
1345 # define LZO_INFO_LIBC "freestanding"
1346 #elif (LZO_LIBC_MOSTLY_FREESTANDING)
1347 # define LZO_INFO_LIBC "mfreestanding"
1348 #elif (LZO_LIBC_ISOC90)
1349 # define LZO_INFO_LIBC "isoc90"
1350 #elif (LZO_LIBC_ISOC99)
1351 # define LZO_INFO_LIBC "isoc99"
1352 #elif defined(__dietlibc__)
1353 # define LZO_LIBC_DIETLIBC 1
1354 # define LZO_INFO_LIBC "dietlibc"
1355 #elif defined(_NEWLIB_VERSION)
1356 # define LZO_LIBC_NEWLIB 1
1357 # define LZO_INFO_LIBC "newlib"
1358 #elif defined(__UCLIBC__) && defined(__UCLIBC_MAJOR__) && defined(__UCLIBC_MINOR__)
1359 # if defined(__UCLIBC_SUBLEVEL__)
1360 # define LZO_LIBC_UCLIBC (__UCLIBC_MAJOR__ * 0x10000L + __UCLIBC_MINOR__ * 0x100 + __UCLIBC_SUBLEVEL__)
1362 # define LZO_LIBC_UCLIBC 0x00090bL
1364 # define LZO_INFO_LIBC "uclibc"
1365 #elif defined(__GLIBC__) && defined(__GLIBC_MINOR__)
1366 # define LZO_LIBC_GLIBC (__GLIBC__ * 0x10000L + __GLIBC_MINOR__ * 0x100)
1367 # define LZO_INFO_LIBC "glibc"
1368 #elif (LZO_CC_MWERKS) && defined(__MSL__)
1369 # define LZO_LIBC_MSL __MSL__
1370 # define LZO_INFO_LIBC "msl"
1371 #elif 1 && defined(__IAR_SYSTEMS_ICC__)
1372 # define LZO_LIBC_ISOC90 1
1373 # define LZO_INFO_LIBC "isoc90"
1375 # define LZO_LIBC_DEFAULT 1
1376 # define LZO_INFO_LIBC "default"
1379 #if !defined(__lzo_gnuc_extension__)
1380 #if (LZO_CC_GNUC >= 0x020800ul)
1381 # define __lzo_gnuc_extension__ __extension__
1382 #elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
1383 # define __lzo_gnuc_extension__ __extension__
1385 # define __lzo_gnuc_extension__ /*empty*/
1388 #if !defined(__lzo_ua_volatile)
1389 # define __lzo_ua_volatile volatile
1391 #if !defined(__lzo_alignof)
1392 #if (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI)
1393 # define __lzo_alignof(e) __alignof__(e)
1394 #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 700))
1395 # define __lzo_alignof(e) __alignof__(e)
1396 #elif (LZO_CC_MSC && (_MSC_VER >= 1300))
1397 # define __lzo_alignof(e) __alignof(e)
1398 #elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100))
1399 # define __lzo_alignof(e) __alignof__(e)
1402 #if defined(__lzo_alignof)
1403 # define __lzo_HAVE_alignof 1
1405 #if !defined(__lzo_constructor)
1406 #if (LZO_CC_GNUC >= 0x030400ul)
1407 # define __lzo_constructor __attribute__((__constructor__,__used__))
1408 #elif (LZO_CC_GNUC >= 0x020700ul)
1409 # define __lzo_constructor __attribute__((__constructor__))
1410 #elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
1411 # define __lzo_constructor __attribute__((__constructor__))
1414 #if defined(__lzo_constructor)
1415 # define __lzo_HAVE_constructor 1
1417 #if !defined(__lzo_destructor)
1418 #if (LZO_CC_GNUC >= 0x030400ul)
1419 # define __lzo_destructor __attribute__((__destructor__,__used__))
1420 #elif (LZO_CC_GNUC >= 0x020700ul)
1421 # define __lzo_destructor __attribute__((__destructor__))
1422 #elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
1423 # define __lzo_destructor __attribute__((__destructor__))
1426 #if defined(__lzo_destructor)
1427 # define __lzo_HAVE_destructor 1
1429 #if (__lzo_HAVE_destructor) && !(__lzo_HAVE_constructor)
1430 # error "this should not happen"
1432 #if !defined(__lzo_inline)
1433 #if (LZO_CC_TURBOC && (__TURBOC__ <= 0x0295))
1434 #elif defined(__cplusplus)
1435 # define __lzo_inline inline
1436 #elif (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0550))
1437 # define __lzo_inline __inline
1438 #elif (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI)
1439 # define __lzo_inline __inline__
1441 # define __lzo_inline __inline
1442 #elif (LZO_CC_INTELC)
1443 # define __lzo_inline __inline
1444 #elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x2405))
1445 # define __lzo_inline __inline
1446 #elif (LZO_CC_MSC && (_MSC_VER >= 900))
1447 # define __lzo_inline __inline
1448 #elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100))
1449 # define __lzo_inline __inline__
1450 #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
1451 # define __lzo_inline inline
1454 #if defined(__lzo_inline)
1455 # define __lzo_HAVE_inline 1
1457 # define __lzo_inline /*empty*/
1459 #if !defined(__lzo_forceinline)
1460 #if (LZO_CC_GNUC >= 0x030200ul)
1461 # define __lzo_forceinline __inline__ __attribute__((__always_inline__))
1462 #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC)
1463 # define __lzo_forceinline __forceinline
1464 #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC)
1465 # define __lzo_forceinline __inline__ __attribute__((__always_inline__))
1466 #elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
1467 # define __lzo_forceinline __inline__ __attribute__((__always_inline__))
1468 #elif (LZO_CC_MSC && (_MSC_VER >= 1200))
1469 # define __lzo_forceinline __forceinline
1470 #elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100))
1471 # define __lzo_forceinline __inline__ __attribute__((__always_inline__))
1474 #if defined(__lzo_forceinline)
1475 # define __lzo_HAVE_forceinline 1
1477 # define __lzo_forceinline /*empty*/
1479 #if !defined(__lzo_noinline)
1480 #if 1 && (LZO_ARCH_I386) && (LZO_CC_GNUC >= 0x040000ul) && (LZO_CC_GNUC < 0x040003ul)
1481 # define __lzo_noinline __attribute__((__noinline__,__used__))
1482 #elif (LZO_CC_GNUC >= 0x030200ul)
1483 # define __lzo_noinline __attribute__((__noinline__))
1484 #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_MSC)
1485 # define __lzo_noinline __declspec(noinline)
1486 #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC)
1487 # define __lzo_noinline __attribute__((__noinline__))
1488 #elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
1489 # define __lzo_noinline __attribute__((__noinline__))
1490 #elif (LZO_CC_MSC && (_MSC_VER >= 1300))
1491 # define __lzo_noinline __declspec(noinline)
1492 #elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x3200) && (LZO_OS_WIN32 || LZO_OS_WIN64))
1493 # if defined(__cplusplus)
1495 # define __lzo_noinline __declspec(noinline)
1497 #elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100))
1498 # define __lzo_noinline __attribute__((__noinline__))
1501 #if defined(__lzo_noinline)
1502 # define __lzo_HAVE_noinline 1
1504 # define __lzo_noinline /*empty*/
1506 #if (__lzo_HAVE_forceinline || __lzo_HAVE_noinline) && !(__lzo_HAVE_inline)
1507 # error "this should not happen"
1509 #if !defined(__lzo_noreturn)
1510 #if (LZO_CC_GNUC >= 0x020700ul)
1511 # define __lzo_noreturn __attribute__((__noreturn__))
1512 #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC)
1513 # define __lzo_noreturn __declspec(noreturn)
1514 #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_GNUC)
1515 # define __lzo_noreturn __attribute__((__noreturn__))
1516 #elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
1517 # define __lzo_noreturn __attribute__((__noreturn__))
1518 #elif (LZO_CC_MSC && (_MSC_VER >= 1200))
1519 # define __lzo_noreturn __declspec(noreturn)
1522 #if defined(__lzo_noreturn)
1523 # define __lzo_HAVE_noreturn 1
1525 # define __lzo_noreturn /*empty*/
1527 #if !defined(__lzo_nothrow)
1528 #if (LZO_CC_GNUC >= 0x030300ul)
1529 # define __lzo_nothrow __attribute__((__nothrow__))
1530 #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) && defined(__cplusplus)
1531 # define __lzo_nothrow __declspec(nothrow)
1532 #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 900) && LZO_CC_SYNTAX_GNUC)
1533 # define __lzo_nothrow __attribute__((__nothrow__))
1534 #elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
1535 # define __lzo_nothrow __attribute__((__nothrow__))
1536 #elif (LZO_CC_MSC && (_MSC_VER >= 1200)) && defined(__cplusplus)
1537 # define __lzo_nothrow __declspec(nothrow)
1540 #if defined(__lzo_nothrow)
1541 # define __lzo_HAVE_nothrow 1
1543 # define __lzo_nothrow /*empty*/
1545 #if !defined(__lzo_restrict)
1546 #if (LZO_CC_GNUC >= 0x030400ul)
1547 # define __lzo_restrict __restrict__
1548 #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_GNUC)
1549 # define __lzo_restrict __restrict__
1550 #elif (LZO_CC_CLANG || LZO_CC_LLVM)
1551 # define __lzo_restrict __restrict__
1552 #elif (LZO_CC_MSC && (_MSC_VER >= 1400))
1553 # define __lzo_restrict __restrict
1556 #if defined(__lzo_restrict)
1557 # define __lzo_HAVE_restrict 1
1559 # define __lzo_restrict /*empty*/
1561 #if !defined(__lzo_likely) && !defined(__lzo_unlikely)
1562 #if (LZO_CC_GNUC >= 0x030200ul)
1563 # define __lzo_likely(e) (__builtin_expect(!!(e),1))
1564 # define __lzo_unlikely(e) (__builtin_expect(!!(e),0))
1565 #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800))
1566 # define __lzo_likely(e) (__builtin_expect(!!(e),1))
1567 # define __lzo_unlikely(e) (__builtin_expect(!!(e),0))
1568 #elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
1569 # define __lzo_likely(e) (__builtin_expect(!!(e),1))
1570 # define __lzo_unlikely(e) (__builtin_expect(!!(e),0))
1573 #if defined(__lzo_likely)
1574 # define __lzo_HAVE_likely 1
1576 # define __lzo_likely(e) (e)
1578 #if defined(__lzo_unlikely)
1579 # define __lzo_HAVE_unlikely 1
1581 # define __lzo_unlikely(e) (e)
1583 #if !defined(LZO_UNUSED)
1584 # if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600))
1585 # define LZO_UNUSED(var) ((void) &var)
1586 # elif (LZO_CC_BORLANDC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PELLESC || LZO_CC_TURBOC)
1587 # define LZO_UNUSED(var) if (&var) ; else
1588 # elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE)
1589 # define LZO_UNUSED(var) ((void) var)
1590 # elif (LZO_CC_MSC && (_MSC_VER < 900))
1591 # define LZO_UNUSED(var) if (&var) ; else
1592 # elif (LZO_CC_KEILC)
1593 # define LZO_UNUSED(var) {extern int __lzo_unused[1-2*!(sizeof(var)>0)];}
1594 # elif (LZO_CC_PACIFICC)
1595 # define LZO_UNUSED(var) ((void) sizeof(var))
1596 # elif (LZO_CC_WATCOMC) && defined(__cplusplus)
1597 # define LZO_UNUSED(var) ((void) var)
1599 # define LZO_UNUSED(var) ((void) &var)
1602 #if !defined(LZO_UNUSED_FUNC)
1603 # if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600))
1604 # define LZO_UNUSED_FUNC(func) ((void) func)
1605 # elif (LZO_CC_BORLANDC || LZO_CC_NDPC || LZO_CC_TURBOC)
1606 # define LZO_UNUSED_FUNC(func) if (func) ; else
1607 # elif (LZO_CC_CLANG || LZO_CC_LLVM)
1608 # define LZO_UNUSED_FUNC(func) ((void) &func)
1609 # elif (LZO_CC_MSC && (_MSC_VER < 900))
1610 # define LZO_UNUSED_FUNC(func) if (func) ; else
1612 # define LZO_UNUSED_FUNC(func) ((void) &func)
1613 # elif (LZO_CC_KEILC || LZO_CC_PELLESC)
1614 # define LZO_UNUSED_FUNC(func) {extern int __lzo_unused[1-2*!(sizeof((int)func)>0)];}
1616 # define LZO_UNUSED_FUNC(func) ((void) func)
1619 #if !defined(LZO_UNUSED_LABEL)
1620 # if (LZO_CC_WATCOMC) && defined(__cplusplus)
1621 # define LZO_UNUSED_LABEL(l) switch(0) case 1:goto l
1622 # elif (LZO_CC_CLANG || LZO_CC_INTELC || LZO_CC_WATCOMC)
1623 # define LZO_UNUSED_LABEL(l) if (0) goto l
1625 # define LZO_UNUSED_LABEL(l) switch(0) case 1:goto l
1628 #if !defined(LZO_DEFINE_UNINITIALIZED_VAR)
1630 # define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var
1631 # elif 0 && (LZO_CC_GNUC)
1632 # define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = var
1634 # define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = init
1637 #if !defined(LZO_UNCONST_CAST)
1638 # if 0 && defined(__cplusplus)
1639 # define LZO_UNCONST_CAST(t,e) (const_cast<t> (e))
1640 # elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE)
1641 # define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((char *) ((lzo_uintptr_t) ((const void *) (e))))))
1643 # define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((char *) ((const void *) (e)))))
1646 #if !defined(LZO_COMPILE_TIME_ASSERT_HEADER)
1647 # if (LZO_CC_AZTECC || LZO_CC_ZORTECHC)
1648 # define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-!(e)];
1649 # elif (LZO_CC_DMC || LZO_CC_SYMANTECC)
1650 # define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1u-2*!(e)];
1651 # elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295))
1652 # define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-!(e)];
1654 # define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-2*!(e)];
1657 #if !defined(LZO_COMPILE_TIME_ASSERT)
1658 # if (LZO_CC_AZTECC)
1659 # define LZO_COMPILE_TIME_ASSERT(e) {typedef int __lzo_cta_t[1-!(e)];}
1660 # elif (LZO_CC_DMC || LZO_CC_PACIFICC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC)
1661 # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break;
1662 # elif (LZO_CC_MSC && (_MSC_VER < 900))
1663 # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break;
1664 # elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295))
1665 # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break;
1667 # define LZO_COMPILE_TIME_ASSERT(e) {typedef int __lzo_cta_t[1-2*!(e)];}
1670 #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)
1671 # if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC)
1672 # elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC)
1673 # define __lzo_cdecl __cdecl
1674 # define __lzo_cdecl_atexit /*empty*/
1675 # define __lzo_cdecl_main __cdecl
1676 # if (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC))
1677 # define __lzo_cdecl_qsort __pascal
1678 # elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC))
1679 # define __lzo_cdecl_qsort _stdcall
1681 # define __lzo_cdecl_qsort __cdecl
1683 # elif (LZO_CC_WATCOMC)
1684 # define __lzo_cdecl __cdecl
1686 # define __lzo_cdecl __cdecl
1687 # define __lzo_cdecl_atexit __cdecl
1688 # define __lzo_cdecl_main __cdecl
1689 # define __lzo_cdecl_qsort __cdecl
1691 # if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC || LZO_CC_WATCOMC)
1692 # elif (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC))
1693 # define __lzo_cdecl_sighandler __pascal
1694 # elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC))
1695 # define __lzo_cdecl_sighandler _stdcall
1696 # elif (LZO_CC_MSC && (_MSC_VER >= 1400)) && defined(_M_CEE_PURE)
1697 # define __lzo_cdecl_sighandler __clrcall
1698 # elif (LZO_CC_MSC && (_MSC_VER >= 600 && _MSC_VER < 700))
1700 # define __lzo_cdecl_sighandler _far _cdecl _loadds
1702 # define __lzo_cdecl_sighandler _far _cdecl
1704 # define __lzo_cdecl_sighandler _cdecl
1707 # define __lzo_cdecl_sighandler __cdecl
1709 #elif (LZO_ARCH_I386) && (LZO_CC_WATCOMC)
1710 # define __lzo_cdecl __cdecl
1711 #elif (LZO_ARCH_M68K && LZO_OS_TOS && (LZO_CC_PUREC || LZO_CC_TURBOC))
1712 # define __lzo_cdecl cdecl
1714 #if !defined(__lzo_cdecl)
1715 # define __lzo_cdecl /*empty*/
1717 #if !defined(__lzo_cdecl_atexit)
1718 # define __lzo_cdecl_atexit /*empty*/
1720 #if !defined(__lzo_cdecl_main)
1721 # define __lzo_cdecl_main /*empty*/
1723 #if !defined(__lzo_cdecl_qsort)
1724 # define __lzo_cdecl_qsort /*empty*/
1726 #if !defined(__lzo_cdecl_sighandler)
1727 # define __lzo_cdecl_sighandler /*empty*/
1729 #if !defined(__lzo_cdecl_va)
1730 # define __lzo_cdecl_va __lzo_cdecl
1732 #if !(LZO_CFG_NO_WINDOWS_H)
1733 #if (LZO_OS_CYGWIN || (LZO_OS_EMX && defined(__RSXNT__)) || LZO_OS_WIN32 || LZO_OS_WIN64)
1734 # if (LZO_CC_WATCOMC && (__WATCOMC__ < 1000))
1735 # elif (LZO_OS_WIN32 && LZO_CC_GNUC) && defined(__PW32__)
1736 # elif ((LZO_OS_CYGWIN || defined(__MINGW32__)) && (LZO_CC_GNUC && (LZO_CC_GNUC < 0x025f00ul)))
1738 # define LZO_HAVE_WINDOWS_H 1
1742 #if (LZO_ARCH_ALPHA)
1743 # define LZO_OPT_AVOID_UINT_INDEX 1
1744 # define LZO_OPT_AVOID_SHORT 1
1745 # define LZO_OPT_AVOID_USHORT 1
1746 #elif (LZO_ARCH_AMD64)
1747 # define LZO_OPT_AVOID_INT_INDEX 1
1748 # define LZO_OPT_AVOID_UINT_INDEX 1
1749 # define LZO_OPT_UNALIGNED16 1
1750 # define LZO_OPT_UNALIGNED32 1
1751 # define LZO_OPT_UNALIGNED64 1
1752 #elif (LZO_ARCH_ARM && LZO_ARCH_ARM_THUMB)
1753 #elif (LZO_ARCH_ARM)
1754 # define LZO_OPT_AVOID_SHORT 1
1755 # define LZO_OPT_AVOID_USHORT 1
1756 #elif (LZO_ARCH_CRIS)
1757 # define LZO_OPT_UNALIGNED16 1
1758 # define LZO_OPT_UNALIGNED32 1
1759 #elif (LZO_ARCH_I386)
1760 # define LZO_OPT_UNALIGNED16 1
1761 # define LZO_OPT_UNALIGNED32 1
1762 #elif (LZO_ARCH_IA64)
1763 # define LZO_OPT_AVOID_INT_INDEX 1
1764 # define LZO_OPT_AVOID_UINT_INDEX 1
1765 # define LZO_OPT_PREFER_POSTINC 1
1766 #elif (LZO_ARCH_M68K)
1767 # define LZO_OPT_PREFER_POSTINC 1
1768 # define LZO_OPT_PREFER_PREDEC 1
1769 # if defined(__mc68020__) && !defined(__mcoldfire__)
1770 # define LZO_OPT_UNALIGNED16 1
1771 # define LZO_OPT_UNALIGNED32 1
1773 #elif (LZO_ARCH_MIPS)
1774 # define LZO_OPT_AVOID_UINT_INDEX 1
1775 #elif (LZO_ARCH_POWERPC)
1776 # define LZO_OPT_PREFER_PREINC 1
1777 # define LZO_OPT_PREFER_PREDEC 1
1778 # if (LZO_ABI_BIG_ENDIAN)
1779 # define LZO_OPT_UNALIGNED16 1
1780 # define LZO_OPT_UNALIGNED32 1
1782 #elif (LZO_ARCH_S390)
1783 # define LZO_OPT_UNALIGNED16 1
1784 # define LZO_OPT_UNALIGNED32 1
1785 # if (LZO_SIZEOF_SIZE_T == 8)
1786 # define LZO_OPT_UNALIGNED64 1
1789 # define LZO_OPT_PREFER_POSTINC 1
1790 # define LZO_OPT_PREFER_PREDEC 1
1792 #ifndef LZO_CFG_NO_INLINE_ASM
1794 # define LZO_CFG_NO_INLINE_ASM 1
1797 #ifndef LZO_CFG_NO_UNALIGNED
1798 #if (LZO_ABI_NEUTRAL_ENDIAN) || (LZO_ARCH_GENERIC)
1799 # define LZO_CFG_NO_UNALIGNED 1
1802 #if (LZO_CFG_NO_UNALIGNED)
1803 # undef LZO_OPT_UNALIGNED16
1804 # undef LZO_OPT_UNALIGNED32
1805 # undef LZO_OPT_UNALIGNED64
1807 #if (LZO_CFG_NO_INLINE_ASM)
1808 #elif (LZO_ARCH_I386 && (LZO_OS_DOS32 || LZO_OS_WIN32) && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC))
1809 # define LZO_ASM_SYNTAX_MSC 1
1810 #elif (LZO_OS_WIN64 && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC))
1811 #elif (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC == 0x011f00ul))
1812 #elif (LZO_ARCH_I386 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE))
1813 # define LZO_ASM_SYNTAX_GNUC 1
1814 #elif (LZO_ARCH_AMD64 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE))
1815 # define LZO_ASM_SYNTAX_GNUC 1
1817 #if (LZO_ASM_SYNTAX_GNUC)
1818 #if (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC < 0x020000ul))
1819 # define __LZO_ASM_CLOBBER "ax"
1820 #elif (LZO_CC_INTELC)
1821 # define __LZO_ASM_CLOBBER "memory"
1823 # define __LZO_ASM_CLOBBER "cc", "memory"
1826 #if defined(__LZO_INFOSTR_MM)
1827 #elif (LZO_MM_FLAT) && (defined(__LZO_INFOSTR_PM) || defined(LZO_INFO_ABI_PM))
1828 # define __LZO_INFOSTR_MM ""
1829 #elif defined(LZO_INFO_MM)
1830 # define __LZO_INFOSTR_MM "." LZO_INFO_MM
1832 # define __LZO_INFOSTR_MM ""
1834 #if defined(__LZO_INFOSTR_PM)
1835 #elif defined(LZO_INFO_ABI_PM)
1836 # define __LZO_INFOSTR_PM "." LZO_INFO_ABI_PM
1838 # define __LZO_INFOSTR_PM ""
1840 #if defined(__LZO_INFOSTR_ENDIAN)
1841 #elif defined(LZO_INFO_ABI_ENDIAN)
1842 # define __LZO_INFOSTR_ENDIAN "." LZO_INFO_ABI_ENDIAN
1844 # define __LZO_INFOSTR_ENDIAN ""
1846 #if defined(__LZO_INFOSTR_OSNAME)
1847 #elif defined(LZO_INFO_OS_CONSOLE)
1848 # define __LZO_INFOSTR_OSNAME LZO_INFO_OS "." LZO_INFO_OS_CONSOLE
1849 #elif defined(LZO_INFO_OS_POSIX)
1850 # define __LZO_INFOSTR_OSNAME LZO_INFO_OS "." LZO_INFO_OS_POSIX
1852 # define __LZO_INFOSTR_OSNAME LZO_INFO_OS
1854 #if defined(__LZO_INFOSTR_LIBC)
1855 #elif defined(LZO_INFO_LIBC)
1856 # define __LZO_INFOSTR_LIBC "." LZO_INFO_LIBC
1858 # define __LZO_INFOSTR_LIBC ""
1860 #if defined(__LZO_INFOSTR_CCVER)
1861 #elif defined(LZO_INFO_CCVER)
1862 # define __LZO_INFOSTR_CCVER " " LZO_INFO_CCVER
1864 # define __LZO_INFOSTR_CCVER ""
1866 #define LZO_INFO_STRING \
1867 LZO_INFO_ARCH __LZO_INFOSTR_MM __LZO_INFOSTR_PM __LZO_INFOSTR_ENDIAN \
1868 " " __LZO_INFOSTR_OSNAME __LZO_INFOSTR_LIBC " " LZO_INFO_CC __LZO_INFOSTR_CCVER
1874 #undef LZO_HAVE_CONFIG_H
1875 #include "minilzo.h"
1877 #if !defined(MINILZO_VERSION) || (MINILZO_VERSION != 0x2050)
1878 # error "version mismatch in miniLZO source files"
1881 #ifdef MINILZO_HAVE_CONFIG_H
1882 # define LZO_HAVE_CONFIG_H 1
1885 #ifndef __LZO_CONF_H
1886 #define __LZO_CONF_H 1
1888 #if !defined(__LZO_IN_MINILZO)
1889 #if (LZO_CFG_FREESTANDING)
1890 # define LZO_LIBC_FREESTANDING 1
1891 # define LZO_OS_FREESTANDING 1
1892 # define ACC_LIBC_FREESTANDING 1
1893 # define ACC_OS_FREESTANDING 1
1895 #if (LZO_CFG_NO_UNALIGNED)
1896 # define ACC_CFG_NO_UNALIGNED 1
1898 #if (LZO_ARCH_GENERIC)
1899 # define ACC_ARCH_GENERIC 1
1901 #if (LZO_ABI_NEUTRAL_ENDIAN)
1902 # define ACC_ABI_NEUTRAL_ENDIAN 1
1904 #if (LZO_HAVE_CONFIG_H)
1905 # define ACC_CONFIG_NO_HEADER 1
1907 #if defined(LZO_CFG_EXTRA_CONFIG_HEADER)
1908 # include LZO_CFG_EXTRA_CONFIG_HEADER
1910 #if defined(__LZOCONF_H) || defined(__LZOCONF_H_INCLUDED)
1911 # error "include this file first"
1913 #include "lzo/lzoconf.h"
1916 #if (LZO_VERSION < 0x02000) || !defined(__LZOCONF_H_INCLUDED)
1917 # error "version mismatch"
1920 #if (LZO_CC_BORLANDC && LZO_ARCH_I086)
1924 #if (LZO_CC_MSC && (_MSC_VER >= 1000))
1925 # pragma warning(disable: 4127 4701)
1927 #if (LZO_CC_MSC && (_MSC_VER >= 1300))
1928 # pragma warning(disable: 4820)
1929 # pragma warning(disable: 4514 4710 4711)
1932 #if (LZO_CC_SUNPROC)
1933 #if !defined(__cplusplus)
1934 # pragma error_messages(off,E_END_OF_LOOP_CODE_NOT_REACHED)
1935 # pragma error_messages(off,E_LOOP_NOT_ENTERED_AT_TOP)
1936 # pragma error_messages(off,E_STATEMENT_NOT_REACHED)
1940 #if (__LZO_MMODEL_HUGE) && !(LZO_HAVE_MM_HUGE_PTR)
1941 # error "this should not happen - check defines for __huge"
1944 #if defined(__LZO_IN_MINILZO) || defined(LZO_CFG_FREESTANDING)
1945 #elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16)
1946 # define ACC_WANT_ACC_INCD_H 1
1947 # define ACC_WANT_ACC_INCE_H 1
1948 # define ACC_WANT_ACC_INCI_H 1
1950 # include <string.h>
1952 # define ACC_WANT_ACC_INCD_H 1
1956 # define ACC_MM_AHSHIFT LZO_MM_AHSHIFT
1957 # define ACC_PTR_FP_OFF(x) (((const unsigned __far*)&(x))[0])
1958 # define ACC_PTR_FP_SEG(x) (((const unsigned __far*)&(x))[1])
1959 # define ACC_PTR_MK_FP(s,o) ((void __far*)(((unsigned long)(s)<<16)+(unsigned)(o)))
1962 #if !defined(lzo_uintptr_t)
1963 # if defined(__LZO_MMODEL_HUGE)
1964 # define lzo_uintptr_t unsigned long
1965 # elif 1 && defined(LZO_OS_OS400) && (LZO_SIZEOF_VOID_P == 16)
1966 # define __LZO_UINTPTR_T_IS_POINTER 1
1967 typedef char* lzo_uintptr_t
;
1968 # define lzo_uintptr_t lzo_uintptr_t
1969 # elif (LZO_SIZEOF_SIZE_T == LZO_SIZEOF_VOID_P)
1970 # define lzo_uintptr_t size_t
1971 # elif (LZO_SIZEOF_LONG == LZO_SIZEOF_VOID_P)
1972 # define lzo_uintptr_t unsigned long
1973 # elif (LZO_SIZEOF_INT == LZO_SIZEOF_VOID_P)
1974 # define lzo_uintptr_t unsigned int
1975 # elif (LZO_SIZEOF_LONG_LONG == LZO_SIZEOF_VOID_P)
1976 # define lzo_uintptr_t unsigned long long
1978 # define lzo_uintptr_t size_t
1981 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uintptr_t
) >= sizeof(lzo_voidp
))
1983 #if 1 && !defined(LZO_CFG_FREESTANDING)
1984 #if 1 && !defined(HAVE_STRING_H)
1985 #define HAVE_STRING_H 1
1987 #if 1 && !defined(HAVE_MEMCMP)
1988 #define HAVE_MEMCMP 1
1990 #if 1 && !defined(HAVE_MEMCPY)
1991 #define HAVE_MEMCPY 1
1993 #if 1 && !defined(HAVE_MEMMOVE)
1994 #define HAVE_MEMMOVE 1
1996 #if 1 && !defined(HAVE_MEMSET)
1997 #define HAVE_MEMSET 1
2001 #if 1 && defined(HAVE_STRING_H)
2005 #if (LZO_CFG_FREESTANDING)
2008 # undef HAVE_MEMMOVE
2014 # define memcmp(a,b,c) lzo_memcmp(a,b,c)
2015 #elif !(__LZO_MMODEL_HUGE)
2017 # define lzo_memcmp(a,b,c) memcmp(a,b,c)
2021 # define memcpy(a,b,c) lzo_memcpy(a,b,c)
2022 #elif !(__LZO_MMODEL_HUGE)
2024 # define lzo_memcpy(a,b,c) memcpy(a,b,c)
2028 # define memmove(a,b,c) lzo_memmove(a,b,c)
2029 #elif !(__LZO_MMODEL_HUGE)
2031 # define lzo_memmove(a,b,c) memmove(a,b,c)
2035 # define memset(a,b,c) lzo_memset(a,b,c)
2036 #elif !(__LZO_MMODEL_HUGE)
2038 # define lzo_memset(a,b,c) memset(a,b,c)
2042 #if (LZO_CFG_FREESTANDING)
2046 # define assert(e) ((void)0)
2048 # if !defined(LZO_DEBUG)
2051 # include <assert.h>
2054 #if 0 && defined(__BOUNDS_CHECKING_ON)
2055 # include <unchecked.h>
2057 # define BOUNDS_CHECKING_OFF_DURING(stmt) stmt
2058 # define BOUNDS_CHECKING_OFF_IN_EXPR(expr) (expr)
2061 #if !defined(__lzo_inline)
2062 # define __lzo_inline /*empty*/
2064 #if !defined(__lzo_forceinline)
2065 # define __lzo_forceinline /*empty*/
2067 #if !defined(__lzo_noinline)
2068 # define __lzo_noinline /*empty*/
2072 # undef __acc_likely
2073 # undef __acc_unlikely
2074 # undef __lzo_likely
2075 # undef __lzo_unlikely
2076 # define __acc_likely(e) (e)
2077 # define __acc_unlikely(e) (e)
2078 # define __lzo_likely(e) (e)
2079 # define __lzo_unlikely(e) (e)
2083 # define LZO_BYTE(x) ((unsigned char) (x))
2085 # define LZO_BYTE(x) ((unsigned char) ((x) & 0xff))
2088 #define LZO_MAX(a,b) ((a) >= (b) ? (a) : (b))
2089 #define LZO_MIN(a,b) ((a) <= (b) ? (a) : (b))
2090 #define LZO_MAX3(a,b,c) ((a) >= (b) ? LZO_MAX(a,c) : LZO_MAX(b,c))
2091 #define LZO_MIN3(a,b,c) ((a) <= (b) ? LZO_MIN(a,c) : LZO_MIN(b,c))
2093 #define lzo_sizeof(type) ((lzo_uint) (sizeof(type)))
2095 #define LZO_HIGH(array) ((lzo_uint) (sizeof(array)/sizeof(*(array))))
2097 #define LZO_SIZE(bits) (1u << (bits))
2098 #define LZO_MASK(bits) (LZO_SIZE(bits) - 1)
2100 #define LZO_LSIZE(bits) (1ul << (bits))
2101 #define LZO_LMASK(bits) (LZO_LSIZE(bits) - 1)
2103 #define LZO_USIZE(bits) ((lzo_uint) 1 << (bits))
2104 #define LZO_UMASK(bits) (LZO_USIZE(bits) - 1)
2109 # define DMUL(a,b) ((lzo_xint) ((lzo_uint32)(a) * (lzo_uint32)(b)))
2111 # define DMUL(a,b) ((lzo_xint) ((a) * (b)))
2115 #if 1 && (LZO_ARCH_AMD64 || LZO_ARCH_I386 || LZO_ARCH_POWERPC)
2116 # if (LZO_SIZEOF_SHORT == 2)
2117 # define LZO_UNALIGNED_OK_2 1
2119 # if (LZO_SIZEOF_INT == 4)
2120 # define LZO_UNALIGNED_OK_4 1
2123 #if 1 && (LZO_ARCH_AMD64)
2124 # if defined(LZO_UINT64_MAX)
2125 # define LZO_UNALIGNED_OK_8 1
2128 #if (LZO_CFG_NO_UNALIGNED)
2129 # undef LZO_UNALIGNED_OK_2
2130 # undef LZO_UNALIGNED_OK_4
2131 # undef LZO_UNALIGNED_OK_8
2143 #if defined(LZO_UNALIGNED_OK_2)
2144 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(unsigned short) == 2)
2145 # if 1 && defined(ACC_UA_COPY16)
2146 # define UA_GET16 ACC_UA_GET16
2147 # define UA_SET16 ACC_UA_SET16
2148 # define UA_COPY16 ACC_UA_COPY16
2150 # define UA_GET16(p) (* (__lzo_ua_volatile const lzo_ushortp) (__lzo_ua_volatile const lzo_voidp) (p))
2151 # define UA_SET16(p,v) ((* (__lzo_ua_volatile lzo_ushortp) (__lzo_ua_volatile lzo_voidp) (p)) = (unsigned short) (v))
2152 # define UA_COPY16(d,s) UA_SET16(d, UA_GET16(s))
2155 #if defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
2156 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint32
) == 4)
2157 # if 1 && defined(ACC_UA_COPY32)
2158 # define UA_GET32 ACC_UA_GET32
2159 # define UA_SET32 ACC_UA_SET32
2160 # define UA_COPY32 ACC_UA_COPY32
2162 # define UA_GET32(p) (* (__lzo_ua_volatile const lzo_uint32p) (__lzo_ua_volatile const lzo_voidp) (p))
2163 # define UA_SET32(p,v) ((* (__lzo_ua_volatile lzo_uint32p) (__lzo_ua_volatile lzo_voidp) (p)) = (lzo_uint32) (v))
2164 # define UA_COPY32(d,s) UA_SET32(d, UA_GET32(s))
2167 #if defined(LZO_UNALIGNED_OK_8)
2168 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint64
) == 8)
2169 # if 1 && defined(ACC_UA_COPY64)
2170 # define UA_GET64 ACC_UA_GET64
2171 # define UA_SET64 ACC_UA_SET64
2172 # define UA_COPY64 ACC_UA_COPY64
2174 # define UA_GET64(p) (* (__lzo_ua_volatile const lzo_uint64p) (__lzo_ua_volatile const lzo_voidp) (p))
2175 # define UA_SET64(p,v) ((* (__lzo_ua_volatile lzo_uint64p) (__lzo_ua_volatile lzo_voidp) (p)) = (lzo_uint64) (v))
2176 # define UA_COPY64(d,s) UA_SET64(d, UA_GET64(s))
2180 #define MEMCPY8_DS(dest,src,len) \
2181 lzo_memcpy(dest,src,len); dest += len; src += len
2183 #define BZERO8_PTR(s,l,n) \
2184 lzo_memset((lzo_voidp)(s),0,(lzo_uint)(l)*(n))
2186 #define MEMCPY_DS(dest,src,len) \
2187 do *dest++ = *src++; while (--len > 0)
2189 LZO_EXTERN(const lzo_bytep
) lzo_copyright(void);
2192 #define __LZO_PTR_H 1
2198 #if !defined(lzo_uintptr_t)
2199 # if (__LZO_MMODEL_HUGE)
2200 # define lzo_uintptr_t unsigned long
2202 # define lzo_uintptr_t acc_uintptr_t
2203 # ifdef __ACC_INTPTR_T_IS_POINTER
2204 # define __LZO_UINTPTR_T_IS_POINTER 1
2210 #define PTR(a) ((lzo_bytep) (a))
2211 #define PTR_ALIGNED_4(a) ((ACC_PTR_FP_OFF(a) & 3) == 0)
2212 #define PTR_ALIGNED2_4(a,b) (((ACC_PTR_FP_OFF(a) | ACC_PTR_FP_OFF(b)) & 3) == 0)
2214 #define PTR(a) ((lzo_bytep) (a))
2215 #define PTR_ALIGNED_8(a) ((((lzo_uintptr_t)(a)) >> 61) == 0)
2216 #define PTR_ALIGNED2_8(a,b) ((((lzo_uintptr_t)(a)|(lzo_uintptr_t)(b)) >> 61) == 0)
2218 #define PTR(a) ((lzo_uintptr_t) (a))
2219 #define PTR_LINEAR(a) PTR(a)
2220 #define PTR_ALIGNED_4(a) ((PTR_LINEAR(a) & 3) == 0)
2221 #define PTR_ALIGNED_8(a) ((PTR_LINEAR(a) & 7) == 0)
2222 #define PTR_ALIGNED2_4(a,b) (((PTR_LINEAR(a) | PTR_LINEAR(b)) & 3) == 0)
2223 #define PTR_ALIGNED2_8(a,b) (((PTR_LINEAR(a) | PTR_LINEAR(b)) & 7) == 0)
2226 #define PTR_LT(a,b) (PTR(a) < PTR(b))
2227 #define PTR_GE(a,b) (PTR(a) >= PTR(b))
2228 #define PTR_DIFF(a,b) (PTR(a) - PTR(b))
2229 #define pd(a,b) ((lzo_uint) ((a)-(b)))
2231 LZO_EXTERN(lzo_uintptr_t
)
2232 __lzo_ptr_linear(const lzo_voidp ptr
);
2237 unsigned char a_uchar
;
2239 unsigned short a_ushort
;
2241 unsigned int a_uint
;
2243 unsigned long a_ulong
;
2245 lzo_uint a_lzo_uint
;
2246 lzo_int32 a_lzo_int32
;
2247 lzo_uint32 a_lzo_uint32
;
2248 #if defined(LZO_UINT64_MAX)
2249 lzo_int64 a_lzo_int64
;
2250 lzo_uint64 a_lzo_uint64
;
2252 ptrdiff_t a_ptrdiff_t
;
2253 lzo_uintptr_t a_lzo_uintptr_t
;
2254 lzo_voidp a_lzo_voidp
;
2256 lzo_bytep a_lzo_bytep
;
2257 lzo_bytepp a_lzo_bytepp
;
2258 lzo_uintp a_lzo_uintp
;
2259 lzo_uint
* a_lzo_uint_p
;
2260 lzo_uint32p a_lzo_uint32p
;
2261 lzo_uint32
* a_lzo_uint32_p
;
2262 unsigned char * a_uchar_p
;
2273 #ifndef LZO_DETERMINISTIC
2274 #define LZO_DETERMINISTIC 1
2277 #ifndef LZO_DICT_USE_PTR
2278 #define LZO_DICT_USE_PTR 1
2279 #if 0 && (LZO_ARCH_I086)
2280 # undef LZO_DICT_USE_PTR
2281 # define LZO_DICT_USE_PTR 0
2285 #if (LZO_DICT_USE_PTR)
2286 # define lzo_dict_t const lzo_bytep
2287 # define lzo_dict_p lzo_dict_t __LZO_MMODEL *
2289 # define lzo_dict_t lzo_uint
2290 # define lzo_dict_p lzo_dict_t __LZO_MMODEL *
2295 #if !defined(MINILZO_CFG_SKIP_LZO_PTR)
2297 LZO_PUBLIC(lzo_uintptr_t
)
2298 __lzo_ptr_linear(const lzo_voidp ptr
)
2303 p
= (((lzo_uintptr_t
)(ACC_PTR_FP_SEG(ptr
))) << (16 - ACC_MM_AHSHIFT
)) + (ACC_PTR_FP_OFF(ptr
));
2305 p
= (lzo_uintptr_t
) (ptr
);
2306 p
= (p
<< 3) | (p
>> 61);
2308 p
= (lzo_uintptr_t
) PTR_LINEAR(ptr
);
2314 LZO_PUBLIC(unsigned)
2315 __lzo_align_gap(const lzo_voidp ptr
, lzo_uint size
)
2317 #if defined(__LZO_UINTPTR_T_IS_POINTER)
2318 size_t n
= (size_t) ptr
;
2319 n
= (((n
+ size
- 1) / size
) * size
) - n
;
2322 p
= __lzo_ptr_linear(ptr
);
2323 n
= (((p
+ size
- 1) / size
) * size
) - p
;
2327 assert((long)n
>= 0);
2333 #if !defined(MINILZO_CFG_SKIP_LZO_UTIL)
2335 /* If you use the LZO library in a product, I would appreciate that you
2336 * keep this copyright string in the executable of your product.
2339 static const char __lzo_copyright
[] =
2340 #if !defined(__LZO_IN_MINLZO)
2344 "LZO data compression library.\n"
2345 "$Copyright: LZO Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer\n"
2346 "<markus@oberhumer.com>\n"
2347 "http://www.oberhumer.com $\n\n"
2349 "$Info: " LZO_INFO_STRING
" $\n";
2352 LZO_PUBLIC(const lzo_bytep
)
2355 #if (LZO_OS_DOS16 && LZO_CC_TURBOC)
2356 return (lzo_voidp
) __lzo_copyright
;
2358 return (const lzo_bytep
) __lzo_copyright
;
2362 LZO_PUBLIC(unsigned)
2368 LZO_PUBLIC(const char *)
2369 lzo_version_string(void)
2371 return LZO_VERSION_STRING
;
2374 LZO_PUBLIC(const char *)
2375 lzo_version_date(void)
2377 return LZO_VERSION_DATE
;
2380 LZO_PUBLIC(const lzo_charp
)
2381 _lzo_version_string(void)
2383 return LZO_VERSION_STRING
;
2386 LZO_PUBLIC(const lzo_charp
)
2387 _lzo_version_date(void)
2389 return LZO_VERSION_DATE
;
2392 #define LZO_BASE 65521u
2393 #define LZO_NMAX 5552
2395 #define LZO_DO1(buf,i) s1 += buf[i]; s2 += s1
2396 #define LZO_DO2(buf,i) LZO_DO1(buf,i); LZO_DO1(buf,i+1);
2397 #define LZO_DO4(buf,i) LZO_DO2(buf,i); LZO_DO2(buf,i+2);
2398 #define LZO_DO8(buf,i) LZO_DO4(buf,i); LZO_DO4(buf,i+4);
2399 #define LZO_DO16(buf,i) LZO_DO8(buf,i); LZO_DO8(buf,i+8);
2401 LZO_PUBLIC(lzo_uint32
)
2402 lzo_adler32(lzo_uint32 adler
, const lzo_bytep buf
, lzo_uint len
)
2404 lzo_uint32 s1
= adler
& 0xffff;
2405 lzo_uint32 s2
= (adler
>> 16) & 0xffff;
2413 k
= len
< LZO_NMAX
? (unsigned) len
: LZO_NMAX
;
2429 return (s2
<< 16) | s1
;
2439 #if !defined(MINILZO_CFG_SKIP_LZO_STRING)
2444 #if !defined(__LZO_MMODEL_HUGE)
2445 # undef LZO_HAVE_MM_HUGE_PTR
2447 #define lzo_hsize_t lzo_uint
2448 #define lzo_hvoid_p lzo_voidp
2449 #define lzo_hbyte_p lzo_bytep
2450 #define LZOLIB_PUBLIC(r,f) LZO_PUBLIC(r) f
2451 #define lzo_hmemcmp lzo_memcmp
2452 #define lzo_hmemcpy lzo_memcpy
2453 #define lzo_hmemmove lzo_memmove
2454 #define lzo_hmemset lzo_memset
2455 #define __LZOLIB_HMEMCPY_CH_INCLUDED 1
2456 #if !defined(LZOLIB_PUBLIC)
2457 # define LZOLIB_PUBLIC(r,f) r __LZOLIB_FUNCNAME(f)
2459 LZOLIB_PUBLIC(int, lzo_hmemcmp
) (const lzo_hvoid_p s1
, const lzo_hvoid_p s2
, lzo_hsize_t len
)
2461 #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMCMP)
2462 const lzo_hbyte_p p1
= (const lzo_hbyte_p
) s1
;
2463 const lzo_hbyte_p p2
= (const lzo_hbyte_p
) s2
;
2464 if __lzo_likely(len
> 0) do
2470 } while __lzo_likely(--len
> 0);
2473 return memcmp(s1
, s2
, len
);
2476 LZOLIB_PUBLIC(lzo_hvoid_p
, lzo_hmemcpy
) (lzo_hvoid_p dest
, const lzo_hvoid_p src
, lzo_hsize_t len
)
2478 #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMCPY)
2479 lzo_hbyte_p p1
= (lzo_hbyte_p
) dest
;
2480 const lzo_hbyte_p p2
= (const lzo_hbyte_p
) src
;
2481 if (!(len
> 0) || p1
== p2
)
2485 while __lzo_likely(--len
> 0);
2488 return memcpy(dest
, src
, len
);
2491 LZOLIB_PUBLIC(lzo_hvoid_p
, lzo_hmemmove
) (lzo_hvoid_p dest
, const lzo_hvoid_p src
, lzo_hsize_t len
)
2493 #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMMOVE)
2494 lzo_hbyte_p p1
= (lzo_hbyte_p
) dest
;
2495 const lzo_hbyte_p p2
= (const lzo_hbyte_p
) src
;
2496 if (!(len
> 0) || p1
== p2
)
2502 while __lzo_likely(--len
> 0);
2510 while __lzo_likely(--len
> 0);
2514 return memmove(dest
, src
, len
);
2517 LZOLIB_PUBLIC(lzo_hvoid_p
, lzo_hmemset
) (lzo_hvoid_p s
, int c
, lzo_hsize_t len
)
2519 #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMSET)
2520 lzo_hbyte_p p
= (lzo_hbyte_p
) s
;
2521 if __lzo_likely(len
> 0) do
2522 *p
++ = (unsigned char) c
;
2523 while __lzo_likely(--len
> 0);
2526 return memset(s
, c
, len
);
2529 #undef LZOLIB_PUBLIC
2531 #if !defined(MINILZO_CFG_SKIP_LZO_INIT)
2533 #if !defined(__LZO_IN_MINILZO)
2535 #define ACC_WANT_ACC_CHK_CH 1
2536 #undef ACCCHK_ASSERT
2538 ACCCHK_ASSERT_IS_SIGNED_T(lzo_int
)
2539 ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uint
)
2541 ACCCHK_ASSERT_IS_SIGNED_T(lzo_int32
)
2542 ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uint32
)
2543 ACCCHK_ASSERT((LZO_UINT32_C(1) << (int)(8*sizeof(LZO_UINT32_C(1))-1)) > 0)
2544 ACCCHK_ASSERT(sizeof(lzo_uint32
) >= 4)
2545 #if defined(LZO_UINT64_MAX)
2546 ACCCHK_ASSERT(sizeof(lzo_uint64
) == 8)
2547 ACCCHK_ASSERT_IS_SIGNED_T(lzo_int64
)
2548 ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uint64
)
2551 #if !defined(__LZO_UINTPTR_T_IS_POINTER)
2552 ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uintptr_t
)
2554 ACCCHK_ASSERT(sizeof(lzo_uintptr_t
) >= sizeof(lzo_voidp
))
2556 ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_xint
)
2557 ACCCHK_ASSERT(sizeof(lzo_xint
) >= sizeof(lzo_uint32
))
2558 ACCCHK_ASSERT(sizeof(lzo_xint
) >= sizeof(lzo_uint
))
2559 ACCCHK_ASSERT(sizeof(lzo_xint
) == sizeof(lzo_uint32
) || sizeof(lzo_xint
) == sizeof(lzo_uint
))
2562 #undef ACCCHK_ASSERT
2565 #define WANT_lzo_bitops_clz32 1
2566 #define WANT_lzo_bitops_clz64 1
2568 #define WANT_lzo_bitops_ctz32 1
2569 #define WANT_lzo_bitops_ctz64 1
2571 #if (defined(_WIN32) || defined(_WIN64)) && ((LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || (LZO_CC_MSC && (_MSC_VER >= 1400)))
2573 #if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32) && 0
2574 #pragma intrinsic(_BitScanReverse)
2575 static __lzo_inline
unsigned lzo_bitops_clz32(lzo_uint32 v
)
2578 (void) _BitScanReverse(&r
, v
);
2579 return (unsigned) r
;
2581 #define lzo_bitops_clz32 lzo_bitops_clz32
2583 #if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX) && 0
2584 #pragma intrinsic(_BitScanReverse64)
2585 static __lzo_inline
unsigned lzo_bitops_clz64(lzo_uint64 v
)
2588 (void) _BitScanReverse64(&r
, v
);
2589 return (unsigned) r
;
2591 #define lzo_bitops_clz64 lzo_bitops_clz64
2593 #if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32)
2594 #pragma intrinsic(_BitScanForward)
2595 static __lzo_inline
unsigned lzo_bitops_ctz32(lzo_uint32 v
)
2598 (void) _BitScanForward(&r
, v
);
2599 return (unsigned) r
;
2601 #define lzo_bitops_ctz32 lzo_bitops_ctz32
2603 #if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX)
2604 #pragma intrinsic(_BitScanForward64)
2605 static __lzo_inline
unsigned lzo_bitops_ctz64(lzo_uint64 v
)
2608 (void) _BitScanForward64(&r
, v
);
2609 return (unsigned) r
;
2611 #define lzo_bitops_ctz64 lzo_bitops_ctz64
2614 #elif (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x030400ul) || (LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || LZO_CC_LLVM)
2615 #if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32)
2616 #define lzo_bitops_clz32(v) ((unsigned) __builtin_clz(v))
2618 #if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX)
2619 #define lzo_bitops_clz64(v) ((unsigned) __builtin_clzll(v))
2621 #if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32)
2622 #define lzo_bitops_ctz32(v) ((unsigned) __builtin_ctz(v))
2624 #if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX)
2625 #define lzo_bitops_ctz64(v) ((unsigned) __builtin_ctzll(v))
2627 #if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount32)
2628 #define lzo_bitops_popcount32(v) ((unsigned) __builtin_popcount(v))
2630 #if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount64) && defined(LZO_UINT64_MAX)
2631 #define lzo_bitops_popcount64(v) ((unsigned) __builtin_popcountll(v))
2636 #define u2p(ptr,off) ((lzo_voidp) (((lzo_bytep)(lzo_voidp)(ptr)) + (off)))
2638 static __lzo_noinline lzo_voidp
u2p(lzo_voidp ptr
, lzo_uint off
)
2640 return (lzo_voidp
) ((lzo_bytep
) ptr
+ off
);
2645 _lzo_config_check(void)
2649 lzo_xint a
[2]; unsigned char b
[2*LZO_MAX(8,sizeof(lzo_xint
))];
2650 #if defined(LZO_UNALIGNED_OK_8)
2653 unsigned short x
[2]; lzo_uint32 y
[2]; lzo_uint z
[2];
2657 u
.a
[0] = u
.a
[1] = 0;
2659 r
&= ((* (lzo_bytep
) p
) == 0);
2660 #if !defined(LZO_CFG_NO_CONFIG_CHECK)
2661 #if defined(LZO_ABI_BIG_ENDIAN)
2662 u
.a
[0] = u
.a
[1] = 0; u
.b
[sizeof(lzo_uint
) - 1] = 128;
2664 r
&= ((* (lzo_uintp
) p
) == 128);
2666 #if defined(LZO_ABI_LITTLE_ENDIAN)
2667 u
.a
[0] = u
.a
[1] = 0; u
.b
[0] = 128;
2669 r
&= ((* (lzo_uintp
) p
) == 128);
2671 #if defined(LZO_UNALIGNED_OK_2)
2672 u
.a
[0] = u
.a
[1] = 0;
2673 u
.b
[0] = 1; u
.b
[sizeof(unsigned short) + 1] = 2;
2675 r
&= ((* (lzo_ushortp
) p
) == 0);
2677 #if defined(LZO_UNALIGNED_OK_4)
2678 u
.a
[0] = u
.a
[1] = 0;
2679 u
.b
[0] = 3; u
.b
[sizeof(lzo_uint32
) + 1] = 4;
2681 r
&= ((* (lzo_uint32p
) p
) == 0);
2683 #if defined(LZO_UNALIGNED_OK_8)
2684 u
.c
[0] = u
.c
[1] = 0;
2685 u
.b
[0] = 5; u
.b
[sizeof(lzo_uint64
) + 1] = 6;
2687 r
&= ((* (lzo_uint64p
) p
) == 0);
2689 #if defined(lzo_bitops_clz32)
2690 { unsigned i
; lzo_uint32 v
= 1;
2691 for (i
= 0; i
< 31; i
++, v
<<= 1)
2692 r
&= lzo_bitops_clz32(v
) == 31 - i
;
2695 #if defined(lzo_bitops_clz64)
2696 { unsigned i
; lzo_uint64 v
= 1;
2697 for (i
= 0; i
< 63; i
++, v
<<= 1)
2698 r
&= lzo_bitops_clz64(v
) == 63 - i
;
2701 #if defined(lzo_bitops_ctz32)
2702 { unsigned i
; lzo_uint32 v
= 1;
2703 for (i
= 0; i
< 31; i
++, v
<<= 1)
2704 r
&= lzo_bitops_ctz32(v
) == i
;
2707 #if defined(lzo_bitops_ctz64)
2708 { unsigned i
; lzo_uint64 v
= 1;
2709 for (i
= 0; i
< 63; i
++, v
<<= 1)
2710 r
&= lzo_bitops_ctz64(v
) == i
;
2715 return r
== 1 ? LZO_E_OK
: LZO_E_ERROR
;
2719 __lzo_init_v2(unsigned v
, int s1
, int s2
, int s3
, int s4
, int s5
,
2720 int s6
, int s7
, int s8
, int s9
)
2724 #if defined(__LZO_IN_MINILZO)
2725 #elif (LZO_CC_MSC && ((_MSC_VER) < 700))
2727 #define ACC_WANT_ACC_CHK_CH 1
2728 #undef ACCCHK_ASSERT
2729 #define ACCCHK_ASSERT(expr) LZO_COMPILE_TIME_ASSERT(expr)
2731 #undef ACCCHK_ASSERT
2736 r
= (s1
== -1 || s1
== (int) sizeof(short)) &&
2737 (s2
== -1 || s2
== (int) sizeof(int)) &&
2738 (s3
== -1 || s3
== (int) sizeof(long)) &&
2739 (s4
== -1 || s4
== (int) sizeof(lzo_uint32
)) &&
2740 (s5
== -1 || s5
== (int) sizeof(lzo_uint
)) &&
2741 (s6
== -1 || s6
== (int) lzo_sizeof_dict_t
) &&
2742 (s7
== -1 || s7
== (int) sizeof(char *)) &&
2743 (s8
== -1 || s8
== (int) sizeof(lzo_voidp
)) &&
2744 (s9
== -1 || s9
== (int) sizeof(lzo_callback_t
));
2748 r
= _lzo_config_check();
2755 #if !defined(__LZO_IN_MINILZO)
2757 #if (LZO_OS_WIN16 && LZO_CC_WATCOMC) && defined(__SW_BD)
2760 BOOL FAR PASCAL
LibMain ( HANDLE hInstance
, WORD wDataSegment
,
2761 WORD wHeapSize
, LPSTR lpszCmdLine
)
2763 int __far __pascal
LibMain ( int a
, short b
, short c
, long d
)
2766 LZO_UNUSED(a
); LZO_UNUSED(b
); LZO_UNUSED(c
); LZO_UNUSED(d
);
2777 #define LZO_EOF_CODE 1
2778 #define M2_MAX_OFFSET 0x0800
2780 #if !defined(MINILZO_CFG_SKIP_LZO1X_1_COMPRESS)
2782 #if 1 && defined(UA_GET32)
2783 #undef LZO_DICT_USE_PTR
2784 #define LZO_DICT_USE_PTR 0
2786 #define lzo_dict_t unsigned short
2789 #define LZO_NEED_DICT_H 1
2793 #define D_INDEX1(d,p) d = DM(DMUL(0x21,DX3(p,5,5,6)) >> 5)
2794 #define D_INDEX2(d,p) d = (d & (D_MASK & 0x7ff)) ^ (D_HIGH | 0x1f)
2796 #define DINDEX(dv,p) DM(((DMUL(0x1824429d,dv)) >> (32-D_BITS)))
2798 #define DINDEX(dv,p) DM((dv) + ((dv) >> (32-D_BITS)))
2801 #ifndef __LZO_CONFIG1X_H
2802 #define __LZO_CONFIG1X_H 1
2804 #if !defined(LZO1X) && !defined(LZO1Y) && !defined(LZO1Z)
2808 #if !defined(__LZO_IN_MINILZO)
2809 #include "lzo/lzo1x.h"
2812 #ifndef LZO_EOF_CODE
2813 #define LZO_EOF_CODE 1
2815 #undef LZO_DETERMINISTIC
2817 #define M1_MAX_OFFSET 0x0400
2818 #ifndef M2_MAX_OFFSET
2819 #define M2_MAX_OFFSET 0x0800
2821 #define M3_MAX_OFFSET 0x4000
2822 #define M4_MAX_OFFSET 0xbfff
2824 #define MX_MAX_OFFSET (M1_MAX_OFFSET + M2_MAX_OFFSET)
2826 #define M1_MIN_LEN 2
2827 #define M1_MAX_LEN 2
2828 #define M2_MIN_LEN 3
2830 #define M2_MAX_LEN 8
2832 #define M3_MIN_LEN 3
2833 #define M3_MAX_LEN 33
2834 #define M4_MIN_LEN 3
2835 #define M4_MAX_LEN 9
2838 #define M2_MARKER 64
2839 #define M3_MARKER 32
2840 #define M4_MARKER 16
2842 #ifndef MIN_LOOKAHEAD
2843 #define MIN_LOOKAHEAD (M2_MAX_LEN + 1)
2846 #if defined(LZO_NEED_DICT_H)
2849 #define LZO_HASH LZO_HASH_LZO_INCREMENTAL_B
2851 #define DL_MIN_LEN M2_MIN_LEN
2853 #ifndef __LZO_DICT_H
2854 #define __LZO_DICT_H 1
2860 #if !defined(D_BITS) && defined(DBITS)
2861 # define D_BITS DBITS
2863 #if !defined(D_BITS)
2864 # error "D_BITS is not defined"
2867 # define D_SIZE LZO_SIZE(D_BITS)
2868 # define D_MASK LZO_MASK(D_BITS)
2870 # define D_SIZE LZO_USIZE(D_BITS)
2871 # define D_MASK LZO_UMASK(D_BITS)
2873 #define D_HIGH ((D_MASK >> 1) + 1)
2875 #if !defined(DD_BITS)
2878 #define DD_SIZE LZO_SIZE(DD_BITS)
2879 #define DD_MASK LZO_MASK(DD_BITS)
2881 #if !defined(DL_BITS)
2882 # define DL_BITS (D_BITS - DD_BITS)
2885 # define DL_SIZE LZO_SIZE(DL_BITS)
2886 # define DL_MASK LZO_MASK(DL_BITS)
2888 # define DL_SIZE LZO_USIZE(DL_BITS)
2889 # define DL_MASK LZO_UMASK(DL_BITS)
2892 #if (D_BITS != DL_BITS + DD_BITS)
2893 # error "D_BITS does not match"
2895 #if (D_BITS < 6 || D_BITS > 18)
2896 # error "invalid D_BITS"
2898 #if (DL_BITS < 6 || DL_BITS > 20)
2899 # error "invalid DL_BITS"
2901 #if (DD_BITS < 0 || DD_BITS > 6)
2902 # error "invalid DD_BITS"
2905 #if !defined(DL_MIN_LEN)
2906 # define DL_MIN_LEN 3
2908 #if !defined(DL_SHIFT)
2909 # define DL_SHIFT ((DL_BITS + (DL_MIN_LEN - 1)) / DL_MIN_LEN)
2912 #define LZO_HASH_GZIP 1
2913 #define LZO_HASH_GZIP_INCREMENTAL 2
2914 #define LZO_HASH_LZO_INCREMENTAL_A 3
2915 #define LZO_HASH_LZO_INCREMENTAL_B 4
2917 #if !defined(LZO_HASH)
2918 # error "choose a hashing strategy"
2924 #if (DL_MIN_LEN == 3)
2925 # define _DV2_A(p,shift1,shift2) \
2926 (((( (lzo_xint)((p)[0]) << shift1) ^ (p)[1]) << shift2) ^ (p)[2])
2927 # define _DV2_B(p,shift1,shift2) \
2928 (((( (lzo_xint)((p)[2]) << shift1) ^ (p)[1]) << shift2) ^ (p)[0])
2929 # define _DV3_B(p,shift1,shift2,shift3) \
2930 ((_DV2_B((p)+1,shift1,shift2) << (shift3)) ^ (p)[0])
2931 #elif (DL_MIN_LEN == 2)
2932 # define _DV2_A(p,shift1,shift2) \
2933 (( (lzo_xint)(p[0]) << shift1) ^ p[1])
2934 # define _DV2_B(p,shift1,shift2) \
2935 (( (lzo_xint)(p[1]) << shift1) ^ p[2])
2937 # error "invalid DL_MIN_LEN"
2939 #define _DV_A(p,shift) _DV2_A(p,shift,shift)
2940 #define _DV_B(p,shift) _DV2_B(p,shift,shift)
2941 #define DA2(p,s1,s2) \
2942 (((((lzo_xint)((p)[2]) << (s2)) + (p)[1]) << (s1)) + (p)[0])
2943 #define DS2(p,s1,s2) \
2944 (((((lzo_xint)((p)[2]) << (s2)) - (p)[1]) << (s1)) - (p)[0])
2945 #define DX2(p,s1,s2) \
2946 (((((lzo_xint)((p)[2]) << (s2)) ^ (p)[1]) << (s1)) ^ (p)[0])
2947 #define DA3(p,s1,s2,s3) ((DA2((p)+1,s2,s3) << (s1)) + (p)[0])
2948 #define DS3(p,s1,s2,s3) ((DS2((p)+1,s2,s3) << (s1)) - (p)[0])
2949 #define DX3(p,s1,s2,s3) ((DX2((p)+1,s2,s3) << (s1)) ^ (p)[0])
2950 #define DMS(v,s) ((lzo_uint) (((v) & (D_MASK >> (s))) << (s)))
2951 #define DM(v) DMS(v,0)
2953 #if (LZO_HASH == LZO_HASH_GZIP)
2954 # define _DINDEX(dv,p) (_DV_A((p),DL_SHIFT))
2956 #elif (LZO_HASH == LZO_HASH_GZIP_INCREMENTAL)
2957 # define __LZO_HASH_INCREMENTAL 1
2958 # define DVAL_FIRST(dv,p) dv = _DV_A((p),DL_SHIFT)
2959 # define DVAL_NEXT(dv,p) dv = (((dv) << DL_SHIFT) ^ p[2])
2960 # define _DINDEX(dv,p) (dv)
2961 # define DVAL_LOOKAHEAD DL_MIN_LEN
2963 #elif (LZO_HASH == LZO_HASH_LZO_INCREMENTAL_A)
2964 # define __LZO_HASH_INCREMENTAL 1
2965 # define DVAL_FIRST(dv,p) dv = _DV_A((p),5)
2966 # define DVAL_NEXT(dv,p) \
2967 dv ^= (lzo_xint)(p[-1]) << (2*5); dv = (((dv) << 5) ^ p[2])
2968 # define _DINDEX(dv,p) ((DMUL(0x9f5f,dv)) >> 5)
2969 # define DVAL_LOOKAHEAD DL_MIN_LEN
2971 #elif (LZO_HASH == LZO_HASH_LZO_INCREMENTAL_B)
2972 # define __LZO_HASH_INCREMENTAL 1
2973 # define DVAL_FIRST(dv,p) dv = _DV_B((p),5)
2974 # define DVAL_NEXT(dv,p) \
2975 dv ^= p[-1]; dv = (((dv) >> 5) ^ ((lzo_xint)(p[2]) << (2*5)))
2976 # define _DINDEX(dv,p) ((DMUL(0x9f5f,dv)) >> 5)
2977 # define DVAL_LOOKAHEAD DL_MIN_LEN
2980 # error "choose a hashing strategy"
2984 #define DINDEX(dv,p) ((lzo_uint)((_DINDEX(dv,p)) & DL_MASK) << DD_BITS)
2986 #if !defined(DINDEX1) && defined(D_INDEX1)
2987 #define DINDEX1 D_INDEX1
2989 #if !defined(DINDEX2) && defined(D_INDEX2)
2990 #define DINDEX2 D_INDEX2
2993 #if !defined(__LZO_HASH_INCREMENTAL)
2994 # define DVAL_FIRST(dv,p) ((void) 0)
2995 # define DVAL_NEXT(dv,p) ((void) 0)
2996 # define DVAL_LOOKAHEAD 0
2999 #if !defined(DVAL_ASSERT)
3000 #if defined(__LZO_HASH_INCREMENTAL) && !defined(NDEBUG)
3001 #if (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x020700ul) || LZO_CC_LLVM)
3002 static void __attribute__((__unused__
))
3006 DVAL_ASSERT(lzo_xint dv
, const lzo_bytep p
)
3010 assert(DINDEX(dv
,p
) == DINDEX(df
,p
));
3013 # define DVAL_ASSERT(dv,p) ((void) 0)
3017 #if (LZO_DICT_USE_PTR)
3018 # define DENTRY(p,in) (p)
3019 # define GINDEX(m_pos,m_off,dict,dindex,in) m_pos = dict[dindex]
3021 # define DENTRY(p,in) ((lzo_dict_t) pd(p, in))
3022 # define GINDEX(m_pos,m_off,dict,dindex,in) m_off = dict[dindex]
3027 # define UPDATE_D(dict,drun,dv,p,in) dict[ DINDEX(dv,p) ] = DENTRY(p,in)
3028 # define UPDATE_I(dict,drun,index,p,in) dict[index] = DENTRY(p,in)
3029 # define UPDATE_P(ptr,drun,p,in) (ptr)[0] = DENTRY(p,in)
3033 # define UPDATE_D(dict,drun,dv,p,in) \
3034 dict[ DINDEX(dv,p) + drun++ ] = DENTRY(p,in); drun &= DD_MASK
3035 # define UPDATE_I(dict,drun,index,p,in) \
3036 dict[ (index) + drun++ ] = DENTRY(p,in); drun &= DD_MASK
3037 # define UPDATE_P(ptr,drun,p,in) \
3038 (ptr) [ drun++ ] = DENTRY(p,in); drun &= DD_MASK
3042 #if (LZO_DICT_USE_PTR)
3044 #define LZO_CHECK_MPOS_DET(m_pos,m_off,in,ip,max_offset) \
3045 (m_pos == NULL || (m_off = pd(ip, m_pos)) > max_offset)
3047 #define LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,max_offset) \
3048 (BOUNDS_CHECKING_OFF_IN_EXPR(( \
3049 m_pos = ip - (lzo_uint) PTR_DIFF(ip,m_pos), \
3050 PTR_LT(m_pos,in) || \
3051 (m_off = (lzo_uint) PTR_DIFF(ip,m_pos)) == 0 || \
3052 m_off > max_offset )))
3056 #define LZO_CHECK_MPOS_DET(m_pos,m_off,in,ip,max_offset) \
3058 ((m_off = pd(ip, in) - m_off) > max_offset) || \
3059 (m_pos = (ip) - (m_off), 0) )
3061 #define LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,max_offset) \
3062 (pd(ip, in) <= m_off || \
3063 ((m_off = pd(ip, in) - m_off) > max_offset) || \
3064 (m_pos = (ip) - (m_off), 0) )
3068 #if (LZO_DETERMINISTIC)
3069 # define LZO_CHECK_MPOS LZO_CHECK_MPOS_DET
3071 # define LZO_CHECK_MPOS LZO_CHECK_MPOS_NON_DET
3084 #define LZO_DETERMINISTIC !(LZO_DICT_USE_PTR)
3087 #define DO_COMPRESS lzo1x_1_compress
3090 #if 1 && defined(DO_COMPRESS) && !defined(do_compress)
3091 # define do_compress LZO_CPP_ECONCAT2(DO_COMPRESS,_core)
3094 #if defined(UA_GET64)
3095 # define WANT_lzo_bitops_ctz64 1
3096 #elif defined(UA_GET32)
3097 # define WANT_lzo_bitops_ctz32 1
3100 #if (defined(_WIN32) || defined(_WIN64)) && ((LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || (LZO_CC_MSC && (_MSC_VER >= 1400)))
3102 #if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32) && 0
3103 #pragma intrinsic(_BitScanReverse)
3104 static __lzo_inline
unsigned lzo_bitops_clz32(lzo_uint32 v
)
3107 (void) _BitScanReverse(&r
, v
);
3108 return (unsigned) r
;
3110 #define lzo_bitops_clz32 lzo_bitops_clz32
3112 #if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX) && 0
3113 #pragma intrinsic(_BitScanReverse64)
3114 static __lzo_inline
unsigned lzo_bitops_clz64(lzo_uint64 v
)
3117 (void) _BitScanReverse64(&r
, v
);
3118 return (unsigned) r
;
3120 #define lzo_bitops_clz64 lzo_bitops_clz64
3122 #if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32)
3123 #pragma intrinsic(_BitScanForward)
3124 static __lzo_inline
unsigned lzo_bitops_ctz32(lzo_uint32 v
)
3127 (void) _BitScanForward(&r
, v
);
3128 return (unsigned) r
;
3130 #define lzo_bitops_ctz32 lzo_bitops_ctz32
3132 #if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX)
3133 #pragma intrinsic(_BitScanForward64)
3134 static __lzo_inline
unsigned lzo_bitops_ctz64(lzo_uint64 v
)
3137 (void) _BitScanForward64(&r
, v
);
3138 return (unsigned) r
;
3140 #define lzo_bitops_ctz64 lzo_bitops_ctz64
3143 #elif (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x030400ul) || (LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || LZO_CC_LLVM)
3144 #if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32)
3145 #define lzo_bitops_clz32(v) ((unsigned) __builtin_clz(v))
3147 #if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX)
3148 #define lzo_bitops_clz64(v) ((unsigned) __builtin_clzll(v))
3150 #if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32)
3151 #define lzo_bitops_ctz32(v) ((unsigned) __builtin_ctz(v))
3153 #if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX)
3154 #define lzo_bitops_ctz64(v) ((unsigned) __builtin_ctzll(v))
3156 #if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount32)
3157 #define lzo_bitops_popcount32(v) ((unsigned) __builtin_popcount(v))
3159 #if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount64) && defined(LZO_UINT64_MAX)
3160 #define lzo_bitops_popcount64(v) ((unsigned) __builtin_popcountll(v))
3164 static __lzo_noinline lzo_uint
3165 do_compress ( const lzo_bytep in
, lzo_uint in_len
,
3166 lzo_bytep out
, lzo_uintp out_len
,
3167 lzo_uint ti
, lzo_voidp wrkmem
)
3169 register const lzo_bytep ip
;
3171 const lzo_bytep
const in_end
= in
+ in_len
;
3172 const lzo_bytep
const ip_end
= in
+ in_len
- 20;
3174 lzo_dict_p
const dict
= (lzo_dict_p
) wrkmem
;
3180 ip
+= ti
< 4 ? 4 - ti
: 0;
3183 const lzo_bytep m_pos
;
3184 #if !(LZO_DETERMINISTIC)
3185 LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint
, m_off
, 0);
3189 if __lzo_unlikely(ip
>= ip_end
)
3192 GINDEX(m_pos
,m_off
,dict
,dindex
,in
);
3193 if (LZO_CHECK_MPOS_NON_DET(m_pos
,m_off
,in
,ip
,M4_MAX_OFFSET
))
3196 if (m_off
<= M2_MAX_OFFSET
|| m_pos
[3] == ip
[3])
3200 GINDEX(m_pos
,m_off
,dict
,dindex
,in
);
3201 if (LZO_CHECK_MPOS_NON_DET(m_pos
,m_off
,in
,ip
,M4_MAX_OFFSET
))
3203 if (m_off
<= M2_MAX_OFFSET
|| m_pos
[3] == ip
[3])
3208 #if defined(UA_GET32)
3209 if (UA_GET32(m_pos
) != UA_GET32(ip
))
3211 if (m_pos
[0] != ip
[0] || m_pos
[1] != ip
[1] || m_pos
[2] != ip
[2] || m_pos
[3] != ip
[3])
3215 UPDATE_I(dict
,0,dindex
,ip
,in
);
3216 ip
+= 1 + ((ip
- ii
) >> 5);
3219 UPDATE_I(dict
,0,dindex
,ip
,in
);
3227 ip
+= 1 + ((ip
- ii
) >> 5);
3229 if __lzo_unlikely(ip
>= ip_end
)
3232 dindex
= DINDEX(dv
,ip
);
3233 GINDEX(m_off
,m_pos
,in
+dict
,dindex
,in
);
3234 UPDATE_I(dict
,0,dindex
,ip
,in
);
3235 if __lzo_unlikely(dv
!= UA_GET32(m_pos
))
3241 register lzo_uint t
= pd(ip
,ii
);
3246 op
[-2] |= LZO_BYTE(t
);
3247 #if defined(UA_COPY32)
3251 { do *op
++ = *ii
++; while (--t
> 0); }
3254 #if defined(UA_COPY32) || defined(UA_COPY64)
3257 *op
++ = LZO_BYTE(t
- 3);
3258 #if defined(UA_COPY64)
3260 UA_COPY64(op
+8, ii
+8);
3263 UA_COPY32(op
+4, ii
+4);
3264 UA_COPY32(op
+8, ii
+8);
3265 UA_COPY32(op
+12, ii
+12);
3273 *op
++ = LZO_BYTE(t
- 3);
3276 register lzo_uint tt
= t
- 18;
3278 while __lzo_unlikely(tt
> 255)
3281 #if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400))
3282 * (volatile unsigned char *) op
++ = 0;
3288 *op
++ = LZO_BYTE(tt
);
3290 #if defined(UA_COPY32) || defined(UA_COPY64)
3292 #if defined(UA_COPY64)
3294 UA_COPY64(op
+8, ii
+8);
3297 UA_COPY32(op
+4, ii
+4);
3298 UA_COPY32(op
+8, ii
+8);
3299 UA_COPY32(op
+12, ii
+12);
3301 op
+= 16; ii
+= 16; t
-= 16;
3302 } while (t
>= 16); if (t
> 0)
3304 { do *op
++ = *ii
++; while (--t
> 0); }
3310 #if defined(UA_GET64)
3312 v
= UA_GET64(ip
+ m_len
) ^ UA_GET64(m_pos
+ m_len
);
3313 if __lzo_unlikely(v
== 0) {
3316 v
= UA_GET64(ip
+ m_len
) ^ UA_GET64(m_pos
+ m_len
);
3317 if __lzo_unlikely(ip
+ m_len
>= ip_end
)
3321 #if (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_ctz64)
3322 m_len
+= lzo_bitops_ctz64(v
) / CHAR_BIT
;
3323 #elif (LZO_ABI_LITTLE_ENDIAN)
3324 if ((v
& UCHAR_MAX
) == 0) do {
3327 } while ((v
& UCHAR_MAX
) == 0);
3329 if (ip
[m_len
] == m_pos
[m_len
]) do {
3331 } while (ip
[m_len
] == m_pos
[m_len
]);
3333 #elif defined(UA_GET32)
3335 v
= UA_GET32(ip
+ m_len
) ^ UA_GET32(m_pos
+ m_len
);
3336 if __lzo_unlikely(v
== 0) {
3339 v
= UA_GET32(ip
+ m_len
) ^ UA_GET32(m_pos
+ m_len
);
3340 if __lzo_unlikely(ip
+ m_len
>= ip_end
)
3344 #if (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_ctz32)
3345 m_len
+= lzo_bitops_ctz32(v
) / CHAR_BIT
;
3346 #elif (LZO_ABI_LITTLE_ENDIAN)
3347 if ((v
& UCHAR_MAX
) == 0) do {
3350 } while ((v
& UCHAR_MAX
) == 0);
3352 if (ip
[m_len
] == m_pos
[m_len
]) do {
3354 } while (ip
[m_len
] == m_pos
[m_len
]);
3357 if __lzo_unlikely(ip
[m_len
] == m_pos
[m_len
]) {
3360 if __lzo_unlikely(ip
+ m_len
>= ip_end
)
3362 } while (ip
[m_len
] == m_pos
[m_len
]);
3367 m_off
= pd(ip
,m_pos
);
3370 if (m_len
<= M2_MAX_LEN
&& m_off
<= M2_MAX_OFFSET
)
3374 *op
++ = LZO_BYTE(((m_len
- 1) << 5) | ((m_off
& 7) << 2));
3375 *op
++ = LZO_BYTE(m_off
>> 3);
3376 #elif defined(LZO1Y)
3377 *op
++ = LZO_BYTE(((m_len
+ 1) << 4) | ((m_off
& 3) << 2));
3378 *op
++ = LZO_BYTE(m_off
>> 2);
3381 else if (m_off
<= M3_MAX_OFFSET
)
3384 if (m_len
<= M3_MAX_LEN
)
3385 *op
++ = LZO_BYTE(M3_MARKER
| (m_len
- 2));
3388 m_len
-= M3_MAX_LEN
;
3389 *op
++ = M3_MARKER
| 0;
3390 while __lzo_unlikely(m_len
> 255)
3393 #if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400))
3394 * (volatile unsigned char *) op
++ = 0;
3399 *op
++ = LZO_BYTE(m_len
);
3401 *op
++ = LZO_BYTE(m_off
<< 2);
3402 *op
++ = LZO_BYTE(m_off
>> 6);
3407 if (m_len
<= M4_MAX_LEN
)
3408 *op
++ = LZO_BYTE(M4_MARKER
| ((m_off
>> 11) & 8) | (m_len
- 2));
3411 m_len
-= M4_MAX_LEN
;
3412 *op
++ = LZO_BYTE(M4_MARKER
| ((m_off
>> 11) & 8));
3413 while __lzo_unlikely(m_len
> 255)
3416 #if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400))
3417 * (volatile unsigned char *) op
++ = 0;
3422 *op
++ = LZO_BYTE(m_len
);
3424 *op
++ = LZO_BYTE(m_off
<< 2);
3425 *op
++ = LZO_BYTE(m_off
>> 6);
3430 *out_len
= pd(op
, out
);
3431 return pd(in_end
,ii
);
3435 DO_COMPRESS ( const lzo_bytep in
, lzo_uint in_len
,
3436 lzo_bytep out
, lzo_uintp out_len
,
3439 const lzo_bytep ip
= in
;
3441 lzo_uint l
= in_len
;
3447 lzo_uintptr_t ll_end
;
3448 #if 0 || (LZO_DETERMINISTIC)
3449 ll
= LZO_MIN(ll
, 49152);
3451 ll_end
= (lzo_uintptr_t
)ip
+ ll
;
3452 if ((ll_end
+ ((t
+ ll
) >> 5)) <= ll_end
|| (const lzo_bytep
)(ll_end
+ ((t
+ ll
) >> 5)) <= ip
+ ll
)
3454 #if (LZO_DETERMINISTIC)
3455 lzo_memset(wrkmem
, 0, ((lzo_uint
)1 << D_BITS
) * sizeof(lzo_dict_t
));
3457 t
= do_compress(ip
,ll
,op
,out_len
,t
,wrkmem
);
3466 const lzo_bytep ii
= in
+ in_len
- t
;
3468 if (op
== out
&& t
<= 238)
3469 *op
++ = LZO_BYTE(17 + t
);
3471 op
[-2] |= LZO_BYTE(t
);
3473 *op
++ = LZO_BYTE(t
- 3);
3476 lzo_uint tt
= t
- 18;
3482 #if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400))
3484 * (volatile unsigned char *) op
++ = 0;
3490 *op
++ = LZO_BYTE(tt
);
3492 do *op
++ = *ii
++; while (--t
> 0);
3495 *op
++ = M4_MARKER
| 1;
3499 *out_len
= pd(op
, out
);
3509 #undef LZO_TEST_OVERRUN
3510 #undef DO_DECOMPRESS
3511 #define DO_DECOMPRESS lzo1x_decompress
3513 #if !defined(MINILZO_CFG_SKIP_LZO1X_DECOMPRESS)
3515 #if defined(LZO_TEST_OVERRUN)
3516 # if !defined(LZO_TEST_OVERRUN_INPUT)
3517 # define LZO_TEST_OVERRUN_INPUT 2
3519 # if !defined(LZO_TEST_OVERRUN_OUTPUT)
3520 # define LZO_TEST_OVERRUN_OUTPUT 2
3522 # if !defined(LZO_TEST_OVERRUN_LOOKBEHIND)
3523 # define LZO_TEST_OVERRUN_LOOKBEHIND 1
3540 #if defined(LZO_TEST_OVERRUN_INPUT)
3541 # if (LZO_TEST_OVERRUN_INPUT >= 1)
3542 # define TEST_IP (ip < ip_end)
3544 # if (LZO_TEST_OVERRUN_INPUT >= 2)
3545 # define NEED_IP(x) \
3546 if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x)) goto input_overrun
3550 #if defined(LZO_TEST_OVERRUN_OUTPUT)
3551 # if (LZO_TEST_OVERRUN_OUTPUT >= 1)
3552 # define TEST_OP (op <= op_end)
3554 # if (LZO_TEST_OVERRUN_OUTPUT >= 2)
3556 # define NEED_OP(x) \
3557 if ((lzo_uint)(op_end - op) < (lzo_uint)(x)) goto output_overrun
3561 #if defined(LZO_TEST_OVERRUN_LOOKBEHIND)
3562 # define TEST_LB(m_pos) if (m_pos < out || m_pos >= op) goto lookbehind_overrun
3563 # define TEST_LBO(m_pos,o) if (m_pos < out || m_pos >= op - (o)) goto lookbehind_overrun
3565 # define TEST_LB(m_pos) ((void) 0)
3566 # define TEST_LBO(m_pos,o) ((void) 0)
3569 #if !defined(LZO_EOF_CODE) && !defined(TEST_IP)
3570 # define TEST_IP (ip < ip_end)
3573 #if defined(TEST_IP)
3574 # define HAVE_TEST_IP 1
3578 #if defined(TEST_OP)
3579 # define HAVE_TEST_OP 1
3584 #if defined(NEED_IP)
3585 # define HAVE_NEED_IP 1
3587 # define NEED_IP(x) ((void) 0)
3589 #if defined(NEED_OP)
3590 # define HAVE_NEED_OP 1
3592 # define NEED_OP(x) ((void) 0)
3595 #if defined(HAVE_TEST_IP) || defined(HAVE_NEED_IP)
3596 # define HAVE_ANY_IP 1
3598 #if defined(HAVE_TEST_OP) || defined(HAVE_NEED_OP)
3599 # define HAVE_ANY_OP 1
3602 #if defined(DO_DECOMPRESS)
3604 DO_DECOMPRESS ( const lzo_bytep in
, lzo_uint in_len
,
3605 lzo_bytep out
, lzo_uintp out_len
,
3609 register lzo_bytep op
;
3610 register const lzo_bytep ip
;
3611 register lzo_uint t
;
3612 #if defined(COPY_DICT)
3614 const lzo_bytep dict_end
;
3616 register const lzo_bytep m_pos
;
3619 const lzo_bytep
const ip_end
= in
+ in_len
;
3620 #if defined(HAVE_ANY_OP)
3621 lzo_bytep
const op_end
= out
+ *out_len
;
3624 lzo_uint last_m_off
= 0;
3629 #if defined(COPY_DICT)
3632 if (dict_len
> M4_MAX_OFFSET
)
3634 dict
+= dict_len
- M4_MAX_OFFSET
;
3635 dict_len
= M4_MAX_OFFSET
;
3637 dict_end
= dict
+ dict_len
;
3656 assert(t
> 0); NEED_OP(t
); NEED_IP(t
+1);
3657 do *op
++ = *ip
++; while (--t
> 0);
3658 goto first_literal_run
;
3661 while (TEST_IP
&& TEST_OP
)
3677 assert(t
> 0); NEED_OP(t
+3); NEED_IP(t
+4);
3678 #if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4)
3683 op
+= 8; ip
+= 8; t
-= 8;
3688 op
+= 4; ip
+= 4; t
-= 4;
3693 if (t
> 1) { *op
++ = *ip
++; if (t
> 2) { *op
++ = *ip
++; } }
3695 #elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
3696 #if !defined(LZO_UNALIGNED_OK_4)
3697 if (PTR_ALIGNED2_4(op
,ip
))
3708 op
+= 4; ip
+= 4; t
-= 4;
3710 if (t
> 0) do *op
++ = *ip
++; while (--t
> 0);
3713 do *op
++ = *ip
++; while (--t
> 0);
3715 #if !defined(LZO_UNALIGNED_OK_4)
3720 #if !defined(LZO_UNALIGNED_OK_4) && !defined(LZO_UNALIGNED_OK_8)
3722 *op
++ = *ip
++; *op
++ = *ip
++; *op
++ = *ip
++;
3723 do *op
++ = *ip
++; while (--t
> 0);
3732 #if defined(COPY_DICT)
3734 m_off
= (1 + M2_MAX_OFFSET
) + (t
<< 6) + (*ip
++ >> 2);
3737 m_off
= (1 + M2_MAX_OFFSET
) + (t
>> 2) + (*ip
++ << 2);
3740 t
= 3; COPY_DICT(t
,m_off
)
3743 t
= (1 + M2_MAX_OFFSET
) + (t
<< 6) + (*ip
++ >> 2);
3747 m_pos
= op
- (1 + M2_MAX_OFFSET
);
3749 m_pos
-= *ip
++ << 2;
3751 TEST_LB(m_pos
); NEED_OP(3);
3752 *op
++ = *m_pos
++; *op
++ = *m_pos
++; *op
++ = *m_pos
;
3760 #if defined(COPY_DICT)
3762 m_off
= 1 + ((t
>> 2) & 7) + (*ip
++ << 3);
3764 #elif defined(LZO1Y)
3765 m_off
= 1 + ((t
>> 2) & 3) + (*ip
++ << 2);
3767 #elif defined(LZO1Z)
3773 m_off
= 1 + (m_off
<< 6) + (*ip
++ >> 2);
3781 m_pos
-= (t
>> 2) & 7;
3782 m_pos
-= *ip
++ << 3;
3784 #elif defined(LZO1Y)
3786 m_pos
-= (t
>> 2) & 3;
3787 m_pos
-= *ip
++ << 2;
3789 #elif defined(LZO1Z)
3791 lzo_uint off
= t
& 0x1f;
3795 assert(last_m_off
> 0);
3796 m_pos
-= last_m_off
;
3800 off
= 1 + (off
<< 6) + (*ip
++ >> 2);
3807 TEST_LB(m_pos
); assert(t
> 0); NEED_OP(t
+3-1);
3825 #if defined(COPY_DICT)
3827 m_off
= 1 + (ip
[0] << 6) + (ip
[1] >> 2);
3830 m_off
= 1 + (ip
[0] >> 2) + (ip
[1] << 6);
3835 lzo_uint off
= 1 + (ip
[0] << 6) + (ip
[1] >> 2);
3839 #elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN)
3841 m_pos
-= UA_GET16(ip
) >> 2;
3844 m_pos
-= (ip
[0] >> 2) + (ip
[1] << 6);
3851 #if defined(COPY_DICT)
3852 m_off
= (t
& 8) << 11;
3855 m_pos
-= (t
& 8) << 11;
3869 #if defined(COPY_DICT)
3871 m_off
+= (ip
[0] << 6) + (ip
[1] >> 2);
3873 m_off
+= (ip
[0] >> 2) + (ip
[1] << 6);
3884 m_pos
-= (ip
[0] << 6) + (ip
[1] >> 2);
3885 #elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN)
3886 m_pos
-= UA_GET16(ip
) >> 2;
3888 m_pos
-= (ip
[0] >> 2) + (ip
[1] << 6);
3895 last_m_off
= pd((const lzo_bytep
)op
, m_pos
);
3901 #if defined(COPY_DICT)
3903 m_off
= 1 + (t
<< 6) + (*ip
++ >> 2);
3906 m_off
= 1 + (t
>> 2) + (*ip
++ << 2);
3909 t
= 2; COPY_DICT(t
,m_off
)
3912 t
= 1 + (t
<< 6) + (*ip
++ >> 2);
3918 m_pos
-= *ip
++ << 2;
3920 TEST_LB(m_pos
); NEED_OP(2);
3921 *op
++ = *m_pos
++; *op
++ = *m_pos
;
3926 #if defined(COPY_DICT)
3929 t
+= 3-1; COPY_DICT(t
,m_off
)
3933 TEST_LB(m_pos
); assert(t
> 0); NEED_OP(t
+3-1);
3934 #if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4)
3935 if (op
- m_pos
>= 8)
3940 UA_COPY64(op
,m_pos
);
3941 op
+= 8; m_pos
+= 8; t
-= 8;
3945 UA_COPY32(op
,m_pos
);
3946 op
+= 4; m_pos
+= 4; t
-= 4;
3951 if (t
> 1) { *op
++ = m_pos
[1]; if (t
> 2) { *op
++ = m_pos
[2]; } }
3955 #elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
3956 #if !defined(LZO_UNALIGNED_OK_4)
3957 if (t
>= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op
,m_pos
))
3959 assert((op
- m_pos
) >= 4);
3961 if (t
>= 2 * 4 - (3 - 1) && (op
- m_pos
) >= 4)
3964 UA_COPY32(op
,m_pos
);
3965 op
+= 4; m_pos
+= 4; t
-= 4 - (3 - 1);
3967 UA_COPY32(op
,m_pos
);
3968 op
+= 4; m_pos
+= 4; t
-= 4;
3970 if (t
> 0) do *op
++ = *m_pos
++; while (--t
> 0);
3976 *op
++ = *m_pos
++; *op
++ = *m_pos
++;
3977 do *op
++ = *m_pos
++; while (--t
> 0);
3992 assert(t
> 0); assert(t
< 4); NEED_OP(t
); NEED_IP(t
+1);
3994 do *op
++ = *ip
++; while (--t
> 0);
3997 if (t
> 1) { *op
++ = *ip
++; if (t
> 2) { *op
++ = *ip
++; } }
4000 } while (TEST_IP
&& TEST_OP
);
4003 #if defined(HAVE_TEST_IP) || defined(HAVE_TEST_OP)
4004 *out_len
= pd(op
, out
);
4005 return LZO_E_EOF_NOT_FOUND
;
4010 *out_len
= pd(op
, out
);
4011 return (ip
== ip_end
? LZO_E_OK
:
4012 (ip
< ip_end
? LZO_E_INPUT_NOT_CONSUMED
: LZO_E_INPUT_OVERRUN
));
4014 #if defined(HAVE_NEED_IP)
4016 *out_len
= pd(op
, out
);
4017 return LZO_E_INPUT_OVERRUN
;
4020 #if defined(HAVE_NEED_OP)
4022 *out_len
= pd(op
, out
);
4023 return LZO_E_OUTPUT_OVERRUN
;
4026 #if defined(LZO_TEST_OVERRUN_LOOKBEHIND)
4028 *out_len
= pd(op
, out
);
4029 return LZO_E_LOOKBEHIND_OVERRUN
;
4035 #define LZO_TEST_OVERRUN 1
4036 #undef DO_DECOMPRESS
4037 #define DO_DECOMPRESS lzo1x_decompress_safe
4039 #if !defined(MINILZO_CFG_SKIP_LZO1X_DECOMPRESS_SAFE)
4041 #if defined(LZO_TEST_OVERRUN)
4042 # if !defined(LZO_TEST_OVERRUN_INPUT)
4043 # define LZO_TEST_OVERRUN_INPUT 2
4045 # if !defined(LZO_TEST_OVERRUN_OUTPUT)
4046 # define LZO_TEST_OVERRUN_OUTPUT 2
4048 # if !defined(LZO_TEST_OVERRUN_LOOKBEHIND)
4049 # define LZO_TEST_OVERRUN_LOOKBEHIND 1
4066 #if defined(LZO_TEST_OVERRUN_INPUT)
4067 # if (LZO_TEST_OVERRUN_INPUT >= 1)
4068 # define TEST_IP (ip < ip_end)
4070 # if (LZO_TEST_OVERRUN_INPUT >= 2)
4071 # define NEED_IP(x) \
4072 if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x)) goto input_overrun
4076 #if defined(LZO_TEST_OVERRUN_OUTPUT)
4077 # if (LZO_TEST_OVERRUN_OUTPUT >= 1)
4078 # define TEST_OP (op <= op_end)
4080 # if (LZO_TEST_OVERRUN_OUTPUT >= 2)
4082 # define NEED_OP(x) \
4083 if ((lzo_uint)(op_end - op) < (lzo_uint)(x)) goto output_overrun
4087 #if defined(LZO_TEST_OVERRUN_LOOKBEHIND)
4088 # define TEST_LB(m_pos) if (m_pos < out || m_pos >= op) goto lookbehind_overrun
4089 # define TEST_LBO(m_pos,o) if (m_pos < out || m_pos >= op - (o)) goto lookbehind_overrun
4091 # define TEST_LB(m_pos) ((void) 0)
4092 # define TEST_LBO(m_pos,o) ((void) 0)
4095 #if !defined(LZO_EOF_CODE) && !defined(TEST_IP)
4096 # define TEST_IP (ip < ip_end)
4099 #if defined(TEST_IP)
4100 # define HAVE_TEST_IP 1
4104 #if defined(TEST_OP)
4105 # define HAVE_TEST_OP 1
4110 #if defined(NEED_IP)
4111 # define HAVE_NEED_IP 1
4113 # define NEED_IP(x) ((void) 0)
4115 #if defined(NEED_OP)
4116 # define HAVE_NEED_OP 1
4118 # define NEED_OP(x) ((void) 0)
4121 #if defined(HAVE_TEST_IP) || defined(HAVE_NEED_IP)
4122 # define HAVE_ANY_IP 1
4124 #if defined(HAVE_TEST_OP) || defined(HAVE_NEED_OP)
4125 # define HAVE_ANY_OP 1
4128 #if defined(DO_DECOMPRESS)
4130 DO_DECOMPRESS ( const lzo_bytep in
, lzo_uint in_len
,
4131 lzo_bytep out
, lzo_uintp out_len
,
4135 register lzo_bytep op
;
4136 register const lzo_bytep ip
;
4137 register lzo_uint t
;
4138 #if defined(COPY_DICT)
4140 const lzo_bytep dict_end
;
4142 register const lzo_bytep m_pos
;
4145 const lzo_bytep
const ip_end
= in
+ in_len
;
4146 #if defined(HAVE_ANY_OP)
4147 lzo_bytep
const op_end
= out
+ *out_len
;
4150 lzo_uint last_m_off
= 0;
4155 #if defined(COPY_DICT)
4158 if (dict_len
> M4_MAX_OFFSET
)
4160 dict
+= dict_len
- M4_MAX_OFFSET
;
4161 dict_len
= M4_MAX_OFFSET
;
4163 dict_end
= dict
+ dict_len
;
4182 assert(t
> 0); NEED_OP(t
); NEED_IP(t
+1);
4183 do *op
++ = *ip
++; while (--t
> 0);
4184 goto first_literal_run
;
4187 while (TEST_IP
&& TEST_OP
)
4203 assert(t
> 0); NEED_OP(t
+3); NEED_IP(t
+4);
4204 #if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4)
4209 op
+= 8; ip
+= 8; t
-= 8;
4214 op
+= 4; ip
+= 4; t
-= 4;
4219 if (t
> 1) { *op
++ = *ip
++; if (t
> 2) { *op
++ = *ip
++; } }
4221 #elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
4222 #if !defined(LZO_UNALIGNED_OK_4)
4223 if (PTR_ALIGNED2_4(op
,ip
))
4234 op
+= 4; ip
+= 4; t
-= 4;
4236 if (t
> 0) do *op
++ = *ip
++; while (--t
> 0);
4239 do *op
++ = *ip
++; while (--t
> 0);
4241 #if !defined(LZO_UNALIGNED_OK_4)
4246 #if !defined(LZO_UNALIGNED_OK_4) && !defined(LZO_UNALIGNED_OK_8)
4248 *op
++ = *ip
++; *op
++ = *ip
++; *op
++ = *ip
++;
4249 do *op
++ = *ip
++; while (--t
> 0);
4258 #if defined(COPY_DICT)
4260 m_off
= (1 + M2_MAX_OFFSET
) + (t
<< 6) + (*ip
++ >> 2);
4263 m_off
= (1 + M2_MAX_OFFSET
) + (t
>> 2) + (*ip
++ << 2);
4266 t
= 3; COPY_DICT(t
,m_off
)
4269 t
= (1 + M2_MAX_OFFSET
) + (t
<< 6) + (*ip
++ >> 2);
4273 m_pos
= op
- (1 + M2_MAX_OFFSET
);
4275 m_pos
-= *ip
++ << 2;
4277 TEST_LB(m_pos
); NEED_OP(3);
4278 *op
++ = *m_pos
++; *op
++ = *m_pos
++; *op
++ = *m_pos
;
4286 #if defined(COPY_DICT)
4288 m_off
= 1 + ((t
>> 2) & 7) + (*ip
++ << 3);
4290 #elif defined(LZO1Y)
4291 m_off
= 1 + ((t
>> 2) & 3) + (*ip
++ << 2);
4293 #elif defined(LZO1Z)
4299 m_off
= 1 + (m_off
<< 6) + (*ip
++ >> 2);
4307 m_pos
-= (t
>> 2) & 7;
4308 m_pos
-= *ip
++ << 3;
4310 #elif defined(LZO1Y)
4312 m_pos
-= (t
>> 2) & 3;
4313 m_pos
-= *ip
++ << 2;
4315 #elif defined(LZO1Z)
4317 lzo_uint off
= t
& 0x1f;
4321 assert(last_m_off
> 0);
4322 m_pos
-= last_m_off
;
4326 off
= 1 + (off
<< 6) + (*ip
++ >> 2);
4333 TEST_LB(m_pos
); assert(t
> 0); NEED_OP(t
+3-1);
4351 #if defined(COPY_DICT)
4353 m_off
= 1 + (ip
[0] << 6) + (ip
[1] >> 2);
4356 m_off
= 1 + (ip
[0] >> 2) + (ip
[1] << 6);
4361 lzo_uint off
= 1 + (ip
[0] << 6) + (ip
[1] >> 2);
4365 #elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN)
4367 m_pos
-= UA_GET16(ip
) >> 2;
4370 m_pos
-= (ip
[0] >> 2) + (ip
[1] << 6);
4377 #if defined(COPY_DICT)
4378 m_off
= (t
& 8) << 11;
4381 m_pos
-= (t
& 8) << 11;
4395 #if defined(COPY_DICT)
4397 m_off
+= (ip
[0] << 6) + (ip
[1] >> 2);
4399 m_off
+= (ip
[0] >> 2) + (ip
[1] << 6);
4410 m_pos
-= (ip
[0] << 6) + (ip
[1] >> 2);
4411 #elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN)
4412 m_pos
-= UA_GET16(ip
) >> 2;
4414 m_pos
-= (ip
[0] >> 2) + (ip
[1] << 6);
4421 last_m_off
= pd((const lzo_bytep
)op
, m_pos
);
4427 #if defined(COPY_DICT)
4429 m_off
= 1 + (t
<< 6) + (*ip
++ >> 2);
4432 m_off
= 1 + (t
>> 2) + (*ip
++ << 2);
4435 t
= 2; COPY_DICT(t
,m_off
)
4438 t
= 1 + (t
<< 6) + (*ip
++ >> 2);
4444 m_pos
-= *ip
++ << 2;
4446 TEST_LB(m_pos
); NEED_OP(2);
4447 *op
++ = *m_pos
++; *op
++ = *m_pos
;
4452 #if defined(COPY_DICT)
4455 t
+= 3-1; COPY_DICT(t
,m_off
)
4459 TEST_LB(m_pos
); assert(t
> 0); NEED_OP(t
+3-1);
4460 #if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4)
4461 if (op
- m_pos
>= 8)
4466 UA_COPY64(op
,m_pos
);
4467 op
+= 8; m_pos
+= 8; t
-= 8;
4471 UA_COPY32(op
,m_pos
);
4472 op
+= 4; m_pos
+= 4; t
-= 4;
4477 if (t
> 1) { *op
++ = m_pos
[1]; if (t
> 2) { *op
++ = m_pos
[2]; } }
4481 #elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
4482 #if !defined(LZO_UNALIGNED_OK_4)
4483 if (t
>= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op
,m_pos
))
4485 assert((op
- m_pos
) >= 4);
4487 if (t
>= 2 * 4 - (3 - 1) && (op
- m_pos
) >= 4)
4490 UA_COPY32(op
,m_pos
);
4491 op
+= 4; m_pos
+= 4; t
-= 4 - (3 - 1);
4493 UA_COPY32(op
,m_pos
);
4494 op
+= 4; m_pos
+= 4; t
-= 4;
4496 if (t
> 0) do *op
++ = *m_pos
++; while (--t
> 0);
4502 *op
++ = *m_pos
++; *op
++ = *m_pos
++;
4503 do *op
++ = *m_pos
++; while (--t
> 0);
4518 assert(t
> 0); assert(t
< 4); NEED_OP(t
); NEED_IP(t
+1);
4520 do *op
++ = *ip
++; while (--t
> 0);
4523 if (t
> 1) { *op
++ = *ip
++; if (t
> 2) { *op
++ = *ip
++; } }
4526 } while (TEST_IP
&& TEST_OP
);
4529 #if defined(HAVE_TEST_IP) || defined(HAVE_TEST_OP)
4530 *out_len
= pd(op
, out
);
4531 return LZO_E_EOF_NOT_FOUND
;
4536 *out_len
= pd(op
, out
);
4537 return (ip
== ip_end
? LZO_E_OK
:
4538 (ip
< ip_end
? LZO_E_INPUT_NOT_CONSUMED
: LZO_E_INPUT_OVERRUN
));
4540 #if defined(HAVE_NEED_IP)
4542 *out_len
= pd(op
, out
);
4543 return LZO_E_INPUT_OVERRUN
;
4546 #if defined(HAVE_NEED_OP)
4548 *out_len
= pd(op
, out
);
4549 return LZO_E_OUTPUT_OVERRUN
;
4552 #if defined(LZO_TEST_OVERRUN_LOOKBEHIND)
4554 *out_len
= pd(op
, out
);
4555 return LZO_E_LOOKBEHIND_OVERRUN
;
4561 /***** End of minilzo.c *****/