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 != 0x2060)
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"
2348 "$Id: LZO version: v" LZO_VERSION_STRING
", " LZO_VERSION_DATE
" $\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
2564 #define WANT_lzo_bitops_clz32 1
2565 #define WANT_lzo_bitops_clz64 1
2566 #define WANT_lzo_bitops_ctz32 1
2567 #define WANT_lzo_bitops_ctz64 1
2569 #if (defined(_WIN32) || defined(_WIN64)) && ((LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || (LZO_CC_MSC && (_MSC_VER >= 1400)))
2571 #if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32) && 0
2572 #pragma intrinsic(_BitScanReverse)
2573 static __lzo_inline
unsigned lzo_bitops_clz32(lzo_uint32 v
)
2576 (void) _BitScanReverse(&r
, v
);
2577 return (unsigned) r
;
2579 #define lzo_bitops_clz32 lzo_bitops_clz32
2581 #if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX) && 0
2582 #pragma intrinsic(_BitScanReverse64)
2583 static __lzo_inline
unsigned lzo_bitops_clz64(lzo_uint64 v
)
2586 (void) _BitScanReverse64(&r
, v
);
2587 return (unsigned) r
;
2589 #define lzo_bitops_clz64 lzo_bitops_clz64
2591 #if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32)
2592 #pragma intrinsic(_BitScanForward)
2593 static __lzo_inline
unsigned lzo_bitops_ctz32(lzo_uint32 v
)
2596 (void) _BitScanForward(&r
, v
);
2597 return (unsigned) r
;
2599 #define lzo_bitops_ctz32 lzo_bitops_ctz32
2601 #if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX)
2602 #pragma intrinsic(_BitScanForward64)
2603 static __lzo_inline
unsigned lzo_bitops_ctz64(lzo_uint64 v
)
2606 (void) _BitScanForward64(&r
, v
);
2607 return (unsigned) r
;
2609 #define lzo_bitops_ctz64 lzo_bitops_ctz64
2612 #elif (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x030400ul) || (LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || (LZO_CC_LLVM && (!defined(__llvm_tools_version__) || (__llvm_tools_version__+0 >= 0x010500ul))))
2613 #if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32)
2614 #define lzo_bitops_clz32(v) ((unsigned) __builtin_clz(v))
2616 #if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX)
2617 #define lzo_bitops_clz64(v) ((unsigned) __builtin_clzll(v))
2619 #if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32)
2620 #define lzo_bitops_ctz32(v) ((unsigned) __builtin_ctz(v))
2622 #if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX)
2623 #define lzo_bitops_ctz64(v) ((unsigned) __builtin_ctzll(v))
2625 #if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount32)
2626 #define lzo_bitops_popcount32(v) ((unsigned) __builtin_popcount(v))
2628 #if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount64) && defined(LZO_UINT64_MAX)
2629 #define lzo_bitops_popcount64(v) ((unsigned) __builtin_popcountll(v))
2634 #define u2p(ptr,off) ((lzo_voidp) (((lzo_bytep)(lzo_voidp)(ptr)) + (off)))
2636 static __lzo_noinline lzo_voidp
u2p(lzo_voidp ptr
, lzo_uint off
)
2638 return (lzo_voidp
) ((lzo_bytep
) ptr
+ off
);
2643 _lzo_config_check(void)
2647 lzo_xint a
[2]; unsigned char b
[2*LZO_MAX(8,sizeof(lzo_xint
))];
2648 #if defined(LZO_UNALIGNED_OK_8)
2651 unsigned short x
[2]; lzo_uint32 y
[2]; lzo_uint z
[2];
2655 u
.a
[0] = u
.a
[1] = 0;
2657 r
&= ((* (lzo_bytep
) p
) == 0);
2658 #if !defined(LZO_CFG_NO_CONFIG_CHECK)
2659 #if defined(LZO_ABI_BIG_ENDIAN)
2660 u
.a
[0] = u
.a
[1] = 0; u
.b
[sizeof(lzo_uint
) - 1] = 128;
2662 r
&= ((* (lzo_uintp
) p
) == 128);
2664 #if defined(LZO_ABI_LITTLE_ENDIAN)
2665 u
.a
[0] = u
.a
[1] = 0; u
.b
[0] = 128;
2667 r
&= ((* (lzo_uintp
) p
) == 128);
2669 #if defined(LZO_UNALIGNED_OK_2)
2670 u
.a
[0] = u
.a
[1] = 0;
2671 u
.b
[0] = 1; u
.b
[sizeof(unsigned short) + 1] = 2;
2673 r
&= ((* (lzo_ushortp
) p
) == 0);
2675 #if defined(LZO_UNALIGNED_OK_4)
2676 u
.a
[0] = u
.a
[1] = 0;
2677 u
.b
[0] = 3; u
.b
[sizeof(lzo_uint32
) + 1] = 4;
2679 r
&= ((* (lzo_uint32p
) p
) == 0);
2681 #if defined(LZO_UNALIGNED_OK_8)
2682 u
.c
[0] = u
.c
[1] = 0;
2683 u
.b
[0] = 5; u
.b
[sizeof(lzo_uint64
) + 1] = 6;
2685 r
&= ((* (lzo_uint64p
) p
) == 0);
2687 #if defined(lzo_bitops_clz32)
2688 { unsigned i
; lzo_uint32 v
= 1;
2689 for (i
= 0; i
< 32; i
++, v
<<= 1)
2690 r
&= lzo_bitops_clz32(v
) == 31 - i
;
2693 #if defined(lzo_bitops_clz64)
2694 { unsigned i
; lzo_uint64 v
= 1;
2695 for (i
= 0; i
< 64; i
++, v
<<= 1)
2696 r
&= lzo_bitops_clz64(v
) == 63 - i
;
2699 #if defined(lzo_bitops_ctz32)
2700 { unsigned i
; lzo_uint32 v
= 1;
2701 for (i
= 0; i
< 32; i
++, v
<<= 1)
2702 r
&= lzo_bitops_ctz32(v
) == i
;
2705 #if defined(lzo_bitops_ctz64)
2706 { unsigned i
; lzo_uint64 v
= 1;
2707 for (i
= 0; i
< 64; i
++, v
<<= 1)
2708 r
&= lzo_bitops_ctz64(v
) == i
;
2713 return r
== 1 ? LZO_E_OK
: LZO_E_ERROR
;
2717 __lzo_init_v2(unsigned v
, int s1
, int s2
, int s3
, int s4
, int s5
,
2718 int s6
, int s7
, int s8
, int s9
)
2722 #if defined(__LZO_IN_MINILZO)
2723 #elif (LZO_CC_MSC && ((_MSC_VER) < 700))
2725 #define ACC_WANT_ACC_CHK_CH 1
2726 #undef ACCCHK_ASSERT
2727 #define ACCCHK_ASSERT(expr) LZO_COMPILE_TIME_ASSERT(expr)
2729 #undef ACCCHK_ASSERT
2734 r
= (s1
== -1 || s1
== (int) sizeof(short)) &&
2735 (s2
== -1 || s2
== (int) sizeof(int)) &&
2736 (s3
== -1 || s3
== (int) sizeof(long)) &&
2737 (s4
== -1 || s4
== (int) sizeof(lzo_uint32
)) &&
2738 (s5
== -1 || s5
== (int) sizeof(lzo_uint
)) &&
2739 (s6
== -1 || s6
== (int) lzo_sizeof_dict_t
) &&
2740 (s7
== -1 || s7
== (int) sizeof(char *)) &&
2741 (s8
== -1 || s8
== (int) sizeof(lzo_voidp
)) &&
2742 (s9
== -1 || s9
== (int) sizeof(lzo_callback_t
));
2746 r
= _lzo_config_check();
2753 #if !defined(__LZO_IN_MINILZO)
2755 #if (LZO_OS_WIN16 && LZO_CC_WATCOMC) && defined(__SW_BD)
2758 BOOL FAR PASCAL
LibMain ( HANDLE hInstance
, WORD wDataSegment
,
2759 WORD wHeapSize
, LPSTR lpszCmdLine
)
2761 int __far __pascal
LibMain ( int a
, short b
, short c
, long d
)
2764 LZO_UNUSED(a
); LZO_UNUSED(b
); LZO_UNUSED(c
); LZO_UNUSED(d
);
2775 #define LZO_EOF_CODE 1
2776 #define M2_MAX_OFFSET 0x0800
2778 #if !defined(MINILZO_CFG_SKIP_LZO1X_1_COMPRESS)
2780 #if 1 && defined(UA_GET32)
2781 #undef LZO_DICT_USE_PTR
2782 #define LZO_DICT_USE_PTR 0
2784 #define lzo_dict_t unsigned short
2787 #define LZO_NEED_DICT_H 1
2791 #define D_INDEX1(d,p) d = DM(DMUL(0x21,DX3(p,5,5,6)) >> 5)
2792 #define D_INDEX2(d,p) d = (d & (D_MASK & 0x7ff)) ^ (D_HIGH | 0x1f)
2794 #define DINDEX(dv,p) DM(((DMUL(0x1824429d,dv)) >> (32-D_BITS)))
2796 #define DINDEX(dv,p) DM((dv) + ((dv) >> (32-D_BITS)))
2799 #ifndef __LZO_CONFIG1X_H
2800 #define __LZO_CONFIG1X_H 1
2802 #if !defined(LZO1X) && !defined(LZO1Y) && !defined(LZO1Z)
2806 #if !defined(__LZO_IN_MINILZO)
2807 #include "lzo/lzo1x.h"
2810 #ifndef LZO_EOF_CODE
2811 #define LZO_EOF_CODE 1
2813 #undef LZO_DETERMINISTIC
2815 #define M1_MAX_OFFSET 0x0400
2816 #ifndef M2_MAX_OFFSET
2817 #define M2_MAX_OFFSET 0x0800
2819 #define M3_MAX_OFFSET 0x4000
2820 #define M4_MAX_OFFSET 0xbfff
2822 #define MX_MAX_OFFSET (M1_MAX_OFFSET + M2_MAX_OFFSET)
2824 #define M1_MIN_LEN 2
2825 #define M1_MAX_LEN 2
2826 #define M2_MIN_LEN 3
2828 #define M2_MAX_LEN 8
2830 #define M3_MIN_LEN 3
2831 #define M3_MAX_LEN 33
2832 #define M4_MIN_LEN 3
2833 #define M4_MAX_LEN 9
2836 #define M2_MARKER 64
2837 #define M3_MARKER 32
2838 #define M4_MARKER 16
2840 #ifndef MIN_LOOKAHEAD
2841 #define MIN_LOOKAHEAD (M2_MAX_LEN + 1)
2844 #if defined(LZO_NEED_DICT_H)
2847 #define LZO_HASH LZO_HASH_LZO_INCREMENTAL_B
2849 #define DL_MIN_LEN M2_MIN_LEN
2851 #ifndef __LZO_DICT_H
2852 #define __LZO_DICT_H 1
2858 #if !defined(D_BITS) && defined(DBITS)
2859 # define D_BITS DBITS
2861 #if !defined(D_BITS)
2862 # error "D_BITS is not defined"
2865 # define D_SIZE LZO_SIZE(D_BITS)
2866 # define D_MASK LZO_MASK(D_BITS)
2868 # define D_SIZE LZO_USIZE(D_BITS)
2869 # define D_MASK LZO_UMASK(D_BITS)
2871 #define D_HIGH ((D_MASK >> 1) + 1)
2873 #if !defined(DD_BITS)
2876 #define DD_SIZE LZO_SIZE(DD_BITS)
2877 #define DD_MASK LZO_MASK(DD_BITS)
2879 #if !defined(DL_BITS)
2880 # define DL_BITS (D_BITS - DD_BITS)
2883 # define DL_SIZE LZO_SIZE(DL_BITS)
2884 # define DL_MASK LZO_MASK(DL_BITS)
2886 # define DL_SIZE LZO_USIZE(DL_BITS)
2887 # define DL_MASK LZO_UMASK(DL_BITS)
2890 #if (D_BITS != DL_BITS + DD_BITS)
2891 # error "D_BITS does not match"
2893 #if (D_BITS < 6 || D_BITS > 18)
2894 # error "invalid D_BITS"
2896 #if (DL_BITS < 6 || DL_BITS > 20)
2897 # error "invalid DL_BITS"
2899 #if (DD_BITS < 0 || DD_BITS > 6)
2900 # error "invalid DD_BITS"
2903 #if !defined(DL_MIN_LEN)
2904 # define DL_MIN_LEN 3
2906 #if !defined(DL_SHIFT)
2907 # define DL_SHIFT ((DL_BITS + (DL_MIN_LEN - 1)) / DL_MIN_LEN)
2910 #define LZO_HASH_GZIP 1
2911 #define LZO_HASH_GZIP_INCREMENTAL 2
2912 #define LZO_HASH_LZO_INCREMENTAL_A 3
2913 #define LZO_HASH_LZO_INCREMENTAL_B 4
2915 #if !defined(LZO_HASH)
2916 # error "choose a hashing strategy"
2922 #if (DL_MIN_LEN == 3)
2923 # define _DV2_A(p,shift1,shift2) \
2924 (((( (lzo_xint)((p)[0]) << shift1) ^ (p)[1]) << shift2) ^ (p)[2])
2925 # define _DV2_B(p,shift1,shift2) \
2926 (((( (lzo_xint)((p)[2]) << shift1) ^ (p)[1]) << shift2) ^ (p)[0])
2927 # define _DV3_B(p,shift1,shift2,shift3) \
2928 ((_DV2_B((p)+1,shift1,shift2) << (shift3)) ^ (p)[0])
2929 #elif (DL_MIN_LEN == 2)
2930 # define _DV2_A(p,shift1,shift2) \
2931 (( (lzo_xint)(p[0]) << shift1) ^ p[1])
2932 # define _DV2_B(p,shift1,shift2) \
2933 (( (lzo_xint)(p[1]) << shift1) ^ p[2])
2935 # error "invalid DL_MIN_LEN"
2937 #define _DV_A(p,shift) _DV2_A(p,shift,shift)
2938 #define _DV_B(p,shift) _DV2_B(p,shift,shift)
2939 #define DA2(p,s1,s2) \
2940 (((((lzo_xint)((p)[2]) << (s2)) + (p)[1]) << (s1)) + (p)[0])
2941 #define DS2(p,s1,s2) \
2942 (((((lzo_xint)((p)[2]) << (s2)) - (p)[1]) << (s1)) - (p)[0])
2943 #define DX2(p,s1,s2) \
2944 (((((lzo_xint)((p)[2]) << (s2)) ^ (p)[1]) << (s1)) ^ (p)[0])
2945 #define DA3(p,s1,s2,s3) ((DA2((p)+1,s2,s3) << (s1)) + (p)[0])
2946 #define DS3(p,s1,s2,s3) ((DS2((p)+1,s2,s3) << (s1)) - (p)[0])
2947 #define DX3(p,s1,s2,s3) ((DX2((p)+1,s2,s3) << (s1)) ^ (p)[0])
2948 #define DMS(v,s) ((lzo_uint) (((v) & (D_MASK >> (s))) << (s)))
2949 #define DM(v) DMS(v,0)
2951 #if (LZO_HASH == LZO_HASH_GZIP)
2952 # define _DINDEX(dv,p) (_DV_A((p),DL_SHIFT))
2954 #elif (LZO_HASH == LZO_HASH_GZIP_INCREMENTAL)
2955 # define __LZO_HASH_INCREMENTAL 1
2956 # define DVAL_FIRST(dv,p) dv = _DV_A((p),DL_SHIFT)
2957 # define DVAL_NEXT(dv,p) dv = (((dv) << DL_SHIFT) ^ p[2])
2958 # define _DINDEX(dv,p) (dv)
2959 # define DVAL_LOOKAHEAD DL_MIN_LEN
2961 #elif (LZO_HASH == LZO_HASH_LZO_INCREMENTAL_A)
2962 # define __LZO_HASH_INCREMENTAL 1
2963 # define DVAL_FIRST(dv,p) dv = _DV_A((p),5)
2964 # define DVAL_NEXT(dv,p) \
2965 dv ^= (lzo_xint)(p[-1]) << (2*5); dv = (((dv) << 5) ^ p[2])
2966 # define _DINDEX(dv,p) ((DMUL(0x9f5f,dv)) >> 5)
2967 # define DVAL_LOOKAHEAD DL_MIN_LEN
2969 #elif (LZO_HASH == LZO_HASH_LZO_INCREMENTAL_B)
2970 # define __LZO_HASH_INCREMENTAL 1
2971 # define DVAL_FIRST(dv,p) dv = _DV_B((p),5)
2972 # define DVAL_NEXT(dv,p) \
2973 dv ^= p[-1]; dv = (((dv) >> 5) ^ ((lzo_xint)(p[2]) << (2*5)))
2974 # define _DINDEX(dv,p) ((DMUL(0x9f5f,dv)) >> 5)
2975 # define DVAL_LOOKAHEAD DL_MIN_LEN
2978 # error "choose a hashing strategy"
2982 #define DINDEX(dv,p) ((lzo_uint)((_DINDEX(dv,p)) & DL_MASK) << DD_BITS)
2984 #if !defined(DINDEX1) && defined(D_INDEX1)
2985 #define DINDEX1 D_INDEX1
2987 #if !defined(DINDEX2) && defined(D_INDEX2)
2988 #define DINDEX2 D_INDEX2
2991 #if !defined(__LZO_HASH_INCREMENTAL)
2992 # define DVAL_FIRST(dv,p) ((void) 0)
2993 # define DVAL_NEXT(dv,p) ((void) 0)
2994 # define DVAL_LOOKAHEAD 0
2997 #if !defined(DVAL_ASSERT)
2998 #if defined(__LZO_HASH_INCREMENTAL) && !defined(NDEBUG)
2999 #if (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x020700ul) || LZO_CC_LLVM)
3000 static void __attribute__((__unused__
))
3004 DVAL_ASSERT(lzo_xint dv
, const lzo_bytep p
)
3008 assert(DINDEX(dv
,p
) == DINDEX(df
,p
));
3011 # define DVAL_ASSERT(dv,p) ((void) 0)
3015 #if (LZO_DICT_USE_PTR)
3016 # define DENTRY(p,in) (p)
3017 # define GINDEX(m_pos,m_off,dict,dindex,in) m_pos = dict[dindex]
3019 # define DENTRY(p,in) ((lzo_dict_t) pd(p, in))
3020 # define GINDEX(m_pos,m_off,dict,dindex,in) m_off = dict[dindex]
3025 # define UPDATE_D(dict,drun,dv,p,in) dict[ DINDEX(dv,p) ] = DENTRY(p,in)
3026 # define UPDATE_I(dict,drun,index,p,in) dict[index] = DENTRY(p,in)
3027 # define UPDATE_P(ptr,drun,p,in) (ptr)[0] = DENTRY(p,in)
3031 # define UPDATE_D(dict,drun,dv,p,in) \
3032 dict[ DINDEX(dv,p) + drun++ ] = DENTRY(p,in); drun &= DD_MASK
3033 # define UPDATE_I(dict,drun,index,p,in) \
3034 dict[ (index) + drun++ ] = DENTRY(p,in); drun &= DD_MASK
3035 # define UPDATE_P(ptr,drun,p,in) \
3036 (ptr) [ drun++ ] = DENTRY(p,in); drun &= DD_MASK
3040 #if (LZO_DICT_USE_PTR)
3042 #define LZO_CHECK_MPOS_DET(m_pos,m_off,in,ip,max_offset) \
3043 (m_pos == NULL || (m_off = pd(ip, m_pos)) > max_offset)
3045 #define LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,max_offset) \
3046 (BOUNDS_CHECKING_OFF_IN_EXPR(( \
3047 m_pos = ip - (lzo_uint) PTR_DIFF(ip,m_pos), \
3048 PTR_LT(m_pos,in) || \
3049 (m_off = (lzo_uint) PTR_DIFF(ip,m_pos)) == 0 || \
3050 m_off > max_offset )))
3054 #define LZO_CHECK_MPOS_DET(m_pos,m_off,in,ip,max_offset) \
3056 ((m_off = pd(ip, in) - m_off) > max_offset) || \
3057 (m_pos = (ip) - (m_off), 0) )
3059 #define LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,max_offset) \
3060 (pd(ip, in) <= m_off || \
3061 ((m_off = pd(ip, in) - m_off) > max_offset) || \
3062 (m_pos = (ip) - (m_off), 0) )
3066 #if (LZO_DETERMINISTIC)
3067 # define LZO_CHECK_MPOS LZO_CHECK_MPOS_DET
3069 # define LZO_CHECK_MPOS LZO_CHECK_MPOS_NON_DET
3082 #define LZO_DETERMINISTIC !(LZO_DICT_USE_PTR)
3085 #define DO_COMPRESS lzo1x_1_compress
3088 #if 1 && defined(DO_COMPRESS) && !defined(do_compress)
3089 # define do_compress LZO_CPP_ECONCAT2(DO_COMPRESS,_core)
3092 #if defined(UA_GET64) && (LZO_ABI_BIG_ENDIAN)
3093 # define WANT_lzo_bitops_clz64 1
3094 #elif defined(UA_GET64) && (LZO_ABI_LITTLE_ENDIAN)
3095 # define WANT_lzo_bitops_ctz64 1
3096 #elif defined(UA_GET32) && (LZO_ABI_BIG_ENDIAN)
3097 # define WANT_lzo_bitops_clz32 1
3098 #elif defined(UA_GET32) && (LZO_ABI_LITTLE_ENDIAN)
3099 # define WANT_lzo_bitops_ctz32 1
3102 #if (defined(_WIN32) || defined(_WIN64)) && ((LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || (LZO_CC_MSC && (_MSC_VER >= 1400)))
3104 #if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32) && 0
3105 #pragma intrinsic(_BitScanReverse)
3106 static __lzo_inline
unsigned lzo_bitops_clz32(lzo_uint32 v
)
3109 (void) _BitScanReverse(&r
, v
);
3110 return (unsigned) r
;
3112 #define lzo_bitops_clz32 lzo_bitops_clz32
3114 #if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX) && 0
3115 #pragma intrinsic(_BitScanReverse64)
3116 static __lzo_inline
unsigned lzo_bitops_clz64(lzo_uint64 v
)
3119 (void) _BitScanReverse64(&r
, v
);
3120 return (unsigned) r
;
3122 #define lzo_bitops_clz64 lzo_bitops_clz64
3124 #if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32)
3125 #pragma intrinsic(_BitScanForward)
3126 static __lzo_inline
unsigned lzo_bitops_ctz32(lzo_uint32 v
)
3129 (void) _BitScanForward(&r
, v
);
3130 return (unsigned) r
;
3132 #define lzo_bitops_ctz32 lzo_bitops_ctz32
3134 #if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX)
3135 #pragma intrinsic(_BitScanForward64)
3136 static __lzo_inline
unsigned lzo_bitops_ctz64(lzo_uint64 v
)
3139 (void) _BitScanForward64(&r
, v
);
3140 return (unsigned) r
;
3142 #define lzo_bitops_ctz64 lzo_bitops_ctz64
3145 #elif (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x030400ul) || (LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || (LZO_CC_LLVM && (!defined(__llvm_tools_version__) || (__llvm_tools_version__+0 >= 0x010500ul))))
3146 #if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32)
3147 #define lzo_bitops_clz32(v) ((unsigned) __builtin_clz(v))
3149 #if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX)
3150 #define lzo_bitops_clz64(v) ((unsigned) __builtin_clzll(v))
3152 #if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32)
3153 #define lzo_bitops_ctz32(v) ((unsigned) __builtin_ctz(v))
3155 #if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX)
3156 #define lzo_bitops_ctz64(v) ((unsigned) __builtin_ctzll(v))
3158 #if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount32)
3159 #define lzo_bitops_popcount32(v) ((unsigned) __builtin_popcount(v))
3161 #if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount64) && defined(LZO_UINT64_MAX)
3162 #define lzo_bitops_popcount64(v) ((unsigned) __builtin_popcountll(v))
3166 static __lzo_noinline lzo_uint
3167 do_compress ( const lzo_bytep in
, lzo_uint in_len
,
3168 lzo_bytep out
, lzo_uintp out_len
,
3169 lzo_uint ti
, lzo_voidp wrkmem
)
3171 register const lzo_bytep ip
;
3173 const lzo_bytep
const in_end
= in
+ in_len
;
3174 const lzo_bytep
const ip_end
= in
+ in_len
- 20;
3176 lzo_dict_p
const dict
= (lzo_dict_p
) wrkmem
;
3182 ip
+= ti
< 4 ? 4 - ti
: 0;
3185 const lzo_bytep m_pos
;
3186 #if !(LZO_DETERMINISTIC)
3187 LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint
, m_off
, 0);
3191 if __lzo_unlikely(ip
>= ip_end
)
3194 GINDEX(m_pos
,m_off
,dict
,dindex
,in
);
3195 if (LZO_CHECK_MPOS_NON_DET(m_pos
,m_off
,in
,ip
,M4_MAX_OFFSET
))
3198 if (m_off
<= M2_MAX_OFFSET
|| m_pos
[3] == ip
[3])
3202 GINDEX(m_pos
,m_off
,dict
,dindex
,in
);
3203 if (LZO_CHECK_MPOS_NON_DET(m_pos
,m_off
,in
,ip
,M4_MAX_OFFSET
))
3205 if (m_off
<= M2_MAX_OFFSET
|| m_pos
[3] == ip
[3])
3210 #if defined(UA_GET32)
3211 if (UA_GET32(m_pos
) != UA_GET32(ip
))
3213 if (m_pos
[0] != ip
[0] || m_pos
[1] != ip
[1] || m_pos
[2] != ip
[2] || m_pos
[3] != ip
[3])
3217 UPDATE_I(dict
,0,dindex
,ip
,in
);
3218 ip
+= 1 + ((ip
- ii
) >> 5);
3221 UPDATE_I(dict
,0,dindex
,ip
,in
);
3229 ip
+= 1 + ((ip
- ii
) >> 5);
3231 if __lzo_unlikely(ip
>= ip_end
)
3234 dindex
= DINDEX(dv
,ip
);
3235 GINDEX(m_off
,m_pos
,in
+dict
,dindex
,in
);
3236 UPDATE_I(dict
,0,dindex
,ip
,in
);
3237 if __lzo_unlikely(dv
!= UA_GET32(m_pos
))
3244 register lzo_uint t
= pd(ip
,ii
);
3249 op
[-2] |= LZO_BYTE(t
);
3250 #if defined(UA_COPY32)
3254 { do *op
++ = *ii
++; while (--t
> 0); }
3257 #if defined(UA_COPY32) || defined(UA_COPY64)
3260 *op
++ = LZO_BYTE(t
- 3);
3261 #if defined(UA_COPY64)
3263 UA_COPY64(op
+8, ii
+8);
3266 UA_COPY32(op
+4, ii
+4);
3267 UA_COPY32(op
+8, ii
+8);
3268 UA_COPY32(op
+12, ii
+12);
3276 *op
++ = LZO_BYTE(t
- 3);
3279 register lzo_uint tt
= t
- 18;
3281 while __lzo_unlikely(tt
> 255)
3284 #if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400))
3285 * (volatile unsigned char *) op
++ = 0;
3291 *op
++ = LZO_BYTE(tt
);
3293 #if defined(UA_COPY32) || defined(UA_COPY64)
3295 #if defined(UA_COPY64)
3297 UA_COPY64(op
+8, ii
+8);
3300 UA_COPY32(op
+4, ii
+4);
3301 UA_COPY32(op
+8, ii
+8);
3302 UA_COPY32(op
+12, ii
+12);
3304 op
+= 16; ii
+= 16; t
-= 16;
3305 } while (t
>= 16); if (t
> 0)
3307 { do *op
++ = *ii
++; while (--t
> 0); }
3313 #if defined(UA_GET64)
3315 v
= UA_GET64(ip
+ m_len
) ^ UA_GET64(m_pos
+ m_len
);
3316 if __lzo_unlikely(v
== 0) {
3319 v
= UA_GET64(ip
+ m_len
) ^ UA_GET64(m_pos
+ m_len
);
3320 if __lzo_unlikely(ip
+ m_len
>= ip_end
)
3324 #if (LZO_ABI_BIG_ENDIAN) && defined(lzo_bitops_clz64)
3325 m_len
+= lzo_bitops_clz64(v
) / CHAR_BIT
;
3326 #elif (LZO_ABI_BIG_ENDIAN)
3327 if ((v
>> (64 - CHAR_BIT
)) == 0) do {
3330 } while ((v
>> (64 - CHAR_BIT
)) == 0);
3331 #elif (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_ctz64)
3332 m_len
+= lzo_bitops_ctz64(v
) / CHAR_BIT
;
3333 #elif (LZO_ABI_LITTLE_ENDIAN)
3334 if ((v
& UCHAR_MAX
) == 0) do {
3337 } while ((v
& UCHAR_MAX
) == 0);
3339 if (ip
[m_len
] == m_pos
[m_len
]) do {
3341 } while (ip
[m_len
] == m_pos
[m_len
]);
3343 #elif defined(UA_GET32)
3345 v
= UA_GET32(ip
+ m_len
) ^ UA_GET32(m_pos
+ m_len
);
3346 if __lzo_unlikely(v
== 0) {
3349 v
= UA_GET32(ip
+ m_len
) ^ UA_GET32(m_pos
+ m_len
);
3350 if __lzo_unlikely(ip
+ m_len
>= ip_end
)
3354 #if (LZO_ABI_BIG_ENDIAN) && defined(lzo_bitops_clz32)
3355 m_len
+= lzo_bitops_clz32(v
) / CHAR_BIT
;
3356 #elif (LZO_ABI_BIG_ENDIAN)
3357 if ((v
>> (32 - CHAR_BIT
)) == 0) do {
3360 } while ((v
>> (32 - CHAR_BIT
)) == 0);
3361 #elif (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_ctz32)
3362 m_len
+= lzo_bitops_ctz32(v
) / CHAR_BIT
;
3363 #elif (LZO_ABI_LITTLE_ENDIAN)
3364 if ((v
& UCHAR_MAX
) == 0) do {
3367 } while ((v
& UCHAR_MAX
) == 0);
3369 if (ip
[m_len
] == m_pos
[m_len
]) do {
3371 } while (ip
[m_len
] == m_pos
[m_len
]);
3374 if __lzo_unlikely(ip
[m_len
] == m_pos
[m_len
]) {
3377 if __lzo_unlikely(ip
+ m_len
>= ip_end
)
3379 } while (ip
[m_len
] == m_pos
[m_len
]);
3384 m_off
= pd(ip
,m_pos
);
3387 if (m_len
<= M2_MAX_LEN
&& m_off
<= M2_MAX_OFFSET
)
3391 *op
++ = LZO_BYTE(((m_len
- 1) << 5) | ((m_off
& 7) << 2));
3392 *op
++ = LZO_BYTE(m_off
>> 3);
3393 #elif defined(LZO1Y)
3394 *op
++ = LZO_BYTE(((m_len
+ 1) << 4) | ((m_off
& 3) << 2));
3395 *op
++ = LZO_BYTE(m_off
>> 2);
3398 else if (m_off
<= M3_MAX_OFFSET
)
3401 if (m_len
<= M3_MAX_LEN
)
3402 *op
++ = LZO_BYTE(M3_MARKER
| (m_len
- 2));
3405 m_len
-= M3_MAX_LEN
;
3406 *op
++ = M3_MARKER
| 0;
3407 while __lzo_unlikely(m_len
> 255)
3410 #if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400))
3411 * (volatile unsigned char *) op
++ = 0;
3416 *op
++ = LZO_BYTE(m_len
);
3418 *op
++ = LZO_BYTE(m_off
<< 2);
3419 *op
++ = LZO_BYTE(m_off
>> 6);
3424 if (m_len
<= M4_MAX_LEN
)
3425 *op
++ = LZO_BYTE(M4_MARKER
| ((m_off
>> 11) & 8) | (m_len
- 2));
3428 m_len
-= M4_MAX_LEN
;
3429 *op
++ = LZO_BYTE(M4_MARKER
| ((m_off
>> 11) & 8));
3430 while __lzo_unlikely(m_len
> 255)
3433 #if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400))
3434 * (volatile unsigned char *) op
++ = 0;
3439 *op
++ = LZO_BYTE(m_len
);
3441 *op
++ = LZO_BYTE(m_off
<< 2);
3442 *op
++ = LZO_BYTE(m_off
>> 6);
3447 *out_len
= pd(op
, out
);
3448 return pd(in_end
,ii
-ti
);
3452 DO_COMPRESS ( const lzo_bytep in
, lzo_uint in_len
,
3453 lzo_bytep out
, lzo_uintp out_len
,
3456 const lzo_bytep ip
= in
;
3458 lzo_uint l
= in_len
;
3464 lzo_uintptr_t ll_end
;
3465 #if 0 || (LZO_DETERMINISTIC)
3466 ll
= LZO_MIN(ll
, 49152);
3468 ll_end
= (lzo_uintptr_t
)ip
+ ll
;
3469 if ((ll_end
+ ((t
+ ll
) >> 5)) <= ll_end
|| (const lzo_bytep
)(ll_end
+ ((t
+ ll
) >> 5)) <= ip
+ ll
)
3471 #if (LZO_DETERMINISTIC)
3472 lzo_memset(wrkmem
, 0, ((lzo_uint
)1 << D_BITS
) * sizeof(lzo_dict_t
));
3474 t
= do_compress(ip
,ll
,op
,out_len
,t
,wrkmem
);
3483 const lzo_bytep ii
= in
+ in_len
- t
;
3485 if (op
== out
&& t
<= 238)
3486 *op
++ = LZO_BYTE(17 + t
);
3488 op
[-2] |= LZO_BYTE(t
);
3490 *op
++ = LZO_BYTE(t
- 3);
3493 lzo_uint tt
= t
- 18;
3499 #if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400))
3501 * (volatile unsigned char *) op
++ = 0;
3507 *op
++ = LZO_BYTE(tt
);
3509 do *op
++ = *ii
++; while (--t
> 0);
3512 *op
++ = M4_MARKER
| 1;
3516 *out_len
= pd(op
, out
);
3526 #undef LZO_TEST_OVERRUN
3527 #undef DO_DECOMPRESS
3528 #define DO_DECOMPRESS lzo1x_decompress
3530 #if !defined(MINILZO_CFG_SKIP_LZO1X_DECOMPRESS)
3532 #if defined(LZO_TEST_OVERRUN)
3533 # if !defined(LZO_TEST_OVERRUN_INPUT)
3534 # define LZO_TEST_OVERRUN_INPUT 2
3536 # if !defined(LZO_TEST_OVERRUN_OUTPUT)
3537 # define LZO_TEST_OVERRUN_OUTPUT 2
3539 # if !defined(LZO_TEST_OVERRUN_LOOKBEHIND)
3540 # define LZO_TEST_OVERRUN_LOOKBEHIND 1
3557 #if defined(LZO_TEST_OVERRUN_INPUT)
3558 # if (LZO_TEST_OVERRUN_INPUT >= 1)
3559 # define TEST_IP (ip < ip_end)
3561 # if (LZO_TEST_OVERRUN_INPUT >= 2)
3562 # define NEED_IP(x) \
3563 if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x)) goto input_overrun
3567 #if defined(LZO_TEST_OVERRUN_OUTPUT)
3568 # if (LZO_TEST_OVERRUN_OUTPUT >= 1)
3569 # define TEST_OP (op <= op_end)
3571 # if (LZO_TEST_OVERRUN_OUTPUT >= 2)
3573 # define NEED_OP(x) \
3574 if ((lzo_uint)(op_end - op) < (lzo_uint)(x)) goto output_overrun
3578 #if defined(LZO_TEST_OVERRUN_LOOKBEHIND)
3579 # define TEST_LB(m_pos) if (m_pos < out || m_pos >= op) goto lookbehind_overrun
3580 # define TEST_LBO(m_pos,o) if (m_pos < out || m_pos >= op - (o)) goto lookbehind_overrun
3582 # define TEST_LB(m_pos) ((void) 0)
3583 # define TEST_LBO(m_pos,o) ((void) 0)
3586 #if !defined(LZO_EOF_CODE) && !defined(TEST_IP)
3587 # define TEST_IP (ip < ip_end)
3590 #if defined(TEST_IP)
3591 # define HAVE_TEST_IP 1
3595 #if defined(TEST_OP)
3596 # define HAVE_TEST_OP 1
3601 #if defined(NEED_IP)
3602 # define HAVE_NEED_IP 1
3604 # define NEED_IP(x) ((void) 0)
3606 #if defined(NEED_OP)
3607 # define HAVE_NEED_OP 1
3609 # define NEED_OP(x) ((void) 0)
3612 #if defined(HAVE_TEST_IP) || defined(HAVE_NEED_IP)
3613 # define HAVE_ANY_IP 1
3615 #if defined(HAVE_TEST_OP) || defined(HAVE_NEED_OP)
3616 # define HAVE_ANY_OP 1
3619 #if defined(DO_DECOMPRESS)
3621 DO_DECOMPRESS ( const lzo_bytep in
, lzo_uint in_len
,
3622 lzo_bytep out
, lzo_uintp out_len
,
3626 register lzo_bytep op
;
3627 register const lzo_bytep ip
;
3628 register lzo_uint t
;
3629 #if defined(COPY_DICT)
3631 const lzo_bytep dict_end
;
3633 register const lzo_bytep m_pos
;
3636 const lzo_bytep
const ip_end
= in
+ in_len
;
3637 #if defined(HAVE_ANY_OP)
3638 lzo_bytep
const op_end
= out
+ *out_len
;
3641 lzo_uint last_m_off
= 0;
3646 #if defined(COPY_DICT)
3649 if (dict_len
> M4_MAX_OFFSET
)
3651 dict
+= dict_len
- M4_MAX_OFFSET
;
3652 dict_len
= M4_MAX_OFFSET
;
3654 dict_end
= dict
+ dict_len
;
3673 assert(t
> 0); NEED_OP(t
); NEED_IP(t
+1);
3674 do *op
++ = *ip
++; while (--t
> 0);
3675 goto first_literal_run
;
3678 while (TEST_IP
&& TEST_OP
)
3694 assert(t
> 0); NEED_OP(t
+3); NEED_IP(t
+4);
3695 #if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4)
3700 op
+= 8; ip
+= 8; t
-= 8;
3705 op
+= 4; ip
+= 4; t
-= 4;
3710 if (t
> 1) { *op
++ = *ip
++; if (t
> 2) { *op
++ = *ip
++; } }
3712 #elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
3713 #if !defined(LZO_UNALIGNED_OK_4)
3714 if (PTR_ALIGNED2_4(op
,ip
))
3725 op
+= 4; ip
+= 4; t
-= 4;
3727 if (t
> 0) do *op
++ = *ip
++; while (--t
> 0);
3730 do *op
++ = *ip
++; while (--t
> 0);
3732 #if !defined(LZO_UNALIGNED_OK_4)
3737 #if !defined(LZO_UNALIGNED_OK_4) && !defined(LZO_UNALIGNED_OK_8)
3739 *op
++ = *ip
++; *op
++ = *ip
++; *op
++ = *ip
++;
3740 do *op
++ = *ip
++; while (--t
> 0);
3749 #if defined(COPY_DICT)
3751 m_off
= (1 + M2_MAX_OFFSET
) + (t
<< 6) + (*ip
++ >> 2);
3754 m_off
= (1 + M2_MAX_OFFSET
) + (t
>> 2) + (*ip
++ << 2);
3757 t
= 3; COPY_DICT(t
,m_off
)
3760 t
= (1 + M2_MAX_OFFSET
) + (t
<< 6) + (*ip
++ >> 2);
3764 m_pos
= op
- (1 + M2_MAX_OFFSET
);
3766 m_pos
-= *ip
++ << 2;
3768 TEST_LB(m_pos
); NEED_OP(3);
3769 *op
++ = *m_pos
++; *op
++ = *m_pos
++; *op
++ = *m_pos
;
3777 #if defined(COPY_DICT)
3779 m_off
= 1 + ((t
>> 2) & 7) + (*ip
++ << 3);
3781 #elif defined(LZO1Y)
3782 m_off
= 1 + ((t
>> 2) & 3) + (*ip
++ << 2);
3784 #elif defined(LZO1Z)
3790 m_off
= 1 + (m_off
<< 6) + (*ip
++ >> 2);
3798 m_pos
-= (t
>> 2) & 7;
3799 m_pos
-= *ip
++ << 3;
3801 #elif defined(LZO1Y)
3803 m_pos
-= (t
>> 2) & 3;
3804 m_pos
-= *ip
++ << 2;
3806 #elif defined(LZO1Z)
3808 lzo_uint off
= t
& 0x1f;
3812 assert(last_m_off
> 0);
3813 m_pos
-= last_m_off
;
3817 off
= 1 + (off
<< 6) + (*ip
++ >> 2);
3824 TEST_LB(m_pos
); assert(t
> 0); NEED_OP(t
+3-1);
3842 #if defined(COPY_DICT)
3844 m_off
= 1 + (ip
[0] << 6) + (ip
[1] >> 2);
3847 m_off
= 1 + (ip
[0] >> 2) + (ip
[1] << 6);
3852 lzo_uint off
= 1 + (ip
[0] << 6) + (ip
[1] >> 2);
3856 #elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN)
3858 m_pos
-= UA_GET16(ip
) >> 2;
3861 m_pos
-= (ip
[0] >> 2) + (ip
[1] << 6);
3868 #if defined(COPY_DICT)
3869 m_off
= (t
& 8) << 11;
3872 m_pos
-= (t
& 8) << 11;
3886 #if defined(COPY_DICT)
3888 m_off
+= (ip
[0] << 6) + (ip
[1] >> 2);
3890 m_off
+= (ip
[0] >> 2) + (ip
[1] << 6);
3901 m_pos
-= (ip
[0] << 6) + (ip
[1] >> 2);
3902 #elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN)
3903 m_pos
-= UA_GET16(ip
) >> 2;
3905 m_pos
-= (ip
[0] >> 2) + (ip
[1] << 6);
3912 last_m_off
= pd((const lzo_bytep
)op
, m_pos
);
3918 #if defined(COPY_DICT)
3920 m_off
= 1 + (t
<< 6) + (*ip
++ >> 2);
3923 m_off
= 1 + (t
>> 2) + (*ip
++ << 2);
3926 t
= 2; COPY_DICT(t
,m_off
)
3929 t
= 1 + (t
<< 6) + (*ip
++ >> 2);
3935 m_pos
-= *ip
++ << 2;
3937 TEST_LB(m_pos
); NEED_OP(2);
3938 *op
++ = *m_pos
++; *op
++ = *m_pos
;
3943 #if defined(COPY_DICT)
3946 t
+= 3-1; COPY_DICT(t
,m_off
)
3950 TEST_LB(m_pos
); assert(t
> 0); NEED_OP(t
+3-1);
3951 #if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4)
3952 if (op
- m_pos
>= 8)
3957 UA_COPY64(op
,m_pos
);
3958 op
+= 8; m_pos
+= 8; t
-= 8;
3962 UA_COPY32(op
,m_pos
);
3963 op
+= 4; m_pos
+= 4; t
-= 4;
3968 if (t
> 1) { *op
++ = m_pos
[1]; if (t
> 2) { *op
++ = m_pos
[2]; } }
3972 #elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
3973 #if !defined(LZO_UNALIGNED_OK_4)
3974 if (t
>= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op
,m_pos
))
3976 assert((op
- m_pos
) >= 4);
3978 if (t
>= 2 * 4 - (3 - 1) && (op
- m_pos
) >= 4)
3981 UA_COPY32(op
,m_pos
);
3982 op
+= 4; m_pos
+= 4; t
-= 4 - (3 - 1);
3984 UA_COPY32(op
,m_pos
);
3985 op
+= 4; m_pos
+= 4; t
-= 4;
3987 if (t
> 0) do *op
++ = *m_pos
++; while (--t
> 0);
3993 *op
++ = *m_pos
++; *op
++ = *m_pos
++;
3994 do *op
++ = *m_pos
++; while (--t
> 0);
4009 assert(t
> 0); assert(t
< 4); NEED_OP(t
); NEED_IP(t
+1);
4011 do *op
++ = *ip
++; while (--t
> 0);
4014 if (t
> 1) { *op
++ = *ip
++; if (t
> 2) { *op
++ = *ip
++; } }
4017 } while (TEST_IP
&& TEST_OP
);
4020 #if defined(HAVE_TEST_IP) || defined(HAVE_TEST_OP)
4021 *out_len
= pd(op
, out
);
4022 return LZO_E_EOF_NOT_FOUND
;
4027 *out_len
= pd(op
, out
);
4028 return (ip
== ip_end
? LZO_E_OK
:
4029 (ip
< ip_end
? LZO_E_INPUT_NOT_CONSUMED
: LZO_E_INPUT_OVERRUN
));
4031 #if defined(HAVE_NEED_IP)
4033 *out_len
= pd(op
, out
);
4034 return LZO_E_INPUT_OVERRUN
;
4037 #if defined(HAVE_NEED_OP)
4039 *out_len
= pd(op
, out
);
4040 return LZO_E_OUTPUT_OVERRUN
;
4043 #if defined(LZO_TEST_OVERRUN_LOOKBEHIND)
4045 *out_len
= pd(op
, out
);
4046 return LZO_E_LOOKBEHIND_OVERRUN
;
4052 #define LZO_TEST_OVERRUN 1
4053 #undef DO_DECOMPRESS
4054 #define DO_DECOMPRESS lzo1x_decompress_safe
4056 #if !defined(MINILZO_CFG_SKIP_LZO1X_DECOMPRESS_SAFE)
4058 #if defined(LZO_TEST_OVERRUN)
4059 # if !defined(LZO_TEST_OVERRUN_INPUT)
4060 # define LZO_TEST_OVERRUN_INPUT 2
4062 # if !defined(LZO_TEST_OVERRUN_OUTPUT)
4063 # define LZO_TEST_OVERRUN_OUTPUT 2
4065 # if !defined(LZO_TEST_OVERRUN_LOOKBEHIND)
4066 # define LZO_TEST_OVERRUN_LOOKBEHIND 1
4083 #if defined(LZO_TEST_OVERRUN_INPUT)
4084 # if (LZO_TEST_OVERRUN_INPUT >= 1)
4085 # define TEST_IP (ip < ip_end)
4087 # if (LZO_TEST_OVERRUN_INPUT >= 2)
4088 # define NEED_IP(x) \
4089 if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x)) goto input_overrun
4093 #if defined(LZO_TEST_OVERRUN_OUTPUT)
4094 # if (LZO_TEST_OVERRUN_OUTPUT >= 1)
4095 # define TEST_OP (op <= op_end)
4097 # if (LZO_TEST_OVERRUN_OUTPUT >= 2)
4099 # define NEED_OP(x) \
4100 if ((lzo_uint)(op_end - op) < (lzo_uint)(x)) goto output_overrun
4104 #if defined(LZO_TEST_OVERRUN_LOOKBEHIND)
4105 # define TEST_LB(m_pos) if (m_pos < out || m_pos >= op) goto lookbehind_overrun
4106 # define TEST_LBO(m_pos,o) if (m_pos < out || m_pos >= op - (o)) goto lookbehind_overrun
4108 # define TEST_LB(m_pos) ((void) 0)
4109 # define TEST_LBO(m_pos,o) ((void) 0)
4112 #if !defined(LZO_EOF_CODE) && !defined(TEST_IP)
4113 # define TEST_IP (ip < ip_end)
4116 #if defined(TEST_IP)
4117 # define HAVE_TEST_IP 1
4121 #if defined(TEST_OP)
4122 # define HAVE_TEST_OP 1
4127 #if defined(NEED_IP)
4128 # define HAVE_NEED_IP 1
4130 # define NEED_IP(x) ((void) 0)
4132 #if defined(NEED_OP)
4133 # define HAVE_NEED_OP 1
4135 # define NEED_OP(x) ((void) 0)
4138 #if defined(HAVE_TEST_IP) || defined(HAVE_NEED_IP)
4139 # define HAVE_ANY_IP 1
4141 #if defined(HAVE_TEST_OP) || defined(HAVE_NEED_OP)
4142 # define HAVE_ANY_OP 1
4145 #if defined(DO_DECOMPRESS)
4147 DO_DECOMPRESS ( const lzo_bytep in
, lzo_uint in_len
,
4148 lzo_bytep out
, lzo_uintp out_len
,
4152 register lzo_bytep op
;
4153 register const lzo_bytep ip
;
4154 register lzo_uint t
;
4155 #if defined(COPY_DICT)
4157 const lzo_bytep dict_end
;
4159 register const lzo_bytep m_pos
;
4162 const lzo_bytep
const ip_end
= in
+ in_len
;
4163 #if defined(HAVE_ANY_OP)
4164 lzo_bytep
const op_end
= out
+ *out_len
;
4167 lzo_uint last_m_off
= 0;
4172 #if defined(COPY_DICT)
4175 if (dict_len
> M4_MAX_OFFSET
)
4177 dict
+= dict_len
- M4_MAX_OFFSET
;
4178 dict_len
= M4_MAX_OFFSET
;
4180 dict_end
= dict
+ dict_len
;
4199 assert(t
> 0); NEED_OP(t
); NEED_IP(t
+1);
4200 do *op
++ = *ip
++; while (--t
> 0);
4201 goto first_literal_run
;
4204 while (TEST_IP
&& TEST_OP
)
4220 assert(t
> 0); NEED_OP(t
+3); NEED_IP(t
+4);
4221 #if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4)
4226 op
+= 8; ip
+= 8; t
-= 8;
4231 op
+= 4; ip
+= 4; t
-= 4;
4236 if (t
> 1) { *op
++ = *ip
++; if (t
> 2) { *op
++ = *ip
++; } }
4238 #elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
4239 #if !defined(LZO_UNALIGNED_OK_4)
4240 if (PTR_ALIGNED2_4(op
,ip
))
4251 op
+= 4; ip
+= 4; t
-= 4;
4253 if (t
> 0) do *op
++ = *ip
++; while (--t
> 0);
4256 do *op
++ = *ip
++; while (--t
> 0);
4258 #if !defined(LZO_UNALIGNED_OK_4)
4263 #if !defined(LZO_UNALIGNED_OK_4) && !defined(LZO_UNALIGNED_OK_8)
4265 *op
++ = *ip
++; *op
++ = *ip
++; *op
++ = *ip
++;
4266 do *op
++ = *ip
++; while (--t
> 0);
4275 #if defined(COPY_DICT)
4277 m_off
= (1 + M2_MAX_OFFSET
) + (t
<< 6) + (*ip
++ >> 2);
4280 m_off
= (1 + M2_MAX_OFFSET
) + (t
>> 2) + (*ip
++ << 2);
4283 t
= 3; COPY_DICT(t
,m_off
)
4286 t
= (1 + M2_MAX_OFFSET
) + (t
<< 6) + (*ip
++ >> 2);
4290 m_pos
= op
- (1 + M2_MAX_OFFSET
);
4292 m_pos
-= *ip
++ << 2;
4294 TEST_LB(m_pos
); NEED_OP(3);
4295 *op
++ = *m_pos
++; *op
++ = *m_pos
++; *op
++ = *m_pos
;
4303 #if defined(COPY_DICT)
4305 m_off
= 1 + ((t
>> 2) & 7) + (*ip
++ << 3);
4307 #elif defined(LZO1Y)
4308 m_off
= 1 + ((t
>> 2) & 3) + (*ip
++ << 2);
4310 #elif defined(LZO1Z)
4316 m_off
= 1 + (m_off
<< 6) + (*ip
++ >> 2);
4324 m_pos
-= (t
>> 2) & 7;
4325 m_pos
-= *ip
++ << 3;
4327 #elif defined(LZO1Y)
4329 m_pos
-= (t
>> 2) & 3;
4330 m_pos
-= *ip
++ << 2;
4332 #elif defined(LZO1Z)
4334 lzo_uint off
= t
& 0x1f;
4338 assert(last_m_off
> 0);
4339 m_pos
-= last_m_off
;
4343 off
= 1 + (off
<< 6) + (*ip
++ >> 2);
4350 TEST_LB(m_pos
); assert(t
> 0); NEED_OP(t
+3-1);
4368 #if defined(COPY_DICT)
4370 m_off
= 1 + (ip
[0] << 6) + (ip
[1] >> 2);
4373 m_off
= 1 + (ip
[0] >> 2) + (ip
[1] << 6);
4378 lzo_uint off
= 1 + (ip
[0] << 6) + (ip
[1] >> 2);
4382 #elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN)
4384 m_pos
-= UA_GET16(ip
) >> 2;
4387 m_pos
-= (ip
[0] >> 2) + (ip
[1] << 6);
4394 #if defined(COPY_DICT)
4395 m_off
= (t
& 8) << 11;
4398 m_pos
-= (t
& 8) << 11;
4412 #if defined(COPY_DICT)
4414 m_off
+= (ip
[0] << 6) + (ip
[1] >> 2);
4416 m_off
+= (ip
[0] >> 2) + (ip
[1] << 6);
4427 m_pos
-= (ip
[0] << 6) + (ip
[1] >> 2);
4428 #elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN)
4429 m_pos
-= UA_GET16(ip
) >> 2;
4431 m_pos
-= (ip
[0] >> 2) + (ip
[1] << 6);
4438 last_m_off
= pd((const lzo_bytep
)op
, m_pos
);
4444 #if defined(COPY_DICT)
4446 m_off
= 1 + (t
<< 6) + (*ip
++ >> 2);
4449 m_off
= 1 + (t
>> 2) + (*ip
++ << 2);
4452 t
= 2; COPY_DICT(t
,m_off
)
4455 t
= 1 + (t
<< 6) + (*ip
++ >> 2);
4461 m_pos
-= *ip
++ << 2;
4463 TEST_LB(m_pos
); NEED_OP(2);
4464 *op
++ = *m_pos
++; *op
++ = *m_pos
;
4469 #if defined(COPY_DICT)
4472 t
+= 3-1; COPY_DICT(t
,m_off
)
4476 TEST_LB(m_pos
); assert(t
> 0); NEED_OP(t
+3-1);
4477 #if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4)
4478 if (op
- m_pos
>= 8)
4483 UA_COPY64(op
,m_pos
);
4484 op
+= 8; m_pos
+= 8; t
-= 8;
4488 UA_COPY32(op
,m_pos
);
4489 op
+= 4; m_pos
+= 4; t
-= 4;
4494 if (t
> 1) { *op
++ = m_pos
[1]; if (t
> 2) { *op
++ = m_pos
[2]; } }
4498 #elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
4499 #if !defined(LZO_UNALIGNED_OK_4)
4500 if (t
>= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op
,m_pos
))
4502 assert((op
- m_pos
) >= 4);
4504 if (t
>= 2 * 4 - (3 - 1) && (op
- m_pos
) >= 4)
4507 UA_COPY32(op
,m_pos
);
4508 op
+= 4; m_pos
+= 4; t
-= 4 - (3 - 1);
4510 UA_COPY32(op
,m_pos
);
4511 op
+= 4; m_pos
+= 4; t
-= 4;
4513 if (t
> 0) do *op
++ = *m_pos
++; while (--t
> 0);
4519 *op
++ = *m_pos
++; *op
++ = *m_pos
++;
4520 do *op
++ = *m_pos
++; while (--t
> 0);
4535 assert(t
> 0); assert(t
< 4); NEED_OP(t
); NEED_IP(t
+1);
4537 do *op
++ = *ip
++; while (--t
> 0);
4540 if (t
> 1) { *op
++ = *ip
++; if (t
> 2) { *op
++ = *ip
++; } }
4543 } while (TEST_IP
&& TEST_OP
);
4546 #if defined(HAVE_TEST_IP) || defined(HAVE_TEST_OP)
4547 *out_len
= pd(op
, out
);
4548 return LZO_E_EOF_NOT_FOUND
;
4553 *out_len
= pd(op
, out
);
4554 return (ip
== ip_end
? LZO_E_OK
:
4555 (ip
< ip_end
? LZO_E_INPUT_NOT_CONSUMED
: LZO_E_INPUT_OVERRUN
));
4557 #if defined(HAVE_NEED_IP)
4559 *out_len
= pd(op
, out
);
4560 return LZO_E_INPUT_OVERRUN
;
4563 #if defined(HAVE_NEED_OP)
4565 *out_len
= pd(op
, out
);
4566 return LZO_E_OUTPUT_OVERRUN
;
4569 #if defined(LZO_TEST_OVERRUN_LOOKBEHIND)
4571 *out_len
= pd(op
, out
);
4572 return LZO_E_LOOKBEHIND_OVERRUN
;
4578 /***** End of minilzo.c *****/