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