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) 2011 Markus Franz Xaver Johannes Oberhumer
6 Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer
7 Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer
8 Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer
9 Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer
10 Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer
11 Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer
12 Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer
13 Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer
14 Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
15 Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
16 Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
17 Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
18 Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
19 Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
20 Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
23 The LZO library is free software; you can redistribute it and/or
24 modify it under the terms of the GNU General Public License as
25 published by the Free Software Foundation; either version 2 of
26 the License, or (at your option) any later version.
28 The LZO library is distributed in the hope that it will be useful,
29 but WITHOUT ANY WARRANTY; without even the implied warranty of
30 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 GNU General Public License for more details.
33 You should have received a copy of the GNU General Public License
34 along with the LZO library; see the file COPYING.
35 If not, write to the Free Software Foundation, Inc.,
36 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
38 Markus F.X.J. Oberhumer
39 <markus@oberhumer.com>
40 http://www.oberhumer.com/opensource/lzo/
44 /* WARNING: this file should *not* be used by applications. It is
45 part of the implementation of the library and is subject
51 #define __LZO_CONF_H 1
53 #if !defined(__LZO_IN_MINILZO)
54 #if (LZO_CFG_FREESTANDING)
55 # define LZO_LIBC_FREESTANDING 1
56 # define LZO_OS_FREESTANDING 1
57 # define ACC_LIBC_FREESTANDING 1
58 # define ACC_OS_FREESTANDING 1
60 #if (LZO_CFG_NO_UNALIGNED)
61 # define ACC_CFG_NO_UNALIGNED 1
63 #if (LZO_ARCH_GENERIC)
64 # define ACC_ARCH_GENERIC 1
66 #if (LZO_ABI_NEUTRAL_ENDIAN)
67 # define ACC_ABI_NEUTRAL_ENDIAN 1
69 #if (LZO_HAVE_CONFIG_H)
70 # define ACC_CONFIG_NO_HEADER 1
72 #if defined(LZO_CFG_EXTRA_CONFIG_HEADER)
73 # include LZO_CFG_EXTRA_CONFIG_HEADER
75 #if defined(__LZOCONF_H) || defined(__LZOCONF_H_INCLUDED)
76 # error "include this file first"
78 #include "lzo/lzoconf.h"
81 #if (LZO_VERSION < 0x02000) || !defined(__LZOCONF_H_INCLUDED)
82 # error "version mismatch"
86 /***********************************************************************
88 ************************************************************************/
90 #if (LZO_CC_BORLANDC && LZO_ARCH_I086)
91 # pragma option -h /* enable fast huge pointers */
94 #if (LZO_CC_MSC && (_MSC_VER >= 1000))
95 # pragma warning(disable: 4127 4701)
97 #if (LZO_CC_MSC && (_MSC_VER >= 1300))
98 /* avoid '-Wall' warnings in system header files */
99 # pragma warning(disable: 4820)
100 /* avoid warnings about inlining */
101 # pragma warning(disable: 4514 4710 4711)
105 #if !defined(__cplusplus)
106 # pragma error_messages(off,E_END_OF_LOOP_CODE_NOT_REACHED)
107 # pragma error_messages(off,E_LOOP_NOT_ENTERED_AT_TOP)
108 # pragma error_messages(off,E_STATEMENT_NOT_REACHED)
113 /***********************************************************************
115 ************************************************************************/
117 #if (__LZO_MMODEL_HUGE) && !(LZO_HAVE_MM_HUGE_PTR)
118 # error "this should not happen - check defines for __huge"
121 #if defined(__LZO_IN_MINILZO) || defined(LZO_CFG_FREESTANDING)
122 #elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16)
123 # define ACC_WANT_ACC_INCD_H 1
124 # define ACC_WANT_ACC_INCE_H 1
125 # define ACC_WANT_ACC_INCI_H 1
129 # define ACC_WANT_ACC_INCD_H 1
134 #if (LZO_CFG_FREESTANDING)
143 # define memcmp(a,b,c) lzo_memcmp(a,b,c)
144 #elif !(__LZO_MMODEL_HUGE)
146 # define lzo_memcmp(a,b,c) memcmp(a,b,c)
150 # define memcpy(a,b,c) lzo_memcpy(a,b,c)
151 #elif !(__LZO_MMODEL_HUGE)
153 # define lzo_memcpy(a,b,c) memcpy(a,b,c)
157 # define memmove(a,b,c) lzo_memmove(a,b,c)
158 #elif !(__LZO_MMODEL_HUGE)
160 # define lzo_memmove(a,b,c) memmove(a,b,c)
164 # define memset(a,b,c) lzo_memset(a,b,c)
165 #elif !(__LZO_MMODEL_HUGE)
167 # define lzo_memset(a,b,c) memset(a,b,c)
172 #if (LZO_CFG_FREESTANDING)
176 # define assert(e) ((void)0)
178 # if !defined(LZO_DEBUG)
184 #if 0 && defined(__BOUNDS_CHECKING_ON)
185 # include <unchecked.h>
187 # define BOUNDS_CHECKING_OFF_DURING(stmt) stmt
188 # define BOUNDS_CHECKING_OFF_IN_EXPR(expr) (expr)
191 #if !defined(__lzo_inline)
192 # define __lzo_inline /*empty*/
194 #if !defined(__lzo_forceinline)
195 # define __lzo_forceinline /*empty*/
197 #if !defined(__lzo_noinline)
198 # define __lzo_noinline /*empty*/
203 # undef __acc_unlikely
205 # undef __lzo_unlikely
206 # define __acc_likely(e) (e)
207 # define __acc_unlikely(e) (e)
208 # define __lzo_likely(e) (e)
209 # define __lzo_unlikely(e) (e)
213 /***********************************************************************
215 ************************************************************************/
218 # define LZO_BYTE(x) ((unsigned char) (x))
220 # define LZO_BYTE(x) ((unsigned char) ((x) & 0xff))
223 #define LZO_MAX(a,b) ((a) >= (b) ? (a) : (b))
224 #define LZO_MIN(a,b) ((a) <= (b) ? (a) : (b))
225 #define LZO_MAX3(a,b,c) ((a) >= (b) ? LZO_MAX(a,c) : LZO_MAX(b,c))
226 #define LZO_MIN3(a,b,c) ((a) <= (b) ? LZO_MIN(a,c) : LZO_MIN(b,c))
228 #define lzo_sizeof(type) ((lzo_uint) (sizeof(type)))
230 #define LZO_HIGH(array) ((lzo_uint) (sizeof(array)/sizeof(*(array))))
232 /* this always fits into 16 bits */
233 #define LZO_SIZE(bits) (1u << (bits))
234 #define LZO_MASK(bits) (LZO_SIZE(bits) - 1)
236 #define LZO_LSIZE(bits) (1ul << (bits))
237 #define LZO_LMASK(bits) (LZO_LSIZE(bits) - 1)
239 #define LZO_USIZE(bits) ((lzo_uint) 1 << (bits))
240 #define LZO_UMASK(bits) (LZO_USIZE(bits) - 1)
244 /* 32*32 multiplies may be faster than 64*64 on some 64-bit machines,
245 * but then we need extra casts from unsigned<->size_t */
246 # define DMUL(a,b) ((lzo_xint) ((lzo_uint32)(a) * (lzo_uint32)(b)))
248 # define DMUL(a,b) ((lzo_xint) ((a) * (b)))
253 /***********************************************************************
254 // compiler and architecture specific stuff
255 ************************************************************************/
257 /* Some defines that indicate if memory can be accessed at unaligned
258 * memory addresses. You should also test that this is actually faster
259 * even if it is allowed by your system.
262 #if 1 && (LZO_ARCH_AMD64 || LZO_ARCH_I386 || LZO_ARCH_POWERPC)
263 # if (LZO_SIZEOF_SHORT == 2)
264 # define LZO_UNALIGNED_OK_2 1
266 # if (LZO_SIZEOF_INT == 4)
267 # define LZO_UNALIGNED_OK_4 1
270 #if 1 && (LZO_ARCH_AMD64)
271 # if defined(LZO_UINT64_MAX)
272 # define LZO_UNALIGNED_OK_8 1
275 #if (LZO_CFG_NO_UNALIGNED)
276 # undef LZO_UNALIGNED_OK_2
277 # undef LZO_UNALIGNED_OK_4
278 # undef LZO_UNALIGNED_OK_8
290 #if defined(LZO_UNALIGNED_OK_2)
291 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(unsigned short) == 2)
292 # if 1 && defined(ACC_UA_COPY16)
293 # define UA_GET16 ACC_UA_GET16
294 # define UA_SET16 ACC_UA_SET16
295 # define UA_COPY16 ACC_UA_COPY16
297 # define UA_GET16(p) (* (__lzo_ua_volatile const lzo_ushortp) (__lzo_ua_volatile const lzo_voidp) (p))
298 # define UA_SET16(p,v) ((* (__lzo_ua_volatile lzo_ushortp) (__lzo_ua_volatile lzo_voidp) (p)) = (unsigned short) (v))
299 # define UA_COPY16(d,s) UA_SET16(d, UA_GET16(s))
302 #if defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
303 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint32
) == 4)
304 # if 1 && defined(ACC_UA_COPY32)
305 # define UA_GET32 ACC_UA_GET32
306 # define UA_SET32 ACC_UA_SET32
307 # define UA_COPY32 ACC_UA_COPY32
309 # define UA_GET32(p) (* (__lzo_ua_volatile const lzo_uint32p) (__lzo_ua_volatile const lzo_voidp) (p))
310 # define UA_SET32(p,v) ((* (__lzo_ua_volatile lzo_uint32p) (__lzo_ua_volatile lzo_voidp) (p)) = (lzo_uint32) (v))
311 # define UA_COPY32(d,s) UA_SET32(d, UA_GET32(s))
314 #if defined(LZO_UNALIGNED_OK_8)
315 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint64
) == 8)
316 # if 1 && defined(ACC_UA_COPY64)
317 # define UA_GET64 ACC_UA_GET64
318 # define UA_SET64 ACC_UA_SET64
319 # define UA_COPY64 ACC_UA_COPY64
321 # define UA_GET64(p) (* (__lzo_ua_volatile const lzo_uint64p) (__lzo_ua_volatile const lzo_voidp) (p))
322 # define UA_SET64(p,v) ((* (__lzo_ua_volatile lzo_uint64p) (__lzo_ua_volatile lzo_voidp) (p)) = (lzo_uint64) (v))
323 # define UA_COPY64(d,s) UA_SET64(d, UA_GET64(s))
328 /* Fast memcpy that copies multiples of 8 byte chunks.
329 * len is the number of bytes.
330 * note: all parameters must be lvalues, len >= 8
331 * dest and src advance, len is undefined afterwards
334 #define MEMCPY8_DS(dest,src,len) \
335 lzo_memcpy(dest,src,len); dest += len; src += len
337 #define BZERO8_PTR(s,l,n) \
338 lzo_memset((lzo_voidp)(s),0,(lzo_uint)(l)*(n))
340 #define MEMCPY_DS(dest,src,len) \
341 do *dest++ = *src++; while (--len > 0)
344 /***********************************************************************
346 ************************************************************************/
348 LZO_EXTERN(const lzo_bytep
) lzo_copyright(void);
351 /***********************************************************************
353 ************************************************************************/
358 /* Generate compressed data in a deterministic way.
359 * This is fully portable, and compression can be faster as well.
360 * A reason NOT to be deterministic is when the block size is
361 * very small (e.g. 8kB) or the dictionary is big, because
362 * then the initialization of the dictionary becomes a relevant
363 * magnitude for compression speed.
365 #ifndef LZO_DETERMINISTIC
366 #define LZO_DETERMINISTIC 1
370 #ifndef LZO_DICT_USE_PTR
371 #define LZO_DICT_USE_PTR 1
372 #if 0 && (LZO_ARCH_I086)
373 # undef LZO_DICT_USE_PTR
374 # define LZO_DICT_USE_PTR 0
378 #if (LZO_DICT_USE_PTR)
379 # define lzo_dict_t const lzo_bytep
380 # define lzo_dict_p lzo_dict_t __LZO_MMODEL *
382 # define lzo_dict_t lzo_uint
383 # define lzo_dict_p lzo_dict_t __LZO_MMODEL *
387 #endif /* already included */