lzo_conf.h 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Command & Conquer *
  23. * *
  24. * $Archive:: /Commando/Library/lzo_conf.h $*
  25. * *
  26. * $Author:: Greg_h $*
  27. * *
  28. * $Modtime:: 7/22/97 11:37a $*
  29. * *
  30. * $Revision:: 1 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. /* lzo_conf.h -- main internal configuration file for the the LZO library
  36. This file is part of the LZO real-time data compression library.
  37. Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
  38. The LZO library is free software; you can redistribute it and/or
  39. modify it under the terms of the GNU Library General Public
  40. License as published by the Free Software Foundation; either
  41. version 2 of the License, or (at your option) any later version.
  42. The LZO library is distributed in the hope that it will be useful,
  43. but WITHOUT ANY WARRANTY; without even the implied warranty of
  44. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  45. Library General Public License for more details.
  46. You should have received a copy of the GNU Library General Public
  47. License along with the LZO library; see the file COPYING.LIB.
  48. If not, write to the Free Software Foundation, Inc.,
  49. 675 Mass Ave, Cambridge, MA 02139, USA.
  50. Markus F.X.J. Oberhumer
  51. [email protected]
  52. */
  53. /* WARNING: this file should *not* be used by applications. It is
  54. part of the implementation of the library and is subject
  55. to change.
  56. */
  57. #ifndef __LZO_CONF_H
  58. #define __LZO_CONF_H
  59. #ifndef __LZOCONF_H
  60. # include "lzoconf.h"
  61. #endif
  62. /***********************************************************************
  63. // compiler specific defines
  64. ************************************************************************/
  65. /* need Borland C 4.0 or above because of huge-pointer bugs */
  66. #if defined(__LZO_MSDOS16) && defined(__TURBOC__)
  67. # if (__TURBOC__ < 0x452)
  68. # error You need a newer compiler version
  69. # endif
  70. #endif
  71. #if defined(__LZO_MSDOS) || defined(__i386__) || defined(__386__)
  72. # if !defined(__LZO_i386)
  73. # define __LZO_i386
  74. # endif
  75. #endif
  76. /***********************************************************************
  77. //
  78. ************************************************************************/
  79. #include <stddef.h> /* ptrdiff_t, size_t */
  80. #include <string.h> /* memcpy, memmove, memcmp, memset */
  81. #if 0 && !defined(assert)
  82. # error <assert.h> not included
  83. #endif
  84. #if defined(__BOUNDS_CHECKING_ON)
  85. # include <unchecked.h>
  86. #else
  87. # define BOUNDS_CHECKING_OFF_DURING(stmt) stmt
  88. # define BOUNDS_CHECKING_OFF_IN_EXPR(expr) (expr)
  89. #endif
  90. /* ptrdiff_t */
  91. #if (UINT_MAX >= 0xffffffffL)
  92. typedef ptrdiff_t lzo_ptrdiff_t;
  93. #else
  94. typedef long lzo_ptrdiff_t;
  95. #endif
  96. #ifdef __cplusplus
  97. # define LZO_UNUSED(parm)
  98. #else
  99. # define LZO_UNUSED(parm) parm
  100. #endif
  101. #if !defined(__inline__) && !defined(__GNUC__)
  102. # if defined(__cplusplus)
  103. # define __inline__ inline
  104. # else
  105. # define __inline__ /* nothing */
  106. # endif
  107. #endif
  108. /***********************************************************************
  109. // compiler and architecture specific stuff
  110. ************************************************************************/
  111. /* Some defines that indicate if memory can be accessed at unaligned
  112. * addresses. You should also test that this is actually faster if
  113. * it is allowed by your system.
  114. */
  115. #if 1 && defined(__LZO_i386)
  116. # if !defined(LZO_UNALIGNED_OK_2)
  117. # define LZO_UNALIGNED_OK_2
  118. # endif
  119. # if !defined(LZO_UNALIGNED_OK_4)
  120. # define LZO_UNALIGNED_OK_4
  121. # endif
  122. #endif
  123. #if defined(LZO_UNALIGNED_OK_2) || defined(LZO_UNALIGNED_OK_4)
  124. # if !defined(LZO_UNALIGNED_OK)
  125. # define LZO_UNALIGNED_OK
  126. # endif
  127. #endif
  128. /* Definitions for byte order, according to significance of bytes, from low
  129. * addresses to high addresses. The value is what you get by putting '4'
  130. * in the most significant byte, '3' in the second most significant byte,
  131. * '2' in the second least significant byte, and '1' in the least
  132. * significant byte.
  133. */
  134. #define LZO_LITTLE_ENDIAN 1234
  135. #define LZO_BIG_ENDIAN 4321
  136. #define LZO_PDP_ENDIAN 3412
  137. /* The byte order is only needed if we use LZO_UNALIGNED_OK */
  138. #if !defined(LZO_BYTE_ORDER)
  139. # if defined(__LZO_i386)
  140. # define LZO_BYTE_ORDER LZO_LITTLE_ENDIAN
  141. # elif defined(__mc68000__)
  142. # define LZO_BYTE_ORDER LZO_BIG_ENDIAN
  143. # elif defined(__BYTE_ORDER)
  144. # define LZO_BYTE_ORDER __BYTE_ORDER
  145. # endif
  146. #endif
  147. #if defined(LZO_UNALIGNED_OK)
  148. # if !defined(LZO_BYTE_ORDER)
  149. # error LZO_BYTE_ORDER is not defined
  150. # elif (LZO_BYTE_ORDER != LZO_LITTLE_ENDIAN) && \
  151. (LZO_BYTE_ORDER != LZO_BIG_ENDIAN)
  152. # error invalid LZO_BYTE_ORDER
  153. # endif
  154. #endif
  155. /***********************************************************************
  156. // optimization
  157. ************************************************************************/
  158. /* gcc 2.6.3 and gcc 2.7.2 have a bug */
  159. #define LZO_OPTIMIZE_GNUC_i386_IS_BUGGY
  160. /* Help the optimizer with register allocation.
  161. * Don't activate this macro for a fair comparision with other algorithms.
  162. */
  163. #if 1 && defined(NDEBUG) && !defined(__BOUNDS_CHECKING_ON)
  164. # if defined(__GNUC__) && defined(__i386__)
  165. # if !defined(LZO_OPTIMIZE_GNUC_i386_IS_BUGGY)
  166. # define LZO_OPTIMIZE_GNUC_i386
  167. # endif
  168. # endif
  169. #endif
  170. /***********************************************************************
  171. //
  172. ************************************************************************/
  173. #define LZO_BYTE(x) ((unsigned char) (x))
  174. #define LZO_MAX(a,b) ((a) >= (b) ? (a) : (b))
  175. #define LZO_MIN(a,b) ((a) <= (b) ? (a) : (b))
  176. #define lzo_sizeof(x) ((lzo_uint) (sizeof(x)))
  177. #define LZO_HIGH(x) ((lzo_uint) (sizeof(x)/sizeof(*(x))))
  178. /* this always fits into 16 bits */
  179. #define LZO_SIZE(bits) (1u << (bits))
  180. #define LZO_MASK(bits) (LZO_SIZE(bits) - 1)
  181. #define LZO_LSIZE(bits) (1ul << (bits))
  182. #define LZO_LMASK(bits) (LZO_LSIZE(bits) - 1)
  183. #define LZO_USIZE(bits) ((lzo_uint) 1 << (bits))
  184. #define LZO_UMASK(bits) (LZO_USIZE(bits) - 1)
  185. /***********************************************************************
  186. // ANSI C preprocessor macros
  187. ************************************************************************/
  188. #define _LZO_STRINGIZE(x) #x
  189. #define _LZO_MEXPAND(x) _LZO_STRINGIZE(x)
  190. /* concatenate */
  191. #define _LZO_CONCAT2(a,b) a ## b
  192. #define _LZO_CONCAT3(a,b,c) a ## b ## c
  193. #define _LZO_CONCAT4(a,b,c,d) a ## b ## c ## d
  194. #define _LZO_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e
  195. /* expand and concatenate (by using one level of indirection) */
  196. #define _LZO_ECONCAT2(a,b) _LZO_CONCAT2(a,b)
  197. #define _LZO_ECONCAT3(a,b,c) _LZO_CONCAT3(a,b,c)
  198. #define _LZO_ECONCAT4(a,b,c,d) _LZO_CONCAT4(a,b,c,d)
  199. #define _LZO_ECONCAT5(a,b,c,d,e) _LZO_CONCAT5(a,b,c,d,e)
  200. /***********************************************************************
  201. //
  202. ************************************************************************/
  203. /* Generate compressed data in a deterministic way.
  204. * This is fully portable, and compression can be faster as well.
  205. * A reason NOT to be deterministic is when the block size is
  206. * very small (e.g. 8kB) or the dictionary is big, because
  207. * then the initialization of the dictionary becomes a relevant
  208. * magnitude for compression speed.
  209. */
  210. #define LZO_DETERMINISTIC
  211. /***********************************************************************
  212. //
  213. ************************************************************************/
  214. #if 0
  215. /* This line causes problems on some architectures */
  216. #define LZO_CHECK_MPOS_DET(m_pos,m_off,in,ip,max_offset) \
  217. (BOUNDS_CHECKING_OFF_IN_EXPR( \
  218. (m_off = ip - m_pos) > max_offset ))
  219. #else
  220. /* This is the safe (but slower) version */
  221. #define LZO_CHECK_MPOS_DET(m_pos,m_off,in,ip,max_offset) \
  222. (m_pos == NULL || (m_off = ip - m_pos) > max_offset)
  223. #endif
  224. /* m_pos may point anywhere...
  225. * This marco is probably a good candidate for architecture specific problems.
  226. * Try casting the pointers to lzo_ptr_t before comparing them.
  227. */
  228. #define LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,max_offset) \
  229. (BOUNDS_CHECKING_OFF_IN_EXPR( \
  230. (m_pos < in || (m_off = ip - m_pos) <= 0 || m_off > max_offset) ))
  231. #endif /* already included */
  232. /*
  233. vi:ts=4
  234. */