2 * this file take from grub 2.0
3 * for btrfs UEFI driver
6 /* minilzo.c -- mini subset of the LZO real-time data compression library
8 This file is part of the LZO real-time data compression library.
10 Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer
11 Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer
12 Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer
13 Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer
14 Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer
15 Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer
16 Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer
17 Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer
18 Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer
19 Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
20 Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
21 Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
22 Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
23 Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
24 Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
25 Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
28 The LZO library is free software; you can redistribute it and/or
29 modify it under the terms of the GNU General Public License as
30 published by the Free Software Foundation; either version 2 of
31 the License, or (at your option) any later version.
33 The LZO library is distributed in the hope that it will be useful,
34 but WITHOUT ANY WARRANTY; without even the implied warranty of
35 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36 GNU General Public License for more details.
38 You should have received a copy of the GNU General Public License
39 along with the LZO library; see the file COPYING.
40 If not, write to the Free Software Foundation, Inc.,
41 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
43 Markus F.X.J. Oberhumer
44 <markus@oberhumer.com>
45 http://www.oberhumer.com/opensource/lzo/
50 * the full LZO package can be found at
51 * http://www.oberhumer.com/opensource/lzo/
54 #define __LZO_IN_MINILZO 1
56 #if defined(LZO_CFG_FREESTANDING)
57 # undef MINILZO_HAVE_CONFIG_H
58 # define LZO_LIBC_FREESTANDING 1
59 # define LZO_OS_FREESTANDING 1
62 #ifdef MINILZO_HAVE_CONFIG_H
67 #if defined(MINILZO_CFG_USE_INTERNAL_LZODEFS)
69 #ifndef __LZODEFS_H_INCLUDED
70 #define __LZODEFS_H_INCLUDED 1
72 #if defined(__CYGWIN32__) && !defined(__CYGWIN__)
73 # define __CYGWIN__ __CYGWIN32__
75 #if defined(__IBMCPP__) && !defined(__IBMC__)
76 # define __IBMC__ __IBMCPP__
78 #if defined(__ICL) && defined(_WIN32) && !defined(__INTEL_COMPILER)
79 # define __INTEL_COMPILER __ICL
81 #if 1 && defined(__INTERIX) && defined(__GNUC__) && !defined(_ALL_SOURCE)
82 # define _ALL_SOURCE 1
84 #if defined(__mips__) && defined(__R5900__)
85 # if !defined(__LONG_MAX__)
86 # define __LONG_MAX__ 9223372036854775807L
89 #if defined(__INTEL_COMPILER) && defined(__linux__)
90 # pragma warning(disable: 193)
92 #if defined(__KEIL__) && defined(__C166__)
93 # pragma warning disable = 322
94 #elif 0 && defined(__C251__)
95 # pragma warning disable = 322
97 #if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__)
98 # if (_MSC_VER >= 1300)
99 # pragma warning(disable: 4668)
102 #if 0 && defined(__WATCOMC__)
103 # if (__WATCOMC__ >= 1050) && (__WATCOMC__ < 1060)
104 # pragma warning 203 9
107 #if defined(__BORLANDC__) && defined(__MSDOS__) && !defined(__FLAT__)
111 #define LZO_0xffffL 0xfffful
112 #define LZO_0xffffffffL 0xfffffffful
114 #define LZO_0xffffL 65535ul
115 #define LZO_0xffffffffL 4294967295ul
117 #if (LZO_0xffffL == LZO_0xffffffffL)
118 # error "your preprocessor is broken 1"
120 #if (16ul * 16384ul != 262144ul)
121 # error "your preprocessor is broken 2"
124 #if (32767 >= 4294967295ul)
125 # error "your preprocessor is broken 3"
127 #if (65535u >= 4294967295ul)
128 # error "your preprocessor is broken 4"
131 #if (UINT_MAX == LZO_0xffffL)
132 #if defined(__ZTC__) && defined(__I86__) && !defined(__OS2__)
136 # if !defined(_MSDOS)
139 #elif 0 && defined(__VERSION) && defined(MB_LEN_MAX)
140 # if (__VERSION == 520) && (MB_LEN_MAX == 1)
141 # if !defined(__AZTEC_C__)
142 # define __AZTEC_C__ __VERSION
144 # if !defined(__DOS__)
150 #if defined(_MSC_VER) && defined(M_I86HM) && (UINT_MAX == LZO_0xffffL)
151 # define ptrdiff_t long
152 # define _PTRDIFF_T_DEFINED 1
154 #if (UINT_MAX == LZO_0xffffL)
155 # undef __LZO_RENAME_A
156 # undef __LZO_RENAME_B
157 # if defined(__AZTEC_C__) && defined(__DOS__)
158 # define __LZO_RENAME_A 1
159 # elif defined(_MSC_VER) && defined(MSDOS)
160 # if (_MSC_VER < 600)
161 # define __LZO_RENAME_A 1
162 # elif (_MSC_VER < 700)
163 # define __LZO_RENAME_B 1
165 # elif defined(__TSC__) && defined(__OS2__)
166 # define __LZO_RENAME_A 1
167 # elif defined(__MSDOS__) && defined(__TURBOC__) && (__TURBOC__ < 0x0410)
168 # define __LZO_RENAME_A 1
169 # elif defined(__PACIFIC__) && defined(DOS)
173 # if !defined(__near)
177 # if defined(__LZO_RENAME_A)
178 # if !defined(__cdecl)
179 # define __cdecl cdecl
184 # if !defined(__huge)
187 # if !defined(__near)
190 # if !defined(__pascal)
191 # define __pascal pascal
193 # if !defined(__huge)
196 # elif defined(__LZO_RENAME_B)
197 # if !defined(__cdecl)
198 # define __cdecl _cdecl
203 # if !defined(__huge)
204 # define __huge _huge
206 # if !defined(__near)
207 # define __near _near
209 # if !defined(__pascal)
210 # define __pascal _pascal
212 # elif (defined(__PUREC__) || defined(__TURBOC__)) && defined(__TOS__)
213 # if !defined(__cdecl)
214 # define __cdecl cdecl
216 # if !defined(__pascal)
217 # define __pascal pascal
220 # undef __LZO_RENAME_A
221 # undef __LZO_RENAME_B
223 #if (UINT_MAX == LZO_0xffffL)
224 #if defined(__AZTEC_C__) && defined(__DOS__)
225 # define LZO_BROKEN_CDECL_ALT_SYNTAX 1
226 #elif defined(_MSC_VER) && defined(MSDOS)
227 # if (_MSC_VER < 600)
228 # define LZO_BROKEN_INTEGRAL_CONSTANTS 1
230 # if (_MSC_VER < 700)
231 # define LZO_BROKEN_INTEGRAL_PROMOTION 1
232 # define LZO_BROKEN_SIZEOF 1
234 #elif defined(__PACIFIC__) && defined(DOS)
235 # define LZO_BROKEN_INTEGRAL_CONSTANTS 1
236 #elif defined(__TURBOC__) && defined(__MSDOS__)
237 # if (__TURBOC__ < 0x0150)
238 # define LZO_BROKEN_CDECL_ALT_SYNTAX 1
239 # define LZO_BROKEN_INTEGRAL_CONSTANTS 1
240 # define LZO_BROKEN_INTEGRAL_PROMOTION 1
242 # if (__TURBOC__ < 0x0200)
243 # define LZO_BROKEN_SIZEOF 1
245 # if (__TURBOC__ < 0x0400) && defined(__cplusplus)
246 # define LZO_BROKEN_CDECL_ALT_SYNTAX 1
248 #elif (defined(__PUREC__) || defined(__TURBOC__)) && defined(__TOS__)
249 # define LZO_BROKEN_CDECL_ALT_SYNTAX 1
250 # define LZO_BROKEN_SIZEOF 1
253 #if defined(__WATCOMC__) && (__WATCOMC__ < 900)
254 # define LZO_BROKEN_INTEGRAL_CONSTANTS 1
256 #if defined(_CRAY) && defined(_CRAY1)
257 # define LZO_BROKEN_SIGNED_RIGHT_SHIFT 1
259 #define LZO_PP_STRINGIZE(x) #x
260 #define LZO_PP_MACRO_EXPAND(x) LZO_PP_STRINGIZE(x)
261 #define LZO_PP_CONCAT2(a,b) a ## b
262 #define LZO_PP_CONCAT3(a,b,c) a ## b ## c
263 #define LZO_PP_CONCAT4(a,b,c,d) a ## b ## c ## d
264 #define LZO_PP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e
265 #define LZO_PP_ECONCAT2(a,b) LZO_PP_CONCAT2(a,b)
266 #define LZO_PP_ECONCAT3(a,b,c) LZO_PP_CONCAT3(a,b,c)
267 #define LZO_PP_ECONCAT4(a,b,c,d) LZO_PP_CONCAT4(a,b,c,d)
268 #define LZO_PP_ECONCAT5(a,b,c,d,e) LZO_PP_CONCAT5(a,b,c,d,e)
270 #define LZO_CPP_STRINGIZE(x) #x
271 #define LZO_CPP_MACRO_EXPAND(x) LZO_CPP_STRINGIZE(x)
272 #define LZO_CPP_CONCAT2(a,b) a ## b
273 #define LZO_CPP_CONCAT3(a,b,c) a ## b ## c
274 #define LZO_CPP_CONCAT4(a,b,c,d) a ## b ## c ## d
275 #define LZO_CPP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e
276 #define LZO_CPP_ECONCAT2(a,b) LZO_CPP_CONCAT2(a,b)
277 #define LZO_CPP_ECONCAT3(a,b,c) LZO_CPP_CONCAT3(a,b,c)
278 #define LZO_CPP_ECONCAT4(a,b,c,d) LZO_CPP_CONCAT4(a,b,c,d)
279 #define LZO_CPP_ECONCAT5(a,b,c,d,e) LZO_CPP_CONCAT5(a,b,c,d,e)
281 #define __LZO_MASK_GEN(o,b) (((((o) << ((b)-1)) - (o)) << 1) + (o))
282 #if 1 && defined(__cplusplus)
283 # if !defined(__STDC_CONSTANT_MACROS)
284 # define __STDC_CONSTANT_MACROS 1
286 # if !defined(__STDC_LIMIT_MACROS)
287 # define __STDC_LIMIT_MACROS 1
290 #if defined(__cplusplus)
291 # define LZO_EXTERN_C extern "C"
293 # define LZO_EXTERN_C extern
295 #if !defined(__LZO_OS_OVERRIDE)
296 #if (LZO_OS_FREESTANDING)
297 # define LZO_INFO_OS "freestanding"
298 #elif (LZO_OS_EMBEDDED)
299 # define LZO_INFO_OS "embedded"
300 #elif 1 && defined(__IAR_SYSTEMS_ICC__)
301 # define LZO_OS_EMBEDDED 1
302 # define LZO_INFO_OS "embedded"
303 #elif defined(__CYGWIN__) && defined(__GNUC__)
304 # define LZO_OS_CYGWIN 1
305 # define LZO_INFO_OS "cygwin"
306 #elif defined(__EMX__) && defined(__GNUC__)
307 # define LZO_OS_EMX 1
308 # define LZO_INFO_OS "emx"
309 #elif defined(__BEOS__)
310 # define LZO_OS_BEOS 1
311 # define LZO_INFO_OS "beos"
312 #elif defined(__Lynx__)
313 # define LZO_OS_LYNXOS 1
314 # define LZO_INFO_OS "lynxos"
315 #elif defined(__OS400__)
316 # define LZO_OS_OS400 1
317 # define LZO_INFO_OS "os400"
318 #elif defined(__QNX__)
319 # define LZO_OS_QNX 1
320 # define LZO_INFO_OS "qnx"
321 #elif defined(__BORLANDC__) && defined(__DPMI32__) && (__BORLANDC__ >= 0x0460)
322 # define LZO_OS_DOS32 1
323 # define LZO_INFO_OS "dos32"
324 #elif defined(__BORLANDC__) && defined(__DPMI16__)
325 # define LZO_OS_DOS16 1
326 # define LZO_INFO_OS "dos16"
327 #elif defined(__ZTC__) && defined(DOS386)
328 # define LZO_OS_DOS32 1
329 # define LZO_INFO_OS "dos32"
330 #elif defined(__OS2__) || defined(__OS2V2__)
331 # if (UINT_MAX == LZO_0xffffL)
332 # define LZO_OS_OS216 1
333 # define LZO_INFO_OS "os216"
334 # elif (UINT_MAX == LZO_0xffffffffL)
335 # define LZO_OS_OS2 1
336 # define LZO_INFO_OS "os2"
338 # error "check your limits.h header"
340 #elif defined(__WIN64__) || defined(_WIN64) || defined(WIN64)
341 # define LZO_OS_WIN64 1
342 # define LZO_INFO_OS "win64"
343 #elif defined(__WIN32__) || defined(_WIN32) || defined(WIN32) || defined(__WINDOWS_386__)
344 # define LZO_OS_WIN32 1
345 # define LZO_INFO_OS "win32"
346 #elif defined(__MWERKS__) && defined(__INTEL__)
347 # define LZO_OS_WIN32 1
348 # define LZO_INFO_OS "win32"
349 #elif defined(__WINDOWS__) || defined(_WINDOWS) || defined(_Windows)
350 # if (UINT_MAX == LZO_0xffffL)
351 # define LZO_OS_WIN16 1
352 # define LZO_INFO_OS "win16"
353 # elif (UINT_MAX == LZO_0xffffffffL)
354 # define LZO_OS_WIN32 1
355 # define LZO_INFO_OS "win32"
357 # error "check your limits.h header"
359 #elif defined(__DOS__) || defined(__MSDOS__) || defined(_MSDOS) || defined(MSDOS) || (defined(__PACIFIC__) && defined(DOS))
360 # if (UINT_MAX == LZO_0xffffL)
361 # define LZO_OS_DOS16 1
362 # define LZO_INFO_OS "dos16"
363 # elif (UINT_MAX == LZO_0xffffffffL)
364 # define LZO_OS_DOS32 1
365 # define LZO_INFO_OS "dos32"
367 # error "check your limits.h header"
369 #elif defined(__WATCOMC__)
370 # if defined(__NT__) && (UINT_MAX == LZO_0xffffL)
371 # define LZO_OS_DOS16 1
372 # define LZO_INFO_OS "dos16"
373 # elif defined(__NT__) && (__WATCOMC__ < 1100)
374 # define LZO_OS_WIN32 1
375 # define LZO_INFO_OS "win32"
376 # elif defined(__linux__) || defined(__LINUX__)
377 # define LZO_OS_POSIX 1
378 # define LZO_INFO_OS "posix"
380 # error "please specify a target using the -bt compiler option"
382 #elif defined(__palmos__)
383 # define LZO_OS_PALMOS 1
384 # define LZO_INFO_OS "palmos"
385 #elif defined(__TOS__) || defined(__atarist__)
386 # define LZO_OS_TOS 1
387 # define LZO_INFO_OS "tos"
388 #elif defined(macintosh) && !defined(__ppc__)
389 # define LZO_OS_MACCLASSIC 1
390 # define LZO_INFO_OS "macclassic"
392 # define LZO_OS_VMS 1
393 # define LZO_INFO_OS "vms"
394 #elif ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__))
395 # define LZO_OS_CONSOLE 1
396 # define LZO_OS_CONSOLE_PS2 1
397 # define LZO_INFO_OS "console"
398 # define LZO_INFO_OS_CONSOLE "ps2"
399 #elif (defined(__mips__) && defined(__psp__))
400 # define LZO_OS_CONSOLE 1
401 # define LZO_OS_CONSOLE_PSP 1
402 # define LZO_INFO_OS "console"
403 # define LZO_INFO_OS_CONSOLE "psp"
405 # define LZO_OS_POSIX 1
406 # define LZO_INFO_OS "posix"
409 # if defined(_AIX) || defined(__AIX__) || defined(__aix__)
410 # define LZO_OS_POSIX_AIX 1
411 # define LZO_INFO_OS_POSIX "aix"
412 # elif defined(__FreeBSD__)
413 # define LZO_OS_POSIX_FREEBSD 1
414 # define LZO_INFO_OS_POSIX "freebsd"
415 # elif defined(__hpux__) || defined(__hpux)
416 # define LZO_OS_POSIX_HPUX 1
417 # define LZO_INFO_OS_POSIX "hpux"
418 # elif defined(__INTERIX)
419 # define LZO_OS_POSIX_INTERIX 1
420 # define LZO_INFO_OS_POSIX "interix"
421 # elif defined(__IRIX__) || defined(__irix__)
422 # define LZO_OS_POSIX_IRIX 1
423 # define LZO_INFO_OS_POSIX "irix"
424 # elif defined(__linux__) || defined(__linux) || defined(__LINUX__)
425 # define LZO_OS_POSIX_LINUX 1
426 # define LZO_INFO_OS_POSIX "linux"
427 # elif defined(__APPLE__) || defined(__MACOS__)
428 # define LZO_OS_POSIX_MACOSX 1
429 # define LZO_INFO_OS_POSIX "macosx"
430 # elif defined(__minix__) || defined(__minix)
431 # define LZO_OS_POSIX_MINIX 1
432 # define LZO_INFO_OS_POSIX "minix"
433 # elif defined(__NetBSD__)
434 # define LZO_OS_POSIX_NETBSD 1
435 # define LZO_INFO_OS_POSIX "netbsd"
436 # elif defined(__OpenBSD__)
437 # define LZO_OS_POSIX_OPENBSD 1
438 # define LZO_INFO_OS_POSIX "openbsd"
439 # elif defined(__osf__)
440 # define LZO_OS_POSIX_OSF 1
441 # define LZO_INFO_OS_POSIX "osf"
442 # elif defined(__solaris__) || defined(__sun)
443 # if defined(__SVR4) || defined(__svr4__)
444 # define LZO_OS_POSIX_SOLARIS 1
445 # define LZO_INFO_OS_POSIX "solaris"
447 # define LZO_OS_POSIX_SUNOS 1
448 # define LZO_INFO_OS_POSIX "sunos"
450 # elif defined(__ultrix__) || defined(__ultrix)
451 # define LZO_OS_POSIX_ULTRIX 1
452 # define LZO_INFO_OS_POSIX "ultrix"
453 # elif defined(_UNICOS)
454 # define LZO_OS_POSIX_UNICOS 1
455 # define LZO_INFO_OS_POSIX "unicos"
457 # define LZO_OS_POSIX_UNKNOWN 1
458 # define LZO_INFO_OS_POSIX "unknown"
462 #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16)
463 # if (UINT_MAX != LZO_0xffffL)
464 # error "this should not happen"
466 # if (ULONG_MAX != LZO_0xffffffffL)
467 # error "this should not happen"
470 #if (LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_WIN32 || LZO_OS_WIN64)
471 # if (UINT_MAX != LZO_0xffffffffL)
472 # error "this should not happen"
474 # if (ULONG_MAX != LZO_0xffffffffL)
475 # error "this should not happen"
478 #if defined(CIL) && defined(_GNUCC) && defined(__GNUC__)
479 # define LZO_CC_CILLY 1
480 # define LZO_INFO_CC "Cilly"
481 # if defined(__CILLY__)
482 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__CILLY__)
484 # define LZO_INFO_CCVER "unknown"
486 #elif 0 && defined(SDCC) && defined(__VERSION__) && !defined(__GNUC__)
487 # define LZO_CC_SDCC 1
488 # define LZO_INFO_CC "sdcc"
489 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(SDCC)
490 #elif defined(__PATHSCALE__) && defined(__PATHCC_PATCHLEVEL__)
491 # define LZO_CC_PATHSCALE (__PATHCC__ * 0x10000L + __PATHCC_MINOR__ * 0x100 + __PATHCC_PATCHLEVEL__)
492 # define LZO_INFO_CC "Pathscale C"
493 # define LZO_INFO_CCVER __PATHSCALE__
494 #elif defined(__INTEL_COMPILER)
495 # define LZO_CC_INTELC 1
496 # define LZO_INFO_CC "Intel C"
497 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__INTEL_COMPILER)
498 # if defined(_WIN32) || defined(_WIN64)
499 # define LZO_CC_SYNTAX_MSC 1
501 # define LZO_CC_SYNTAX_GNUC 1
503 #elif defined(__POCC__) && defined(_WIN32)
504 # define LZO_CC_PELLESC 1
505 # define LZO_INFO_CC "Pelles C"
506 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__POCC__)
507 #elif defined(__clang__) && defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__)
508 # if defined(__GNUC_PATCHLEVEL__)
509 # define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__)
511 # define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100)
513 # if defined(__clang_major__) && defined(__clang_minor__) && defined(__clang_patchlevel__)
514 # define LZO_CC_CLANG_CLANG (__clang_major__ * 0x10000L + __clang_minor__ * 0x100 + __clang_patchlevel__)
516 # define LZO_CC_CLANG_CLANG 0x010000L
518 # define LZO_CC_CLANG LZO_CC_CLANG_GNUC
519 # define LZO_INFO_CC "clang"
520 # define LZO_INFO_CCVER __VERSION__
521 #elif defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__)
522 # if defined(__GNUC_PATCHLEVEL__)
523 # define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__)
525 # define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100)
527 # define LZO_CC_LLVM LZO_CC_LLVM_GNUC
528 # define LZO_INFO_CC "llvm-gcc"
529 # define LZO_INFO_CCVER __VERSION__
530 #elif defined(__GNUC__) && defined(__VERSION__)
531 # if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
532 # define LZO_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__)
533 # elif defined(__GNUC_MINOR__)
534 # define LZO_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100)
536 # define LZO_CC_GNUC (__GNUC__ * 0x10000L)
538 # define LZO_INFO_CC "gcc"
539 # define LZO_INFO_CCVER __VERSION__
540 #elif defined(__ACK__) && defined(_ACK)
541 # define LZO_CC_ACK 1
542 # define LZO_INFO_CC "Amsterdam Compiler Kit C"
543 # define LZO_INFO_CCVER "unknown"
544 #elif defined(__AZTEC_C__)
545 # define LZO_CC_AZTECC 1
546 # define LZO_INFO_CC "Aztec C"
547 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__AZTEC_C__)
548 #elif defined(__CODEGEARC__)
549 # define LZO_CC_CODEGEARC 1
550 # define LZO_INFO_CC "CodeGear C"
551 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__CODEGEARC__)
552 #elif defined(__BORLANDC__)
553 # define LZO_CC_BORLANDC 1
554 # define LZO_INFO_CC "Borland C"
555 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__BORLANDC__)
556 #elif defined(_CRAYC) && defined(_RELEASE)
557 # define LZO_CC_CRAYC 1
558 # define LZO_INFO_CC "Cray C"
559 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_RELEASE)
560 #elif defined(__DMC__) && defined(__SC__)
561 # define LZO_CC_DMC 1
562 # define LZO_INFO_CC "Digital Mars C"
563 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__DMC__)
564 #elif defined(__DECC)
565 # define LZO_CC_DECC 1
566 # define LZO_INFO_CC "DEC C"
567 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__DECC)
568 #elif defined(__HIGHC__)
569 # define LZO_CC_HIGHC 1
570 # define LZO_INFO_CC "MetaWare High C"
571 # define LZO_INFO_CCVER "unknown"
572 #elif defined(__IAR_SYSTEMS_ICC__)
573 # define LZO_CC_IARC 1
574 # define LZO_INFO_CC "IAR C"
575 # if defined(__VER__)
576 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__VER__)
578 # define LZO_INFO_CCVER "unknown"
580 #elif defined(__IBMC__)
581 # define LZO_CC_IBMC 1
582 # define LZO_INFO_CC "IBM C"
583 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__IBMC__)
584 #elif defined(__KEIL__) && defined(__C166__)
585 # define LZO_CC_KEILC 1
586 # define LZO_INFO_CC "Keil C"
587 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__C166__)
588 #elif defined(__LCC__) && defined(_WIN32) && defined(__LCCOPTIMLEVEL)
589 # define LZO_CC_LCCWIN32 1
590 # define LZO_INFO_CC "lcc-win32"
591 # define LZO_INFO_CCVER "unknown"
592 #elif defined(__LCC__)
593 # define LZO_CC_LCC 1
594 # define LZO_INFO_CC "lcc"
595 # if defined(__LCC_VERSION__)
596 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__LCC_VERSION__)
598 # define LZO_INFO_CCVER "unknown"
600 #elif defined(_MSC_VER)
601 # define LZO_CC_MSC 1
602 # define LZO_INFO_CC "Microsoft C"
603 # if defined(_MSC_FULL_VER)
604 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) "." LZO_PP_MACRO_EXPAND(_MSC_FULL_VER)
606 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER)
608 #elif defined(__MWERKS__)
609 # define LZO_CC_MWERKS 1
610 # define LZO_INFO_CC "Metrowerks C"
611 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__MWERKS__)
612 #elif (defined(__NDPC__) || defined(__NDPX__)) && defined(__i386)
613 # define LZO_CC_NDPC 1
614 # define LZO_INFO_CC "Microway NDP C"
615 # define LZO_INFO_CCVER "unknown"
616 #elif defined(__PACIFIC__)
617 # define LZO_CC_PACIFICC 1
618 # define LZO_INFO_CC "Pacific C"
619 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PACIFIC__)
620 #elif defined(__PGI) && (defined(__linux__) || defined(__WIN32__))
621 # define LZO_CC_PGI 1
622 # define LZO_INFO_CC "Portland Group PGI C"
623 # define LZO_INFO_CCVER "unknown"
624 #elif defined(__PUREC__) && defined(__TOS__)
625 # define LZO_CC_PUREC 1
626 # define LZO_INFO_CC "Pure C"
627 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PUREC__)
628 #elif defined(__SC__) && defined(__ZTC__)
629 # define LZO_CC_SYMANTECC 1
630 # define LZO_INFO_CC "Symantec C"
631 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SC__)
632 #elif defined(__SUNPRO_C)
633 # define LZO_INFO_CC "SunPro C"
634 # if ((__SUNPRO_C)+0 > 0)
635 # define LZO_CC_SUNPROC __SUNPRO_C
636 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_C)
638 # define LZO_CC_SUNPROC 1
639 # define LZO_INFO_CCVER "unknown"
641 #elif defined(__SUNPRO_CC)
642 # define LZO_INFO_CC "SunPro C"
643 # if ((__SUNPRO_CC)+0 > 0)
644 # define LZO_CC_SUNPROC __SUNPRO_CC
645 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_CC)
647 # define LZO_CC_SUNPROC 1
648 # define LZO_INFO_CCVER "unknown"
650 #elif defined(__TINYC__)
651 # define LZO_CC_TINYC 1
652 # define LZO_INFO_CC "Tiny C"
653 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TINYC__)
654 #elif defined(__TSC__)
655 # define LZO_CC_TOPSPEEDC 1
656 # define LZO_INFO_CC "TopSpeed C"
657 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TSC__)
658 #elif defined(__WATCOMC__)
659 # define LZO_CC_WATCOMC 1
660 # define LZO_INFO_CC "Watcom C"
661 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__WATCOMC__)
662 #elif defined(__TURBOC__)
663 # define LZO_CC_TURBOC 1
664 # define LZO_INFO_CC "Turbo C"
665 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TURBOC__)
666 #elif defined(__ZTC__)
667 # define LZO_CC_ZORTECHC 1
668 # define LZO_INFO_CC "Zortech C"
669 # if (__ZTC__ == 0x310)
670 # define LZO_INFO_CCVER "0x310"
672 # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__ZTC__)
675 # define LZO_CC_UNKNOWN 1
676 # define LZO_INFO_CC "unknown"
677 # define LZO_INFO_CCVER "unknown"
679 #if 0 && (LZO_CC_MSC && (_MSC_VER >= 1200)) && !defined(_MSC_FULL_VER)
680 # error "LZO_CC_MSC: _MSC_FULL_VER is not defined"
682 #if !defined(__LZO_ARCH_OVERRIDE) && !(LZO_ARCH_GENERIC) && defined(_CRAY)
683 # if (UINT_MAX > LZO_0xffffffffL) && defined(_CRAY)
684 # if defined(_CRAYMPP) || defined(_CRAYT3D) || defined(_CRAYT3E)
685 # define LZO_ARCH_CRAY_MPP 1
686 # elif defined(_CRAY1)
687 # define LZO_ARCH_CRAY_PVP 1
691 #if !defined(__LZO_ARCH_OVERRIDE)
692 #if (LZO_ARCH_GENERIC)
693 # define LZO_INFO_ARCH "generic"
694 #elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16)
695 # define LZO_ARCH_I086 1
696 # define LZO_ARCH_IA16 1
697 # define LZO_INFO_ARCH "i086"
698 #elif defined(__alpha__) || defined(__alpha) || defined(_M_ALPHA)
699 # define LZO_ARCH_ALPHA 1
700 # define LZO_INFO_ARCH "alpha"
701 #elif (LZO_ARCH_CRAY_MPP) && (defined(_CRAYT3D) || defined(_CRAYT3E))
702 # define LZO_ARCH_ALPHA 1
703 # define LZO_INFO_ARCH "alpha"
704 #elif defined(__amd64__) || defined(__x86_64__) || defined(_M_AMD64)
705 # define LZO_ARCH_AMD64 1
706 # define LZO_INFO_ARCH "amd64"
707 #elif defined(__thumb__) || (defined(_M_ARM) && defined(_M_THUMB))
708 # define LZO_ARCH_ARM 1
709 # define LZO_ARCH_ARM_THUMB 1
710 # define LZO_INFO_ARCH "arm_thumb"
711 #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCARM__)
712 # define LZO_ARCH_ARM 1
713 # if defined(__CPU_MODE__) && ((__CPU_MODE__)+0 == 1)
714 # define LZO_ARCH_ARM_THUMB 1
715 # define LZO_INFO_ARCH "arm_thumb"
716 # elif defined(__CPU_MODE__) && ((__CPU_MODE__)+0 == 2)
717 # define LZO_INFO_ARCH "arm"
719 # define LZO_INFO_ARCH "arm"
721 #elif defined(__arm__) || defined(_M_ARM)
722 # define LZO_ARCH_ARM 1
723 # define LZO_INFO_ARCH "arm"
724 #elif (UINT_MAX <= LZO_0xffffL) && defined(__AVR__)
725 # define LZO_ARCH_AVR 1
726 # define LZO_INFO_ARCH "avr"
727 #elif defined(__avr32__) || defined(__AVR32__)
728 # define LZO_ARCH_AVR32 1
729 # define LZO_INFO_ARCH "avr32"
730 #elif defined(__bfin__)
731 # define LZO_ARCH_BLACKFIN 1
732 # define LZO_INFO_ARCH "blackfin"
733 #elif (UINT_MAX == LZO_0xffffL) && defined(__C166__)
734 # define LZO_ARCH_C166 1
735 # define LZO_INFO_ARCH "c166"
736 #elif defined(__cris__)
737 # define LZO_ARCH_CRIS 1
738 # define LZO_INFO_ARCH "cris"
739 #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCEZ80__)
740 # define LZO_ARCH_EZ80 1
741 # define LZO_INFO_ARCH "ez80"
742 #elif defined(__H8300__) || defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__)
743 # define LZO_ARCH_H8300 1
744 # define LZO_INFO_ARCH "h8300"
745 #elif defined(__hppa__) || defined(__hppa)
746 # define LZO_ARCH_HPPA 1
747 # define LZO_INFO_ARCH "hppa"
748 #elif defined(__386__) || defined(__i386__) || defined(__i386) || defined(_M_IX86) || defined(_M_I386)
749 # define LZO_ARCH_I386 1
750 # define LZO_ARCH_IA32 1
751 # define LZO_INFO_ARCH "i386"
752 #elif (LZO_CC_ZORTECHC && defined(__I86__))
753 # define LZO_ARCH_I386 1
754 # define LZO_ARCH_IA32 1
755 # define LZO_INFO_ARCH "i386"
756 #elif (LZO_OS_DOS32 && LZO_CC_HIGHC) && defined(_I386)
757 # define LZO_ARCH_I386 1
758 # define LZO_ARCH_IA32 1
759 # define LZO_INFO_ARCH "i386"
760 #elif defined(__ia64__) || defined(__ia64) || defined(_M_IA64)
761 # define LZO_ARCH_IA64 1
762 # define LZO_INFO_ARCH "ia64"
763 #elif (UINT_MAX == LZO_0xffffL) && defined(__m32c__)
764 # define LZO_ARCH_M16C 1
765 # define LZO_INFO_ARCH "m16c"
766 #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCM16C__)
767 # define LZO_ARCH_M16C 1
768 # define LZO_INFO_ARCH "m16c"
769 #elif defined(__m32r__)
770 # define LZO_ARCH_M32R 1
771 # define LZO_INFO_ARCH "m32r"
772 #elif (LZO_OS_TOS) || defined(__m68k__) || defined(__m68000__) || defined(__mc68000__) || defined(__mc68020__) || defined(_M_M68K)
773 # define LZO_ARCH_M68K 1
774 # define LZO_INFO_ARCH "m68k"
775 #elif (UINT_MAX == LZO_0xffffL) && defined(__C251__)
776 # define LZO_ARCH_MCS251 1
777 # define LZO_INFO_ARCH "mcs251"
778 #elif (UINT_MAX == LZO_0xffffL) && defined(__C51__)
779 # define LZO_ARCH_MCS51 1
780 # define LZO_INFO_ARCH "mcs51"
781 #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICC8051__)
782 # define LZO_ARCH_MCS51 1
783 # define LZO_INFO_ARCH "mcs51"
784 #elif defined(__mips__) || defined(__mips) || defined(_MIPS_ARCH) || defined(_M_MRX000)
785 # define LZO_ARCH_MIPS 1
786 # define LZO_INFO_ARCH "mips"
787 #elif (UINT_MAX == LZO_0xffffL) && defined(__MSP430__)
788 # define LZO_ARCH_MSP430 1
789 # define LZO_INFO_ARCH "msp430"
790 #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICC430__)
791 # define LZO_ARCH_MSP430 1
792 # define LZO_INFO_ARCH "msp430"
793 #elif defined(__powerpc__) || defined(__powerpc) || defined(__ppc__) || defined(__PPC__) || defined(_M_PPC) || defined(_ARCH_PPC) || defined(_ARCH_PWR)
794 # define LZO_ARCH_POWERPC 1
795 # define LZO_INFO_ARCH "powerpc"
796 #elif defined(__s390__) || defined(__s390) || defined(__s390x__) || defined(__s390x)
797 # define LZO_ARCH_S390 1
798 # define LZO_INFO_ARCH "s390"
799 #elif defined(__sh__) || defined(_M_SH)
800 # define LZO_ARCH_SH 1
801 # define LZO_INFO_ARCH "sh"
802 #elif defined(__sparc__) || defined(__sparc) || defined(__sparcv8)
803 # define LZO_ARCH_SPARC 1
804 # define LZO_INFO_ARCH "sparc"
805 #elif defined(__SPU__)
806 # define LZO_ARCH_SPU 1
807 # define LZO_INFO_ARCH "spu"
808 #elif (UINT_MAX == LZO_0xffffL) && defined(__z80)
809 # define LZO_ARCH_Z80 1
810 # define LZO_INFO_ARCH "z80"
811 #elif (LZO_ARCH_CRAY_PVP)
812 # if defined(_CRAYSV1)
813 # define LZO_ARCH_CRAY_SV1 1
814 # define LZO_INFO_ARCH "cray_sv1"
816 # define LZO_ARCH_CRAY_T90 1
817 # define LZO_INFO_ARCH "cray_t90"
819 # define LZO_ARCH_CRAY_YMP 1
820 # define LZO_INFO_ARCH "cray_ymp"
822 # define LZO_ARCH_CRAY_XMP 1
823 # define LZO_INFO_ARCH "cray_xmp"
826 # define LZO_ARCH_UNKNOWN 1
827 # define LZO_INFO_ARCH "unknown"
830 #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_DOS32 || LZO_OS_OS2)
831 # error "FIXME - missing define for CPU architecture"
833 #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN32)
834 # error "FIXME - missing WIN32 define for CPU architecture"
836 #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN64)
837 # error "FIXME - missing WIN64 define for CPU architecture"
839 #if (LZO_OS_OS216 || LZO_OS_WIN16)
840 # define LZO_ARCH_I086PM 1
841 # define LZO_ARCH_IA16PM 1
842 #elif 1 && (LZO_OS_DOS16 && defined(BLX286))
843 # define LZO_ARCH_I086PM 1
844 # define LZO_ARCH_IA16PM 1
845 #elif 1 && (LZO_OS_DOS16 && defined(DOSX286))
846 # define LZO_ARCH_I086PM 1
847 # define LZO_ARCH_IA16PM 1
848 #elif 1 && (LZO_OS_DOS16 && LZO_CC_BORLANDC && defined(__DPMI16__))
849 # define LZO_ARCH_I086PM 1
850 # define LZO_ARCH_IA16PM 1
852 #if (LZO_ARCH_ARM_THUMB) && !(LZO_ARCH_ARM)
853 # error "this should not happen"
855 #if (LZO_ARCH_I086PM) && !(LZO_ARCH_I086)
856 # error "this should not happen"
859 # if (UINT_MAX != LZO_0xffffL)
860 # error "this should not happen"
862 # if (ULONG_MAX != LZO_0xffffffffL)
863 # error "this should not happen"
867 # if (UINT_MAX != LZO_0xffffL) && defined(__i386_int16__)
868 # error "this should not happen"
870 # if (UINT_MAX != LZO_0xffffffffL) && !defined(__i386_int16__)
871 # error "this should not happen"
873 # if (ULONG_MAX != LZO_0xffffffffL)
874 # error "this should not happen"
877 #if !defined(__LZO_MM_OVERRIDE)
879 #if (UINT_MAX != LZO_0xffffL)
880 # error "this should not happen"
882 #if defined(__TINY__) || defined(M_I86TM) || defined(_M_I86TM)
883 # define LZO_MM_TINY 1
884 #elif defined(__HUGE__) || defined(_HUGE_) || defined(M_I86HM) || defined(_M_I86HM)
885 # define LZO_MM_HUGE 1
886 #elif defined(__SMALL__) || defined(M_I86SM) || defined(_M_I86SM) || defined(SMALL_MODEL)
887 # define LZO_MM_SMALL 1
888 #elif defined(__MEDIUM__) || defined(M_I86MM) || defined(_M_I86MM)
889 # define LZO_MM_MEDIUM 1
890 #elif defined(__COMPACT__) || defined(M_I86CM) || defined(_M_I86CM)
891 # define LZO_MM_COMPACT 1
892 #elif defined(__LARGE__) || defined(M_I86LM) || defined(_M_I86LM) || defined(LARGE_MODEL)
893 # define LZO_MM_LARGE 1
894 #elif (LZO_CC_AZTECC)
895 # if defined(_LARGE_CODE) && defined(_LARGE_DATA)
896 # define LZO_MM_LARGE 1
897 # elif defined(_LARGE_CODE)
898 # define LZO_MM_MEDIUM 1
899 # elif defined(_LARGE_DATA)
900 # define LZO_MM_COMPACT 1
902 # define LZO_MM_SMALL 1
904 #elif (LZO_CC_ZORTECHC && defined(__VCM__))
905 # define LZO_MM_LARGE 1
907 # error "unknown memory model"
909 #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16)
910 #define LZO_HAVE_MM_HUGE_PTR 1
911 #define LZO_HAVE_MM_HUGE_ARRAY 1
913 # undef LZO_HAVE_MM_HUGE_ARRAY
915 #if (LZO_CC_AZTECC || LZO_CC_PACIFICC || LZO_CC_ZORTECHC)
916 # undef LZO_HAVE_MM_HUGE_PTR
917 # undef LZO_HAVE_MM_HUGE_ARRAY
918 #elif (LZO_CC_DMC || LZO_CC_SYMANTECC)
919 # undef LZO_HAVE_MM_HUGE_ARRAY
920 #elif (LZO_CC_MSC && defined(_QC))
921 # undef LZO_HAVE_MM_HUGE_ARRAY
922 # if (_MSC_VER < 600)
923 # undef LZO_HAVE_MM_HUGE_PTR
925 #elif (LZO_CC_TURBOC && (__TURBOC__ < 0x0295))
926 # undef LZO_HAVE_MM_HUGE_ARRAY
928 #if (LZO_ARCH_I086PM) && !(LZO_HAVE_MM_HUGE_PTR)
930 # error "this should not happen"
931 # elif (LZO_CC_ZORTECHC)
933 # error "this should not happen"
939 #if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0200))
940 extern void __near __cdecl
_AHSHIFT(void);
941 # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT)
942 #elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC)
943 extern void __near __cdecl
_AHSHIFT(void);
944 # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT)
945 #elif (LZO_CC_MSC || LZO_CC_TOPSPEEDC)
946 extern void __near __cdecl
_AHSHIFT(void);
947 # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT)
948 #elif (LZO_CC_TURBOC && (__TURBOC__ >= 0x0295))
949 extern void __near __cdecl
_AHSHIFT(void);
950 # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT)
951 #elif ((LZO_CC_AZTECC || LZO_CC_PACIFICC || LZO_CC_TURBOC) && LZO_OS_DOS16)
952 # define LZO_MM_AHSHIFT 12
953 #elif (LZO_CC_WATCOMC)
954 extern unsigned char _HShift
;
955 # define LZO_MM_AHSHIFT ((unsigned) _HShift)
957 # error "FIXME - implement LZO_MM_AHSHIFT"
963 #elif (LZO_ARCH_C166)
964 #if !defined(__MODEL__)
965 # error "FIXME - C166 __MODEL__"
966 #elif ((__MODEL__) == 0)
967 # define LZO_MM_SMALL 1
968 #elif ((__MODEL__) == 1)
969 # define LZO_MM_SMALL 1
970 #elif ((__MODEL__) == 2)
971 # define LZO_MM_LARGE 1
972 #elif ((__MODEL__) == 3)
973 # define LZO_MM_TINY 1
974 #elif ((__MODEL__) == 4)
975 # define LZO_MM_XTINY 1
976 #elif ((__MODEL__) == 5)
977 # define LZO_MM_XSMALL 1
979 # error "FIXME - C166 __MODEL__"
981 #elif (LZO_ARCH_MCS251)
982 #if !defined(__MODEL__)
983 # error "FIXME - MCS251 __MODEL__"
984 #elif ((__MODEL__) == 0)
985 # define LZO_MM_SMALL 1
986 #elif ((__MODEL__) == 2)
987 # define LZO_MM_LARGE 1
988 #elif ((__MODEL__) == 3)
989 # define LZO_MM_TINY 1
990 #elif ((__MODEL__) == 4)
991 # define LZO_MM_XTINY 1
992 #elif ((__MODEL__) == 5)
993 # define LZO_MM_XSMALL 1
995 # error "FIXME - MCS251 __MODEL__"
997 #elif (LZO_ARCH_MCS51)
998 #if !defined(__MODEL__)
999 # error "FIXME - MCS51 __MODEL__"
1000 #elif ((__MODEL__) == 1)
1001 # define LZO_MM_SMALL 1
1002 #elif ((__MODEL__) == 2)
1003 # define LZO_MM_LARGE 1
1004 #elif ((__MODEL__) == 3)
1005 # define LZO_MM_TINY 1
1006 #elif ((__MODEL__) == 4)
1007 # define LZO_MM_XTINY 1
1008 #elif ((__MODEL__) == 5)
1009 # define LZO_MM_XSMALL 1
1011 # error "FIXME - MCS51 __MODEL__"
1013 #elif (LZO_ARCH_CRAY_PVP)
1014 # define LZO_MM_PVP 1
1016 # define LZO_MM_FLAT 1
1018 #if (LZO_MM_COMPACT)
1019 # define LZO_INFO_MM "compact"
1021 # define LZO_INFO_MM "flat"
1023 # define LZO_INFO_MM "huge"
1024 #elif (LZO_MM_LARGE)
1025 # define LZO_INFO_MM "large"
1026 #elif (LZO_MM_MEDIUM)
1027 # define LZO_INFO_MM "medium"
1029 # define LZO_INFO_MM "pvp"
1030 #elif (LZO_MM_SMALL)
1031 # define LZO_INFO_MM "small"
1033 # define LZO_INFO_MM "tiny"
1035 # error "unknown memory model"
1038 #if defined(SIZEOF_SHORT)
1039 # define LZO_SIZEOF_SHORT (SIZEOF_SHORT)
1041 #if defined(SIZEOF_INT)
1042 # define LZO_SIZEOF_INT (SIZEOF_INT)
1044 #if defined(SIZEOF_LONG)
1045 # define LZO_SIZEOF_LONG (SIZEOF_LONG)
1047 #if defined(SIZEOF_LONG_LONG)
1048 # define LZO_SIZEOF_LONG_LONG (SIZEOF_LONG_LONG)
1050 #if defined(SIZEOF___INT16)
1051 # define LZO_SIZEOF___INT16 (SIZEOF___INT16)
1053 #if defined(SIZEOF___INT32)
1054 # define LZO_SIZEOF___INT32 (SIZEOF___INT32)
1056 #if defined(SIZEOF___INT64)
1057 # define LZO_SIZEOF___INT64 (SIZEOF___INT64)
1059 #if defined(SIZEOF_VOID_P)
1060 # define LZO_SIZEOF_VOID_P (SIZEOF_VOID_P)
1062 #if defined(SIZEOF_SIZE_T)
1063 # define LZO_SIZEOF_SIZE_T (SIZEOF_SIZE_T)
1065 #if defined(SIZEOF_PTRDIFF_T)
1066 # define LZO_SIZEOF_PTRDIFF_T (SIZEOF_PTRDIFF_T)
1068 #define __LZO_LSR(x,b) (((x)+0ul) >> (b))
1069 #if !defined(LZO_SIZEOF_SHORT)
1070 # if (LZO_ARCH_CRAY_PVP)
1071 # define LZO_SIZEOF_SHORT 8
1072 # elif (USHRT_MAX == LZO_0xffffL)
1073 # define LZO_SIZEOF_SHORT 2
1074 # elif (__LZO_LSR(USHRT_MAX,7) == 1)
1075 # define LZO_SIZEOF_SHORT 1
1076 # elif (__LZO_LSR(USHRT_MAX,15) == 1)
1077 # define LZO_SIZEOF_SHORT 2
1078 # elif (__LZO_LSR(USHRT_MAX,31) == 1)
1079 # define LZO_SIZEOF_SHORT 4
1080 # elif (__LZO_LSR(USHRT_MAX,63) == 1)
1081 # define LZO_SIZEOF_SHORT 8
1082 # elif (__LZO_LSR(USHRT_MAX,127) == 1)
1083 # define LZO_SIZEOF_SHORT 16
1085 # error "LZO_SIZEOF_SHORT"
1088 #if !defined(LZO_SIZEOF_INT)
1089 # if (LZO_ARCH_CRAY_PVP)
1090 # define LZO_SIZEOF_INT 8
1091 # elif (UINT_MAX == LZO_0xffffL)
1092 # define LZO_SIZEOF_INT 2
1093 # elif (UINT_MAX == LZO_0xffffffffL)
1094 # define LZO_SIZEOF_INT 4
1095 # elif (__LZO_LSR(UINT_MAX,7) == 1)
1096 # define LZO_SIZEOF_INT 1
1097 # elif (__LZO_LSR(UINT_MAX,15) == 1)
1098 # define LZO_SIZEOF_INT 2
1099 # elif (__LZO_LSR(UINT_MAX,31) == 1)
1100 # define LZO_SIZEOF_INT 4
1101 # elif (__LZO_LSR(UINT_MAX,63) == 1)
1102 # define LZO_SIZEOF_INT 8
1103 # elif (__LZO_LSR(UINT_MAX,127) == 1)
1104 # define LZO_SIZEOF_INT 16
1106 # error "LZO_SIZEOF_INT"
1109 #if !defined(LZO_SIZEOF_LONG)
1110 # if (ULONG_MAX == LZO_0xffffffffL)
1111 # define LZO_SIZEOF_LONG 4
1112 # elif (__LZO_LSR(ULONG_MAX,7) == 1)
1113 # define LZO_SIZEOF_LONG 1
1114 # elif (__LZO_LSR(ULONG_MAX,15) == 1)
1115 # define LZO_SIZEOF_LONG 2
1116 # elif (__LZO_LSR(ULONG_MAX,31) == 1)
1117 # define LZO_SIZEOF_LONG 4
1118 # elif (__LZO_LSR(ULONG_MAX,63) == 1)
1119 # define LZO_SIZEOF_LONG 8
1120 # elif (__LZO_LSR(ULONG_MAX,127) == 1)
1121 # define LZO_SIZEOF_LONG 16
1123 # error "LZO_SIZEOF_LONG"
1126 #if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64)
1127 #if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8)
1128 # if defined(__LONG_MAX__) && defined(__LONG_LONG_MAX__)
1129 # if (LZO_CC_GNUC >= 0x030300ul)
1130 # if ((__LONG_MAX__)+0 == (__LONG_LONG_MAX__)+0)
1131 # define LZO_SIZEOF_LONG_LONG LZO_SIZEOF_LONG
1132 # elif (__LZO_LSR(__LONG_LONG_MAX__,30) == 1)
1133 # define LZO_SIZEOF_LONG_LONG 4
1139 #if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64)
1140 #if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8)
1141 #if (LZO_ARCH_I086 && LZO_CC_DMC)
1142 #elif (LZO_CC_CILLY) && defined(__GNUC__)
1143 # define LZO_SIZEOF_LONG_LONG 8
1144 #elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE)
1145 # define LZO_SIZEOF_LONG_LONG 8
1146 #elif ((LZO_OS_WIN32 || LZO_OS_WIN64 || defined(_WIN32)) && LZO_CC_MSC && (_MSC_VER >= 1400))
1147 # define LZO_SIZEOF_LONG_LONG 8
1148 #elif (LZO_OS_WIN64 || defined(_WIN64))
1149 # define LZO_SIZEOF___INT64 8
1150 #elif (LZO_ARCH_I386 && (LZO_CC_DMC))
1151 # define LZO_SIZEOF_LONG_LONG 8
1152 #elif (LZO_ARCH_I386 && (LZO_CC_SYMANTECC && (__SC__ >= 0x700)))
1153 # define LZO_SIZEOF_LONG_LONG 8
1154 #elif (LZO_ARCH_I386 && (LZO_CC_INTELC && defined(__linux__)))
1155 # define LZO_SIZEOF_LONG_LONG 8
1156 #elif (LZO_ARCH_I386 && (LZO_CC_MWERKS || LZO_CC_PELLESC || LZO_CC_PGI || LZO_CC_SUNPROC))
1157 # define LZO_SIZEOF_LONG_LONG 8
1158 #elif (LZO_ARCH_I386 && (LZO_CC_INTELC || LZO_CC_MSC))
1159 # define LZO_SIZEOF___INT64 8
1160 #elif ((LZO_OS_WIN32 || defined(_WIN32)) && (LZO_CC_MSC))
1161 # define LZO_SIZEOF___INT64 8
1162 #elif (LZO_ARCH_I386 && (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0520)))
1163 # define LZO_SIZEOF___INT64 8
1164 #elif (LZO_ARCH_I386 && (LZO_CC_WATCOMC && (__WATCOMC__ >= 1100)))
1165 # define LZO_SIZEOF___INT64 8
1166 #elif (LZO_CC_WATCOMC && defined(_INTEGRAL_MAX_BITS) && (_INTEGRAL_MAX_BITS == 64))
1167 # define LZO_SIZEOF___INT64 8
1168 #elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__)
1169 # define LZO_SIZEOF_LONG_LONG 8
1170 #elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64)
1171 # define LZO_SIZEOF_LONG_LONG 8
1172 #elif (LZO_CC_SDCC) && (LZO_SIZEOF_INT == 2)
1173 #elif 1 && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
1174 # define LZO_SIZEOF_LONG_LONG 8
1178 #if defined(__cplusplus) && (LZO_CC_GNUC)
1179 # if (LZO_CC_GNUC < 0x020800ul)
1180 # undef LZO_SIZEOF_LONG_LONG
1183 #if (LZO_CFG_NO_LONG_LONG) || defined(__NO_LONG_LONG)
1184 # undef LZO_SIZEOF_LONG_LONG
1186 #if !defined(LZO_SIZEOF_VOID_P)
1188 # define __LZO_WORDSIZE 2
1189 # if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM)
1190 # define LZO_SIZEOF_VOID_P 2
1191 # elif (LZO_MM_COMPACT || LZO_MM_LARGE || LZO_MM_HUGE)
1192 # define LZO_SIZEOF_VOID_P 4
1196 #elif (LZO_ARCH_AVR || LZO_ARCH_Z80)
1197 # define __LZO_WORDSIZE 1
1198 # define LZO_SIZEOF_VOID_P 2
1199 #elif (LZO_ARCH_C166 || LZO_ARCH_MCS51 || LZO_ARCH_MCS251 || LZO_ARCH_MSP430)
1200 # define LZO_SIZEOF_VOID_P 2
1201 #elif (LZO_ARCH_H8300)
1202 # if defined(__NORMAL_MODE__)
1203 # define __LZO_WORDSIZE 4
1204 # define LZO_SIZEOF_VOID_P 2
1205 # elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__)
1206 # define __LZO_WORDSIZE 4
1207 # define LZO_SIZEOF_VOID_P 4
1209 # define __LZO_WORDSIZE 2
1210 # define LZO_SIZEOF_VOID_P 2
1212 # if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_SIZEOF_INT == 4)
1213 # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_INT
1214 # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_INT
1216 #elif (LZO_ARCH_M16C)
1217 # define __LZO_WORDSIZE 2
1218 # if defined(__m32c_cpu__) || defined(__m32cm_cpu__)
1219 # define LZO_SIZEOF_VOID_P 4
1221 # define LZO_SIZEOF_VOID_P 2
1223 #elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__))
1224 # define __LZO_WORDSIZE 8
1225 # define LZO_SIZEOF_VOID_P 4
1226 #elif defined(__LLP64__) || defined(__LLP64) || defined(_LLP64) || defined(_WIN64)
1227 # define __LZO_WORDSIZE 8
1228 # define LZO_SIZEOF_VOID_P 8
1229 #elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__)
1230 # define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG
1231 # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG
1232 # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG
1233 #elif (LZO_OS_OS400 || defined(__OS400__))
1234 # define __LZO_WORDSIZE LZO_SIZEOF_LONG
1235 # define LZO_SIZEOF_VOID_P 16
1236 # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG
1237 # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG
1238 #elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64)
1239 # define LZO_SIZEOF_VOID_P 8
1240 # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG
1241 # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG
1242 #elif (LZO_ARCH_SPU)
1244 # define __LZO_WORDSIZE 16
1246 # define LZO_SIZEOF_VOID_P 4
1248 # define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG
1251 #if !defined(LZO_WORDSIZE)
1252 # if defined(__LZO_WORDSIZE)
1253 # define LZO_WORDSIZE __LZO_WORDSIZE
1255 # define LZO_WORDSIZE LZO_SIZEOF_VOID_P
1258 #if !defined(LZO_SIZEOF_SIZE_T)
1259 #if (LZO_ARCH_I086 || LZO_ARCH_M16C)
1260 # define LZO_SIZEOF_SIZE_T 2
1262 # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_VOID_P
1265 #if !defined(LZO_SIZEOF_PTRDIFF_T)
1267 # if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM || LZO_MM_HUGE)
1268 # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_VOID_P
1269 # elif (LZO_MM_COMPACT || LZO_MM_LARGE)
1270 # if (LZO_CC_BORLANDC || LZO_CC_TURBOC)
1271 # define LZO_SIZEOF_PTRDIFF_T 4
1273 # define LZO_SIZEOF_PTRDIFF_T 2
1279 # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_SIZE_T
1282 #if (LZO_ABI_NEUTRAL_ENDIAN)
1283 # undef LZO_ABI_BIG_ENDIAN
1284 # undef LZO_ABI_LITTLE_ENDIAN
1285 #elif !(LZO_ABI_BIG_ENDIAN) && !(LZO_ABI_LITTLE_ENDIAN)
1286 #if (LZO_ARCH_ALPHA) && (LZO_ARCH_CRAY_MPP)
1287 # define LZO_ABI_BIG_ENDIAN 1
1288 #elif (LZO_ARCH_IA64) && (LZO_OS_POSIX_LINUX || LZO_OS_WIN64)
1289 # define LZO_ABI_LITTLE_ENDIAN 1
1290 #elif (LZO_ARCH_ALPHA || LZO_ARCH_AMD64 || LZO_ARCH_BLACKFIN || LZO_ARCH_CRIS || LZO_ARCH_I086 || LZO_ARCH_I386 || LZO_ARCH_MSP430)
1291 # define LZO_ABI_LITTLE_ENDIAN 1
1292 #elif (LZO_ARCH_AVR32 || LZO_ARCH_M68K || LZO_ARCH_S390)
1293 # define LZO_ABI_BIG_ENDIAN 1
1294 #elif 1 && defined(__IAR_SYSTEMS_ICC__) && defined(__LITTLE_ENDIAN__)
1295 # if (__LITTLE_ENDIAN__ == 1)
1296 # define LZO_ABI_LITTLE_ENDIAN 1
1298 # define LZO_ABI_BIG_ENDIAN 1
1300 #elif 1 && defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__)
1301 # define LZO_ABI_BIG_ENDIAN 1
1302 #elif 1 && defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)
1303 # define LZO_ABI_LITTLE_ENDIAN 1
1304 #elif 1 && (LZO_ARCH_ARM) && defined(__ARMEB__) && !defined(__ARMEL__)
1305 # define LZO_ABI_BIG_ENDIAN 1
1306 #elif 1 && (LZO_ARCH_ARM) && defined(__ARMEL__) && !defined(__ARMEB__)
1307 # define LZO_ABI_LITTLE_ENDIAN 1
1308 #elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEB__) && !defined(__MIPSEL__)
1309 # define LZO_ABI_BIG_ENDIAN 1
1310 #elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEL__) && !defined(__MIPSEB__)
1311 # define LZO_ABI_LITTLE_ENDIAN 1
1314 #if (LZO_ABI_BIG_ENDIAN) && (LZO_ABI_LITTLE_ENDIAN)
1315 # error "this should not happen"
1317 #if (LZO_ABI_BIG_ENDIAN)
1318 # define LZO_INFO_ABI_ENDIAN "be"
1319 #elif (LZO_ABI_LITTLE_ENDIAN)
1320 # define LZO_INFO_ABI_ENDIAN "le"
1321 #elif (LZO_ABI_NEUTRAL_ENDIAN)
1322 # define LZO_INFO_ABI_ENDIAN "neutral"
1324 #if (LZO_SIZEOF_INT == 1 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2)
1325 # define LZO_ABI_I8LP16 1
1326 # define LZO_INFO_ABI_PM "i8lp16"
1327 #elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2)
1328 # define LZO_ABI_ILP16 1
1329 # define LZO_INFO_ABI_PM "ilp16"
1330 #elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4)
1331 # define LZO_ABI_ILP32 1
1332 # define LZO_INFO_ABI_PM "ilp32"
1333 #elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 8 && LZO_SIZEOF_SIZE_T == 8)
1334 # define LZO_ABI_LLP64 1
1335 # define LZO_INFO_ABI_PM "llp64"
1336 #elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8)
1337 # define LZO_ABI_LP64 1
1338 # define LZO_INFO_ABI_PM "lp64"
1339 #elif (LZO_SIZEOF_INT == 8 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8)
1340 # define LZO_ABI_ILP64 1
1341 # define LZO_INFO_ABI_PM "ilp64"
1342 #elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 4)
1343 # define LZO_ABI_IP32L64 1
1344 # define LZO_INFO_ABI_PM "ip32l64"
1346 #if !defined(__LZO_LIBC_OVERRIDE)
1347 #if (LZO_LIBC_NAKED)
1348 # define LZO_INFO_LIBC "naked"
1349 #elif (LZO_LIBC_FREESTANDING)
1350 # define LZO_INFO_LIBC "freestanding"
1351 #elif (LZO_LIBC_MOSTLY_FREESTANDING)
1352 # define LZO_INFO_LIBC "mfreestanding"
1353 #elif (LZO_LIBC_ISOC90)
1354 # define LZO_INFO_LIBC "isoc90"
1355 #elif (LZO_LIBC_ISOC99)
1356 # define LZO_INFO_LIBC "isoc99"
1357 #elif defined(__dietlibc__)
1358 # define LZO_LIBC_DIETLIBC 1
1359 # define LZO_INFO_LIBC "dietlibc"
1360 #elif defined(_NEWLIB_VERSION)
1361 # define LZO_LIBC_NEWLIB 1
1362 # define LZO_INFO_LIBC "newlib"
1363 #elif defined(__UCLIBC__) && defined(__UCLIBC_MAJOR__) && defined(__UCLIBC_MINOR__)
1364 # if defined(__UCLIBC_SUBLEVEL__)
1365 # define LZO_LIBC_UCLIBC (__UCLIBC_MAJOR__ * 0x10000L + __UCLIBC_MINOR__ * 0x100 + __UCLIBC_SUBLEVEL__)
1367 # define LZO_LIBC_UCLIBC 0x00090bL
1369 # define LZO_INFO_LIBC "uclibc"
1370 #elif defined(__GLIBC__) && defined(__GLIBC_MINOR__)
1371 # define LZO_LIBC_GLIBC (__GLIBC__ * 0x10000L + __GLIBC_MINOR__ * 0x100)
1372 # define LZO_INFO_LIBC "glibc"
1373 #elif (LZO_CC_MWERKS) && defined(__MSL__)
1374 # define LZO_LIBC_MSL __MSL__
1375 # define LZO_INFO_LIBC "msl"
1376 #elif 1 && defined(__IAR_SYSTEMS_ICC__)
1377 # define LZO_LIBC_ISOC90 1
1378 # define LZO_INFO_LIBC "isoc90"
1380 # define LZO_LIBC_DEFAULT 1
1381 # define LZO_INFO_LIBC "default"
1384 #if !defined(__lzo_gnuc_extension__)
1385 #if (LZO_CC_GNUC >= 0x020800ul)
1386 # define __lzo_gnuc_extension__ __extension__
1387 #elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
1388 # define __lzo_gnuc_extension__ __extension__
1390 # define __lzo_gnuc_extension__ /*empty*/
1393 #if !defined(__lzo_ua_volatile)
1394 # define __lzo_ua_volatile volatile
1396 #if !defined(__lzo_alignof)
1397 #if (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI)
1398 # define __lzo_alignof(e) __alignof__(e)
1399 #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 700))
1400 # define __lzo_alignof(e) __alignof__(e)
1401 #elif (LZO_CC_MSC && (_MSC_VER >= 1300))
1402 # define __lzo_alignof(e) __alignof(e)
1403 #elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100))
1404 # define __lzo_alignof(e) __alignof__(e)
1407 #if defined(__lzo_alignof)
1408 # define __lzo_HAVE_alignof 1
1410 #if !defined(__lzo_constructor)
1411 #if (LZO_CC_GNUC >= 0x030400ul)
1412 # define __lzo_constructor __attribute__((__constructor__,__used__))
1413 #elif (LZO_CC_GNUC >= 0x020700ul)
1414 # define __lzo_constructor __attribute__((__constructor__))
1415 #elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
1416 # define __lzo_constructor __attribute__((__constructor__))
1419 #if defined(__lzo_constructor)
1420 # define __lzo_HAVE_constructor 1
1422 #if !defined(__lzo_destructor)
1423 #if (LZO_CC_GNUC >= 0x030400ul)
1424 # define __lzo_destructor __attribute__((__destructor__,__used__))
1425 #elif (LZO_CC_GNUC >= 0x020700ul)
1426 # define __lzo_destructor __attribute__((__destructor__))
1427 #elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
1428 # define __lzo_destructor __attribute__((__destructor__))
1431 #if defined(__lzo_destructor)
1432 # define __lzo_HAVE_destructor 1
1434 #if (__lzo_HAVE_destructor) && !(__lzo_HAVE_constructor)
1435 # error "this should not happen"
1437 #if !defined(__lzo_inline)
1438 #if (LZO_CC_TURBOC && (__TURBOC__ <= 0x0295))
1439 #elif defined(__cplusplus)
1440 # define __lzo_inline inline
1441 #elif (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0550))
1442 # define __lzo_inline __inline
1443 #elif (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI)
1444 # define __lzo_inline __inline__
1446 # define __lzo_inline __inline
1447 #elif (LZO_CC_INTELC)
1448 # define __lzo_inline __inline
1449 #elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x2405))
1450 # define __lzo_inline __inline
1451 #elif (LZO_CC_MSC && (_MSC_VER >= 900))
1452 # define __lzo_inline __inline
1453 #elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100))
1454 # define __lzo_inline __inline__
1455 #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
1456 # define __lzo_inline inline
1459 #if defined(__lzo_inline)
1460 # define __lzo_HAVE_inline 1
1462 # define __lzo_inline /*empty*/
1464 #if !defined(__lzo_forceinline)
1465 #if (LZO_CC_GNUC >= 0x030200ul)
1466 # define __lzo_forceinline __inline__ __attribute__((__always_inline__))
1467 #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC)
1468 # define __lzo_forceinline __forceinline
1469 #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC)
1470 # define __lzo_forceinline __inline__ __attribute__((__always_inline__))
1471 #elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
1472 # define __lzo_forceinline __inline__ __attribute__((__always_inline__))
1473 #elif (LZO_CC_MSC && (_MSC_VER >= 1200))
1474 # define __lzo_forceinline __forceinline
1475 #elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100))
1476 # define __lzo_forceinline __inline__ __attribute__((__always_inline__))
1479 #if defined(__lzo_forceinline)
1480 # define __lzo_HAVE_forceinline 1
1482 # define __lzo_forceinline /*empty*/
1484 #if !defined(__lzo_noinline)
1485 #if 1 && (LZO_ARCH_I386) && (LZO_CC_GNUC >= 0x040000ul) && (LZO_CC_GNUC < 0x040003ul)
1486 # define __lzo_noinline __attribute__((__noinline__,__used__))
1487 #elif (LZO_CC_GNUC >= 0x030200ul)
1488 # define __lzo_noinline __attribute__((__noinline__))
1489 #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_MSC)
1490 # define __lzo_noinline __declspec(noinline)
1491 #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC)
1492 # define __lzo_noinline __attribute__((__noinline__))
1493 #elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
1494 # define __lzo_noinline __attribute__((__noinline__))
1495 #elif (LZO_CC_MSC && (_MSC_VER >= 1300))
1496 # define __lzo_noinline __declspec(noinline)
1497 #elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x3200) && (LZO_OS_WIN32 || LZO_OS_WIN64))
1498 # if defined(__cplusplus)
1500 # define __lzo_noinline __declspec(noinline)
1502 #elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100))
1503 # define __lzo_noinline __attribute__((__noinline__))
1506 #if defined(__lzo_noinline)
1507 # define __lzo_HAVE_noinline 1
1509 # define __lzo_noinline /*empty*/
1511 #if (__lzo_HAVE_forceinline || __lzo_HAVE_noinline) && !(__lzo_HAVE_inline)
1512 # error "this should not happen"
1514 #if !defined(__lzo_noreturn)
1515 #if (LZO_CC_GNUC >= 0x020700ul)
1516 # define __lzo_noreturn __attribute__((__noreturn__))
1517 #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC)
1518 # define __lzo_noreturn __declspec(noreturn)
1519 #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_GNUC)
1520 # define __lzo_noreturn __attribute__((__noreturn__))
1521 #elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
1522 # define __lzo_noreturn __attribute__((__noreturn__))
1523 #elif (LZO_CC_MSC && (_MSC_VER >= 1200))
1524 # define __lzo_noreturn __declspec(noreturn)
1527 #if defined(__lzo_noreturn)
1528 # define __lzo_HAVE_noreturn 1
1530 # define __lzo_noreturn /*empty*/
1532 #if !defined(__lzo_nothrow)
1533 #if (LZO_CC_GNUC >= 0x030300ul)
1534 # define __lzo_nothrow __attribute__((__nothrow__))
1535 #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) && defined(__cplusplus)
1536 # define __lzo_nothrow __declspec(nothrow)
1537 #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 900) && LZO_CC_SYNTAX_GNUC)
1538 # define __lzo_nothrow __attribute__((__nothrow__))
1539 #elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
1540 # define __lzo_nothrow __attribute__((__nothrow__))
1541 #elif (LZO_CC_MSC && (_MSC_VER >= 1200)) && defined(__cplusplus)
1542 # define __lzo_nothrow __declspec(nothrow)
1545 #if defined(__lzo_nothrow)
1546 # define __lzo_HAVE_nothrow 1
1548 # define __lzo_nothrow /*empty*/
1550 #if !defined(__lzo_restrict)
1551 #if (LZO_CC_GNUC >= 0x030400ul)
1552 # define __lzo_restrict __restrict__
1553 #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_GNUC)
1554 # define __lzo_restrict __restrict__
1555 #elif (LZO_CC_CLANG || LZO_CC_LLVM)
1556 # define __lzo_restrict __restrict__
1557 #elif (LZO_CC_MSC && (_MSC_VER >= 1400))
1558 # define __lzo_restrict __restrict
1561 #if defined(__lzo_restrict)
1562 # define __lzo_HAVE_restrict 1
1564 # define __lzo_restrict /*empty*/
1566 #if !defined(__lzo_likely) && !defined(__lzo_unlikely)
1567 #if (LZO_CC_GNUC >= 0x030200ul)
1568 # define __lzo_likely(e) (__builtin_expect(!!(e),1))
1569 # define __lzo_unlikely(e) (__builtin_expect(!!(e),0))
1570 #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800))
1571 # define __lzo_likely(e) (__builtin_expect(!!(e),1))
1572 # define __lzo_unlikely(e) (__builtin_expect(!!(e),0))
1573 #elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
1574 # define __lzo_likely(e) (__builtin_expect(!!(e),1))
1575 # define __lzo_unlikely(e) (__builtin_expect(!!(e),0))
1578 #if defined(__lzo_likely)
1579 # define __lzo_HAVE_likely 1
1581 # define __lzo_likely(e) (e)
1583 #if defined(__lzo_unlikely)
1584 # define __lzo_HAVE_unlikely 1
1586 # define __lzo_unlikely(e) (e)
1588 #if !defined(LZO_UNUSED)
1589 # if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600))
1590 # define LZO_UNUSED(var) ((void) &var)
1591 # elif (LZO_CC_BORLANDC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PELLESC || LZO_CC_TURBOC)
1592 # define LZO_UNUSED(var) if (&var) ; else
1593 # elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE)
1594 # define LZO_UNUSED(var) ((void) var)
1595 # elif (LZO_CC_MSC && (_MSC_VER < 900))
1596 # define LZO_UNUSED(var) if (&var) ; else
1597 # elif (LZO_CC_KEILC)
1598 # define LZO_UNUSED(var) {extern int __lzo_unused[1-2*!(sizeof(var)>0)];}
1599 # elif (LZO_CC_PACIFICC)
1600 # define LZO_UNUSED(var) ((void) sizeof(var))
1601 # elif (LZO_CC_WATCOMC) && defined(__cplusplus)
1602 # define LZO_UNUSED(var) ((void) var)
1604 # define LZO_UNUSED(var) ((void) &var)
1607 #if !defined(LZO_UNUSED_FUNC)
1608 # if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600))
1609 # define LZO_UNUSED_FUNC(func) ((void) func)
1610 # elif (LZO_CC_BORLANDC || LZO_CC_NDPC || LZO_CC_TURBOC)
1611 # define LZO_UNUSED_FUNC(func) if (func) ; else
1612 # elif (LZO_CC_CLANG || LZO_CC_LLVM)
1613 # define LZO_UNUSED_FUNC(func) ((void) &func)
1614 # elif (LZO_CC_MSC && (_MSC_VER < 900))
1615 # define LZO_UNUSED_FUNC(func) if (func) ; else
1617 # define LZO_UNUSED_FUNC(func) ((void) &func)
1618 # elif (LZO_CC_KEILC || LZO_CC_PELLESC)
1619 # define LZO_UNUSED_FUNC(func) {extern int __lzo_unused[1-2*!(sizeof((int)func)>0)];}
1621 # define LZO_UNUSED_FUNC(func) ((void) func)
1624 #if !defined(LZO_UNUSED_LABEL)
1625 # if (LZO_CC_WATCOMC) && defined(__cplusplus)
1626 # define LZO_UNUSED_LABEL(l) switch(0) case 1:goto l
1627 # elif (LZO_CC_CLANG || LZO_CC_INTELC || LZO_CC_WATCOMC)
1628 # define LZO_UNUSED_LABEL(l) if (0) goto l
1630 # define LZO_UNUSED_LABEL(l) switch(0) case 1:goto l
1633 #if !defined(LZO_DEFINE_UNINITIALIZED_VAR)
1635 # define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var
1636 # elif 0 && (LZO_CC_GNUC)
1637 # define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = var
1639 # define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = init
1642 #if !defined(LZO_UNCONST_CAST)
1643 # if 0 && defined(__cplusplus)
1644 # define LZO_UNCONST_CAST(t,e) (const_cast<t> (e))
1645 # elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE)
1646 # define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((char *) ((lzo_uintptr_t) ((const void *) (e))))))
1648 # define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((char *) ((const void *) (e)))))
1651 #if !defined(LZO_COMPILE_TIME_ASSERT_HEADER)
1652 # if (LZO_CC_AZTECC || LZO_CC_ZORTECHC)
1653 # define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-!(e)];
1654 # elif (LZO_CC_DMC || LZO_CC_SYMANTECC)
1655 # define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1u-2*!(e)];
1656 # elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295))
1657 # define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-!(e)];
1659 # define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-2*!(e)];
1662 #if !defined(LZO_COMPILE_TIME_ASSERT)
1663 # if (LZO_CC_AZTECC)
1664 # define LZO_COMPILE_TIME_ASSERT(e) {typedef int __lzo_cta_t[1-!(e)];}
1665 # elif (LZO_CC_DMC || LZO_CC_PACIFICC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC)
1666 # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break;
1667 # elif (LZO_CC_MSC && (_MSC_VER < 900))
1668 # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break;
1669 # elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295))
1670 # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break;
1672 # define LZO_COMPILE_TIME_ASSERT(e) {typedef int __lzo_cta_t[1-2*!(e)];}
1675 #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)
1676 # if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC)
1677 # elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC)
1678 # define __lzo_cdecl __cdecl
1679 # define __lzo_cdecl_atexit /*empty*/
1680 # define __lzo_cdecl_main __cdecl
1681 # if (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC))
1682 # define __lzo_cdecl_qsort __pascal
1683 # elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC))
1684 # define __lzo_cdecl_qsort _stdcall
1686 # define __lzo_cdecl_qsort __cdecl
1688 # elif (LZO_CC_WATCOMC)
1689 # define __lzo_cdecl __cdecl
1691 # define __lzo_cdecl __cdecl
1692 # define __lzo_cdecl_atexit __cdecl
1693 # define __lzo_cdecl_main __cdecl
1694 # define __lzo_cdecl_qsort __cdecl
1696 # if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC || LZO_CC_WATCOMC)
1697 # elif (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC))
1698 # define __lzo_cdecl_sighandler __pascal
1699 # elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC))
1700 # define __lzo_cdecl_sighandler _stdcall
1701 # elif (LZO_CC_MSC && (_MSC_VER >= 1400)) && defined(_M_CEE_PURE)
1702 # define __lzo_cdecl_sighandler __clrcall
1703 # elif (LZO_CC_MSC && (_MSC_VER >= 600 && _MSC_VER < 700))
1705 # define __lzo_cdecl_sighandler _far _cdecl _loadds
1707 # define __lzo_cdecl_sighandler _far _cdecl
1709 # define __lzo_cdecl_sighandler _cdecl
1712 # define __lzo_cdecl_sighandler __cdecl
1714 #elif (LZO_ARCH_I386) && (LZO_CC_WATCOMC)
1715 # define __lzo_cdecl __cdecl
1716 #elif (LZO_ARCH_M68K && LZO_OS_TOS && (LZO_CC_PUREC || LZO_CC_TURBOC))
1717 # define __lzo_cdecl cdecl
1719 #if !defined(__lzo_cdecl)
1720 # define __lzo_cdecl /*empty*/
1722 #if !defined(__lzo_cdecl_atexit)
1723 # define __lzo_cdecl_atexit /*empty*/
1725 #if !defined(__lzo_cdecl_main)
1726 # define __lzo_cdecl_main /*empty*/
1728 #if !defined(__lzo_cdecl_qsort)
1729 # define __lzo_cdecl_qsort /*empty*/
1731 #if !defined(__lzo_cdecl_sighandler)
1732 # define __lzo_cdecl_sighandler /*empty*/
1734 #if !defined(__lzo_cdecl_va)
1735 # define __lzo_cdecl_va __lzo_cdecl
1737 #if !(LZO_CFG_NO_WINDOWS_H)
1738 #if (LZO_OS_CYGWIN || (LZO_OS_EMX && defined(__RSXNT__)) || LZO_OS_WIN32 || LZO_OS_WIN64)
1739 # if (LZO_CC_WATCOMC && (__WATCOMC__ < 1000))
1740 # elif (LZO_OS_WIN32 && LZO_CC_GNUC) && defined(__PW32__)
1741 # elif ((LZO_OS_CYGWIN || defined(__MINGW32__)) && (LZO_CC_GNUC && (LZO_CC_GNUC < 0x025f00ul)))
1743 # define LZO_HAVE_WINDOWS_H 1
1747 #if (LZO_ARCH_ALPHA)
1748 # define LZO_OPT_AVOID_UINT_INDEX 1
1749 # define LZO_OPT_AVOID_SHORT 1
1750 # define LZO_OPT_AVOID_USHORT 1
1751 #elif (LZO_ARCH_AMD64)
1752 # define LZO_OPT_AVOID_INT_INDEX 1
1753 # define LZO_OPT_AVOID_UINT_INDEX 1
1754 # define LZO_OPT_UNALIGNED16 1
1755 # define LZO_OPT_UNALIGNED32 1
1756 # define LZO_OPT_UNALIGNED64 1
1757 #elif (LZO_ARCH_ARM && LZO_ARCH_ARM_THUMB)
1758 #elif (LZO_ARCH_ARM)
1759 # define LZO_OPT_AVOID_SHORT 1
1760 # define LZO_OPT_AVOID_USHORT 1
1761 #elif (LZO_ARCH_CRIS)
1762 # define LZO_OPT_UNALIGNED16 1
1763 # define LZO_OPT_UNALIGNED32 1
1764 #elif (LZO_ARCH_I386)
1765 # define LZO_OPT_UNALIGNED16 1
1766 # define LZO_OPT_UNALIGNED32 1
1767 #elif (LZO_ARCH_IA64)
1768 # define LZO_OPT_AVOID_INT_INDEX 1
1769 # define LZO_OPT_AVOID_UINT_INDEX 1
1770 # define LZO_OPT_PREFER_POSTINC 1
1771 #elif (LZO_ARCH_M68K)
1772 # define LZO_OPT_PREFER_POSTINC 1
1773 # define LZO_OPT_PREFER_PREDEC 1
1774 # if defined(__mc68020__) && !defined(__mcoldfire__)
1775 # define LZO_OPT_UNALIGNED16 1
1776 # define LZO_OPT_UNALIGNED32 1
1778 #elif (LZO_ARCH_MIPS)
1779 # define LZO_OPT_AVOID_UINT_INDEX 1
1780 #elif (LZO_ARCH_POWERPC)
1781 # define LZO_OPT_PREFER_PREINC 1
1782 # define LZO_OPT_PREFER_PREDEC 1
1783 # if (LZO_ABI_BIG_ENDIAN)
1784 # define LZO_OPT_UNALIGNED16 1
1785 # define LZO_OPT_UNALIGNED32 1
1787 #elif (LZO_ARCH_S390)
1788 # define LZO_OPT_UNALIGNED16 1
1789 # define LZO_OPT_UNALIGNED32 1
1790 # if (LZO_SIZEOF_SIZE_T == 8)
1791 # define LZO_OPT_UNALIGNED64 1
1794 # define LZO_OPT_PREFER_POSTINC 1
1795 # define LZO_OPT_PREFER_PREDEC 1
1797 #ifndef LZO_CFG_NO_INLINE_ASM
1799 # define LZO_CFG_NO_INLINE_ASM 1
1802 #ifndef LZO_CFG_NO_UNALIGNED
1803 #if (LZO_ABI_NEUTRAL_ENDIAN) || (LZO_ARCH_GENERIC)
1804 # define LZO_CFG_NO_UNALIGNED 1
1807 #if (LZO_CFG_NO_UNALIGNED)
1808 # undef LZO_OPT_UNALIGNED16
1809 # undef LZO_OPT_UNALIGNED32
1810 # undef LZO_OPT_UNALIGNED64
1812 #if (LZO_CFG_NO_INLINE_ASM)
1813 #elif (LZO_ARCH_I386 && (LZO_OS_DOS32 || LZO_OS_WIN32) && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC))
1814 # define LZO_ASM_SYNTAX_MSC 1
1815 #elif (LZO_OS_WIN64 && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC))
1816 #elif (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC == 0x011f00ul))
1817 #elif (LZO_ARCH_I386 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE))
1818 # define LZO_ASM_SYNTAX_GNUC 1
1819 #elif (LZO_ARCH_AMD64 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE))
1820 # define LZO_ASM_SYNTAX_GNUC 1
1822 #if (LZO_ASM_SYNTAX_GNUC)
1823 #if (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC < 0x020000ul))
1824 # define __LZO_ASM_CLOBBER "ax"
1825 #elif (LZO_CC_INTELC)
1826 # define __LZO_ASM_CLOBBER "memory"
1828 # define __LZO_ASM_CLOBBER "cc", "memory"
1831 #if defined(__LZO_INFOSTR_MM)
1832 #elif (LZO_MM_FLAT) && (defined(__LZO_INFOSTR_PM) || defined(LZO_INFO_ABI_PM))
1833 # define __LZO_INFOSTR_MM ""
1834 #elif defined(LZO_INFO_MM)
1835 # define __LZO_INFOSTR_MM "." LZO_INFO_MM
1837 # define __LZO_INFOSTR_MM ""
1839 #if defined(__LZO_INFOSTR_PM)
1840 #elif defined(LZO_INFO_ABI_PM)
1841 # define __LZO_INFOSTR_PM "." LZO_INFO_ABI_PM
1843 # define __LZO_INFOSTR_PM ""
1845 #if defined(__LZO_INFOSTR_ENDIAN)
1846 #elif defined(LZO_INFO_ABI_ENDIAN)
1847 # define __LZO_INFOSTR_ENDIAN "." LZO_INFO_ABI_ENDIAN
1849 # define __LZO_INFOSTR_ENDIAN ""
1851 #if defined(__LZO_INFOSTR_OSNAME)
1852 #elif defined(LZO_INFO_OS_CONSOLE)
1853 # define __LZO_INFOSTR_OSNAME LZO_INFO_OS "." LZO_INFO_OS_CONSOLE
1854 #elif defined(LZO_INFO_OS_POSIX)
1855 # define __LZO_INFOSTR_OSNAME LZO_INFO_OS "." LZO_INFO_OS_POSIX
1857 # define __LZO_INFOSTR_OSNAME LZO_INFO_OS
1859 #if defined(__LZO_INFOSTR_LIBC)
1860 #elif defined(LZO_INFO_LIBC)
1861 # define __LZO_INFOSTR_LIBC "." LZO_INFO_LIBC
1863 # define __LZO_INFOSTR_LIBC ""
1865 #if defined(__LZO_INFOSTR_CCVER)
1866 #elif defined(LZO_INFO_CCVER)
1867 # define __LZO_INFOSTR_CCVER " " LZO_INFO_CCVER
1869 # define __LZO_INFOSTR_CCVER ""
1871 #define LZO_INFO_STRING \
1872 LZO_INFO_ARCH __LZO_INFOSTR_MM __LZO_INFOSTR_PM __LZO_INFOSTR_ENDIAN \
1873 " " __LZO_INFOSTR_OSNAME __LZO_INFOSTR_LIBC " " LZO_INFO_CC __LZO_INFOSTR_CCVER
1879 #undef LZO_HAVE_CONFIG_H
1880 #include "minilzo.h"
1882 #if !defined(MINILZO_VERSION) || (MINILZO_VERSION != 0x2050)
1883 # error "version mismatch in miniLZO source files"
1886 #ifdef MINILZO_HAVE_CONFIG_H
1887 # define LZO_HAVE_CONFIG_H 1
1890 #ifndef __LZO_CONF_H
1891 #define __LZO_CONF_H 1
1893 #if !defined(__LZO_IN_MINILZO)
1894 #if (LZO_CFG_FREESTANDING)
1895 # define LZO_LIBC_FREESTANDING 1
1896 # define LZO_OS_FREESTANDING 1
1897 # define ACC_LIBC_FREESTANDING 1
1898 # define ACC_OS_FREESTANDING 1
1900 #if (LZO_CFG_NO_UNALIGNED)
1901 # define ACC_CFG_NO_UNALIGNED 1
1903 #if (LZO_ARCH_GENERIC)
1904 # define ACC_ARCH_GENERIC 1
1906 #if (LZO_ABI_NEUTRAL_ENDIAN)
1907 # define ACC_ABI_NEUTRAL_ENDIAN 1
1909 #if (LZO_HAVE_CONFIG_H)
1910 # define ACC_CONFIG_NO_HEADER 1
1912 #if defined(LZO_CFG_EXTRA_CONFIG_HEADER)
1913 # include LZO_CFG_EXTRA_CONFIG_HEADER
1915 #if defined(__LZOCONF_H) || defined(__LZOCONF_H_INCLUDED)
1916 # error "include this file first"
1918 #include "lzo/lzoconf.h"
1921 #if (LZO_VERSION < 0x02000) || !defined(__LZOCONF_H_INCLUDED)
1922 # error "version mismatch"
1925 #if (LZO_CC_BORLANDC && LZO_ARCH_I086)
1929 #if (LZO_CC_MSC && (_MSC_VER >= 1000))
1930 # pragma warning(disable: 4127 4701)
1932 #if (LZO_CC_MSC && (_MSC_VER >= 1300))
1933 # pragma warning(disable: 4820)
1934 # pragma warning(disable: 4514 4710 4711)
1937 #if (LZO_CC_SUNPROC)
1938 #if !defined(__cplusplus)
1939 # pragma error_messages(off,E_END_OF_LOOP_CODE_NOT_REACHED)
1940 # pragma error_messages(off,E_LOOP_NOT_ENTERED_AT_TOP)
1941 # pragma error_messages(off,E_STATEMENT_NOT_REACHED)
1945 #if (__LZO_MMODEL_HUGE) && !(LZO_HAVE_MM_HUGE_PTR)
1946 # error "this should not happen - check defines for __huge"
1949 #if defined(__LZO_IN_MINILZO) || defined(LZO_CFG_FREESTANDING)
1950 #elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16)
1951 # define ACC_WANT_ACC_INCD_H 1
1952 # define ACC_WANT_ACC_INCE_H 1
1953 # define ACC_WANT_ACC_INCI_H 1
1955 # include <string.h>
1957 # define ACC_WANT_ACC_INCD_H 1
1961 # define ACC_MM_AHSHIFT LZO_MM_AHSHIFT
1962 # define ACC_PTR_FP_OFF(x) (((const unsigned __far*)&(x))[0])
1963 # define ACC_PTR_FP_SEG(x) (((const unsigned __far*)&(x))[1])
1964 # define ACC_PTR_MK_FP(s,o) ((void __far*)(((unsigned long)(s)<<16)+(unsigned)(o)))
1967 #if !defined(lzo_uintptr_t)
1968 # if defined(__LZO_MMODEL_HUGE)
1969 # define lzo_uintptr_t unsigned long
1970 # elif 1 && defined(LZO_OS_OS400) && (LZO_SIZEOF_VOID_P == 16)
1971 # define __LZO_UINTPTR_T_IS_POINTER 1
1972 typedef char* lzo_uintptr_t
;
1973 # define lzo_uintptr_t lzo_uintptr_t
1974 # elif (LZO_SIZEOF_SIZE_T == LZO_SIZEOF_VOID_P)
1975 # define lzo_uintptr_t size_t
1976 # elif (LZO_SIZEOF_LONG == LZO_SIZEOF_VOID_P)
1977 # define lzo_uintptr_t unsigned long
1978 # elif (LZO_SIZEOF_INT == LZO_SIZEOF_VOID_P)
1979 # define lzo_uintptr_t unsigned int
1980 # elif (LZO_SIZEOF_LONG_LONG == LZO_SIZEOF_VOID_P)
1981 # define lzo_uintptr_t unsigned long long
1983 # define lzo_uintptr_t size_t
1986 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uintptr_t
) >= sizeof(lzo_voidp
))
1988 #if 1 && !defined(LZO_CFG_FREESTANDING)
1989 #if 1 && !defined(HAVE_STRING_H)
1990 #define HAVE_STRING_H 1
1992 #if 1 && !defined(HAVE_MEMCMP)
1993 #define HAVE_MEMCMP 1
1995 #if 1 && !defined(HAVE_MEMCPY)
1996 #define HAVE_MEMCPY 1
1998 #if 1 && !defined(HAVE_MEMMOVE)
1999 #define HAVE_MEMMOVE 1
2001 #if 1 && !defined(HAVE_MEMSET)
2002 #define HAVE_MEMSET 1
2006 #if 1 && defined(HAVE_STRING_H)
2010 #if (LZO_CFG_FREESTANDING)
2013 # undef HAVE_MEMMOVE
2019 # define memcmp(a,b,c) lzo_memcmp(a,b,c)
2020 #elif !(__LZO_MMODEL_HUGE)
2022 # define lzo_memcmp(a,b,c) memcmp(a,b,c)
2026 # define memcpy(a,b,c) lzo_memcpy(a,b,c)
2027 #elif !(__LZO_MMODEL_HUGE)
2029 # define lzo_memcpy(a,b,c) memcpy(a,b,c)
2033 # define memmove(a,b,c) lzo_memmove(a,b,c)
2034 #elif !(__LZO_MMODEL_HUGE)
2036 # define lzo_memmove(a,b,c) memmove(a,b,c)
2040 # define memset(a,b,c) lzo_memset(a,b,c)
2041 #elif !(__LZO_MMODEL_HUGE)
2043 # define lzo_memset(a,b,c) memset(a,b,c)
2047 #if (LZO_CFG_FREESTANDING)
2051 # define assert(e) ((void)0)
2053 # if !defined(LZO_DEBUG)
2056 # include <assert.h>
2059 #if 0 && defined(__BOUNDS_CHECKING_ON)
2060 # include <unchecked.h>
2062 # define BOUNDS_CHECKING_OFF_DURING(stmt) stmt
2063 # define BOUNDS_CHECKING_OFF_IN_EXPR(expr) (expr)
2066 #if !defined(__lzo_inline)
2067 # define __lzo_inline /*empty*/
2069 #if !defined(__lzo_forceinline)
2070 # define __lzo_forceinline /*empty*/
2072 #if !defined(__lzo_noinline)
2073 # define __lzo_noinline /*empty*/
2077 # undef __acc_likely
2078 # undef __acc_unlikely
2079 # undef __lzo_likely
2080 # undef __lzo_unlikely
2081 # define __acc_likely(e) (e)
2082 # define __acc_unlikely(e) (e)
2083 # define __lzo_likely(e) (e)
2084 # define __lzo_unlikely(e) (e)
2088 # define LZO_BYTE(x) ((unsigned char) (x))
2090 # define LZO_BYTE(x) ((unsigned char) ((x) & 0xff))
2093 #define LZO_MAX(a,b) ((a) >= (b) ? (a) : (b))
2094 #define LZO_MIN(a,b) ((a) <= (b) ? (a) : (b))
2095 #define LZO_MAX3(a,b,c) ((a) >= (b) ? LZO_MAX(a,c) : LZO_MAX(b,c))
2096 #define LZO_MIN3(a,b,c) ((a) <= (b) ? LZO_MIN(a,c) : LZO_MIN(b,c))
2098 #define lzo_sizeof(type) ((lzo_uint) (sizeof(type)))
2100 #define LZO_HIGH(array) ((lzo_uint) (sizeof(array)/sizeof(*(array))))
2102 #define LZO_SIZE(bits) (1u << (bits))
2103 #define LZO_MASK(bits) (LZO_SIZE(bits) - 1)
2105 #define LZO_LSIZE(bits) (1ul << (bits))
2106 #define LZO_LMASK(bits) (LZO_LSIZE(bits) - 1)
2108 #define LZO_USIZE(bits) ((lzo_uint) 1 << (bits))
2109 #define LZO_UMASK(bits) (LZO_USIZE(bits) - 1)
2114 # define DMUL(a,b) ((lzo_xint) ((lzo_uint32)(a) * (lzo_uint32)(b)))
2116 # define DMUL(a,b) ((lzo_xint) ((a) * (b)))
2120 #if 1 && (LZO_ARCH_AMD64 || LZO_ARCH_I386 || LZO_ARCH_POWERPC)
2121 # if (LZO_SIZEOF_SHORT == 2)
2122 # define LZO_UNALIGNED_OK_2 1
2124 # if (LZO_SIZEOF_INT == 4)
2125 # define LZO_UNALIGNED_OK_4 1
2128 #if 1 && (LZO_ARCH_AMD64)
2129 # if defined(LZO_UINT64_MAX)
2130 # define LZO_UNALIGNED_OK_8 1
2133 #if (LZO_CFG_NO_UNALIGNED)
2134 # undef LZO_UNALIGNED_OK_2
2135 # undef LZO_UNALIGNED_OK_4
2136 # undef LZO_UNALIGNED_OK_8
2148 #if defined(LZO_UNALIGNED_OK_2)
2149 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(unsigned short) == 2)
2150 # if 1 && defined(ACC_UA_COPY16)
2151 # define UA_GET16 ACC_UA_GET16
2152 # define UA_SET16 ACC_UA_SET16
2153 # define UA_COPY16 ACC_UA_COPY16
2155 # define UA_GET16(p) (* (__lzo_ua_volatile const lzo_ushortp) (__lzo_ua_volatile const lzo_voidp) (p))
2156 # define UA_SET16(p,v) ((* (__lzo_ua_volatile lzo_ushortp) (__lzo_ua_volatile lzo_voidp) (p)) = (unsigned short) (v))
2157 # define UA_COPY16(d,s) UA_SET16(d, UA_GET16(s))
2160 #if defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
2161 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint32
) == 4)
2162 # if 1 && defined(ACC_UA_COPY32)
2163 # define UA_GET32 ACC_UA_GET32
2164 # define UA_SET32 ACC_UA_SET32
2165 # define UA_COPY32 ACC_UA_COPY32
2167 # define UA_GET32(p) (* (__lzo_ua_volatile const lzo_uint32p) (__lzo_ua_volatile const lzo_voidp) (p))
2168 # define UA_SET32(p,v) ((* (__lzo_ua_volatile lzo_uint32p) (__lzo_ua_volatile lzo_voidp) (p)) = (lzo_uint32) (v))
2169 # define UA_COPY32(d,s) UA_SET32(d, UA_GET32(s))
2172 #if defined(LZO_UNALIGNED_OK_8)
2173 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint64
) == 8)
2174 # if 1 && defined(ACC_UA_COPY64)
2175 # define UA_GET64 ACC_UA_GET64
2176 # define UA_SET64 ACC_UA_SET64
2177 # define UA_COPY64 ACC_UA_COPY64
2179 # define UA_GET64(p) (* (__lzo_ua_volatile const lzo_uint64p) (__lzo_ua_volatile const lzo_voidp) (p))
2180 # define UA_SET64(p,v) ((* (__lzo_ua_volatile lzo_uint64p) (__lzo_ua_volatile lzo_voidp) (p)) = (lzo_uint64) (v))
2181 # define UA_COPY64(d,s) UA_SET64(d, UA_GET64(s))
2185 #define MEMCPY8_DS(dest,src,len) \
2186 lzo_memcpy(dest,src,len); dest += len; src += len
2188 #define BZERO8_PTR(s,l,n) \
2189 lzo_memset((lzo_voidp)(s),0,(lzo_uint)(l)*(n))
2191 #define MEMCPY_DS(dest,src,len) \
2192 do *dest++ = *src++; while (--len > 0)
2194 LZO_EXTERN(const lzo_bytep
) lzo_copyright(void);
2197 #define __LZO_PTR_H 1
2203 #if !defined(lzo_uintptr_t)
2204 # if (__LZO_MMODEL_HUGE)
2205 # define lzo_uintptr_t unsigned long
2207 # define lzo_uintptr_t acc_uintptr_t
2208 # ifdef __ACC_INTPTR_T_IS_POINTER
2209 # define __LZO_UINTPTR_T_IS_POINTER 1
2215 #define PTR(a) ((lzo_bytep) (a))
2216 #define PTR_ALIGNED_4(a) ((ACC_PTR_FP_OFF(a) & 3) == 0)
2217 #define PTR_ALIGNED2_4(a,b) (((ACC_PTR_FP_OFF(a) | ACC_PTR_FP_OFF(b)) & 3) == 0)
2219 #define PTR(a) ((lzo_bytep) (a))
2220 #define PTR_ALIGNED_8(a) ((((lzo_uintptr_t)(a)) >> 61) == 0)
2221 #define PTR_ALIGNED2_8(a,b) ((((lzo_uintptr_t)(a)|(lzo_uintptr_t)(b)) >> 61) == 0)
2223 #define PTR(a) ((lzo_uintptr_t) (a))
2224 #define PTR_LINEAR(a) PTR(a)
2225 #define PTR_ALIGNED_4(a) ((PTR_LINEAR(a) & 3) == 0)
2226 #define PTR_ALIGNED_8(a) ((PTR_LINEAR(a) & 7) == 0)
2227 #define PTR_ALIGNED2_4(a,b) (((PTR_LINEAR(a) | PTR_LINEAR(b)) & 3) == 0)
2228 #define PTR_ALIGNED2_8(a,b) (((PTR_LINEAR(a) | PTR_LINEAR(b)) & 7) == 0)
2231 #define PTR_LT(a,b) (PTR(a) < PTR(b))
2232 #define PTR_GE(a,b) (PTR(a) >= PTR(b))
2233 #define PTR_DIFF(a,b) (PTR(a) - PTR(b))
2234 #define pd(a,b) ((lzo_uint) ((a)-(b)))
2236 LZO_EXTERN(lzo_uintptr_t
)
2237 __lzo_ptr_linear(const lzo_voidp ptr
);
2242 unsigned char a_uchar
;
2244 unsigned short a_ushort
;
2246 unsigned int a_uint
;
2248 unsigned long a_ulong
;
2250 lzo_uint a_lzo_uint
;
2251 lzo_int32 a_lzo_int32
;
2252 lzo_uint32 a_lzo_uint32
;
2253 #if defined(LZO_UINT64_MAX)
2254 lzo_int64 a_lzo_int64
;
2255 lzo_uint64 a_lzo_uint64
;
2257 ptrdiff_t a_ptrdiff_t
;
2258 lzo_uintptr_t a_lzo_uintptr_t
;
2259 lzo_voidp a_lzo_voidp
;
2261 lzo_bytep a_lzo_bytep
;
2262 lzo_bytepp a_lzo_bytepp
;
2263 lzo_uintp a_lzo_uintp
;
2264 lzo_uint
* a_lzo_uint_p
;
2265 lzo_uint32p a_lzo_uint32p
;
2266 lzo_uint32
* a_lzo_uint32_p
;
2267 unsigned char * a_uchar_p
;
2278 #ifndef LZO_DETERMINISTIC
2279 #define LZO_DETERMINISTIC 1
2282 #ifndef LZO_DICT_USE_PTR
2283 #define LZO_DICT_USE_PTR 1
2284 #if 0 && (LZO_ARCH_I086)
2285 # undef LZO_DICT_USE_PTR
2286 # define LZO_DICT_USE_PTR 0
2290 #if (LZO_DICT_USE_PTR)
2291 # define lzo_dict_t const lzo_bytep
2292 # define lzo_dict_p lzo_dict_t __LZO_MMODEL *
2294 # define lzo_dict_t lzo_uint
2295 # define lzo_dict_p lzo_dict_t __LZO_MMODEL *
2300 #if !defined(MINILZO_CFG_SKIP_LZO_PTR)
2302 LZO_PUBLIC(lzo_uintptr_t
)
2303 __lzo_ptr_linear(const lzo_voidp ptr
)
2308 p
= (((lzo_uintptr_t
)(ACC_PTR_FP_SEG(ptr
))) << (16 - ACC_MM_AHSHIFT
)) + (ACC_PTR_FP_OFF(ptr
));
2310 p
= (lzo_uintptr_t
) (ptr
);
2311 p
= (p
<< 3) | (p
>> 61);
2313 p
= (lzo_uintptr_t
) PTR_LINEAR(ptr
);
2319 LZO_PUBLIC(unsigned)
2320 __lzo_align_gap(const lzo_voidp ptr
, lzo_uint size
)
2322 #if defined(__LZO_UINTPTR_T_IS_POINTER)
2323 size_t n
= (size_t) ptr
;
2324 n
= (((n
+ size
- 1) / size
) * size
) - n
;
2327 p
= __lzo_ptr_linear(ptr
);
2328 n
= (((p
+ size
- 1) / size
) * size
) - p
;
2332 assert((long)n
>= 0);
2338 #if !defined(MINILZO_CFG_SKIP_LZO_UTIL)
2340 /* If you use the LZO library in a product, I would appreciate that you
2341 * keep this copyright string in the executable of your product.
2344 static const char __lzo_copyright
[] =
2345 #if !defined(__LZO_IN_MINLZO)
2349 "LZO data compression library.\n"
2350 "$Copyright: LZO Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer\n"
2351 "<markus@oberhumer.com>\n"
2352 "http://www.oberhumer.com $\n\n"
2353 "$Id: LZO version: v" LZO_VERSION_STRING
", " LZO_VERSION_DATE
" $\n"
2354 "$Info: " LZO_INFO_STRING
" $\n";
2357 LZO_PUBLIC(const lzo_bytep
)
2360 #if (LZO_OS_DOS16 && LZO_CC_TURBOC)
2361 return (lzo_voidp
) __lzo_copyright
;
2363 return (const lzo_bytep
) __lzo_copyright
;
2367 LZO_PUBLIC(unsigned)
2373 LZO_PUBLIC(const char *)
2374 lzo_version_string(void)
2376 return LZO_VERSION_STRING
;
2379 LZO_PUBLIC(const char *)
2380 lzo_version_date(void)
2382 return LZO_VERSION_DATE
;
2385 LZO_PUBLIC(const lzo_charp
)
2386 _lzo_version_string(void)
2388 return LZO_VERSION_STRING
;
2391 LZO_PUBLIC(const lzo_charp
)
2392 _lzo_version_date(void)
2394 return LZO_VERSION_DATE
;
2397 #define LZO_BASE 65521u
2398 #define LZO_NMAX 5552
2400 #define LZO_DO1(buf,i) s1 += buf[i]; s2 += s1
2401 #define LZO_DO2(buf,i) LZO_DO1(buf,i); LZO_DO1(buf,i+1);
2402 #define LZO_DO4(buf,i) LZO_DO2(buf,i); LZO_DO2(buf,i+2);
2403 #define LZO_DO8(buf,i) LZO_DO4(buf,i); LZO_DO4(buf,i+4);
2404 #define LZO_DO16(buf,i) LZO_DO8(buf,i); LZO_DO8(buf,i+8);
2406 LZO_PUBLIC(lzo_uint32
)
2407 lzo_adler32(lzo_uint32 adler
, const lzo_bytep buf
, lzo_uint len
)
2409 lzo_uint32 s1
= adler
& 0xffff;
2410 lzo_uint32 s2
= (adler
>> 16) & 0xffff;
2418 k
= len
< LZO_NMAX
? (unsigned) len
: LZO_NMAX
;
2434 return (s2
<< 16) | s1
;
2444 #if !defined(MINILZO_CFG_SKIP_LZO_STRING)
2449 #if !defined(__LZO_MMODEL_HUGE)
2450 # undef LZO_HAVE_MM_HUGE_PTR
2452 #define lzo_hsize_t lzo_uint
2453 #define lzo_hvoid_p lzo_voidp
2454 #define lzo_hbyte_p lzo_bytep
2455 #define LZOLIB_PUBLIC(r,f) LZO_PUBLIC(r) f
2456 #define lzo_hmemcmp lzo_memcmp
2457 #define lzo_hmemcpy lzo_memcpy
2458 #define lzo_hmemmove lzo_memmove
2459 #define lzo_hmemset lzo_memset
2460 #define __LZOLIB_HMEMCPY_CH_INCLUDED 1
2461 #if !defined(LZOLIB_PUBLIC)
2462 # define LZOLIB_PUBLIC(r,f) r __LZOLIB_FUNCNAME(f)
2464 LZOLIB_PUBLIC(int, lzo_hmemcmp
) (const lzo_hvoid_p s1
, const lzo_hvoid_p s2
, lzo_hsize_t len
)
2466 #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMCMP)
2467 const lzo_hbyte_p p1
= (const lzo_hbyte_p
) s1
;
2468 const lzo_hbyte_p p2
= (const lzo_hbyte_p
) s2
;
2469 if __lzo_likely(len
> 0) do
2475 } while __lzo_likely(--len
> 0);
2478 return memcmp(s1
, s2
, len
);
2481 LZOLIB_PUBLIC(lzo_hvoid_p
, lzo_hmemcpy
) (lzo_hvoid_p dest
, const lzo_hvoid_p src
, lzo_hsize_t len
)
2483 #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMCPY)
2484 lzo_hbyte_p p1
= (lzo_hbyte_p
) dest
;
2485 const lzo_hbyte_p p2
= (const lzo_hbyte_p
) src
;
2486 if (!(len
> 0) || p1
== p2
)
2490 while __lzo_likely(--len
> 0);
2493 return memcpy(dest
, src
, len
);
2496 LZOLIB_PUBLIC(lzo_hvoid_p
, lzo_hmemmove
) (lzo_hvoid_p dest
, const lzo_hvoid_p src
, lzo_hsize_t len
)
2498 #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMMOVE)
2499 lzo_hbyte_p p1
= (lzo_hbyte_p
) dest
;
2500 const lzo_hbyte_p p2
= (const lzo_hbyte_p
) src
;
2501 if (!(len
> 0) || p1
== p2
)
2507 while __lzo_likely(--len
> 0);
2515 while __lzo_likely(--len
> 0);
2519 return memmove(dest
, src
, len
);
2522 LZOLIB_PUBLIC(lzo_hvoid_p
, lzo_hmemset
) (lzo_hvoid_p s
, int c
, lzo_hsize_t len
)
2524 #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMSET)
2525 lzo_hbyte_p p
= (lzo_hbyte_p
) s
;
2526 if __lzo_likely(len
> 0) do
2527 *p
++ = (unsigned char) c
;
2528 while __lzo_likely(--len
> 0);
2531 return memset(s
, c
, len
);
2534 #undef LZOLIB_PUBLIC
2536 #if !defined(MINILZO_CFG_SKIP_LZO_INIT)
2538 #if !defined(__LZO_IN_MINILZO)
2540 #define ACC_WANT_ACC_CHK_CH 1
2541 #undef ACCCHK_ASSERT
2543 ACCCHK_ASSERT_IS_SIGNED_T(lzo_int
)
2544 ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uint
)
2546 ACCCHK_ASSERT_IS_SIGNED_T(lzo_int32
)
2547 ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uint32
)
2548 ACCCHK_ASSERT((LZO_UINT32_C(1) << (int)(8*sizeof(LZO_UINT32_C(1))-1)) > 0)
2549 ACCCHK_ASSERT(sizeof(lzo_uint32
) >= 4)
2550 #if defined(LZO_UINT64_MAX)
2551 ACCCHK_ASSERT(sizeof(lzo_uint64
) == 8)
2552 ACCCHK_ASSERT_IS_SIGNED_T(lzo_int64
)
2553 ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uint64
)
2556 #if !defined(__LZO_UINTPTR_T_IS_POINTER)
2557 ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uintptr_t
)
2559 ACCCHK_ASSERT(sizeof(lzo_uintptr_t
) >= sizeof(lzo_voidp
))
2561 ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_xint
)
2562 ACCCHK_ASSERT(sizeof(lzo_xint
) >= sizeof(lzo_uint32
))
2563 ACCCHK_ASSERT(sizeof(lzo_xint
) >= sizeof(lzo_uint
))
2564 ACCCHK_ASSERT(sizeof(lzo_xint
) == sizeof(lzo_uint32
) || sizeof(lzo_xint
) == sizeof(lzo_uint
))
2567 #undef ACCCHK_ASSERT
2570 #define WANT_lzo_bitops_clz32 1
2571 #define WANT_lzo_bitops_clz64 1
2573 #define WANT_lzo_bitops_ctz32 1
2574 #define WANT_lzo_bitops_ctz64 1
2576 #if (defined(_WIN32) || defined(_WIN64)) && ((LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || (LZO_CC_MSC && (_MSC_VER >= 1400)))
2578 #if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32) && 0
2579 #pragma intrinsic(_BitScanReverse)
2580 static __lzo_inline
unsigned lzo_bitops_clz32(lzo_uint32 v
)
2583 (void) _BitScanReverse(&r
, v
);
2584 return (unsigned) r
;
2586 #define lzo_bitops_clz32 lzo_bitops_clz32
2588 #if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX) && 0
2589 #pragma intrinsic(_BitScanReverse64)
2590 static __lzo_inline
unsigned lzo_bitops_clz64(lzo_uint64 v
)
2593 (void) _BitScanReverse64(&r
, v
);
2594 return (unsigned) r
;
2596 #define lzo_bitops_clz64 lzo_bitops_clz64
2598 #if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32)
2599 #pragma intrinsic(_BitScanForward)
2600 static __lzo_inline
unsigned lzo_bitops_ctz32(lzo_uint32 v
)
2603 (void) _BitScanForward(&r
, v
);
2604 return (unsigned) r
;
2606 #define lzo_bitops_ctz32 lzo_bitops_ctz32
2608 #if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX)
2609 #pragma intrinsic(_BitScanForward64)
2610 static __lzo_inline
unsigned lzo_bitops_ctz64(lzo_uint64 v
)
2613 (void) _BitScanForward64(&r
, v
);
2614 return (unsigned) r
;
2616 #define lzo_bitops_ctz64 lzo_bitops_ctz64
2619 #elif (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x030400ul) || (LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || LZO_CC_LLVM)
2620 #if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32)
2621 #define lzo_bitops_clz32(v) ((unsigned) __builtin_clz(v))
2623 #if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX)
2624 #define lzo_bitops_clz64(v) ((unsigned) __builtin_clzll(v))
2626 #if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32)
2627 #define lzo_bitops_ctz32(v) ((unsigned) __builtin_ctz(v))
2629 #if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX)
2630 #define lzo_bitops_ctz64(v) ((unsigned) __builtin_ctzll(v))
2632 #if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount32)
2633 #define lzo_bitops_popcount32(v) ((unsigned) __builtin_popcount(v))
2635 #if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount64) && defined(LZO_UINT64_MAX)
2636 #define lzo_bitops_popcount64(v) ((unsigned) __builtin_popcountll(v))
2641 #define u2p(ptr,off) ((lzo_voidp) (((lzo_bytep)(lzo_voidp)(ptr)) + (off)))
2643 static __lzo_noinline lzo_voidp
u2p(lzo_voidp ptr
, lzo_uint off
)
2645 return (lzo_voidp
) ((lzo_bytep
) ptr
+ off
);
2650 _lzo_config_check(void)
2654 lzo_xint a
[2]; unsigned char b
[2*LZO_MAX(8,sizeof(lzo_xint
))];
2655 #if defined(LZO_UNALIGNED_OK_8)
2658 unsigned short x
[2]; lzo_uint32 y
[2]; lzo_uint z
[2];
2662 u
.a
[0] = u
.a
[1] = 0;
2664 r
&= ((* (lzo_bytep
) p
) == 0);
2665 #if !defined(LZO_CFG_NO_CONFIG_CHECK)
2666 #if defined(LZO_ABI_BIG_ENDIAN)
2667 u
.a
[0] = u
.a
[1] = 0; u
.b
[sizeof(lzo_uint
) - 1] = 128;
2669 r
&= ((* (lzo_uintp
) p
) == 128);
2671 #if defined(LZO_ABI_LITTLE_ENDIAN)
2672 u
.a
[0] = u
.a
[1] = 0; u
.b
[0] = 128;
2674 r
&= ((* (lzo_uintp
) p
) == 128);
2676 #if defined(LZO_UNALIGNED_OK_2)
2677 u
.a
[0] = u
.a
[1] = 0;
2678 u
.b
[0] = 1; u
.b
[sizeof(unsigned short) + 1] = 2;
2680 r
&= ((* (lzo_ushortp
) p
) == 0);
2682 #if defined(LZO_UNALIGNED_OK_4)
2683 u
.a
[0] = u
.a
[1] = 0;
2684 u
.b
[0] = 3; u
.b
[sizeof(lzo_uint32
) + 1] = 4;
2686 r
&= ((* (lzo_uint32p
) p
) == 0);
2688 #if defined(LZO_UNALIGNED_OK_8)
2689 u
.c
[0] = u
.c
[1] = 0;
2690 u
.b
[0] = 5; u
.b
[sizeof(lzo_uint64
) + 1] = 6;
2692 r
&= ((* (lzo_uint64p
) p
) == 0);
2694 #if defined(lzo_bitops_clz32)
2695 { unsigned i
; lzo_uint32 v
= 1;
2696 for (i
= 0; i
< 31; i
++, v
<<= 1)
2697 r
&= lzo_bitops_clz32(v
) == 31 - i
;
2700 #if defined(lzo_bitops_clz64)
2701 { unsigned i
; lzo_uint64 v
= 1;
2702 for (i
= 0; i
< 63; i
++, v
<<= 1)
2703 r
&= lzo_bitops_clz64(v
) == 63 - i
;
2706 #if defined(lzo_bitops_ctz32)
2707 { unsigned i
; lzo_uint32 v
= 1;
2708 for (i
= 0; i
< 31; i
++, v
<<= 1)
2709 r
&= lzo_bitops_ctz32(v
) == i
;
2712 #if defined(lzo_bitops_ctz64)
2713 { unsigned i
; lzo_uint64 v
= 1;
2714 for (i
= 0; i
< 63; i
++, v
<<= 1)
2715 r
&= lzo_bitops_ctz64(v
) == i
;
2720 return r
== 1 ? LZO_E_OK
: LZO_E_ERROR
;
2724 __lzo_init_v2(unsigned v
, int s1
, int s2
, int s3
, int s4
, int s5
,
2725 int s6
, int s7
, int s8
, int s9
)
2729 #if defined(__LZO_IN_MINILZO)
2730 #elif (LZO_CC_MSC && ((_MSC_VER) < 700))
2732 #define ACC_WANT_ACC_CHK_CH 1
2733 #undef ACCCHK_ASSERT
2734 #define ACCCHK_ASSERT(expr) LZO_COMPILE_TIME_ASSERT(expr)
2736 #undef ACCCHK_ASSERT
2741 r
= (s1
== -1 || s1
== (int) sizeof(short)) &&
2742 (s2
== -1 || s2
== (int) sizeof(int)) &&
2743 (s3
== -1 || s3
== (int) sizeof(long)) &&
2744 (s4
== -1 || s4
== (int) sizeof(lzo_uint32
)) &&
2745 (s5
== -1 || s5
== (int) sizeof(lzo_uint
)) &&
2746 (s6
== -1 || s6
== (int) lzo_sizeof_dict_t
) &&
2747 (s7
== -1 || s7
== (int) sizeof(char *)) &&
2748 (s8
== -1 || s8
== (int) sizeof(lzo_voidp
)) &&
2749 (s9
== -1 || s9
== (int) sizeof(lzo_callback_t
));
2753 r
= _lzo_config_check();
2760 #if !defined(__LZO_IN_MINILZO)
2762 #if (LZO_OS_WIN16 && LZO_CC_WATCOMC) && defined(__SW_BD)
2765 BOOL FAR PASCAL
LibMain ( HANDLE hInstance
, WORD wDataSegment
,
2766 WORD wHeapSize
, LPSTR lpszCmdLine
)
2768 int __far __pascal
LibMain ( int a
, short b
, short c
, long d
)
2771 LZO_UNUSED(a
); LZO_UNUSED(b
); LZO_UNUSED(c
); LZO_UNUSED(d
);
2782 #define LZO_EOF_CODE 1
2783 #define M2_MAX_OFFSET 0x0800
2785 #if !defined(MINILZO_CFG_SKIP_LZO1X_1_COMPRESS)
2787 #if 1 && defined(UA_GET32)
2788 #undef LZO_DICT_USE_PTR
2789 #define LZO_DICT_USE_PTR 0
2791 #define lzo_dict_t unsigned short
2794 #define LZO_NEED_DICT_H 1
2798 #define D_INDEX1(d,p) d = DM(DMUL(0x21,DX3(p,5,5,6)) >> 5)
2799 #define D_INDEX2(d,p) d = (d & (D_MASK & 0x7ff)) ^ (D_HIGH | 0x1f)
2801 #define DINDEX(dv,p) DM(((DMUL(0x1824429d,dv)) >> (32-D_BITS)))
2803 #define DINDEX(dv,p) DM((dv) + ((dv) >> (32-D_BITS)))
2806 #ifndef __LZO_CONFIG1X_H
2807 #define __LZO_CONFIG1X_H 1
2809 #if !defined(LZO1X) && !defined(LZO1Y) && !defined(LZO1Z)
2813 #if !defined(__LZO_IN_MINILZO)
2814 #include "lzo/lzo1x.h"
2817 #ifndef LZO_EOF_CODE
2818 #define LZO_EOF_CODE 1
2820 #undef LZO_DETERMINISTIC
2822 #define M1_MAX_OFFSET 0x0400
2823 #ifndef M2_MAX_OFFSET
2824 #define M2_MAX_OFFSET 0x0800
2826 #define M3_MAX_OFFSET 0x4000
2827 #define M4_MAX_OFFSET 0xbfff
2829 #define MX_MAX_OFFSET (M1_MAX_OFFSET + M2_MAX_OFFSET)
2831 #define M1_MIN_LEN 2
2832 #define M1_MAX_LEN 2
2833 #define M2_MIN_LEN 3
2835 #define M2_MAX_LEN 8
2837 #define M3_MIN_LEN 3
2838 #define M3_MAX_LEN 33
2839 #define M4_MIN_LEN 3
2840 #define M4_MAX_LEN 9
2843 #define M2_MARKER 64
2844 #define M3_MARKER 32
2845 #define M4_MARKER 16
2847 #ifndef MIN_LOOKAHEAD
2848 #define MIN_LOOKAHEAD (M2_MAX_LEN + 1)
2851 #if defined(LZO_NEED_DICT_H)
2854 #define LZO_HASH LZO_HASH_LZO_INCREMENTAL_B
2856 #define DL_MIN_LEN M2_MIN_LEN
2858 #ifndef __LZO_DICT_H
2859 #define __LZO_DICT_H 1
2865 #if !defined(D_BITS) && defined(DBITS)
2866 # define D_BITS DBITS
2868 #if !defined(D_BITS)
2869 # error "D_BITS is not defined"
2872 # define D_SIZE LZO_SIZE(D_BITS)
2873 # define D_MASK LZO_MASK(D_BITS)
2875 # define D_SIZE LZO_USIZE(D_BITS)
2876 # define D_MASK LZO_UMASK(D_BITS)
2878 #define D_HIGH ((D_MASK >> 1) + 1)
2880 #if !defined(DD_BITS)
2883 #define DD_SIZE LZO_SIZE(DD_BITS)
2884 #define DD_MASK LZO_MASK(DD_BITS)
2886 #if !defined(DL_BITS)
2887 # define DL_BITS (D_BITS - DD_BITS)
2890 # define DL_SIZE LZO_SIZE(DL_BITS)
2891 # define DL_MASK LZO_MASK(DL_BITS)
2893 # define DL_SIZE LZO_USIZE(DL_BITS)
2894 # define DL_MASK LZO_UMASK(DL_BITS)
2897 #if (D_BITS != DL_BITS + DD_BITS)
2898 # error "D_BITS does not match"
2900 #if (D_BITS < 6 || D_BITS > 18)
2901 # error "invalid D_BITS"
2903 #if (DL_BITS < 6 || DL_BITS > 20)
2904 # error "invalid DL_BITS"
2906 #if (DD_BITS < 0 || DD_BITS > 6)
2907 # error "invalid DD_BITS"
2910 #if !defined(DL_MIN_LEN)
2911 # define DL_MIN_LEN 3
2913 #if !defined(DL_SHIFT)
2914 # define DL_SHIFT ((DL_BITS + (DL_MIN_LEN - 1)) / DL_MIN_LEN)
2917 #define LZO_HASH_GZIP 1
2918 #define LZO_HASH_GZIP_INCREMENTAL 2
2919 #define LZO_HASH_LZO_INCREMENTAL_A 3
2920 #define LZO_HASH_LZO_INCREMENTAL_B 4
2922 #if !defined(LZO_HASH)
2923 # error "choose a hashing strategy"
2929 #if (DL_MIN_LEN == 3)
2930 # define _DV2_A(p,shift1,shift2) \
2931 (((( (lzo_xint)((p)[0]) << shift1) ^ (p)[1]) << shift2) ^ (p)[2])
2932 # define _DV2_B(p,shift1,shift2) \
2933 (((( (lzo_xint)((p)[2]) << shift1) ^ (p)[1]) << shift2) ^ (p)[0])
2934 # define _DV3_B(p,shift1,shift2,shift3) \
2935 ((_DV2_B((p)+1,shift1,shift2) << (shift3)) ^ (p)[0])
2936 #elif (DL_MIN_LEN == 2)
2937 # define _DV2_A(p,shift1,shift2) \
2938 (( (lzo_xint)(p[0]) << shift1) ^ p[1])
2939 # define _DV2_B(p,shift1,shift2) \
2940 (( (lzo_xint)(p[1]) << shift1) ^ p[2])
2942 # error "invalid DL_MIN_LEN"
2944 #define _DV_A(p,shift) _DV2_A(p,shift,shift)
2945 #define _DV_B(p,shift) _DV2_B(p,shift,shift)
2946 #define DA2(p,s1,s2) \
2947 (((((lzo_xint)((p)[2]) << (s2)) + (p)[1]) << (s1)) + (p)[0])
2948 #define DS2(p,s1,s2) \
2949 (((((lzo_xint)((p)[2]) << (s2)) - (p)[1]) << (s1)) - (p)[0])
2950 #define DX2(p,s1,s2) \
2951 (((((lzo_xint)((p)[2]) << (s2)) ^ (p)[1]) << (s1)) ^ (p)[0])
2952 #define DA3(p,s1,s2,s3) ((DA2((p)+1,s2,s3) << (s1)) + (p)[0])
2953 #define DS3(p,s1,s2,s3) ((DS2((p)+1,s2,s3) << (s1)) - (p)[0])
2954 #define DX3(p,s1,s2,s3) ((DX2((p)+1,s2,s3) << (s1)) ^ (p)[0])
2955 #define DMS(v,s) ((lzo_uint) (((v) & (D_MASK >> (s))) << (s)))
2956 #define DM(v) DMS(v,0)
2958 #if (LZO_HASH == LZO_HASH_GZIP)
2959 # define _DINDEX(dv,p) (_DV_A((p),DL_SHIFT))
2961 #elif (LZO_HASH == LZO_HASH_GZIP_INCREMENTAL)
2962 # define __LZO_HASH_INCREMENTAL 1
2963 # define DVAL_FIRST(dv,p) dv = _DV_A((p),DL_SHIFT)
2964 # define DVAL_NEXT(dv,p) dv = (((dv) << DL_SHIFT) ^ p[2])
2965 # define _DINDEX(dv,p) (dv)
2966 # define DVAL_LOOKAHEAD DL_MIN_LEN
2968 #elif (LZO_HASH == LZO_HASH_LZO_INCREMENTAL_A)
2969 # define __LZO_HASH_INCREMENTAL 1
2970 # define DVAL_FIRST(dv,p) dv = _DV_A((p),5)
2971 # define DVAL_NEXT(dv,p) \
2972 dv ^= (lzo_xint)(p[-1]) << (2*5); dv = (((dv) << 5) ^ p[2])
2973 # define _DINDEX(dv,p) ((DMUL(0x9f5f,dv)) >> 5)
2974 # define DVAL_LOOKAHEAD DL_MIN_LEN
2976 #elif (LZO_HASH == LZO_HASH_LZO_INCREMENTAL_B)
2977 # define __LZO_HASH_INCREMENTAL 1
2978 # define DVAL_FIRST(dv,p) dv = _DV_B((p),5)
2979 # define DVAL_NEXT(dv,p) \
2980 dv ^= p[-1]; dv = (((dv) >> 5) ^ ((lzo_xint)(p[2]) << (2*5)))
2981 # define _DINDEX(dv,p) ((DMUL(0x9f5f,dv)) >> 5)
2982 # define DVAL_LOOKAHEAD DL_MIN_LEN
2985 # error "choose a hashing strategy"
2989 #define DINDEX(dv,p) ((lzo_uint)((_DINDEX(dv,p)) & DL_MASK) << DD_BITS)
2991 #if !defined(DINDEX1) && defined(D_INDEX1)
2992 #define DINDEX1 D_INDEX1
2994 #if !defined(DINDEX2) && defined(D_INDEX2)
2995 #define DINDEX2 D_INDEX2
2998 #if !defined(__LZO_HASH_INCREMENTAL)
2999 # define DVAL_FIRST(dv,p) ((void) 0)
3000 # define DVAL_NEXT(dv,p) ((void) 0)
3001 # define DVAL_LOOKAHEAD 0
3004 #if !defined(DVAL_ASSERT)
3005 #if defined(__LZO_HASH_INCREMENTAL) && !defined(NDEBUG)
3006 #if (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x020700ul) || LZO_CC_LLVM)
3007 static void __attribute__((__unused__
))
3011 DVAL_ASSERT(lzo_xint dv
, const lzo_bytep p
)
3015 assert(DINDEX(dv
,p
) == DINDEX(df
,p
));
3018 # define DVAL_ASSERT(dv,p) ((void) 0)
3022 #if (LZO_DICT_USE_PTR)
3023 # define DENTRY(p,in) (p)
3024 # define GINDEX(m_pos,m_off,dict,dindex,in) m_pos = dict[dindex]
3026 # define DENTRY(p,in) ((lzo_dict_t) pd(p, in))
3027 # define GINDEX(m_pos,m_off,dict,dindex,in) m_off = dict[dindex]
3032 # define UPDATE_D(dict,drun,dv,p,in) dict[ DINDEX(dv,p) ] = DENTRY(p,in)
3033 # define UPDATE_I(dict,drun,index,p,in) dict[index] = DENTRY(p,in)
3034 # define UPDATE_P(ptr,drun,p,in) (ptr)[0] = DENTRY(p,in)
3038 # define UPDATE_D(dict,drun,dv,p,in) \
3039 dict[ DINDEX(dv,p) + drun++ ] = DENTRY(p,in); drun &= DD_MASK
3040 # define UPDATE_I(dict,drun,index,p,in) \
3041 dict[ (index) + drun++ ] = DENTRY(p,in); drun &= DD_MASK
3042 # define UPDATE_P(ptr,drun,p,in) \
3043 (ptr) [ drun++ ] = DENTRY(p,in); drun &= DD_MASK
3047 #if (LZO_DICT_USE_PTR)
3049 #define LZO_CHECK_MPOS_DET(m_pos,m_off,in,ip,max_offset) \
3050 (m_pos == NULL || (m_off = pd(ip, m_pos)) > max_offset)
3052 #define LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,max_offset) \
3053 (BOUNDS_CHECKING_OFF_IN_EXPR(( \
3054 m_pos = ip - (lzo_uint) PTR_DIFF(ip,m_pos), \
3055 PTR_LT(m_pos,in) || \
3056 (m_off = (lzo_uint) PTR_DIFF(ip,m_pos)) == 0 || \
3057 m_off > max_offset )))
3061 #define LZO_CHECK_MPOS_DET(m_pos,m_off,in,ip,max_offset) \
3063 ((m_off = pd(ip, in) - m_off) > max_offset) || \
3064 (m_pos = (ip) - (m_off), 0) )
3066 #define LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,max_offset) \
3067 (pd(ip, in) <= m_off || \
3068 ((m_off = pd(ip, in) - m_off) > max_offset) || \
3069 (m_pos = (ip) - (m_off), 0) )
3073 #if (LZO_DETERMINISTIC)
3074 # define LZO_CHECK_MPOS LZO_CHECK_MPOS_DET
3076 # define LZO_CHECK_MPOS LZO_CHECK_MPOS_NON_DET
3089 #define LZO_DETERMINISTIC !(LZO_DICT_USE_PTR)
3092 #define DO_COMPRESS lzo1x_1_compress
3095 #if 1 && defined(DO_COMPRESS) && !defined(do_compress)
3096 # define do_compress LZO_CPP_ECONCAT2(DO_COMPRESS,_core)
3099 #if defined(UA_GET64)
3100 # define WANT_lzo_bitops_ctz64 1
3101 #elif defined(UA_GET32)
3102 # define WANT_lzo_bitops_ctz32 1
3105 #if (defined(_WIN32) || defined(_WIN64)) && ((LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || (LZO_CC_MSC && (_MSC_VER >= 1400)))
3107 #if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32) && 0
3108 #pragma intrinsic(_BitScanReverse)
3109 static __lzo_inline
unsigned lzo_bitops_clz32(lzo_uint32 v
)
3112 (void) _BitScanReverse(&r
, v
);
3113 return (unsigned) r
;
3115 #define lzo_bitops_clz32 lzo_bitops_clz32
3117 #if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX) && 0
3118 #pragma intrinsic(_BitScanReverse64)
3119 static __lzo_inline
unsigned lzo_bitops_clz64(lzo_uint64 v
)
3122 (void) _BitScanReverse64(&r
, v
);
3123 return (unsigned) r
;
3125 #define lzo_bitops_clz64 lzo_bitops_clz64
3127 #if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32)
3128 #pragma intrinsic(_BitScanForward)
3129 static __lzo_inline
unsigned lzo_bitops_ctz32(lzo_uint32 v
)
3132 (void) _BitScanForward(&r
, v
);
3133 return (unsigned) r
;
3135 #define lzo_bitops_ctz32 lzo_bitops_ctz32
3137 #if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX)
3138 #pragma intrinsic(_BitScanForward64)
3139 static __lzo_inline
unsigned lzo_bitops_ctz64(lzo_uint64 v
)
3142 (void) _BitScanForward64(&r
, v
);
3143 return (unsigned) r
;
3145 #define lzo_bitops_ctz64 lzo_bitops_ctz64
3148 #elif (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x030400ul) || (LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || LZO_CC_LLVM)
3149 #if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32)
3150 #define lzo_bitops_clz32(v) ((unsigned) __builtin_clz(v))
3152 #if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX)
3153 #define lzo_bitops_clz64(v) ((unsigned) __builtin_clzll(v))
3155 #if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32)
3156 #define lzo_bitops_ctz32(v) ((unsigned) __builtin_ctz(v))
3158 #if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX)
3159 #define lzo_bitops_ctz64(v) ((unsigned) __builtin_ctzll(v))
3161 #if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount32)
3162 #define lzo_bitops_popcount32(v) ((unsigned) __builtin_popcount(v))
3164 #if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount64) && defined(LZO_UINT64_MAX)
3165 #define lzo_bitops_popcount64(v) ((unsigned) __builtin_popcountll(v))
3169 static __lzo_noinline lzo_uint
3170 do_compress ( const lzo_bytep in
, lzo_uint in_len
,
3171 lzo_bytep out
, lzo_uintp out_len
,
3172 lzo_uint ti
, lzo_voidp wrkmem
)
3174 register const lzo_bytep ip
;
3176 const lzo_bytep
const in_end
= in
+ in_len
;
3177 const lzo_bytep
const ip_end
= in
+ in_len
- 20;
3179 lzo_dict_p
const dict
= (lzo_dict_p
) wrkmem
;
3185 ip
+= ti
< 4 ? 4 - ti
: 0;
3188 const lzo_bytep m_pos
;
3189 #if !(LZO_DETERMINISTIC)
3190 LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint
, m_off
, 0);
3194 if __lzo_unlikely(ip
>= ip_end
)
3197 GINDEX(m_pos
,m_off
,dict
,dindex
,in
);
3198 if (LZO_CHECK_MPOS_NON_DET(m_pos
,m_off
,in
,ip
,M4_MAX_OFFSET
))
3201 if (m_off
<= M2_MAX_OFFSET
|| m_pos
[3] == ip
[3])
3205 GINDEX(m_pos
,m_off
,dict
,dindex
,in
);
3206 if (LZO_CHECK_MPOS_NON_DET(m_pos
,m_off
,in
,ip
,M4_MAX_OFFSET
))
3208 if (m_off
<= M2_MAX_OFFSET
|| m_pos
[3] == ip
[3])
3213 #if defined(UA_GET32)
3214 if (UA_GET32(m_pos
) != UA_GET32(ip
))
3216 if (m_pos
[0] != ip
[0] || m_pos
[1] != ip
[1] || m_pos
[2] != ip
[2] || m_pos
[3] != ip
[3])
3220 UPDATE_I(dict
,0,dindex
,ip
,in
);
3221 ip
+= 1 + ((ip
- ii
) >> 5);
3224 UPDATE_I(dict
,0,dindex
,ip
,in
);
3232 ip
+= 1 + ((ip
- ii
) >> 5);
3234 if __lzo_unlikely(ip
>= ip_end
)
3237 dindex
= DINDEX(dv
,ip
);
3238 GINDEX(m_off
,m_pos
,in
+dict
,dindex
,in
);
3239 UPDATE_I(dict
,0,dindex
,ip
,in
);
3240 if __lzo_unlikely(dv
!= UA_GET32(m_pos
))
3246 register lzo_uint t
= pd(ip
,ii
);
3251 op
[-2] |= LZO_BYTE(t
);
3252 #if defined(UA_COPY32)
3256 { do *op
++ = *ii
++; while (--t
> 0); }
3259 #if defined(UA_COPY32) || defined(UA_COPY64)
3262 *op
++ = LZO_BYTE(t
- 3);
3263 #if defined(UA_COPY64)
3265 UA_COPY64(op
+8, ii
+8);
3268 UA_COPY32(op
+4, ii
+4);
3269 UA_COPY32(op
+8, ii
+8);
3270 UA_COPY32(op
+12, ii
+12);
3278 *op
++ = LZO_BYTE(t
- 3);
3281 register lzo_uint tt
= t
- 18;
3283 while __lzo_unlikely(tt
> 255)
3286 #if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400))
3287 * (volatile unsigned char *) op
++ = 0;
3293 *op
++ = LZO_BYTE(tt
);
3295 #if defined(UA_COPY32) || defined(UA_COPY64)
3297 #if defined(UA_COPY64)
3299 UA_COPY64(op
+8, ii
+8);
3302 UA_COPY32(op
+4, ii
+4);
3303 UA_COPY32(op
+8, ii
+8);
3304 UA_COPY32(op
+12, ii
+12);
3306 op
+= 16; ii
+= 16; t
-= 16;
3307 } while (t
>= 16); if (t
> 0)
3309 { do *op
++ = *ii
++; while (--t
> 0); }
3315 #if defined(UA_GET64)
3317 v
= UA_GET64(ip
+ m_len
) ^ UA_GET64(m_pos
+ m_len
);
3318 if __lzo_unlikely(v
== 0) {
3321 v
= UA_GET64(ip
+ m_len
) ^ UA_GET64(m_pos
+ m_len
);
3322 if __lzo_unlikely(ip
+ m_len
>= ip_end
)
3326 #if (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_ctz64)
3327 m_len
+= lzo_bitops_ctz64(v
) / CHAR_BIT
;
3328 #elif (LZO_ABI_LITTLE_ENDIAN)
3329 if ((v
& UCHAR_MAX
) == 0) do {
3332 } while ((v
& UCHAR_MAX
) == 0);
3334 if (ip
[m_len
] == m_pos
[m_len
]) do {
3336 } while (ip
[m_len
] == m_pos
[m_len
]);
3338 #elif defined(UA_GET32)
3340 v
= UA_GET32(ip
+ m_len
) ^ UA_GET32(m_pos
+ m_len
);
3341 if __lzo_unlikely(v
== 0) {
3344 v
= UA_GET32(ip
+ m_len
) ^ UA_GET32(m_pos
+ m_len
);
3345 if __lzo_unlikely(ip
+ m_len
>= ip_end
)
3349 #if (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_ctz32)
3350 m_len
+= lzo_bitops_ctz32(v
) / CHAR_BIT
;
3351 #elif (LZO_ABI_LITTLE_ENDIAN)
3352 if ((v
& UCHAR_MAX
) == 0) do {
3355 } while ((v
& UCHAR_MAX
) == 0);
3357 if (ip
[m_len
] == m_pos
[m_len
]) do {
3359 } while (ip
[m_len
] == m_pos
[m_len
]);
3362 if __lzo_unlikely(ip
[m_len
] == m_pos
[m_len
]) {
3365 if __lzo_unlikely(ip
+ m_len
>= ip_end
)
3367 } while (ip
[m_len
] == m_pos
[m_len
]);
3372 m_off
= pd(ip
,m_pos
);
3375 if (m_len
<= M2_MAX_LEN
&& m_off
<= M2_MAX_OFFSET
)
3379 *op
++ = LZO_BYTE(((m_len
- 1) << 5) | ((m_off
& 7) << 2));
3380 *op
++ = LZO_BYTE(m_off
>> 3);
3381 #elif defined(LZO1Y)
3382 *op
++ = LZO_BYTE(((m_len
+ 1) << 4) | ((m_off
& 3) << 2));
3383 *op
++ = LZO_BYTE(m_off
>> 2);
3386 else if (m_off
<= M3_MAX_OFFSET
)
3389 if (m_len
<= M3_MAX_LEN
)
3390 *op
++ = LZO_BYTE(M3_MARKER
| (m_len
- 2));
3393 m_len
-= M3_MAX_LEN
;
3394 *op
++ = M3_MARKER
| 0;
3395 while __lzo_unlikely(m_len
> 255)
3398 #if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400))
3399 * (volatile unsigned char *) op
++ = 0;
3404 *op
++ = LZO_BYTE(m_len
);
3406 *op
++ = LZO_BYTE(m_off
<< 2);
3407 *op
++ = LZO_BYTE(m_off
>> 6);
3412 if (m_len
<= M4_MAX_LEN
)
3413 *op
++ = LZO_BYTE(M4_MARKER
| ((m_off
>> 11) & 8) | (m_len
- 2));
3416 m_len
-= M4_MAX_LEN
;
3417 *op
++ = LZO_BYTE(M4_MARKER
| ((m_off
>> 11) & 8));
3418 while __lzo_unlikely(m_len
> 255)
3421 #if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400))
3422 * (volatile unsigned char *) op
++ = 0;
3427 *op
++ = LZO_BYTE(m_len
);
3429 *op
++ = LZO_BYTE(m_off
<< 2);
3430 *op
++ = LZO_BYTE(m_off
>> 6);
3435 *out_len
= pd(op
, out
);
3436 return pd(in_end
,ii
);
3440 DO_COMPRESS ( const lzo_bytep in
, lzo_uint in_len
,
3441 lzo_bytep out
, lzo_uintp out_len
,
3444 const lzo_bytep ip
= in
;
3446 lzo_uint l
= in_len
;
3452 lzo_uintptr_t ll_end
;
3453 #if 0 || (LZO_DETERMINISTIC)
3454 ll
= LZO_MIN(ll
, 49152);
3456 ll_end
= (lzo_uintptr_t
)ip
+ ll
;
3457 if ((ll_end
+ ((t
+ ll
) >> 5)) <= ll_end
|| (const lzo_bytep
)(ll_end
+ ((t
+ ll
) >> 5)) <= ip
+ ll
)
3459 #if (LZO_DETERMINISTIC)
3460 lzo_memset(wrkmem
, 0, ((lzo_uint
)1 << D_BITS
) * sizeof(lzo_dict_t
));
3462 t
= do_compress(ip
,ll
,op
,out_len
,t
,wrkmem
);
3471 const lzo_bytep ii
= in
+ in_len
- t
;
3473 if (op
== out
&& t
<= 238)
3474 *op
++ = LZO_BYTE(17 + t
);
3476 op
[-2] |= LZO_BYTE(t
);
3478 *op
++ = LZO_BYTE(t
- 3);
3481 lzo_uint tt
= t
- 18;
3487 #if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400))
3489 * (volatile unsigned char *) op
++ = 0;
3495 *op
++ = LZO_BYTE(tt
);
3497 do *op
++ = *ii
++; while (--t
> 0);
3500 *op
++ = M4_MARKER
| 1;
3504 *out_len
= pd(op
, out
);
3514 #undef LZO_TEST_OVERRUN
3515 #undef DO_DECOMPRESS
3516 #define DO_DECOMPRESS lzo1x_decompress
3518 #if !defined(MINILZO_CFG_SKIP_LZO1X_DECOMPRESS)
3520 #if defined(LZO_TEST_OVERRUN)
3521 # if !defined(LZO_TEST_OVERRUN_INPUT)
3522 # define LZO_TEST_OVERRUN_INPUT 2
3524 # if !defined(LZO_TEST_OVERRUN_OUTPUT)
3525 # define LZO_TEST_OVERRUN_OUTPUT 2
3527 # if !defined(LZO_TEST_OVERRUN_LOOKBEHIND)
3528 # define LZO_TEST_OVERRUN_LOOKBEHIND 1
3545 #if defined(LZO_TEST_OVERRUN_INPUT)
3546 # if (LZO_TEST_OVERRUN_INPUT >= 1)
3547 # define TEST_IP (ip < ip_end)
3549 # if (LZO_TEST_OVERRUN_INPUT >= 2)
3550 # define NEED_IP(x) \
3551 if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x)) goto input_overrun
3555 #if defined(LZO_TEST_OVERRUN_OUTPUT)
3556 # if (LZO_TEST_OVERRUN_OUTPUT >= 1)
3557 # define TEST_OP (op <= op_end)
3559 # if (LZO_TEST_OVERRUN_OUTPUT >= 2)
3561 # define NEED_OP(x) \
3562 if ((lzo_uint)(op_end - op) < (lzo_uint)(x)) goto output_overrun
3566 #if defined(LZO_TEST_OVERRUN_LOOKBEHIND)
3567 # define TEST_LB(m_pos) if (m_pos < out || m_pos >= op) goto lookbehind_overrun
3568 # define TEST_LBO(m_pos,o) if (m_pos < out || m_pos >= op - (o)) goto lookbehind_overrun
3570 # define TEST_LB(m_pos) ((void) 0)
3571 # define TEST_LBO(m_pos,o) ((void) 0)
3574 #if !defined(LZO_EOF_CODE) && !defined(TEST_IP)
3575 # define TEST_IP (ip < ip_end)
3578 #if defined(TEST_IP)
3579 # define HAVE_TEST_IP 1
3583 #if defined(TEST_OP)
3584 # define HAVE_TEST_OP 1
3589 #if defined(NEED_IP)
3590 # define HAVE_NEED_IP 1
3592 # define NEED_IP(x) ((void) 0)
3594 #if defined(NEED_OP)
3595 # define HAVE_NEED_OP 1
3597 # define NEED_OP(x) ((void) 0)
3600 #if defined(HAVE_TEST_IP) || defined(HAVE_NEED_IP)
3601 # define HAVE_ANY_IP 1
3603 #if defined(HAVE_TEST_OP) || defined(HAVE_NEED_OP)
3604 # define HAVE_ANY_OP 1
3607 #if defined(DO_DECOMPRESS)
3609 DO_DECOMPRESS ( const lzo_bytep in
, lzo_uint in_len
,
3610 lzo_bytep out
, lzo_uintp out_len
,
3614 register lzo_bytep op
;
3615 register const lzo_bytep ip
;
3616 register lzo_uint t
;
3617 #if defined(COPY_DICT)
3619 const lzo_bytep dict_end
;
3621 register const lzo_bytep m_pos
;
3624 const lzo_bytep
const ip_end
= in
+ in_len
;
3625 #if defined(HAVE_ANY_OP)
3626 lzo_bytep
const op_end
= out
+ *out_len
;
3629 lzo_uint last_m_off
= 0;
3634 #if defined(COPY_DICT)
3637 if (dict_len
> M4_MAX_OFFSET
)
3639 dict
+= dict_len
- M4_MAX_OFFSET
;
3640 dict_len
= M4_MAX_OFFSET
;
3642 dict_end
= dict
+ dict_len
;
3661 assert(t
> 0); NEED_OP(t
); NEED_IP(t
+1);
3662 do *op
++ = *ip
++; while (--t
> 0);
3663 goto first_literal_run
;
3666 while (TEST_IP
&& TEST_OP
)
3682 assert(t
> 0); NEED_OP(t
+3); NEED_IP(t
+4);
3683 #if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4)
3688 op
+= 8; ip
+= 8; t
-= 8;
3693 op
+= 4; ip
+= 4; t
-= 4;
3698 if (t
> 1) { *op
++ = *ip
++; if (t
> 2) { *op
++ = *ip
++; } }
3700 #elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
3701 #if !defined(LZO_UNALIGNED_OK_4)
3702 if (PTR_ALIGNED2_4(op
,ip
))
3713 op
+= 4; ip
+= 4; t
-= 4;
3715 if (t
> 0) do *op
++ = *ip
++; while (--t
> 0);
3718 do *op
++ = *ip
++; while (--t
> 0);
3720 #if !defined(LZO_UNALIGNED_OK_4)
3725 #if !defined(LZO_UNALIGNED_OK_4) && !defined(LZO_UNALIGNED_OK_8)
3727 *op
++ = *ip
++; *op
++ = *ip
++; *op
++ = *ip
++;
3728 do *op
++ = *ip
++; while (--t
> 0);
3737 #if defined(COPY_DICT)
3739 m_off
= (1 + M2_MAX_OFFSET
) + (t
<< 6) + (*ip
++ >> 2);
3742 m_off
= (1 + M2_MAX_OFFSET
) + (t
>> 2) + (*ip
++ << 2);
3745 t
= 3; COPY_DICT(t
,m_off
)
3748 t
= (1 + M2_MAX_OFFSET
) + (t
<< 6) + (*ip
++ >> 2);
3752 m_pos
= op
- (1 + M2_MAX_OFFSET
);
3754 m_pos
-= *ip
++ << 2;
3756 TEST_LB(m_pos
); NEED_OP(3);
3757 *op
++ = *m_pos
++; *op
++ = *m_pos
++; *op
++ = *m_pos
;
3765 #if defined(COPY_DICT)
3767 m_off
= 1 + ((t
>> 2) & 7) + (*ip
++ << 3);
3769 #elif defined(LZO1Y)
3770 m_off
= 1 + ((t
>> 2) & 3) + (*ip
++ << 2);
3772 #elif defined(LZO1Z)
3778 m_off
= 1 + (m_off
<< 6) + (*ip
++ >> 2);
3786 m_pos
-= (t
>> 2) & 7;
3787 m_pos
-= *ip
++ << 3;
3789 #elif defined(LZO1Y)
3791 m_pos
-= (t
>> 2) & 3;
3792 m_pos
-= *ip
++ << 2;
3794 #elif defined(LZO1Z)
3796 lzo_uint off
= t
& 0x1f;
3800 assert(last_m_off
> 0);
3801 m_pos
-= last_m_off
;
3805 off
= 1 + (off
<< 6) + (*ip
++ >> 2);
3812 TEST_LB(m_pos
); assert(t
> 0); NEED_OP(t
+3-1);
3830 #if defined(COPY_DICT)
3832 m_off
= 1 + (ip
[0] << 6) + (ip
[1] >> 2);
3835 m_off
= 1 + (ip
[0] >> 2) + (ip
[1] << 6);
3840 lzo_uint off
= 1 + (ip
[0] << 6) + (ip
[1] >> 2);
3844 #elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN)
3846 m_pos
-= UA_GET16(ip
) >> 2;
3849 m_pos
-= (ip
[0] >> 2) + (ip
[1] << 6);
3856 #if defined(COPY_DICT)
3857 m_off
= (t
& 8) << 11;
3860 m_pos
-= (t
& 8) << 11;
3874 #if defined(COPY_DICT)
3876 m_off
+= (ip
[0] << 6) + (ip
[1] >> 2);
3878 m_off
+= (ip
[0] >> 2) + (ip
[1] << 6);
3889 m_pos
-= (ip
[0] << 6) + (ip
[1] >> 2);
3890 #elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN)
3891 m_pos
-= UA_GET16(ip
) >> 2;
3893 m_pos
-= (ip
[0] >> 2) + (ip
[1] << 6);
3900 last_m_off
= pd((const lzo_bytep
)op
, m_pos
);
3906 #if defined(COPY_DICT)
3908 m_off
= 1 + (t
<< 6) + (*ip
++ >> 2);
3911 m_off
= 1 + (t
>> 2) + (*ip
++ << 2);
3914 t
= 2; COPY_DICT(t
,m_off
)
3917 t
= 1 + (t
<< 6) + (*ip
++ >> 2);
3923 m_pos
-= *ip
++ << 2;
3925 TEST_LB(m_pos
); NEED_OP(2);
3926 *op
++ = *m_pos
++; *op
++ = *m_pos
;
3931 #if defined(COPY_DICT)
3934 t
+= 3-1; COPY_DICT(t
,m_off
)
3938 TEST_LB(m_pos
); assert(t
> 0); NEED_OP(t
+3-1);
3939 #if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4)
3940 if (op
- m_pos
>= 8)
3945 UA_COPY64(op
,m_pos
);
3946 op
+= 8; m_pos
+= 8; t
-= 8;
3950 UA_COPY32(op
,m_pos
);
3951 op
+= 4; m_pos
+= 4; t
-= 4;
3956 if (t
> 1) { *op
++ = m_pos
[1]; if (t
> 2) { *op
++ = m_pos
[2]; } }
3960 #elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
3961 #if !defined(LZO_UNALIGNED_OK_4)
3962 if (t
>= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op
,m_pos
))
3964 assert((op
- m_pos
) >= 4);
3966 if (t
>= 2 * 4 - (3 - 1) && (op
- m_pos
) >= 4)
3969 UA_COPY32(op
,m_pos
);
3970 op
+= 4; m_pos
+= 4; t
-= 4 - (3 - 1);
3972 UA_COPY32(op
,m_pos
);
3973 op
+= 4; m_pos
+= 4; t
-= 4;
3975 if (t
> 0) do *op
++ = *m_pos
++; while (--t
> 0);
3981 *op
++ = *m_pos
++; *op
++ = *m_pos
++;
3982 do *op
++ = *m_pos
++; while (--t
> 0);
3997 assert(t
> 0); assert(t
< 4); NEED_OP(t
); NEED_IP(t
+1);
3999 do *op
++ = *ip
++; while (--t
> 0);
4002 if (t
> 1) { *op
++ = *ip
++; if (t
> 2) { *op
++ = *ip
++; } }
4005 } while (TEST_IP
&& TEST_OP
);
4008 #if defined(HAVE_TEST_IP) || defined(HAVE_TEST_OP)
4009 *out_len
= pd(op
, out
);
4010 return LZO_E_EOF_NOT_FOUND
;
4015 *out_len
= pd(op
, out
);
4016 return (ip
== ip_end
? LZO_E_OK
:
4017 (ip
< ip_end
? LZO_E_INPUT_NOT_CONSUMED
: LZO_E_INPUT_OVERRUN
));
4019 #if defined(HAVE_NEED_IP)
4021 *out_len
= pd(op
, out
);
4022 return LZO_E_INPUT_OVERRUN
;
4025 #if defined(HAVE_NEED_OP)
4027 *out_len
= pd(op
, out
);
4028 return LZO_E_OUTPUT_OVERRUN
;
4031 #if defined(LZO_TEST_OVERRUN_LOOKBEHIND)
4033 *out_len
= pd(op
, out
);
4034 return LZO_E_LOOKBEHIND_OVERRUN
;
4040 #define LZO_TEST_OVERRUN 1
4041 #undef DO_DECOMPRESS
4042 #define DO_DECOMPRESS lzo1x_decompress_safe
4044 #if !defined(MINILZO_CFG_SKIP_LZO1X_DECOMPRESS_SAFE)
4046 #if defined(LZO_TEST_OVERRUN)
4047 # if !defined(LZO_TEST_OVERRUN_INPUT)
4048 # define LZO_TEST_OVERRUN_INPUT 2
4050 # if !defined(LZO_TEST_OVERRUN_OUTPUT)
4051 # define LZO_TEST_OVERRUN_OUTPUT 2
4053 # if !defined(LZO_TEST_OVERRUN_LOOKBEHIND)
4054 # define LZO_TEST_OVERRUN_LOOKBEHIND 1
4071 #if defined(LZO_TEST_OVERRUN_INPUT)
4072 # if (LZO_TEST_OVERRUN_INPUT >= 1)
4073 # define TEST_IP (ip < ip_end)
4075 # if (LZO_TEST_OVERRUN_INPUT >= 2)
4076 # define NEED_IP(x) \
4077 if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x)) goto input_overrun
4081 #if defined(LZO_TEST_OVERRUN_OUTPUT)
4082 # if (LZO_TEST_OVERRUN_OUTPUT >= 1)
4083 # define TEST_OP (op <= op_end)
4085 # if (LZO_TEST_OVERRUN_OUTPUT >= 2)
4087 # define NEED_OP(x) \
4088 if ((lzo_uint)(op_end - op) < (lzo_uint)(x)) goto output_overrun
4092 #if defined(LZO_TEST_OVERRUN_LOOKBEHIND)
4093 # define TEST_LB(m_pos) if (m_pos < out || m_pos >= op) goto lookbehind_overrun
4094 # define TEST_LBO(m_pos,o) if (m_pos < out || m_pos >= op - (o)) goto lookbehind_overrun
4096 # define TEST_LB(m_pos) ((void) 0)
4097 # define TEST_LBO(m_pos,o) ((void) 0)
4100 #if !defined(LZO_EOF_CODE) && !defined(TEST_IP)
4101 # define TEST_IP (ip < ip_end)
4104 #if defined(TEST_IP)
4105 # define HAVE_TEST_IP 1
4109 #if defined(TEST_OP)
4110 # define HAVE_TEST_OP 1
4115 #if defined(NEED_IP)
4116 # define HAVE_NEED_IP 1
4118 # define NEED_IP(x) ((void) 0)
4120 #if defined(NEED_OP)
4121 # define HAVE_NEED_OP 1
4123 # define NEED_OP(x) ((void) 0)
4126 #if defined(HAVE_TEST_IP) || defined(HAVE_NEED_IP)
4127 # define HAVE_ANY_IP 1
4129 #if defined(HAVE_TEST_OP) || defined(HAVE_NEED_OP)
4130 # define HAVE_ANY_OP 1
4133 #if defined(DO_DECOMPRESS)
4135 DO_DECOMPRESS ( const lzo_bytep in
, lzo_uint in_len
,
4136 lzo_bytep out
, lzo_uintp out_len
,
4140 register lzo_bytep op
;
4141 register const lzo_bytep ip
;
4142 register lzo_uint t
;
4143 #if defined(COPY_DICT)
4145 const lzo_bytep dict_end
;
4147 register const lzo_bytep m_pos
;
4150 const lzo_bytep
const ip_end
= in
+ in_len
;
4151 #if defined(HAVE_ANY_OP)
4152 lzo_bytep
const op_end
= out
+ *out_len
;
4155 lzo_uint last_m_off
= 0;
4160 #if defined(COPY_DICT)
4163 if (dict_len
> M4_MAX_OFFSET
)
4165 dict
+= dict_len
- M4_MAX_OFFSET
;
4166 dict_len
= M4_MAX_OFFSET
;
4168 dict_end
= dict
+ dict_len
;
4187 assert(t
> 0); NEED_OP(t
); NEED_IP(t
+1);
4188 do *op
++ = *ip
++; while (--t
> 0);
4189 goto first_literal_run
;
4192 while (TEST_IP
&& TEST_OP
)
4208 assert(t
> 0); NEED_OP(t
+3); NEED_IP(t
+4);
4209 #if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4)
4214 op
+= 8; ip
+= 8; t
-= 8;
4219 op
+= 4; ip
+= 4; t
-= 4;
4224 if (t
> 1) { *op
++ = *ip
++; if (t
> 2) { *op
++ = *ip
++; } }
4226 #elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
4227 #if !defined(LZO_UNALIGNED_OK_4)
4228 if (PTR_ALIGNED2_4(op
,ip
))
4239 op
+= 4; ip
+= 4; t
-= 4;
4241 if (t
> 0) do *op
++ = *ip
++; while (--t
> 0);
4244 do *op
++ = *ip
++; while (--t
> 0);
4246 #if !defined(LZO_UNALIGNED_OK_4)
4251 #if !defined(LZO_UNALIGNED_OK_4) && !defined(LZO_UNALIGNED_OK_8)
4253 *op
++ = *ip
++; *op
++ = *ip
++; *op
++ = *ip
++;
4254 do *op
++ = *ip
++; while (--t
> 0);
4263 #if defined(COPY_DICT)
4265 m_off
= (1 + M2_MAX_OFFSET
) + (t
<< 6) + (*ip
++ >> 2);
4268 m_off
= (1 + M2_MAX_OFFSET
) + (t
>> 2) + (*ip
++ << 2);
4271 t
= 3; COPY_DICT(t
,m_off
)
4274 t
= (1 + M2_MAX_OFFSET
) + (t
<< 6) + (*ip
++ >> 2);
4278 m_pos
= op
- (1 + M2_MAX_OFFSET
);
4280 m_pos
-= *ip
++ << 2;
4282 TEST_LB(m_pos
); NEED_OP(3);
4283 *op
++ = *m_pos
++; *op
++ = *m_pos
++; *op
++ = *m_pos
;
4291 #if defined(COPY_DICT)
4293 m_off
= 1 + ((t
>> 2) & 7) + (*ip
++ << 3);
4295 #elif defined(LZO1Y)
4296 m_off
= 1 + ((t
>> 2) & 3) + (*ip
++ << 2);
4298 #elif defined(LZO1Z)
4304 m_off
= 1 + (m_off
<< 6) + (*ip
++ >> 2);
4312 m_pos
-= (t
>> 2) & 7;
4313 m_pos
-= *ip
++ << 3;
4315 #elif defined(LZO1Y)
4317 m_pos
-= (t
>> 2) & 3;
4318 m_pos
-= *ip
++ << 2;
4320 #elif defined(LZO1Z)
4322 lzo_uint off
= t
& 0x1f;
4326 assert(last_m_off
> 0);
4327 m_pos
-= last_m_off
;
4331 off
= 1 + (off
<< 6) + (*ip
++ >> 2);
4338 TEST_LB(m_pos
); assert(t
> 0); NEED_OP(t
+3-1);
4356 #if defined(COPY_DICT)
4358 m_off
= 1 + (ip
[0] << 6) + (ip
[1] >> 2);
4361 m_off
= 1 + (ip
[0] >> 2) + (ip
[1] << 6);
4366 lzo_uint off
= 1 + (ip
[0] << 6) + (ip
[1] >> 2);
4370 #elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN)
4372 m_pos
-= UA_GET16(ip
) >> 2;
4375 m_pos
-= (ip
[0] >> 2) + (ip
[1] << 6);
4382 #if defined(COPY_DICT)
4383 m_off
= (t
& 8) << 11;
4386 m_pos
-= (t
& 8) << 11;
4400 #if defined(COPY_DICT)
4402 m_off
+= (ip
[0] << 6) + (ip
[1] >> 2);
4404 m_off
+= (ip
[0] >> 2) + (ip
[1] << 6);
4415 m_pos
-= (ip
[0] << 6) + (ip
[1] >> 2);
4416 #elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN)
4417 m_pos
-= UA_GET16(ip
) >> 2;
4419 m_pos
-= (ip
[0] >> 2) + (ip
[1] << 6);
4426 last_m_off
= pd((const lzo_bytep
)op
, m_pos
);
4432 #if defined(COPY_DICT)
4434 m_off
= 1 + (t
<< 6) + (*ip
++ >> 2);
4437 m_off
= 1 + (t
>> 2) + (*ip
++ << 2);
4440 t
= 2; COPY_DICT(t
,m_off
)
4443 t
= 1 + (t
<< 6) + (*ip
++ >> 2);
4449 m_pos
-= *ip
++ << 2;
4451 TEST_LB(m_pos
); NEED_OP(2);
4452 *op
++ = *m_pos
++; *op
++ = *m_pos
;
4457 #if defined(COPY_DICT)
4460 t
+= 3-1; COPY_DICT(t
,m_off
)
4464 TEST_LB(m_pos
); assert(t
> 0); NEED_OP(t
+3-1);
4465 #if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4)
4466 if (op
- m_pos
>= 8)
4471 UA_COPY64(op
,m_pos
);
4472 op
+= 8; m_pos
+= 8; t
-= 8;
4476 UA_COPY32(op
,m_pos
);
4477 op
+= 4; m_pos
+= 4; t
-= 4;
4482 if (t
> 1) { *op
++ = m_pos
[1]; if (t
> 2) { *op
++ = m_pos
[2]; } }
4486 #elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
4487 #if !defined(LZO_UNALIGNED_OK_4)
4488 if (t
>= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op
,m_pos
))
4490 assert((op
- m_pos
) >= 4);
4492 if (t
>= 2 * 4 - (3 - 1) && (op
- m_pos
) >= 4)
4495 UA_COPY32(op
,m_pos
);
4496 op
+= 4; m_pos
+= 4; t
-= 4 - (3 - 1);
4498 UA_COPY32(op
,m_pos
);
4499 op
+= 4; m_pos
+= 4; t
-= 4;
4501 if (t
> 0) do *op
++ = *m_pos
++; while (--t
> 0);
4507 *op
++ = *m_pos
++; *op
++ = *m_pos
++;
4508 do *op
++ = *m_pos
++; while (--t
> 0);
4523 assert(t
> 0); assert(t
< 4); NEED_OP(t
); NEED_IP(t
+1);
4525 do *op
++ = *ip
++; while (--t
> 0);
4528 if (t
> 1) { *op
++ = *ip
++; if (t
> 2) { *op
++ = *ip
++; } }
4531 } while (TEST_IP
&& TEST_OP
);
4534 #if defined(HAVE_TEST_IP) || defined(HAVE_TEST_OP)
4535 *out_len
= pd(op
, out
);
4536 return LZO_E_EOF_NOT_FOUND
;
4541 *out_len
= pd(op
, out
);
4542 return (ip
== ip_end
? LZO_E_OK
:
4543 (ip
< ip_end
? LZO_E_INPUT_NOT_CONSUMED
: LZO_E_INPUT_OVERRUN
));
4545 #if defined(HAVE_NEED_IP)
4547 *out_len
= pd(op
, out
);
4548 return LZO_E_INPUT_OVERRUN
;
4551 #if defined(HAVE_NEED_OP)
4553 *out_len
= pd(op
, out
);
4554 return LZO_E_OUTPUT_OVERRUN
;
4557 #if defined(LZO_TEST_OVERRUN_LOOKBEHIND)
4559 *out_len
= pd(op
, out
);
4560 return LZO_E_LOOKBEHIND_OVERRUN
;
4566 /***** End of minilzo.c *****/