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