1 /* lzo_conf.h -- main internal configuration file for the the LZO library 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 /* WARNING: this file should *not* be used by applications. It is 30 part of the implementation of the library and is subject 31 to change. 32 */ 33 34 35 #ifndef __LZO_CONF_H 36 #define __LZO_CONF_H 1 37 38 #if !defined(__LZO_IN_MINILZO) 39 #if defined(LZO_CFG_FREESTANDING) && (LZO_CFG_FREESTANDING) 40 # define LZO_LIBC_FREESTANDING 1 41 # define LZO_OS_FREESTANDING 1 42 #endif 43 #if defined(LZO_CFG_EXTRA_CONFIG_HEADER) 44 # include LZO_CFG_EXTRA_CONFIG_HEADER 45 #endif 46 #if defined(__LZOCONF_H) || defined(__LZOCONF_H_INCLUDED) 47 # error "include this file first" 48 #endif 49 #include "lzo/lzoconf.h" 50 #if defined(LZO_CFG_EXTRA_CONFIG_HEADER2) 51 # include LZO_CFG_EXTRA_CONFIG_HEADER2 52 #endif 53 #endif 54 55 #if (LZO_VERSION < 0x2070) || !defined(__LZOCONF_H_INCLUDED) 56 # error "version mismatch" 57 #endif 58 59 60 /*********************************************************************** 61 // pragmas 62 ************************************************************************/ 63 64 #if (LZO_CC_MSC && (_MSC_VER >= 1000 && _MSC_VER < 1100)) 65 /* disable bogus "unreachable code" warnings */ 66 # pragma warning(disable: 4702) 67 #endif 68 #if (LZO_CC_MSC && (_MSC_VER >= 1000)) 69 # pragma warning(disable: 4127 4701) 70 /* disable warnings about inlining */ 71 # pragma warning(disable: 4514 4710 4711) 72 #endif 73 #if (LZO_CC_MSC && (_MSC_VER >= 1300)) 74 /* disable '-Wall' warnings in system header files */ 75 # pragma warning(disable: 4820) 76 #endif 77 #if (LZO_CC_MSC && (_MSC_VER >= 1800)) 78 /* disable '-Wall' warnings in system header files */ 79 # pragma warning(disable: 4746) 80 #endif 81 82 #if (LZO_CC_SUNPROC) 83 #if !defined(__cplusplus) 84 # pragma error_messages(off,E_END_OF_LOOP_CODE_NOT_REACHED) 85 # pragma error_messages(off,E_LOOP_NOT_ENTERED_AT_TOP) 86 # pragma error_messages(off,E_STATEMENT_NOT_REACHED) 87 #endif 88 #endif 89 90 91 /*********************************************************************** 92 // 93 ************************************************************************/ 94 95 #if defined(__LZO_IN_MINILZO) || (LZO_CFG_FREESTANDING) 96 #elif 1 97 # include <string.h> 98 #else 99 # define LZO_WANT_ACC_INCD_H 1 100 #endif 101 #if defined(LZO_HAVE_CONFIG_H) 102 # define LZO_CFG_NO_CONFIG_HEADER 1 103 #endif 104 #include "lzo_supp.h" 105 106 /* Integral types */ 107 #if 1 || defined(lzo_int8_t) || defined(lzo_uint8_t) 108 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int8_t) == 1) 109 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint8_t) == 1) 110 #endif 111 #if 1 || defined(lzo_int16_t) || defined(lzo_uint16_t) 112 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16_t) == 2) 113 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint16_t) == 2) 114 #endif 115 #if 1 || defined(lzo_int32_t) || defined(lzo_uint32_t) 116 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32_t) == 4) 117 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint32_t) == 4) 118 #endif 119 #if defined(lzo_int64_t) || defined(lzo_uint64_t) 120 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64_t) == 8) 121 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint64_t) == 8) 122 #endif 123 124 #if (LZO_CFG_FREESTANDING) 125 # undef HAVE_MEMCMP 126 # undef HAVE_MEMCPY 127 # undef HAVE_MEMMOVE 128 # undef HAVE_MEMSET 129 #endif 130 131 #if !(HAVE_MEMCMP) 132 # undef memcmp 133 # define memcmp(a,b,c) lzo_memcmp(a,b,c) 134 #else 135 # undef lzo_memcmp 136 # define lzo_memcmp(a,b,c) memcmp(a,b,c) 137 #endif 138 #if !(HAVE_MEMCPY) 139 # undef memcpy 140 # define memcpy(a,b,c) lzo_memcpy(a,b,c) 141 #else 142 # undef lzo_memcpy 143 # define lzo_memcpy(a,b,c) memcpy(a,b,c) 144 #endif 145 #if !(HAVE_MEMMOVE) 146 # undef memmove 147 # define memmove(a,b,c) lzo_memmove(a,b,c) 148 #else 149 # undef lzo_memmove 150 # define lzo_memmove(a,b,c) memmove(a,b,c) 151 #endif 152 #if !(HAVE_MEMSET) 153 # undef memset 154 # define memset(a,b,c) lzo_memset(a,b,c) 155 #else 156 # undef lzo_memset 157 # define lzo_memset(a,b,c) memset(a,b,c) 158 #endif 159 160 #undef NDEBUG 161 #if (LZO_CFG_FREESTANDING) 162 # undef LZO_DEBUG 163 # define NDEBUG 1 164 # undef assert 165 # define assert(e) ((void)0) 166 #else 167 # if !defined(LZO_DEBUG) 168 # define NDEBUG 1 169 # endif 170 # include <assert.h> 171 #endif 172 173 #if 0 && defined(__BOUNDS_CHECKING_ON) 174 # include <unchecked.h> 175 #else 176 # define BOUNDS_CHECKING_OFF_DURING(stmt) stmt 177 # define BOUNDS_CHECKING_OFF_IN_EXPR(expr) (expr) 178 #endif 179 180 #if (LZO_CFG_PGO) 181 # undef __lzo_likely 182 # undef __lzo_unlikely 183 # define __lzo_likely(e) (e) 184 # define __lzo_unlikely(e) (e) 185 #endif 186 187 #undef _ 188 #undef __ 189 #undef ___ 190 #undef ____ 191 #undef _p0 192 #undef _p1 193 #undef _p2 194 #undef _p3 195 #undef _p4 196 #undef _s0 197 #undef _s1 198 #undef _s2 199 #undef _s3 200 #undef _s4 201 #undef _ww 202 203 204 /*********************************************************************** 205 // 206 ************************************************************************/ 207 208 #if 1 209 # define LZO_BYTE(x) ((unsigned char) (x)) 210 #else 211 # define LZO_BYTE(x) ((unsigned char) ((x) & 0xff)) 212 #endif 213 214 #define LZO_MAX(a,b) ((a) >= (b) ? (a) : (b)) 215 #define LZO_MIN(a,b) ((a) <= (b) ? (a) : (b)) 216 #define LZO_MAX3(a,b,c) ((a) >= (b) ? LZO_MAX(a,c) : LZO_MAX(b,c)) 217 #define LZO_MIN3(a,b,c) ((a) <= (b) ? LZO_MIN(a,c) : LZO_MIN(b,c)) 218 219 #define lzo_sizeof(type) ((lzo_uint) (sizeof(type))) 220 221 #define LZO_HIGH(array) ((lzo_uint) (sizeof(array)/sizeof(*(array)))) 222 223 /* this always fits into 32 bits */ 224 #define LZO_SIZE(bits) (1u << (bits)) 225 #define LZO_MASK(bits) (LZO_SIZE(bits) - 1) 226 227 #define LZO_USIZE(bits) ((lzo_uint) 1 << (bits)) 228 #define LZO_UMASK(bits) (LZO_USIZE(bits) - 1) 229 230 #if !defined(DMUL) 231 #if 0 232 /* 32*32 multiplies may be faster than 64*64 on some 64-bit machines, 233 * but then we need extra casts from unsigned<->size_t */ 234 # define DMUL(a,b) ((lzo_xint) ((lzo_uint32_t)(a) * (lzo_uint32_t)(b))) 235 #else 236 # define DMUL(a,b) ((lzo_xint) ((a) * (b))) 237 #endif 238 #endif 239 240 241 /*********************************************************************** 242 // compiler and architecture specific stuff 243 ************************************************************************/ 244 245 /* Some defines that indicate if memory can be accessed at unaligned 246 * memory addresses. You should also test that this is actually faster 247 * even if it is allowed by your system. 248 */ 249 250 #include "lzo_func.h" 251 252 #ifndef UA_SET1 253 #define UA_SET1 LZO_MEMOPS_SET1 254 #endif 255 #ifndef UA_SET2 256 #define UA_SET2 LZO_MEMOPS_SET2 257 #endif 258 #ifndef UA_SET3 259 #define UA_SET3 LZO_MEMOPS_SET3 260 #endif 261 #ifndef UA_SET4 262 #define UA_SET4 LZO_MEMOPS_SET4 263 #endif 264 #ifndef UA_MOVE1 265 #define UA_MOVE1 LZO_MEMOPS_MOVE1 266 #endif 267 #ifndef UA_MOVE2 268 #define UA_MOVE2 LZO_MEMOPS_MOVE2 269 #endif 270 #ifndef UA_MOVE3 271 #define UA_MOVE3 LZO_MEMOPS_MOVE3 272 #endif 273 #ifndef UA_MOVE4 274 #define UA_MOVE4 LZO_MEMOPS_MOVE4 275 #endif 276 #ifndef UA_MOVE8 277 #define UA_MOVE8 LZO_MEMOPS_MOVE8 278 #endif 279 #ifndef UA_COPY1 280 #define UA_COPY1 LZO_MEMOPS_COPY1 281 #endif 282 #ifndef UA_COPY2 283 #define UA_COPY2 LZO_MEMOPS_COPY2 284 #endif 285 #ifndef UA_COPY3 286 #define UA_COPY3 LZO_MEMOPS_COPY3 287 #endif 288 #ifndef UA_COPY4 289 #define UA_COPY4 LZO_MEMOPS_COPY4 290 #endif 291 #ifndef UA_COPY8 292 #define UA_COPY8 LZO_MEMOPS_COPY8 293 #endif 294 #ifndef UA_COPYN 295 #define UA_COPYN LZO_MEMOPS_COPYN 296 #endif 297 #ifndef UA_COPYN_X 298 #define UA_COPYN_X LZO_MEMOPS_COPYN 299 #endif 300 #ifndef UA_GET_LE16 301 #define UA_GET_LE16 LZO_MEMOPS_GET_LE16 302 #endif 303 #ifndef UA_GET_LE32 304 #define UA_GET_LE32 LZO_MEMOPS_GET_LE32 305 #endif 306 #ifdef LZO_MEMOPS_GET_LE64 307 #ifndef UA_GET_LE64 308 #define UA_GET_LE64 LZO_MEMOPS_GET_LE64 309 #endif 310 #endif 311 #ifndef UA_GET_NE16 312 #define UA_GET_NE16 LZO_MEMOPS_GET_NE16 313 #endif 314 #ifndef UA_GET_NE32 315 #define UA_GET_NE32 LZO_MEMOPS_GET_NE32 316 #endif 317 #ifdef LZO_MEMOPS_GET_NE64 318 #ifndef UA_GET_NE64 319 #define UA_GET_NE64 LZO_MEMOPS_GET_NE64 320 #endif 321 #endif 322 #ifndef UA_PUT_LE16 323 #define UA_PUT_LE16 LZO_MEMOPS_PUT_LE16 324 #endif 325 #ifndef UA_PUT_LE32 326 #define UA_PUT_LE32 LZO_MEMOPS_PUT_LE32 327 #endif 328 #ifndef UA_PUT_NE16 329 #define UA_PUT_NE16 LZO_MEMOPS_PUT_NE16 330 #endif 331 #ifndef UA_PUT_NE32 332 #define UA_PUT_NE32 LZO_MEMOPS_PUT_NE32 333 #endif 334 335 336 /* Fast memcpy that copies multiples of 8 byte chunks. 337 * len is the number of bytes. 338 * note: all parameters must be lvalues, len >= 8 339 * dest and src advance, len is undefined afterwards 340 */ 341 342 #define MEMCPY8_DS(dest,src,len) \ 343 lzo_memcpy(dest,src,len); dest += len; src += len 344 345 #define BZERO8_PTR(s,l,n) \ 346 lzo_memset((lzo_voidp)(s),0,(lzo_uint)(l)*(n)) 347 348 #define MEMCPY_DS(dest,src,len) \ 349 do *dest++ = *src++; while (--len > 0) 350 351 352 /*********************************************************************** 353 // 354 ************************************************************************/ 355 356 LZO_EXTERN(const lzo_bytep) lzo_copyright(void); 357 358 #include "lzo_ptr.h" 359 360 /* Generate compressed data in a deterministic way. 361 * This is fully portable, and compression can be faster as well. 362 * A reason NOT to be deterministic is when the block size is 363 * very small (e.g. 8kB) or the dictionary is big, because 364 * then the initialization of the dictionary becomes a relevant 365 * magnitude for compression speed. 366 */ 367 #ifndef LZO_DETERMINISTIC 368 #define LZO_DETERMINISTIC 1 369 #endif 370 371 372 #ifndef LZO_DICT_USE_PTR 373 #define LZO_DICT_USE_PTR 1 374 #endif 375 376 #if (LZO_DICT_USE_PTR) 377 # define lzo_dict_t const lzo_bytep 378 # define lzo_dict_p lzo_dict_t * 379 #else 380 # define lzo_dict_t lzo_uint 381 # define lzo_dict_p lzo_dict_t * 382 #endif 383 384 385 #endif /* already included */ 386 387 /* 388 vi:ts=4:et 389 */ 390 391