Subversion Repositories freemyipod

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
160 theseven 1
/* ucl_conf.h -- main internal configuration file for the the UCL library
2
 
3
   This file is part of the UCL data compression library.
4
 
5
   Copyright (C) 1996-2002 Markus Franz Xaver Johannes Oberhumer
6
   All Rights Reserved.
7
 
8
   The UCL 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 UCL 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 UCL library; see the file COPYING.
20
   If not, write to the Free Software Foundation, Inc.,
21
   59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
 
23
   Markus F.X.J. Oberhumer
24
   <markus@oberhumer.com>
25
 */
26
 
27
 
28
/* WARNING: this file should *not* be used by applications. It is
29
   part of the implementation of the library and is subject
30
   to change.
31
 */
32
 
33
 
34
#ifndef __UCL_CONF_H
35
#define __UCL_CONF_H
36
 
37
#if !defined(__UCL_IN_MINIUCL)
38
#  ifndef __UCLCONF_H
39
#    include <ucl/uclconf.h>
40
#  endif
41
#endif
42
 
43
 
44
/***********************************************************************
45
// memory checkers
46
************************************************************************/
47
 
184 farthen 48
#if !defined(__BOUNDS_CHECKING_ON)
160 theseven 49
#  define BOUNDS_CHECKING_OFF_DURING(stmt)      stmt
50
#  define BOUNDS_CHECKING_OFF_IN_EXPR(expr)     (expr)
51
#endif
52
 
53
 
54
/***********************************************************************
55
// autoconf section
56
************************************************************************/
57
 
58
#if !defined(UCL_HAVE_CONFIG_H)
59
#  define HAVE_MEMCMP
60
#  define HAVE_MEMCPY
61
#  define HAVE_MEMMOVE
62
#  define HAVE_MEMSET
63
#endif
64
 
65
#if defined(__UCL_DOS16) || defined(__UCL_WIN16)
66
#  define HAVE_MALLOC_H
67
#  define HAVE_HALLOC
68
#endif
69
 
70
 
71
#undef NDEBUG
72
#if !defined(UCL_DEBUG)
73
#  define NDEBUG
74
#endif
75
 
76
 
77
#if !defined(UCL_UNUSED)
78
#  define UCL_UNUSED(parm)  (parm = parm)
79
#endif
80
 
81
 
82
#if !defined(__inline__) && !defined(__GNUC__)
83
#  if defined(__cplusplus)
84
#    define __inline__      inline
85
#  else
86
#    define __inline__      /* nothing */
87
#  endif
88
#endif
89
 
90
 
91
/***********************************************************************
92
//
93
************************************************************************/
94
 
95
#if 1
96
#  define UCL_BYTE(x)       ((unsigned char) (x))
97
#else
98
#  define UCL_BYTE(x)       ((unsigned char) ((x) & 0xff))
99
#endif
100
#if 0
101
#  define UCL_USHORT(x)     ((unsigned short) (x))
102
#else
103
#  define UCL_USHORT(x)     ((unsigned short) ((x) & 0xffff))
104
#endif
105
 
106
#define UCL_MAX(a,b)        ((a) >= (b) ? (a) : (b))
107
#define UCL_MIN(a,b)        ((a) <= (b) ? (a) : (b))
108
#define UCL_MAX3(a,b,c)     ((a) >= (b) ? UCL_MAX(a,c) : UCL_MAX(b,c))
109
#define UCL_MIN3(a,b,c)     ((a) <= (b) ? UCL_MIN(a,c) : UCL_MIN(b,c))
110
 
111
#define ucl_sizeof(type)    ((ucl_uint) (sizeof(type)))
112
 
113
#define UCL_HIGH(array)     ((ucl_uint) (sizeof(array)/sizeof(*(array))))
114
 
115
/* this always fits into 16 bits */
116
#define UCL_SIZE(bits)      (1u << (bits))
117
#define UCL_MASK(bits)      (UCL_SIZE(bits) - 1)
118
 
119
#define UCL_LSIZE(bits)     (1ul << (bits))
120
#define UCL_LMASK(bits)     (UCL_LSIZE(bits) - 1)
121
 
122
#define UCL_USIZE(bits)     ((ucl_uint) 1 << (bits))
123
#define UCL_UMASK(bits)     (UCL_USIZE(bits) - 1)
124
 
125
/* Maximum value of a signed/unsigned type.
126
   Do not use casts, avoid overflows ! */
