|
kusano |
7d535a |
/* lzo_conf.h -- main internal configuration file for the the LZO library
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
This file is part of the LZO real-time data compression library.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer
|
|
kusano |
7d535a |
Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer
|
|
kusano |
7d535a |
Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer
|
|
kusano |
7d535a |
Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer
|
|
kusano |
7d535a |
Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer
|
|
kusano |
7d535a |
Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer
|
|
kusano |
7d535a |
Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
|
|
kusano |
7d535a |
Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
|
|
kusano |
7d535a |
Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
|
|
kusano |
7d535a |
Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
|
|
kusano |
7d535a |
Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
|
|
kusano |
7d535a |
Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
|
|
kusano |
7d535a |
Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
|
|
kusano |
7d535a |
All Rights Reserved.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
The LZO library is free software; you can redistribute it and/or
|
|
kusano |
7d535a |
modify it under the terms of the GNU General Public License as
|
|
kusano |
7d535a |
published by the Free Software Foundation; either version 2 of
|
|
kusano |
7d535a |
the License, or (at your option) any later version.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
The LZO library is distributed in the hope that it will be useful,
|
|
kusano |
7d535a |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
kusano |
7d535a |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
kusano |
7d535a |
GNU General Public License for more details.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
You should have received a copy of the GNU General Public License
|
|
kusano |
7d535a |
along with the LZO library; see the file COPYING.
|
|
kusano |
7d535a |
If not, write to the Free Software Foundation, Inc.,
|
|
kusano |
7d535a |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Markus F.X.J. Oberhumer
|
|
kusano |
7d535a |
<markus@oberhumer.com></markus@oberhumer.com>
|
|
kusano |
7d535a |
http://www.oberhumer.com/opensource/lzo/
|
|
kusano |
7d535a |
*/
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/* WARNING: this file should *not* be used by applications. It is
|
|
kusano |
7d535a |
part of the implementation of the library and is subject
|
|
kusano |
7d535a |
to change.
|
|
kusano |
7d535a |
*/
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#ifndef __LZO_CONF_H
|
|
kusano |
7d535a |
#define __LZO_CONF_H
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#if !defined(__LZO_IN_MINILZO)
|
|
kusano |
7d535a |
#if defined(LZO_CFG_FREESTANDING)
|
|
kusano |
7d535a |
# define LZO_LIBC_FREESTANDING 1
|
|
kusano |
7d535a |
# define LZO_OS_FREESTANDING 1
|
|
kusano |
7d535a |
# define ACC_LIBC_FREESTANDING 1
|
|
kusano |
7d535a |
# define ACC_OS_FREESTANDING 1
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
#if defined(LZO_CFG_NO_UNALIGNED)
|
|
kusano |
7d535a |
# define ACC_CFG_NO_UNALIGNED 1
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
#if defined(LZO_ARCH_GENERIC)
|
|
kusano |
7d535a |
# define ACC_ARCH_GENERIC 1
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
#if defined(LZO_ABI_NEUTRAL_ENDIAN)
|
|
kusano |
7d535a |
# define ACC_ABI_NEUTRAL_ENDIAN 1
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
#if defined(LZO_HAVE_CONFIG_H)
|
|
kusano |
7d535a |
# define ACC_CONFIG_NO_HEADER 1
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
#if defined(LZO_CFG_EXTRA_CONFIG_HEADER)
|
|
kusano |
7d535a |
# include LZO_CFG_EXTRA_CONFIG_HEADER
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
#if defined(__LZOCONF_H) || defined(__LZOCONF_H_INCLUDED)
|
|
kusano |
7d535a |
# error "include this file first"
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
#include "lzo/lzoconf.h"
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#if (LZO_VERSION < 0x02000) || !defined(__LZOCONF_H_INCLUDED)
|
|
kusano |
7d535a |
# error "version mismatch"
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/***********************************************************************
|
|
kusano |
7d535a |
// pragmas
|
|
kusano |
7d535a |
************************************************************************/
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#if (LZO_CC_BORLANDC && LZO_ARCH_I086)
|
|
kusano |
7d535a |
# pragma option -h /* enable fast huge pointers */
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#if (LZO_CC_MSC && (_MSC_VER >= 1000))
|
|
kusano |
7d535a |
# pragma warning(disable: 4127 4701)
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
#if (LZO_CC_MSC && (_MSC_VER >= 1300))
|
|
kusano |
7d535a |
/* avoid `-Wall' warnings in system header files */
|
|
kusano |
7d535a |
# pragma warning(disable: 4820)
|
|
kusano |
7d535a |
/* avoid warnings about inlining */
|
|
kusano |
7d535a |
# pragma warning(disable: 4514 4710 4711)
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#if (LZO_CC_SUNPROC)
|
|
kusano |
7d535a |
# pragma error_messages(off,E_END_OF_LOOP_CODE_NOT_REACHED)
|
|
kusano |
7d535a |
# pragma error_messages(off,E_LOOP_NOT_ENTERED_AT_TOP)
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/***********************************************************************
|
|
kusano |
7d535a |
//
|
|
kusano |
7d535a |
************************************************************************/
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#if defined(__LZO_MMODEL_HUGE) && (!LZO_HAVE_MM_HUGE_PTR)
|
|
kusano |
7d535a |
# error "this should not happen - check defines for __huge"
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#if defined(__LZO_IN_MINILZO) || defined(LZO_CFG_FREESTANDING)
|
|
kusano |
7d535a |
#elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16)
|
|
kusano |
7d535a |
# define ACC_WANT_ACC_INCD_H 1
|
|
kusano |
7d535a |
# define ACC_WANT_ACC_INCE_H 1
|
|
kusano |
7d535a |
# define ACC_WANT_ACC_INCI_H 1
|
|
kusano |
7d535a |
#elif 1
|
|
kusano |
7d535a |
# include <string.h></string.h>
|
|
kusano |
7d535a |
#else
|
|
kusano |
7d535a |
# define ACC_WANT_ACC_INCD_H 1
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
#include "miniacc.h"
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#if defined(LZO_CFG_FREESTANDING)
|
|
kusano |
7d535a |
# undef HAVE_MEMCMP
|
|
kusano |
7d535a |
# undef HAVE_MEMCPY
|
|
kusano |
7d535a |
# undef HAVE_MEMMOVE
|
|
kusano |
7d535a |
# undef HAVE_MEMSET
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#if !defined(HAVE_MEMCMP)
|
|
kusano |
7d535a |
# undef memcmp
|
|
kusano |
7d535a |
# define memcmp(a,b,c) lzo_memcmp(a,b,c)
|
|
kusano |
7d535a |
#elif !defined(__LZO_MMODEL_HUGE)
|
|
kusano |
7d535a |
# define lzo_memcmp(a,b,c) memcmp(a,b,c)
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
#if !defined(HAVE_MEMCPY)
|
|
kusano |
7d535a |
# undef memcpy
|
|
kusano |
7d535a |
# define memcpy(a,b,c) lzo_memcpy(a,b,c)
|
|
kusano |
7d535a |
#elif !defined(__LZO_MMODEL_HUGE)
|
|
kusano |
7d535a |
# define lzo_memcpy(a,b,c) memcpy(a,b,c)
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
#if !defined(HAVE_MEMMOVE)
|
|
kusano |
7d535a |
# undef memmove
|
|
kusano |
7d535a |
# define memmove(a,b,c) lzo_memmove(a,b,c)
|
|
kusano |
7d535a |
#elif !defined(__LZO_MMODEL_HUGE)
|
|
kusano |
7d535a |
# define lzo_memmove(a,b,c) memmove(a,b,c)
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
#if !defined(HAVE_MEMSET)
|
|
kusano |
7d535a |
# undef memset
|
|
kusano |
7d535a |
# define memset(a,b,c) lzo_memset(a,b,c)
|
|
kusano |
7d535a |
#elif !defined(__LZO_MMODEL_HUGE)
|
|
kusano |
7d535a |
# define lzo_memset(a,b,c) memset(a,b,c)
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#undef NDEBUG
|
|
kusano |
7d535a |
#if defined(LZO_CFG_FREESTANDING)
|
|
kusano |
7d535a |
# undef LZO_DEBUG
|
|
kusano |
7d535a |
# define NDEBUG 1
|
|
kusano |
7d535a |
# undef assert
|
|
kusano |
7d535a |
# define assert(e) ((void)0)
|
|
kusano |
7d535a |
#else
|
|
kusano |
7d535a |
# if !defined(LZO_DEBUG)
|
|
kusano |
7d535a |
# define NDEBUG 1
|
|
kusano |
7d535a |
# endif
|
|
kusano |
7d535a |
# include <assert.h></assert.h>
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#if 0 && defined(__BOUNDS_CHECKING_ON)
|
|
kusano |
7d535a |
# include <unchecked.h></unchecked.h>
|
|
kusano |
7d535a |
#else
|
|
kusano |
7d535a |
# define BOUNDS_CHECKING_OFF_DURING(stmt) stmt
|
|
kusano |
7d535a |
# define BOUNDS_CHECKING_OFF_IN_EXPR(expr) (expr)
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#if !defined(__lzo_inline)
|
|
kusano |
7d535a |
# define __lzo_inline
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
#if !defined(__lzo_forceinline)
|
|
kusano |
7d535a |
# define __lzo_forceinline
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
#if !defined(__lzo_noinline)
|
|
kusano |
7d535a |
# define __lzo_noinline
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/***********************************************************************
|
|
kusano |
7d535a |
//
|
|
kusano |
7d535a |
************************************************************************/
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#if 1
|
|
kusano |
7d535a |
# define LZO_BYTE(x) ((unsigned char) (x))
|
|
kusano |
7d535a |
#else
|
|
kusano |
7d535a |
# define LZO_BYTE(x) ((unsigned char) ((x) & 0xff))
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#define LZO_MAX(a,b) ((a) >= (b) ? (a) : (b))
|
|
kusano |
7d535a |
#define LZO_MIN(a,b) ((a) <= (b) ? (a) : (b))
|
|
kusano |
7d535a |
#define LZO_MAX3(a,b,c) ((a) >= (b) ? LZO_MAX(a,c) : LZO_MAX(b,c))
|
|
kusano |
7d535a |
#define LZO_MIN3(a,b,c) ((a) <= (b) ? LZO_MIN(a,c) : LZO_MIN(b,c))
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#define lzo_sizeof(type) ((lzo_uint) (sizeof(type)))
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#define LZO_HIGH(array) ((lzo_uint) (sizeof(array)/sizeof(*(array))))
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/* this always fits into 16 bits */
|
|
kusano |
7d535a |
#define LZO_SIZE(bits) (1u << (bits))
|
|
kusano |
7d535a |
#define LZO_MASK(bits) (LZO_SIZE(bits) - 1)
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#define LZO_LSIZE(bits) (1ul << (bits))
|
|
kusano |
7d535a |
#define LZO_LMASK(bits) (LZO_LSIZE(bits) - 1)
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#define LZO_USIZE(bits) ((lzo_uint) 1 << (bits))
|
|
kusano |
7d535a |
#define LZO_UMASK(bits) (LZO_USIZE(bits) - 1)
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#if !defined(DMUL)
|
|
kusano |
7d535a |
#if 0
|
|
kusano |
7d535a |
/* 32*32 multiplies may be faster than 64*64 on some 64-bit machines,
|
|
kusano |
7d535a |
* but then we need extra casts from unsigned<->size_t */
|
|
kusano |
7d535a |
# define DMUL(a,b) ((lzo_xint) ((lzo_uint32)(a) * (lzo_uint32)(b)))
|
|
kusano |
7d535a |
#else
|
|
kusano |
7d535a |
# define DMUL(a,b) ((lzo_xint) ((a) * (b)))
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/***********************************************************************
|
|
kusano |
7d535a |
// compiler and architecture specific stuff
|
|
kusano |
7d535a |
************************************************************************/
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/* Some defines that indicate if memory can be accessed at unaligned
|
|
kusano |
7d535a |
* memory addresses. You should also test that this is actually faster
|
|
kusano |
7d535a |
* even if it is allowed by your system.
|
|
kusano |
7d535a |
*/
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#if 1 && !defined(LZO_CFG_NO_UNALIGNED)
|
|
kusano |
7d535a |
#if 1 && (LZO_ARCH_AMD64 || LZO_ARCH_I386)
|
|
kusano |
7d535a |
# if (LZO_SIZEOF_SHORT == 2)
|
|
kusano |
7d535a |
# define LZO_UNALIGNED_OK_2
|
|
kusano |
7d535a |
# endif
|
|
kusano |
7d535a |
# if (LZO_SIZEOF_INT == 4)
|
|
kusano |
7d535a |
# define LZO_UNALIGNED_OK_4
|
|
kusano |
7d535a |
# endif
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#if defined(LZO_UNALIGNED_OK_2)
|
|
kusano |
7d535a |
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(short) == 2)
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
#if defined(LZO_UNALIGNED_OK_4)
|
|
kusano |
7d535a |
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint32) == 4)
|
|
kusano |
7d535a |
#elif defined(LZO_ALIGNED_OK_4)
|
|
kusano |
7d535a |
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint32) == 4)
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/* Fast memcpy that copies multiples of 8 byte chunks.
|
|
kusano |
7d535a |
* len is the number of bytes.
|
|
kusano |
7d535a |
* note: all parameters must be lvalues, len >= 8
|
|
kusano |
7d535a |
* dest and src advance, len is undefined afterwards
|
|
kusano |
7d535a |
*/
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#define MEMCPY8_DS(dest,src,len) \
|
|
kusano |
7d535a |
lzo_memcpy(dest,src,len); dest += len; src += len
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#define BZERO8_PTR(s,l,n) \
|
|
kusano |
7d535a |
lzo_memset((lzo_voidp)(s),0,(lzo_uint)(l)*(n))
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#define MEMCPY_DS(dest,src,len) \
|
|
kusano |
7d535a |
do *dest++ = *src++; while (--len > 0)
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/***********************************************************************
|
|
kusano |
7d535a |
// some globals
|
|
kusano |
7d535a |
************************************************************************/
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
__LZO_EXTERN_C int __lzo_init_done;
|
|
kusano |
7d535a |
__LZO_EXTERN_C const char __lzo_copyright[];
|
|
kusano |
7d535a |
LZO_EXTERN(const lzo_bytep) lzo_copyright(void);
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/***********************************************************************
|
|
kusano |
7d535a |
//
|
|
kusano |
7d535a |
************************************************************************/
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#include "lzo_ptr.h"
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/* Generate compressed data in a deterministic way.
|
|
kusano |
7d535a |
* This is fully portable, and compression can be faster as well.
|
|
kusano |
7d535a |
* A reason NOT to be deterministic is when the block size is
|
|
kusano |
7d535a |
* very small (e.g. 8kB) or the dictionary is big, because
|
|
kusano |
7d535a |
* then the initialization of the dictionary becomes a relevant
|
|
kusano |
7d535a |
* magnitude for compression speed.
|
|
kusano |
7d535a |
*/
|
|
kusano |
7d535a |
#define LZO_DETERMINISTIC
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#define LZO_DICT_USE_PTR
|
|
kusano |
7d535a |
#if 0 && (LZO_ARCH_I086)
|
|
kusano |
7d535a |
# undef LZO_DICT_USE_PTR
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#if defined(LZO_DICT_USE_PTR)
|
|
kusano |
7d535a |
# define lzo_dict_t const lzo_bytep
|
|
kusano |
7d535a |
# define lzo_dict_p lzo_dict_t __LZO_MMODEL *
|
|
kusano |
7d535a |
#else
|
|
kusano |
7d535a |
# define lzo_dict_t lzo_uint
|
|
kusano |
7d535a |
# define lzo_dict_p lzo_dict_t __LZO_MMODEL *
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#endif /* already included */
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/*
|
|
kusano |
7d535a |
vi:ts=4:et
|
|
kusano |
7d535a |
*/
|
|
kusano |
7d535a |
|