1/* lzo1_d.ch -- common decompression stuff 2 3 This file is part of the LZO real-time data compression library. 4 5 Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer 6 All Rights Reserved. 7 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. 12 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. 17 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. 22 23 Markus F.X.J. Oberhumer 24 <markus@oberhumer.com> 25 http://www.oberhumer.com/opensource/lzo/ 26 */ 27 28 29 30#if defined(LZO_TEST_OVERRUN) 31# if !defined(LZO_TEST_OVERRUN_INPUT) 32# define LZO_TEST_OVERRUN_INPUT 2 33# endif 34# if !defined(LZO_TEST_OVERRUN_OUTPUT) 35# define LZO_TEST_OVERRUN_OUTPUT 2 36# endif 37# if !defined(LZO_TEST_OVERRUN_LOOKBEHIND) 38# define LZO_TEST_OVERRUN_LOOKBEHIND 1 39# endif 40#endif 41 42 43/*********************************************************************** 44// Overrun detection is internally handled by these macros: 45// 46// TEST_IP test input overrun at loop begin 47// NEED_IP test input overrun at every input byte 48// 49// TEST_OP test output overrun at loop begin 50// NEED_OP test output overrun at every output byte 51// 52// TEST_LB test match position 53// 54// The fastest decompressor results when testing for no overruns 55// and using LZO_EOF_CODE. 56************************************************************************/ 57 58#undef TEST_IP 59#undef TEST_OP 60#undef TEST_IP_AND_TEST_OP 61#undef TEST_LB 62#undef TEST_LBO 63#undef NEED_IP 64#undef NEED_OP 65#undef TEST_IV 66#undef TEST_OV 67#undef HAVE_TEST_IP 68#undef HAVE_TEST_OP 69#undef HAVE_NEED_IP 70#undef HAVE_NEED_OP 71#undef HAVE_ANY_IP 72#undef HAVE_ANY_OP 73 74 75#if defined(LZO_TEST_OVERRUN_INPUT) 76# if (LZO_TEST_OVERRUN_INPUT >= 1) 77# define TEST_IP (ip < ip_end) 78# endif 79# if (LZO_TEST_OVERRUN_INPUT >= 2) 80# define NEED_IP(x) \ 81 if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x)) goto input_overrun 82# define TEST_IV(x) if ((x) > (lzo_uint)0 - (511)) goto input_overrun 83# endif 84#endif 85 86#if defined(LZO_TEST_OVERRUN_OUTPUT) 87# if (LZO_TEST_OVERRUN_OUTPUT >= 1) 88# define TEST_OP (op <= op_end) 89# endif 90# if (LZO_TEST_OVERRUN_OUTPUT >= 2) 91# undef TEST_OP /* don't need both of the tests here */ 92# define NEED_OP(x) \ 93 if ((lzo_uint)(op_end - op) < (lzo_uint)(x)) goto output_overrun 94# define TEST_OV(x) if ((x) > (lzo_uint)0 - (511)) goto output_overrun 95# endif 96#endif 97 98#if defined(LZO_TEST_OVERRUN_LOOKBEHIND) 99# define TEST_LB(m_pos) if (PTR_LT(m_pos,out) || PTR_GE(m_pos,op)) goto lookbehind_overrun 100# define TEST_LBO(m_pos,o) if (PTR_LT(m_pos,out) || PTR_GE(m_pos,op-(o))) goto lookbehind_overrun 101#else 102# define TEST_LB(m_pos) ((void) 0) 103# define TEST_LBO(m_pos,o) ((void) 0) 104#endif 105 106 107#if !defined(LZO_EOF_CODE) && !defined(TEST_IP) 108 /* if we have no EOF code, we have to test for the end of the input */ 109# define TEST_IP (ip < ip_end) 110#endif 111 112 113#if defined(TEST_IP) 114# define HAVE_TEST_IP 1 115#else 116# define TEST_IP 1 117#endif 118#if defined(TEST_OP) 119# define HAVE_TEST_OP 1 120#else 121# define TEST_OP 1 122#endif 123 124#if defined(HAVE_TEST_IP) && defined(HAVE_TEST_OP) 125# define TEST_IP_AND_TEST_OP (TEST_IP && TEST_OP) 126#elif defined(HAVE_TEST_IP) 127# define TEST_IP_AND_TEST_OP TEST_IP 128#elif defined(HAVE_TEST_OP) 129# define TEST_IP_AND_TEST_OP TEST_OP 130#else 131# define TEST_IP_AND_TEST_OP 1 132#endif 133 134#if defined(NEED_IP) 135# define HAVE_NEED_IP 1 136#else 137# define NEED_IP(x) ((void) 0) 138# define TEST_IV(x) ((void) 0) 139#endif 140#if defined(NEED_OP) 141# define HAVE_NEED_OP 1 142#else 143# define NEED_OP(x) ((void) 0) 144# define TEST_OV(x) ((void) 0) 145#endif 146 147 148#if defined(HAVE_TEST_IP) || defined(HAVE_NEED_IP) 149# define HAVE_ANY_IP 1 150#endif 151#if defined(HAVE_TEST_OP) || defined(HAVE_NEED_OP) 152# define HAVE_ANY_OP 1 153#endif 154 155 156 157/* 158vi:ts=4:et 159*/ 160 161