127
#define UCL_STYPE_MAX(b)    (((1l  << (8*(b)-2)) - 1l)  + (1l  << (8*(b)-2)))
128
#define UCL_UTYPE_MAX(b)    (((1ul << (8*(b)-1)) - 1ul) + (1ul << (8*(b)-1)))
129
 
130
 
131
/***********************************************************************
132
//
133
************************************************************************/
134
 
135
#if !defined(SIZEOF_UNSIGNED)
136
#  if (UINT_MAX == 0xffff)
137
#    define SIZEOF_UNSIGNED         2
138
#  elif (UINT_MAX == UCL_0xffffffffL)
139
#    define SIZEOF_UNSIGNED         4
140
#  elif (UINT_MAX >= UCL_0xffffffffL)
141
#    define SIZEOF_UNSIGNED         8
142
#  else
143
#    error "SIZEOF_UNSIGNED"
144
#  endif
145
#endif
146
 
147
#if !defined(SIZEOF_UNSIGNED_LONG)
148
#  if (ULONG_MAX == UCL_0xffffffffL)
149
#    define SIZEOF_UNSIGNED_LONG    4
150
#  elif (ULONG_MAX >= UCL_0xffffffffL)
151
#    define SIZEOF_UNSIGNED_LONG    8
152
#  else
153
#    error "SIZEOF_UNSIGNED_LONG"
154
#  endif
155
#endif
156
 
157
 
158
#if !defined(SIZEOF_SIZE_T)
159
#  define SIZEOF_SIZE_T             SIZEOF_UNSIGNED_LONG
160
#endif
161
#if !defined(SIZE_T_MAX)
162
#  define SIZE_T_MAX                UCL_UTYPE_MAX(SIZEOF_SIZE_T)
163
#endif
164
 
165
 
166
/***********************************************************************
167
// <string.h> section
168
************************************************************************/
169
 
170
#if defined(NO_MEMCMP)
171
#  undef HAVE_MEMCMP
172
#endif
173
 
174
#if (UCL_UINT_MAX <= SIZE_T_MAX) && defined(HAVE_MEMCMP)
175
#  define ucl_memcmp                memcmp
176
#endif
177
#if (UCL_UINT_MAX <= SIZE_T_MAX) && defined(HAVE_MEMCPY)
178
#  define ucl_memcpy                memcpy
179
#endif
180
#if (UCL_UINT_MAX <= SIZE_T_MAX) && defined(HAVE_MEMMOVE)
181
#  define ucl_memmove               memmove
182
#endif
183
#if (UCL_UINT_MAX <= SIZE_T_MAX) && defined(HAVE_MEMSET)
184
#  define ucl_memset                memset
185
#endif
186
 
187
#if !defined(HAVE_MEMCMP)
188
#  undef memcmp
189
#  define memcmp                    ucl_memcmp
190
#endif
191
#if !defined(HAVE_MEMCPY)
192
#  undef memcpy
193
#  define memcpy                    ucl_memcpy
194
#endif
195
#if !defined(HAVE_MEMMOVE)
196
#  undef memmove
197
#  define memmove                   ucl_memmove
198
#endif
199
#if !defined(HAVE_MEMSET)
200
#  undef memset
201
#  define memset                    ucl_memset
202
#endif
203
 
204
 
205
/***********************************************************************
206
// compiler and architecture specific stuff
207
************************************************************************/
208
 
209
/* Some defines that indicate if memory can be accessed at unaligned
210
 * memory addresses. You should also test that this is actually faster
211
 * even if it is allowed by your system.
212
 */
213
 
214
#if 1 && defined(__UCL_i386) && (UINT_MAX == UCL_0xffffffffL)
215
#  if !defined(UCL_UNALIGNED_OK_2) && (USHRT_MAX == 0xffff)
216
#    define UCL_UNALIGNED_OK_2
217
#  endif
218
#  if !defined(UCL_UNALIGNED_OK_4) && (UCL_UINT32_MAX == UCL_0xffffffffL)
219
#    define UCL_UNALIGNED_OK_4
220
#  endif
221
#endif
222
 
223
#if defined(UCL_UNALIGNED_OK_2) || defined(UCL_UNALIGNED_OK_4)
224
#  if !defined(UCL_UNALIGNED_OK)
225
#    define UCL_UNALIGNED_OK
226
#  endif
227
#endif
228
 
229
#if defined(__UCL_NO_UNALIGNED)
230
#  undef UCL_UNALIGNED_OK
231
#  undef UCL_UNALIGNED_OK_2
232
#  undef UCL_UNALIGNED_OK_4
233
#endif
234
 
