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) 1996-2015 Markus Franz Xaver Johannes Oberhumer
8 The LZO library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2 of
11 the License, or (at your option) any later version.
13 The LZO library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with the LZO library; see the file COPYING.
20 If not, write to the Free Software Foundation, Inc.,
21 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 Markus F.X.J. Oberhumer
24 <markus@oberhumer.com>
25 http://www.oberhumer.com/opensource/lzo/
29 /* WARNING: this file should *not* be used by applications. It is
30 part of the implementation of the library and is subject
36 #define __LZO_CONF_H 1
38 #if !defined(__LZO_IN_MINILZO)
39 #if defined(LZO_CFG_FREESTANDING) && (LZO_CFG_FREESTANDING)
40 # define LZO_LIBC_FREESTANDING 1
41 # define LZO_OS_FREESTANDING 1
43 #if defined(LZO_CFG_EXTRA_CONFIG_HEADER)
44 # include LZO_CFG_EXTRA_CONFIG_HEADER
46 #if defined(__LZOCONF_H) || defined(__LZOCONF_H_INCLUDED)
47 # error "include this file first"
49 #if defined(LZO_CFG_BUILD_DLL) && (LZO_CFG_BUILD_DLL+0) && !defined(__LZO_EXPORT1) && !defined(__LZO_EXPORT2) && 0
50 /* idea: we could auto-define __LZO_EXPORT1 for DLL exports */
51 #ifndef __LZODEFS_H_INCLUDED
52 #if defined(LZO_HAVE_CONFIG_H)
57 #include <lzo/lzodefs.h>
59 /* #define __LZO_EXPORT1 __attribute__((__visibility__("default"))) */
60 /* #define __LZO_EXPORT1 __declspec(dllexport) */
62 #include <lzo/lzoconf.h>
63 #if defined(LZO_CFG_EXTRA_CONFIG_HEADER2)
64 # include LZO_CFG_EXTRA_CONFIG_HEADER2
66 #endif /* !defined(__LZO_IN_MINILZO) */
68 #if !defined(__LZOCONF_H_INCLUDED) || (LZO_VERSION+0 != 0x2090)
69 # error "version mismatch"
73 /***********************************************************************
75 ************************************************************************/
77 #if (LZO_CC_MSC && (_MSC_VER >= 1000 && _MSC_VER < 1100))
78 /* disable bogus "unreachable code" warnings */
79 # pragma warning(disable: 4702)
81 #if (LZO_CC_MSC && (_MSC_VER >= 1000))
82 # pragma warning(disable: 4127 4701)
83 /* disable warnings about inlining */
84 # pragma warning(disable: 4514 4710 4711)
86 #if (LZO_CC_MSC && (_MSC_VER >= 1300))
87 /* disable '-Wall' warnings in system header files */
88 # pragma warning(disable: 4820)
90 #if (LZO_CC_MSC && (_MSC_VER >= 1800))
91 /* disable '-Wall' warnings in system header files */
92 # pragma warning(disable: 4746)
94 #if (LZO_CC_INTELC && (__INTEL_COMPILER >= 900))
95 /* disable pedantic warnings in system header files */
96 # pragma warning(disable: 1684)
100 #if !defined(__cplusplus)
101 # pragma error_messages(off,E_END_OF_LOOP_CODE_NOT_REACHED)
102 # pragma error_messages(off,E_LOOP_NOT_ENTERED_AT_TOP)
103 # pragma error_messages(off,E_STATEMENT_NOT_REACHED)
108 /***********************************************************************
110 ************************************************************************/
112 #if !defined(__LZO_NOEXPORT1)
113 # define __LZO_NOEXPORT1 /*empty*/
115 #if !defined(__LZO_NOEXPORT2)
116 # define __LZO_NOEXPORT2 /*empty*/
120 # define LZO_PUBLIC_DECL(r) LZO_EXTERN(r)
123 # define LZO_PUBLIC_IMPL(r) LZO_PUBLIC(r)
125 #if !defined(LZO_LOCAL_DECL)
126 # define LZO_LOCAL_DECL(r) __LZO_EXTERN_C LZO_LOCAL_IMPL(r)
128 #if !defined(LZO_LOCAL_IMPL)
129 # define LZO_LOCAL_IMPL(r) __LZO_NOEXPORT1 r __LZO_NOEXPORT2 __LZO_CDECL
132 # define LZO_STATIC_DECL(r) LZO_PRIVATE(r)
135 # define LZO_STATIC_IMPL(r) LZO_PRIVATE(r)
139 /***********************************************************************
141 ************************************************************************/
143 #if defined(__LZO_IN_MINILZO) || (LZO_CFG_FREESTANDING)
147 # define LZO_WANT_ACC_INCD_H 1
149 #if defined(LZO_HAVE_CONFIG_H)
150 # define LZO_CFG_NO_CONFIG_HEADER 1
152 #include "lzo_supp.h"
155 #if 1 || defined(lzo_int8_t) || defined(lzo_uint8_t)
156 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int8_t
) == 1)
157 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint8_t
) == 1)
159 #if 1 || defined(lzo_int16_t) || defined(lzo_uint16_t)
160 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16_t
) == 2)
161 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint16_t
) == 2)
163 #if 1 || defined(lzo_int32_t) || defined(lzo_uint32_t)
164 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32_t
) == 4)
165 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint32_t
) == 4)
167 #if defined(lzo_int64_t) || defined(lzo_uint64_t)
168 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64_t
) == 8)
169 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint64_t
) == 8)
172 #if (LZO_CFG_FREESTANDING)
181 # define memcmp(a,b,c) lzo_memcmp(a,b,c)
184 # define lzo_memcmp(a,b,c) memcmp(a,b,c)
188 # define memcpy(a,b,c) lzo_memcpy(a,b,c)
191 # define lzo_memcpy(a,b,c) memcpy(a,b,c)
195 # define memmove(a,b,c) lzo_memmove(a,b,c)
198 # define lzo_memmove(a,b,c) memmove(a,b,c)
202 # define memset(a,b,c) lzo_memset(a,b,c)
205 # define lzo_memset(a,b,c) memset(a,b,c)
209 #if (LZO_CFG_FREESTANDING)
213 # define assert(e) ((void)0)
215 # if !defined(LZO_DEBUG)
221 #if 0 && defined(__BOUNDS_CHECKING_ON)
222 # include <unchecked.h>
224 # define BOUNDS_CHECKING_OFF_DURING(stmt) stmt
225 # define BOUNDS_CHECKING_OFF_IN_EXPR(expr) (expr)
230 # undef __lzo_unlikely
231 # define __lzo_likely(e) (e)
232 # define __lzo_unlikely(e) (e)
252 /***********************************************************************
254 ************************************************************************/
257 # define LZO_BYTE(x) ((unsigned char) (x))
259 # define LZO_BYTE(x) ((unsigned char) ((x) & 0xff))
262 #define LZO_MAX(a,b) ((a) >= (b) ? (a) : (b))
263 #define LZO_MIN(a,b) ((a) <= (b) ? (a) : (b))
264 #define LZO_MAX3(a,b,c) ((a) >= (b) ? LZO_MAX(a,c) : LZO_MAX(b,c))
265 #define LZO_MIN3(a,b,c) ((a) <= (b) ? LZO_MIN(a,c) : LZO_MIN(b,c))
267 #define lzo_sizeof(type) ((lzo_uint) (sizeof(type)))
269 #define LZO_HIGH(array) ((lzo_uint) (sizeof(array)/sizeof(*(array))))
271 /* this always fits into 32 bits */
272 #define LZO_SIZE(bits) (1u << (bits))
273 #define LZO_MASK(bits) (LZO_SIZE(bits) - 1)
275 #define LZO_USIZE(bits) ((lzo_uint) 1 << (bits))
276 #define LZO_UMASK(bits) (LZO_USIZE(bits) - 1)
280 /* 32*32 multiplies may be faster than 64*64 on some 64-bit machines,
281 * but then we need extra casts from unsigned<->size_t */
282 # define DMUL(a,b) ((lzo_xint) ((lzo_uint32_t)(a) * (lzo_uint32_t)(b)))
284 # define DMUL(a,b) ((lzo_xint) ((a) * (b)))
289 /***********************************************************************
290 // compiler and architecture specific stuff
291 ************************************************************************/
293 /* Some defines that indicate if memory can be accessed at unaligned
294 * memory addresses. You should also test that this is actually faster
295 * even if it is allowed by your system.
298 #include "lzo_func.h"
301 #define UA_SET1 LZO_MEMOPS_SET1
304 #define UA_SET2 LZO_MEMOPS_SET2
307 #define UA_SET3 LZO_MEMOPS_SET3
310 #define UA_SET4 LZO_MEMOPS_SET4
313 #define UA_MOVE1 LZO_MEMOPS_MOVE1
316 #define UA_MOVE2 LZO_MEMOPS_MOVE2
319 #define UA_MOVE3 LZO_MEMOPS_MOVE3
322 #define UA_MOVE4 LZO_MEMOPS_MOVE4
325 #define UA_MOVE8 LZO_MEMOPS_MOVE8
328 #define UA_COPY1 LZO_MEMOPS_COPY1
331 #define UA_COPY2 LZO_MEMOPS_COPY2
334 #define UA_COPY3 LZO_MEMOPS_COPY3
337 #define UA_COPY4 LZO_MEMOPS_COPY4
340 #define UA_COPY8 LZO_MEMOPS_COPY8
343 #define UA_COPYN LZO_MEMOPS_COPYN
346 #define UA_COPYN_X LZO_MEMOPS_COPYN
349 #define UA_GET_LE16 LZO_MEMOPS_GET_LE16
352 #define UA_GET_LE32 LZO_MEMOPS_GET_LE32
354 #ifdef LZO_MEMOPS_GET_LE64
356 #define UA_GET_LE64 LZO_MEMOPS_GET_LE64
360 #define UA_GET_NE16 LZO_MEMOPS_GET_NE16
363 #define UA_GET_NE32 LZO_MEMOPS_GET_NE32
365 #ifdef LZO_MEMOPS_GET_NE64
367 #define UA_GET_NE64 LZO_MEMOPS_GET_NE64
371 #define UA_PUT_LE16 LZO_MEMOPS_PUT_LE16
374 #define UA_PUT_LE32 LZO_MEMOPS_PUT_LE32
377 #define UA_PUT_NE16 LZO_MEMOPS_PUT_NE16
380 #define UA_PUT_NE32 LZO_MEMOPS_PUT_NE32
384 /* Fast memcpy that copies multiples of 8 byte chunks.
385 * len is the number of bytes.
386 * note: all parameters must be lvalues, len >= 8
387 * dest and src advance, len is undefined afterwards
390 #define MEMCPY8_DS(dest,src,len) \
391 lzo_memcpy(dest,src,len); dest += len; src += len
393 #define BZERO8_PTR(s,l,n) \
394 lzo_memset((lzo_voidp)(s),0,(lzo_uint)(l)*(n))
396 #define MEMCPY_DS(dest,src,len) \
397 do *dest++ = *src++; while (--len > 0)
400 /***********************************************************************
402 ************************************************************************/
404 LZO_EXTERN(const lzo_bytep
) lzo_copyright(void);
408 /* Generate compressed data in a deterministic way.
409 * This is fully portable, and compression can be faster as well.
410 * A reason NOT to be deterministic is when the block size is
411 * very small (e.g. 8kB) or the dictionary is big, because
412 * then the initialization of the dictionary becomes a relevant
413 * magnitude for compression speed.
415 #ifndef LZO_DETERMINISTIC
416 #define LZO_DETERMINISTIC 1
420 #ifndef LZO_DICT_USE_PTR
421 #define LZO_DICT_USE_PTR 1
424 #if (LZO_DICT_USE_PTR)
425 # define lzo_dict_t const lzo_bytep
426 # define lzo_dict_p lzo_dict_t *
428 # define lzo_dict_t lzo_uint
429 # define lzo_dict_p lzo_dict_t *
433 #endif /* already included */
436 /* vim:set ts=4 sw=4 et: */