liblzo.h 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. This file is part of the LZO real-time data compression library.
  3. Copyright (C) 1996..2008 Markus Franz Xaver Johannes Oberhumer
  4. All Rights Reserved.
  5. Markus F.X.J. Oberhumer <markus@oberhumer.com>
  6. http://www.oberhumer.com/opensource/lzo/
  7. The LZO library is free software; you can redistribute it and/or
  8. modify it under the terms of the GNU General Public License as
  9. published by the Free Software Foundation; either version 2 of
  10. the License, or (at your option) any later version.
  11. The LZO library is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU General Public License for more details.
  15. You should have received a copy of the GNU General Public License
  16. along with the LZO library; see the file COPYING.
  17. If not, write to the Free Software Foundation, Inc.,
  18. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. #include "liblzo_interface.h"
  21. /* lzo-2.03/src/config1x.h */
  22. #define M2_MIN_LEN 3
  23. #define M2_MAX_LEN 8
  24. #define M3_MAX_LEN 33
  25. #define M4_MAX_LEN 9
  26. #define M1_MAX_OFFSET 0x0400
  27. #define M2_MAX_OFFSET 0x0800
  28. #define M3_MAX_OFFSET 0x4000
  29. #define M4_MAX_OFFSET 0xbfff
  30. #define M1_MARKER 0
  31. #define M3_MARKER 32
  32. #define M4_MARKER 16
  33. #define MX_MAX_OFFSET (M1_MAX_OFFSET + M2_MAX_OFFSET)
  34. #define MIN_LOOKAHEAD (M2_MAX_LEN + 1)
  35. #define LZO_EOF_CODE
  36. /* lzo-2.03/src/lzo_dict.h */
  37. #define GINDEX(m_pos,m_off,dict,dindex,in) m_pos = dict[dindex]
  38. #define DX2(p,s1,s2) \
  39. (((((unsigned)((p)[2]) << (s2)) ^ (p)[1]) << (s1)) ^ (p)[0])
  40. //#define DA3(p,s1,s2,s3) ((DA2((p)+1,s2,s3) << (s1)) + (p)[0])
  41. //#define DS3(p,s1,s2,s3) ((DS2((p)+1,s2,s3) << (s1)) - (p)[0])
  42. #define DX3(p,s1,s2,s3) ((DX2((p)+1,s2,s3) << (s1)) ^ (p)[0])
  43. #define D_SIZE (1U << D_BITS)
  44. #define D_MASK ((1U << D_BITS) - 1)
  45. #define D_HIGH ((D_MASK >> 1) + 1)
  46. #define LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,max_offset) \
  47. ( \
  48. m_pos = ip - (unsigned)(ip - m_pos), \
  49. ((uintptr_t)m_pos < (uintptr_t)in \
  50. || (m_off = (unsigned)(ip - m_pos)) <= 0 \
  51. || m_off > max_offset) \
  52. )
  53. #define DENTRY(p,in) (p)
  54. #define UPDATE_I(dict,drun,index,p,in) dict[index] = DENTRY(p,in)
  55. #define DMS(v,s) ((unsigned) (((v) & (D_MASK >> (s))) << (s)))
  56. #define DM(v) ((unsigned) ((v) & D_MASK))
  57. #define DMUL(a,b) ((unsigned) ((a) * (b)))
  58. /* lzo-2.03/src/lzo_ptr.h */
  59. #define pd(a,b) ((unsigned)((a)-(b)))
  60. # define TEST_IP (ip < ip_end)
  61. # define NEED_IP(x) \
  62. if ((unsigned)(ip_end - ip) < (unsigned)(x)) goto input_overrun
  63. # define TEST_IV(x) if ((x) > (unsigned)0 - (511)) goto input_overrun
  64. # undef TEST_OP /* don't need both of the tests here */
  65. # define TEST_OP 1
  66. # define NEED_OP(x) \
  67. if ((unsigned)(op_end - op) < (unsigned)(x)) goto output_overrun
  68. # define TEST_OV(x) if ((x) > (unsigned)0 - (511)) goto output_overrun
  69. #define HAVE_ANY_OP 1
  70. //#if defined(LZO_TEST_OVERRUN_LOOKBEHIND)
  71. # define TEST_LB(m_pos) if (m_pos < out || m_pos >= op) goto lookbehind_overrun
  72. //# define TEST_LBO(m_pos,o) if (m_pos < out || m_pos >= op - (o)) goto lookbehind_overrun
  73. //#else
  74. //# define TEST_LB(m_pos) ((void) 0)
  75. //# define TEST_LBO(m_pos,o) ((void) 0)
  76. //#endif