176d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman/* lzo_conf.h -- main internal configuration file for the the LZO library
276d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
376d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman   This file is part of the LZO real-time data compression library.
476d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
576d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman   Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer
676d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman   All Rights Reserved.
776d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
876d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman   The LZO library is free software; you can redistribute it and/or
976d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman   modify it under the terms of the GNU General Public License as
1076d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman   published by the Free Software Foundation; either version 2 of
1176d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman   the License, or (at your option) any later version.
1276d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
1376d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman   The LZO library is distributed in the hope that it will be useful,
1476d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman   but WITHOUT ANY WARRANTY; without even the implied warranty of
1576d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1676d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman   GNU General Public License for more details.
1776d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
1876d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman   You should have received a copy of the GNU General Public License
1976d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman   along with the LZO library; see the file COPYING.
2076d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman   If not, write to the Free Software Foundation, Inc.,
2176d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2276d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
2376d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman   Markus F.X.J. Oberhumer
2476d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman   <markus@oberhumer.com>
2576d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman   http://www.oberhumer.com/opensource/lzo/
2676d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman */
2776d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
2876d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
2976d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman/* WARNING: this file should *not* be used by applications. It is
3076d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman   part of the implementation of the library and is subject
3176d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman   to change.
3276d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman */
3376d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
3476d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
3576d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#ifndef __LZO_CONF_H
3676d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#define __LZO_CONF_H 1
3776d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
3876d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#if !defined(__LZO_IN_MINILZO)
3976d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#if defined(LZO_CFG_FREESTANDING) && (LZO_CFG_FREESTANDING)
4076d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  define LZO_LIBC_FREESTANDING 1
4176d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  define LZO_OS_FREESTANDING 1
4276d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
4376d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#if defined(LZO_CFG_EXTRA_CONFIG_HEADER)
4476d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  include LZO_CFG_EXTRA_CONFIG_HEADER
4576d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
4676d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#if defined(__LZOCONF_H) || defined(__LZOCONF_H_INCLUDED)
4776d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  error "include this file first"
4876d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
4976d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#include "lzo/lzoconf.h"
5076d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#if defined(LZO_CFG_EXTRA_CONFIG_HEADER2)
5176d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  include LZO_CFG_EXTRA_CONFIG_HEADER2
5276d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
5376d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
5476d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
5576d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#if (LZO_VERSION < 0x2070) || !defined(__LZOCONF_H_INCLUDED)
5676d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  error "version mismatch"
5776d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
5876d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
5976d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
6076d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman/***********************************************************************
6176d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman// pragmas
6276d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman************************************************************************/
6376d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
6476d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#if (LZO_CC_MSC && (_MSC_VER >= 1000 && _MSC_VER < 1100))
6576d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman   /* disable bogus "unreachable code" warnings */
6676d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  pragma warning(disable: 4702)
6776d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
6876d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#if (LZO_CC_MSC && (_MSC_VER >= 1000))
6976d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  pragma warning(disable: 4127 4701)
7076d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman   /* disable warnings about inlining */
7176d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  pragma warning(disable: 4514 4710 4711)
7276d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
7376d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#if (LZO_CC_MSC && (_MSC_VER >= 1300))
7476d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman   /* disable '-Wall' warnings in system header files */
7576d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  pragma warning(disable: 4820)
7676d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
7776d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#if (LZO_CC_MSC && (_MSC_VER >= 1800))
7876d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman   /* disable '-Wall' warnings in system header files */
7976d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  pragma warning(disable: 4746)
8076d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
8176d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
8276d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#if (LZO_CC_SUNPROC)
8376d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#if !defined(__cplusplus)
8476d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  pragma error_messages(off,E_END_OF_LOOP_CODE_NOT_REACHED)
8576d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  pragma error_messages(off,E_LOOP_NOT_ENTERED_AT_TOP)
8676d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  pragma error_messages(off,E_STATEMENT_NOT_REACHED)
8776d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
8876d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
8976d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
9076d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
9176d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman/***********************************************************************
9276d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman//
9376d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman************************************************************************/
9476d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
9576d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#if defined(__LZO_IN_MINILZO) || (LZO_CFG_FREESTANDING)
9676d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#elif 1
9776d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  include <string.h>
9876d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#else
9976d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  define LZO_WANT_ACC_INCD_H 1
10076d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
10176d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#if defined(LZO_HAVE_CONFIG_H)
10276d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  define LZO_CFG_NO_CONFIG_HEADER 1
10376d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
10476d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#include "lzo_supp.h"
10576d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
10676d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman/* Integral types */
10776d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#if 1 || defined(lzo_int8_t) || defined(lzo_uint8_t)
10876d05dc695b06c4e987bb8078f78032441e1430cGreg HartmanLZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int8_t)  == 1)
10976d05dc695b06c4e987bb8078f78032441e1430cGreg HartmanLZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint8_t) == 1)
11076d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
11176d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#if 1 || defined(lzo_int16_t) || defined(lzo_uint16_t)
11276d05dc695b06c4e987bb8078f78032441e1430cGreg HartmanLZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16_t)  == 2)
11376d05dc695b06c4e987bb8078f78032441e1430cGreg HartmanLZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint16_t) == 2)
11476d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
11576d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#if 1 || defined(lzo_int32_t) || defined(lzo_uint32_t)
11676d05dc695b06c4e987bb8078f78032441e1430cGreg HartmanLZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32_t)  == 4)
11776d05dc695b06c4e987bb8078f78032441e1430cGreg HartmanLZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint32_t) == 4)
11876d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
11976d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#if defined(lzo_int64_t) || defined(lzo_uint64_t)
12076d05dc695b06c4e987bb8078f78032441e1430cGreg HartmanLZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64_t)  == 8)
12176d05dc695b06c4e987bb8078f78032441e1430cGreg HartmanLZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint64_t) == 8)
12276d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
12376d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
12476d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#if (LZO_CFG_FREESTANDING)
12576d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  undef HAVE_MEMCMP
12676d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  undef HAVE_MEMCPY
12776d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  undef HAVE_MEMMOVE
12876d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  undef HAVE_MEMSET
12976d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
13076d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
13176d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#if !(HAVE_MEMCMP)
13276d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  undef memcmp
13376d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  define memcmp(a,b,c)         lzo_memcmp(a,b,c)
13476d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#else
13576d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  undef lzo_memcmp
13676d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  define lzo_memcmp(a,b,c)     memcmp(a,b,c)
13776d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
13876d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#if !(HAVE_MEMCPY)
13976d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  undef memcpy
14076d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  define memcpy(a,b,c)         lzo_memcpy(a,b,c)
14176d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#else
14276d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  undef lzo_memcpy
14376d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  define lzo_memcpy(a,b,c)     memcpy(a,b,c)
14476d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
14576d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#if !(HAVE_MEMMOVE)
14676d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  undef memmove
14776d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  define memmove(a,b,c)        lzo_memmove(a,b,c)
14876d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#else
14976d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  undef lzo_memmove
15076d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  define lzo_memmove(a,b,c)    memmove(a,b,c)
15176d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
15276d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#if !(HAVE_MEMSET)
15376d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  undef memset
15476d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  define memset(a,b,c)         lzo_memset(a,b,c)
15576d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#else
15676d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  undef lzo_memset
15776d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  define lzo_memset(a,b,c)     memset(a,b,c)
15876d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
15976d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
16076d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#undef NDEBUG
16176d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#if (LZO_CFG_FREESTANDING)
16276d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  undef LZO_DEBUG
16376d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  define NDEBUG 1
16476d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  undef assert
16576d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  define assert(e) ((void)0)
16676d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#else
16776d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  if !defined(LZO_DEBUG)
16876d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#    define NDEBUG 1
16976d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  endif
17076d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  include <assert.h>
17176d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
17276d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
17376d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#if 0 && defined(__BOUNDS_CHECKING_ON)
17476d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  include <unchecked.h>
17576d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#else
17676d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  define BOUNDS_CHECKING_OFF_DURING(stmt)      stmt
17776d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  define BOUNDS_CHECKING_OFF_IN_EXPR(expr)     (expr)
17876d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
17976d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
18076d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#if (LZO_CFG_PGO)
18176d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  undef __lzo_likely
18276d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  undef __lzo_unlikely
18376d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  define __lzo_likely(e)       (e)
18476d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  define __lzo_unlikely(e)     (e)
18576d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
18676d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
18776d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#undef _
18876d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#undef __
18976d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#undef ___
19076d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#undef ____
19176d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#undef _p0
19276d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#undef _p1
19376d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#undef _p2
19476d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#undef _p3
19576d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#undef _p4
19676d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#undef _s0
19776d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#undef _s1
19876d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#undef _s2
19976d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#undef _s3
20076d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#undef _s4
20176d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#undef _ww
20276d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
20376d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
20476d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman/***********************************************************************
20576d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman//
20676d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman************************************************************************/
20776d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
20876d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#if 1
20976d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  define LZO_BYTE(x)       ((unsigned char) (x))
21076d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#else
21176d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  define LZO_BYTE(x)       ((unsigned char) ((x) & 0xff))
21276d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
21376d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
21476d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#define LZO_MAX(a,b)        ((a) >= (b) ? (a) : (b))
21576d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#define LZO_MIN(a,b)        ((a) <= (b) ? (a) : (b))
21676d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#define LZO_MAX3(a,b,c)     ((a) >= (b) ? LZO_MAX(a,c) : LZO_MAX(b,c))
21776d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#define LZO_MIN3(a,b,c)     ((a) <= (b) ? LZO_MIN(a,c) : LZO_MIN(b,c))
21876d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
21976d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#define lzo_sizeof(type)    ((lzo_uint) (sizeof(type)))
22076d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
22176d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#define LZO_HIGH(array)     ((lzo_uint) (sizeof(array)/sizeof(*(array))))
22276d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
22376d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman/* this always fits into 32 bits */
22476d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#define LZO_SIZE(bits)      (1u << (bits))
22576d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#define LZO_MASK(bits)      (LZO_SIZE(bits) - 1)
22676d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
22776d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#define LZO_USIZE(bits)     ((lzo_uint) 1 << (bits))
22876d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#define LZO_UMASK(bits)     (LZO_USIZE(bits) - 1)
22976d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
23076d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#if !defined(DMUL)
23176d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#if 0
23276d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman   /* 32*32 multiplies may be faster than 64*64 on some 64-bit machines,
23376d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman    * but then we need extra casts from unsigned<->size_t */
23476d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  define DMUL(a,b) ((lzo_xint) ((lzo_uint32_t)(a) * (lzo_uint32_t)(b)))
23576d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#else
23676d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  define DMUL(a,b) ((lzo_xint) ((a) * (b)))
23776d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
23876d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
23976d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
24076d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
24176d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman/***********************************************************************
24276d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman// compiler and architecture specific stuff
24376d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman************************************************************************/
24476d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
24576d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman/* Some defines that indicate if memory can be accessed at unaligned
24676d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman * memory addresses. You should also test that this is actually faster
24776d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman * even if it is allowed by your system.
24876d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman */
24976d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
25076d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#include "lzo_func.h"
25176d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
25276d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#ifndef UA_SET1
25376d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#define UA_SET1             LZO_MEMOPS_SET1
25476d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
25576d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#ifndef UA_SET2
25676d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#define UA_SET2             LZO_MEMOPS_SET2
25776d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
25876d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#ifndef UA_SET3
25976d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#define UA_SET3             LZO_MEMOPS_SET3
26076d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
26176d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#ifndef UA_SET4
26276d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#define UA_SET4             LZO_MEMOPS_SET4
26376d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
26476d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#ifndef UA_MOVE1
26576d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#define UA_MOVE1            LZO_MEMOPS_MOVE1
26676d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
26776d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#ifndef UA_MOVE2
26876d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#define UA_MOVE2            LZO_MEMOPS_MOVE2
26976d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
27076d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#ifndef UA_MOVE3
27176d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#define UA_MOVE3            LZO_MEMOPS_MOVE3
27276d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
27376d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#ifndef UA_MOVE4
27476d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#define UA_MOVE4            LZO_MEMOPS_MOVE4
27576d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
27676d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#ifndef UA_MOVE8
27776d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#define UA_MOVE8            LZO_MEMOPS_MOVE8
27876d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
27976d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#ifndef UA_COPY1
28076d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#define UA_COPY1            LZO_MEMOPS_COPY1
28176d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
28276d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#ifndef UA_COPY2
28376d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#define UA_COPY2            LZO_MEMOPS_COPY2
28476d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
28576d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#ifndef UA_COPY3
28676d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#define UA_COPY3            LZO_MEMOPS_COPY3
28776d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
28876d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#ifndef UA_COPY4
28976d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#define UA_COPY4            LZO_MEMOPS_COPY4
29076d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
29176d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#ifndef UA_COPY8
29276d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#define UA_COPY8            LZO_MEMOPS_COPY8
29376d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
29476d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#ifndef UA_COPYN
29576d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#define UA_COPYN            LZO_MEMOPS_COPYN
29676d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
29776d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#ifndef UA_COPYN_X
29876d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#define UA_COPYN_X          LZO_MEMOPS_COPYN
29976d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
30076d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#ifndef UA_GET_LE16
30176d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#define UA_GET_LE16         LZO_MEMOPS_GET_LE16
30276d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
30376d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#ifndef UA_GET_LE32
30476d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#define UA_GET_LE32         LZO_MEMOPS_GET_LE32
30576d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
30676d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#ifdef LZO_MEMOPS_GET_LE64
30776d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#ifndef UA_GET_LE64
30876d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#define UA_GET_LE64         LZO_MEMOPS_GET_LE64
30976d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
31076d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
31176d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#ifndef UA_GET_NE16
31276d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#define UA_GET_NE16         LZO_MEMOPS_GET_NE16
31376d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
31476d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#ifndef UA_GET_NE32
31576d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#define UA_GET_NE32         LZO_MEMOPS_GET_NE32
31676d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
31776d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#ifdef LZO_MEMOPS_GET_NE64
31876d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#ifndef UA_GET_NE64
31976d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#define UA_GET_NE64         LZO_MEMOPS_GET_NE64
32076d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
32176d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
32276d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#ifndef UA_PUT_LE16
32376d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#define UA_PUT_LE16         LZO_MEMOPS_PUT_LE16
32476d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
32576d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#ifndef UA_PUT_LE32
32676d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#define UA_PUT_LE32         LZO_MEMOPS_PUT_LE32
32776d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
32876d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#ifndef UA_PUT_NE16
32976d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#define UA_PUT_NE16         LZO_MEMOPS_PUT_NE16
33076d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
33176d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#ifndef UA_PUT_NE32
33276d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#define UA_PUT_NE32         LZO_MEMOPS_PUT_NE32
33376d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
33476d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
33576d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
33676d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman/* Fast memcpy that copies multiples of 8 byte chunks.
33776d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman * len is the number of bytes.
33876d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman * note: all parameters must be lvalues, len >= 8
33976d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman *       dest and src advance, len is undefined afterwards
34076d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman */
34176d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
34276d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#define MEMCPY8_DS(dest,src,len) \
34376d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman    lzo_memcpy(dest,src,len); dest += len; src += len
34476d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
34576d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#define BZERO8_PTR(s,l,n) \
34676d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman    lzo_memset((lzo_voidp)(s),0,(lzo_uint)(l)*(n))
34776d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
34876d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#define MEMCPY_DS(dest,src,len) \
34976d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman    do *dest++ = *src++; while (--len > 0)
35076d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
35176d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
35276d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman/***********************************************************************
35376d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman//
35476d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman************************************************************************/
35576d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
35676d05dc695b06c4e987bb8078f78032441e1430cGreg HartmanLZO_EXTERN(const lzo_bytep) lzo_copyright(void);
35776d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
35876d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#include "lzo_ptr.h"
35976d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
36076d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman/* Generate compressed data in a deterministic way.
36176d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman * This is fully portable, and compression can be faster as well.
36276d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman * A reason NOT to be deterministic is when the block size is
36376d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman * very small (e.g. 8kB) or the dictionary is big, because
36476d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman * then the initialization of the dictionary becomes a relevant
36576d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman * magnitude for compression speed.
36676d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman */
36776d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#ifndef LZO_DETERMINISTIC
36876d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#define LZO_DETERMINISTIC 1
36976d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
37076d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
37176d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
37276d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#ifndef LZO_DICT_USE_PTR
37376d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#define LZO_DICT_USE_PTR 1
37476d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
37576d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
37676d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#if (LZO_DICT_USE_PTR)
37776d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  define lzo_dict_t    const lzo_bytep
37876d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  define lzo_dict_p    lzo_dict_t *
37976d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#else
38076d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  define lzo_dict_t    lzo_uint
38176d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#  define lzo_dict_p    lzo_dict_t *
38276d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif
38376d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
38476d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
38576d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman#endif /* already included */
38676d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
38776d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman/*
38876d05dc695b06c4e987bb8078f78032441e1430cGreg Hartmanvi:ts=4:et
38976d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman*/
39076d05dc695b06c4e987bb8078f78032441e1430cGreg Hartman
391