235
#if defined(UCL_UNALIGNED_OK_2) && (USHRT_MAX != 0xffff)
236
#  error "UCL_UNALIGNED_OK_2 must not be defined on this system"
237
#endif
238
#if defined(UCL_UNALIGNED_OK_4) && (UCL_UINT32_MAX != UCL_0xffffffffL)
239
#  error "UCL_UNALIGNED_OK_4 must not be defined on this system"
240
#endif
241
 
242
 
243
/* Many modern processors can transfer 32bit words much faster than
244
 * bytes - this can significantly speed decompression.
245
 */
246
 
247
#if defined(__UCL_NO_ALIGNED)
248
#  undef UCL_ALIGNED_OK_4
249
#endif
250
 
251
#if defined(UCL_ALIGNED_OK_4) && (UCL_UINT32_MAX != UCL_0xffffffffL)
252
#  error "UCL_ALIGNED_OK_4 must not be defined on this system"
253
#endif
254
 
255
 
256
/* Definitions for byte order, according to significance of bytes, from low
257
 * addresses to high addresses. The value is what you get by putting '4'
258
 * in the most significant byte, '3' in the second most significant byte,
259
 * '2' in the second least significant byte, and '1' in the least
260
 * significant byte.
261
 * The byte order is only needed if we use UCL_UNALIGNED_OK.
262
 */
263
 
264
#define UCL_LITTLE_ENDIAN       1234
265
#define UCL_BIG_ENDIAN          4321
266
#define UCL_PDP_ENDIAN          3412
267
 
268
#if !defined(UCL_BYTE_ORDER)
269
#  if defined(MFX_BYTE_ORDER)
270
#    define UCL_BYTE_ORDER      MFX_BYTE_ORDER
271
#  elif defined(__UCL_i386)
272
#    define UCL_BYTE_ORDER      UCL_LITTLE_ENDIAN
273
#  elif defined(BYTE_ORDER)
274
#    define UCL_BYTE_ORDER      BYTE_ORDER
275
#  elif defined(__BYTE_ORDER)
276
#    define UCL_BYTE_ORDER      __BYTE_ORDER
277
#  endif
278
#endif
279
 
280
#if defined(UCL_BYTE_ORDER)
281
#  if (UCL_BYTE_ORDER != UCL_LITTLE_ENDIAN) && \
282
      (UCL_BYTE_ORDER != UCL_BIG_ENDIAN)
283
#    error "invalid UCL_BYTE_ORDER"
284
#  endif
285
#endif
286
 
287
#if defined(UCL_UNALIGNED_OK) && !defined(UCL_BYTE_ORDER)
288
#  error "UCL_BYTE_ORDER is not defined"
289
#endif
290
 
291
 
292
/***********************************************************************
293
// some globals
294
************************************************************************/
295
 
296
__UCL_EXTERN_C int __ucl_init_done;
297
__UCL_EXTERN_C const ucl_byte __ucl_copyright[];
298
UCL_EXTERN(const ucl_byte *) ucl_copyright(void);
299
__UCL_EXTERN_C const ucl_uint32 _ucl_crc32_table[256];
300
 
301
 
302
/***********************************************************************
303
// ANSI C preprocessor macros
304
************************************************************************/
305
 
306
#define _UCL_STRINGIZE(x)           #x
307
#define _UCL_MEXPAND(x)             _UCL_STRINGIZE(x)
308
 
309
/* concatenate */
310
#define _UCL_CONCAT2(a,b)           a ## b
311
#define _UCL_CONCAT3(a,b,c)         a ## b ## c
312
#define _UCL_CONCAT4(a,b,c,d)       a ## b ## c ## d
313
#define _UCL_CONCAT5(a,b,c,d,e)     a ## b ## c ## d ## e
314
 
315
/* expand and concatenate (by using one level of indirection) */
316
#define _UCL_ECONCAT2(a,b)          _UCL_CONCAT2(a,b)
317
#define _UCL_ECONCAT3(a,b,c)        _UCL_CONCAT3(a,b,c)
318
#define _UCL_ECONCAT4(a,b,c,d)      _UCL_CONCAT4(a,b,c,d)
319
#define _UCL_ECONCAT5(a,b,c,d,e)    _UCL_CONCAT5(a,b,c,d,e)
320
 
321
 
322
/***********************************************************************
323
//
324
************************************************************************/
325
 
326
#include "ucl_ptr.h"
327
 
328
 
329
#endif /* already included */
330
 
331
/*
332
vi:ts=4:et
333
*/
334