1 /* lzo_conf.h -- main internal configuration file for the the LZO library
3 This file is part of the LZO real-time data compression library.
5 Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer
6 Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer
7 Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer
8 Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer
9 Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer
10 Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer
11 Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
12 Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
13 Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
14 Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
15 Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
16 Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
17 Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
20 The LZO library is free software; you can redistribute it and/or
21 modify it under the terms of the GNU General Public License as
22 published by the Free Software Foundation; either version 2 of
23 the License, or (at your option) any later version.
25 The LZO library is distributed in the hope that it will be useful,
26 but WITHOUT ANY WARRANTY; without even the implied warranty of
27 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 GNU General Public License for more details.
30 You should have received a copy of the GNU General Public License
31 along with the LZO library; see the file COPYING.
32 If not, write to the Free Software Foundation, Inc.,
33 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
35 Markus F.X.J. Oberhumer
36 <markus@oberhumer.com>
37 http://www.oberhumer.com/opensource/lzo/
41 /* WARNING: this file should *not* be used by applications. It is
42 part of the implementation of the library and is subject
50 #if !defined(__LZO_IN_MINILZO)
51 #if defined(LZO_CFG_FREESTANDING)
52 # define LZO_LIBC_FREESTANDING 1
53 # define LZO_OS_FREESTANDING 1
54 # define ACC_LIBC_FREESTANDING 1
55 # define ACC_OS_FREESTANDING 1
57 #if defined(LZO_CFG_NO_UNALIGNED)
58 # define ACC_CFG_NO_UNALIGNED 1
60 #if defined(LZO_ARCH_GENERIC)
61 # define ACC_ARCH_GENERIC 1
63 #if defined(LZO_ABI_NEUTRAL_ENDIAN)
64 # define ACC_ABI_NEUTRAL_ENDIAN 1
66 #if defined(LZO_HAVE_CONFIG_H)
67 # define ACC_CONFIG_NO_HEADER 1
69 #if defined(LZO_CFG_EXTRA_CONFIG_HEADER)
70 # include LZO_CFG_EXTRA_CONFIG_HEADER
72 #if defined(__LZOCONF_H) || defined(__LZOCONF_H_INCLUDED)
73 # error "include this file first"
75 #include "lzo/lzoconf.h"
78 #if (LZO_VERSION < 0x02000) || !defined(__LZOCONF_H_INCLUDED)
79 # error "version mismatch"
83 /***********************************************************************
85 ************************************************************************/
87 #if (LZO_CC_BORLANDC && LZO_ARCH_I086)
88 # pragma option -h /* enable fast huge pointers */
91 #if (LZO_CC_MSC && (_MSC_VER >= 1000))
92 # pragma warning(disable: 4127 4701)
94 #if (LZO_CC_MSC && (_MSC_VER >= 1300))
95 /* avoid `-Wall' warnings in system header files */
96 # pragma warning(disable: 4820)
97 /* avoid warnings about inlining */
98 # pragma warning(disable: 4514 4710 4711)
102 # pragma error_messages(off,E_END_OF_LOOP_CODE_NOT_REACHED)
103 # pragma error_messages(off,E_LOOP_NOT_ENTERED_AT_TOP)
107 /***********************************************************************
109 ************************************************************************/
111 #if defined(__LZO_MMODEL_HUGE) && (!LZO_HAVE_MM_HUGE_PTR)
112 # error "this should not happen - check defines for __huge"
115 #if defined(__LZO_IN_MINILZO) || defined(LZO_CFG_FREESTANDING)
116 #elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16)
117 # define ACC_WANT_ACC_INCD_H 1
118 # define ACC_WANT_ACC_INCE_H 1
119 # define ACC_WANT_ACC_INCI_H 1
123 # define ACC_WANT_ACC_INCD_H 1
128 #if defined(LZO_CFG_FREESTANDING)
135 #if !defined(HAVE_MEMCMP)
137 # define memcmp(a,b,c) lzo_memcmp(a,b,c)
138 #elif !defined(__LZO_MMODEL_HUGE)
139 # define lzo_memcmp(a,b,c) memcmp(a,b,c)
141 #if !defined(HAVE_MEMCPY)
143 # define memcpy(a,b,c) lzo_memcpy(a,b,c)
144 #elif !defined(__LZO_MMODEL_HUGE)
145 # define lzo_memcpy(a,b,c) memcpy(a,b,c)
147 #if !defined(HAVE_MEMMOVE)
149 # define memmove(a,b,c) lzo_memmove(a,b,c)
150 #elif !defined(__LZO_MMODEL_HUGE)
151 # define lzo_memmove(a,b,c) memmove(a,b,c)
153 #if !defined(HAVE_MEMSET)
155 # define memset(a,b,c) lzo_memset(a,b,c)
156 #elif !defined(__LZO_MMODEL_HUGE)
157 # define lzo_memset(a,b,c) memset(a,b,c)
162 #if defined(LZO_CFG_FREESTANDING)
166 # define assert(e) ((void)0)
168 # if !defined(LZO_DEBUG)
174 #if 0 && defined(__BOUNDS_CHECKING_ON)
175 # include <unchecked.h>
177 # define BOUNDS_CHECKING_OFF_DURING(stmt) stmt
178 # define BOUNDS_CHECKING_OFF_IN_EXPR(expr) (expr)
181 #if !defined(__lzo_inline)
182 # define __lzo_inline
184 #if !defined(__lzo_forceinline)
185 # define __lzo_forceinline
187 #if !defined(__lzo_noinline)
188 # define __lzo_noinline
192 /***********************************************************************
194 ************************************************************************/
197 # define LZO_BYTE(x) ((unsigned char) (x))
199 # define LZO_BYTE(x) ((unsigned char) ((x) & 0xff))
202 #define LZO_MAX(a,b) ((a) >= (b) ? (a) : (b))
203 #define LZO_MIN(a,b) ((a) <= (b) ? (a) : (b))
204 #define LZO_MAX3(a,b,c) ((a) >= (b) ? LZO_MAX(a,c) : LZO_MAX(b,c))
205 #define LZO_MIN3(a,b,c) ((a) <= (b) ? LZO_MIN(a,c) : LZO_MIN(b,c))
207 #define lzo_sizeof(type) ((lzo_uint) (sizeof(type)))
209 #define LZO_HIGH(array) ((lzo_uint) (sizeof(array)/sizeof(*(array))))
211 /* this always fits into 16 bits */
212 #define LZO_SIZE(bits) (1u << (bits))
213 #define LZO_MASK(bits) (LZO_SIZE(bits) - 1)
215 #define LZO_LSIZE(bits) (1ul << (bits))
216 #define LZO_LMASK(bits) (LZO_LSIZE(bits) - 1)
218 #define LZO_USIZE(bits) ((lzo_uint) 1 << (bits))
219 #define LZO_UMASK(bits) (LZO_USIZE(bits) - 1)
223 /* 32*32 multiplies may be faster than 64*64 on some 64-bit machines,
224 * but then we need extra casts from unsigned<->size_t */
225 # define DMUL(a,b) ((lzo_xint) ((lzo_uint32)(a) * (lzo_uint32)(b)))
227 # define DMUL(a,b) ((lzo_xint) ((a) * (b)))
232 /***********************************************************************
233 // compiler and architecture specific stuff
234 ************************************************************************/
236 /* Some defines that indicate if memory can be accessed at unaligned
237 * memory addresses. You should also test that this is actually faster
238 * even if it is allowed by your system.
241 #if 1 && !defined(LZO_CFG_NO_UNALIGNED)
242 #if 1 && (LZO_ARCH_AMD64 || LZO_ARCH_I386)
243 # if (LZO_SIZEOF_SHORT == 2)
244 # define LZO_UNALIGNED_OK_2
246 # if (LZO_SIZEOF_INT == 4)
247 # define LZO_UNALIGNED_OK_4
252 #if defined(LZO_UNALIGNED_OK_2)
253 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(short) == 2)
255 #if defined(LZO_UNALIGNED_OK_4)
256 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint32
) == 4)
257 #elif defined(LZO_ALIGNED_OK_4)
258 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint32
) == 4)
262 /* Fast memcpy that copies multiples of 8 byte chunks.
263 * len is the number of bytes.
264 * note: all parameters must be lvalues, len >= 8
265 * dest and src advance, len is undefined afterwards
268 #define MEMCPY8_DS(dest,src,len) \
269 lzo_memcpy(dest,src,len); dest += len; src += len
271 #define BZERO8_PTR(s,l,n) \
272 lzo_memset((lzo_voidp)(s),0,(lzo_uint)(l)*(n))
274 #define MEMCPY_DS(dest,src,len) \
275 do *dest++ = *src++; while (--len > 0)
278 /***********************************************************************
280 ************************************************************************/
282 __LZO_EXTERN_C
int __lzo_init_done
;
283 __LZO_EXTERN_C
const char __lzo_copyright
[];
284 LZO_EXTERN(const lzo_bytep
) lzo_copyright(void);
287 /***********************************************************************
289 ************************************************************************/
294 /* Generate compressed data in a deterministic way.
295 * This is fully portable, and compression can be faster as well.
296 * A reason NOT to be deterministic is when the block size is
297 * very small (e.g. 8kB) or the dictionary is big, because
298 * then the initialization of the dictionary becomes a relevant
299 * magnitude for compression speed.
301 #define LZO_DETERMINISTIC
304 #define LZO_DICT_USE_PTR
305 #if 0 && (LZO_ARCH_I086)
306 # undef LZO_DICT_USE_PTR
309 #if defined(LZO_DICT_USE_PTR)
310 # define lzo_dict_t const lzo_bytep
311 # define lzo_dict_p lzo_dict_t __LZO_MMODEL *
313 # define lzo_dict_t lzo_uint
314 # define lzo_dict_p lzo_dict_t __LZO_MMODEL *
318 #endif /* already included */