Updates to Tomato RAF including NGINX && PHP
[tomato.git] / release / src / router / lzo / src / lzo_conf.h
blob5fcf9635e0070f09cb12bc17b359d2c4b2b6425a
1 /* lzo_conf.h -- main internal configuration file for the the LZO library
3 This file is part of the LZO real-time data compression library.
5 Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer
6 Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer
7 Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer
8 Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer
9 Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer
10 Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer
11 Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer
12 Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer
13 Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer
14 Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
15 Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
16 Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
17 Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
18 Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
19 Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
20 Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
21 All Rights Reserved.
23 The LZO library is free software; you can redistribute it and/or
24 modify it under the terms of the GNU General Public License as
25 published by the Free Software Foundation; either version 2 of
26 the License, or (at your option) any later version.
28 The LZO library is distributed in the hope that it will be useful,
29 but WITHOUT ANY WARRANTY; without even the implied warranty of
30 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 GNU General Public License for more details.
33 You should have received a copy of the GNU General Public License
34 along with the LZO library; see the file COPYING.
35 If not, write to the Free Software Foundation, Inc.,
36 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
38 Markus F.X.J. Oberhumer
39 <markus@oberhumer.com>
40 http://www.oberhumer.com/opensource/lzo/
44 /* WARNING: this file should *not* be used by applications. It is
45 part of the implementation of the library and is subject
46 to change.
50 #ifndef __LZO_CONF_H
51 #define __LZO_CONF_H 1
53 #if !defined(__LZO_IN_MINILZO)
54 #if (LZO_CFG_FREESTANDING)
55 # define LZO_LIBC_FREESTANDING 1
56 # define LZO_OS_FREESTANDING 1
57 # define ACC_LIBC_FREESTANDING 1
58 # define ACC_OS_FREESTANDING 1
59 #endif
60 #if (LZO_CFG_NO_UNALIGNED)
61 # define ACC_CFG_NO_UNALIGNED 1
62 #endif
63 #if (LZO_ARCH_GENERIC)
64 # define ACC_ARCH_GENERIC 1
65 #endif
66 #if (LZO_ABI_NEUTRAL_ENDIAN)
67 # define ACC_ABI_NEUTRAL_ENDIAN 1
68 #endif
69 #if (LZO_HAVE_CONFIG_H)
70 # define ACC_CONFIG_NO_HEADER 1
71 #endif
72 #if defined(LZO_CFG_EXTRA_CONFIG_HEADER)
73 # include LZO_CFG_EXTRA_CONFIG_HEADER
74 #endif
75 #if defined(__LZOCONF_H) || defined(__LZOCONF_H_INCLUDED)
76 # error "include this file first"
77 #endif
78 #include "lzo/lzoconf.h"
79 #endif
81 #if (LZO_VERSION < 0x02000) || !defined(__LZOCONF_H_INCLUDED)
82 # error "version mismatch"
83 #endif
86 /***********************************************************************
87 // pragmas
88 ************************************************************************/
90 #if (LZO_CC_BORLANDC && LZO_ARCH_I086)
91 # pragma option -h /* enable fast huge pointers */
92 #endif
94 #if (LZO_CC_MSC && (_MSC_VER >= 1000))
95 # pragma warning(disable: 4127 4701)
96 #endif
97 #if (LZO_CC_MSC && (_MSC_VER >= 1300))
98 /* avoid '-Wall' warnings in system header files */
99 # pragma warning(disable: 4820)
100 /* avoid warnings about inlining */
101 # pragma warning(disable: 4514 4710 4711)
102 #endif
104 #if (LZO_CC_SUNPROC)
105 #if !defined(__cplusplus)
106 # pragma error_messages(off,E_END_OF_LOOP_CODE_NOT_REACHED)
107 # pragma error_messages(off,E_LOOP_NOT_ENTERED_AT_TOP)
108 # pragma error_messages(off,E_STATEMENT_NOT_REACHED)
109 #endif
110 #endif
113 /***********************************************************************
115 ************************************************************************/
117 #if (__LZO_MMODEL_HUGE) && !(LZO_HAVE_MM_HUGE_PTR)
118 # error "this should not happen - check defines for __huge"
119 #endif
121 #if defined(__LZO_IN_MINILZO) || defined(LZO_CFG_FREESTANDING)
122 #elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16)
123 # define ACC_WANT_ACC_INCD_H 1
124 # define ACC_WANT_ACC_INCE_H 1
125 # define ACC_WANT_ACC_INCI_H 1
126 #elif 1
127 # include <string.h>
128 #else
129 # define ACC_WANT_ACC_INCD_H 1
130 #endif
131 #include "miniacc.h"
134 #if (LZO_CFG_FREESTANDING)
135 # undef HAVE_MEMCMP
136 # undef HAVE_MEMCPY
137 # undef HAVE_MEMMOVE
138 # undef HAVE_MEMSET
139 #endif
141 #if !(HAVE_MEMCMP)
142 # undef memcmp
143 # define memcmp(a,b,c) lzo_memcmp(a,b,c)
144 #elif !(__LZO_MMODEL_HUGE)
145 # undef lzo_memcmp
146 # define lzo_memcmp(a,b,c) memcmp(a,b,c)
147 #endif
148 #if !(HAVE_MEMCPY)
149 # undef memcpy
150 # define memcpy(a,b,c) lzo_memcpy(a,b,c)
151 #elif !(__LZO_MMODEL_HUGE)
152 # undef lzo_memcpy
153 # define lzo_memcpy(a,b,c) memcpy(a,b,c)
154 #endif
155 #if !(HAVE_MEMMOVE)
156 # undef memmove
157 # define memmove(a,b,c) lzo_memmove(a,b,c)
158 #elif !(__LZO_MMODEL_HUGE)
159 # undef lzo_memmove
160 # define lzo_memmove(a,b,c) memmove(a,b,c)
161 #endif
162 #if !(HAVE_MEMSET)
163 # undef memset
164 # define memset(a,b,c) lzo_memset(a,b,c)
165 #elif !(__LZO_MMODEL_HUGE)
166 # undef lzo_memset
167 # define lzo_memset(a,b,c) memset(a,b,c)
168 #endif
171 #undef NDEBUG
172 #if (LZO_CFG_FREESTANDING)
173 # undef LZO_DEBUG
174 # define NDEBUG 1
175 # undef assert
176 # define assert(e) ((void)0)
177 #else
178 # if !defined(LZO_DEBUG)
179 # define NDEBUG 1
180 # endif
181 # include <assert.h>
182 #endif
184 #if 0 && defined(__BOUNDS_CHECKING_ON)
185 # include <unchecked.h>
186 #else
187 # define BOUNDS_CHECKING_OFF_DURING(stmt) stmt
188 # define BOUNDS_CHECKING_OFF_IN_EXPR(expr) (expr)
189 #endif
191 #if !defined(__lzo_inline)
192 # define __lzo_inline /*empty*/
193 #endif
194 #if !defined(__lzo_forceinline)
195 # define __lzo_forceinline /*empty*/
196 #endif
197 #if !defined(__lzo_noinline)
198 # define __lzo_noinline /*empty*/
199 #endif
201 #if (LZO_CFG_PGO)
202 # undef __acc_likely
203 # undef __acc_unlikely
204 # undef __lzo_likely
205 # undef __lzo_unlikely
206 # define __acc_likely(e) (e)
207 # define __acc_unlikely(e) (e)
208 # define __lzo_likely(e) (e)
209 # define __lzo_unlikely(e) (e)
210 #endif
213 /***********************************************************************
215 ************************************************************************/
217 #if 1
218 # define LZO_BYTE(x) ((unsigned char) (x))
219 #else
220 # define LZO_BYTE(x) ((unsigned char) ((x) & 0xff))
221 #endif
223 #define LZO_MAX(a,b) ((a) >= (b) ? (a) : (b))
224 #define LZO_MIN(a,b) ((a) <= (b) ? (a) : (b))
225 #define LZO_MAX3(a,b,c) ((a) >= (b) ? LZO_MAX(a,c) : LZO_MAX(b,c))
226 #define LZO_MIN3(a,b,c) ((a) <= (b) ? LZO_MIN(a,c) : LZO_MIN(b,c))
228 #define lzo_sizeof(type) ((lzo_uint) (sizeof(type)))
230 #define LZO_HIGH(array) ((lzo_uint) (sizeof(array)/sizeof(*(array))))
232 /* this always fits into 16 bits */
233 #define LZO_SIZE(bits) (1u << (bits))
234 #define LZO_MASK(bits) (LZO_SIZE(bits) - 1)
236 #define LZO_LSIZE(bits) (1ul << (bits))
237 #define LZO_LMASK(bits) (LZO_LSIZE(bits) - 1)
239 #define LZO_USIZE(bits) ((lzo_uint) 1 << (bits))
240 #define LZO_UMASK(bits) (LZO_USIZE(bits) - 1)
242 #if !defined(DMUL)
243 #if 0
244 /* 32*32 multiplies may be faster than 64*64 on some 64-bit machines,
245 * but then we need extra casts from unsigned<->size_t */
246 # define DMUL(a,b) ((lzo_xint) ((lzo_uint32)(a) * (lzo_uint32)(b)))
247 #else
248 # define DMUL(a,b) ((lzo_xint) ((a) * (b)))
249 #endif
250 #endif
253 /***********************************************************************
254 // compiler and architecture specific stuff
255 ************************************************************************/
257 /* Some defines that indicate if memory can be accessed at unaligned
258 * memory addresses. You should also test that this is actually faster
259 * even if it is allowed by your system.
262 #if 1 && (LZO_ARCH_AMD64 || LZO_ARCH_I386 || LZO_ARCH_POWERPC)
263 # if (LZO_SIZEOF_SHORT == 2)
264 # define LZO_UNALIGNED_OK_2 1
265 # endif
266 # if (LZO_SIZEOF_INT == 4)
267 # define LZO_UNALIGNED_OK_4 1
268 # endif
269 #endif
270 #if 1 && (LZO_ARCH_AMD64)
271 # if defined(LZO_UINT64_MAX)
272 # define LZO_UNALIGNED_OK_8 1
273 # endif
274 #endif
275 #if (LZO_CFG_NO_UNALIGNED)
276 # undef LZO_UNALIGNED_OK_2
277 # undef LZO_UNALIGNED_OK_4
278 # undef LZO_UNALIGNED_OK_8
279 #endif
281 #undef UA_GET16
282 #undef UA_SET16
283 #undef UA_COPY16
284 #undef UA_GET32
285 #undef UA_SET32
286 #undef UA_COPY32
287 #undef UA_GET64
288 #undef UA_SET64
289 #undef UA_COPY64
290 #if defined(LZO_UNALIGNED_OK_2)
291 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(unsigned short) == 2)
292 # if 1 && defined(ACC_UA_COPY16)
293 # define UA_GET16 ACC_UA_GET16
294 # define UA_SET16 ACC_UA_SET16
295 # define UA_COPY16 ACC_UA_COPY16
296 # else
297 # define UA_GET16(p) (* (__lzo_ua_volatile const lzo_ushortp) (__lzo_ua_volatile const lzo_voidp) (p))
298 # define UA_SET16(p,v) ((* (__lzo_ua_volatile lzo_ushortp) (__lzo_ua_volatile lzo_voidp) (p)) = (unsigned short) (v))
299 # define UA_COPY16(d,s) UA_SET16(d, UA_GET16(s))
300 # endif
301 #endif
302 #if defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
303 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint32) == 4)
304 # if 1 && defined(ACC_UA_COPY32)
305 # define UA_GET32 ACC_UA_GET32
306 # define UA_SET32 ACC_UA_SET32
307 # define UA_COPY32 ACC_UA_COPY32
308 # else
309 # define UA_GET32(p) (* (__lzo_ua_volatile const lzo_uint32p) (__lzo_ua_volatile const lzo_voidp) (p))
310 # define UA_SET32(p,v) ((* (__lzo_ua_volatile lzo_uint32p) (__lzo_ua_volatile lzo_voidp) (p)) = (lzo_uint32) (v))
311 # define UA_COPY32(d,s) UA_SET32(d, UA_GET32(s))
312 # endif
313 #endif
314 #if defined(LZO_UNALIGNED_OK_8)
315 LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint64) == 8)
316 # if 1 && defined(ACC_UA_COPY64)
317 # define UA_GET64 ACC_UA_GET64
318 # define UA_SET64 ACC_UA_SET64
319 # define UA_COPY64 ACC_UA_COPY64
320 # else
321 # define UA_GET64(p) (* (__lzo_ua_volatile const lzo_uint64p) (__lzo_ua_volatile const lzo_voidp) (p))
322 # define UA_SET64(p,v) ((* (__lzo_ua_volatile lzo_uint64p) (__lzo_ua_volatile lzo_voidp) (p)) = (lzo_uint64) (v))
323 # define UA_COPY64(d,s) UA_SET64(d, UA_GET64(s))
324 # endif
325 #endif
328 /* Fast memcpy that copies multiples of 8 byte chunks.
329 * len is the number of bytes.
330 * note: all parameters must be lvalues, len >= 8
331 * dest and src advance, len is undefined afterwards
334 #define MEMCPY8_DS(dest,src,len) \
335 lzo_memcpy(dest,src,len); dest += len; src += len
337 #define BZERO8_PTR(s,l,n) \
338 lzo_memset((lzo_voidp)(s),0,(lzo_uint)(l)*(n))
340 #define MEMCPY_DS(dest,src,len) \
341 do *dest++ = *src++; while (--len > 0)
344 /***********************************************************************
345 // some globals
346 ************************************************************************/
348 LZO_EXTERN(const lzo_bytep) lzo_copyright(void);
351 /***********************************************************************
353 ************************************************************************/
355 #include "lzo_ptr.h"
358 /* Generate compressed data in a deterministic way.
359 * This is fully portable, and compression can be faster as well.
360 * A reason NOT to be deterministic is when the block size is
361 * very small (e.g. 8kB) or the dictionary is big, because
362 * then the initialization of the dictionary becomes a relevant
363 * magnitude for compression speed.
365 #ifndef LZO_DETERMINISTIC
366 #define LZO_DETERMINISTIC 1
367 #endif
370 #ifndef LZO_DICT_USE_PTR
371 #define LZO_DICT_USE_PTR 1
372 #if 0 && (LZO_ARCH_I086)
373 # undef LZO_DICT_USE_PTR
374 # define LZO_DICT_USE_PTR 0
375 #endif
376 #endif
378 #if (LZO_DICT_USE_PTR)
379 # define lzo_dict_t const lzo_bytep
380 # define lzo_dict_p lzo_dict_t __LZO_MMODEL *
381 #else
382 # define lzo_dict_t lzo_uint
383 # define lzo_dict_p lzo_dict_t __LZO_MMODEL *
384 #endif
387 #endif /* already included */
390 vi:ts=4:et