Subversion Repositories freemyipod

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
65 cmwslw 1
/* uclconf.h -- configuration for the UCL real-time data compression library
2
 
3
   This file is part of the UCL data compression library.
4
 
5
   Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
6
   Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
7
   Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
8
   Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
9
   Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
10
   Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
11
   Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
12
   All Rights Reserved.
13
 
14
   The UCL library is free software; you can redistribute it and/or
15
   modify it under the terms of the GNU General Public License as
16
   published by the Free Software Foundation; either version 2 of
17
   the License, or (at your option) any later version.
18
 
19
   The UCL library is distributed in the hope that it will be useful,
20
   but WITHOUT ANY WARRANTY; without even the implied warranty of
21
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
   GNU General Public License for more details.
23
 
24
   You should have received a copy of the GNU General Public License
25
   along with the UCL library; see the file COPYING.
26
   If not, write to the Free Software Foundation, Inc.,
27
   59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28
 
29
   Markus F.X.J. Oberhumer
30
   <markus@oberhumer.com>
31
   http://www.oberhumer.com/opensource/ucl/
32
 */
33
 
34
 
35
#ifndef __UCLCONF_H
36
#define __UCLCONF_H
37
 
38
#define UCL_VERSION             0x010100L
39
#define UCL_VERSION_STRING      "1.01"
40
#define UCL_VERSION_DATE        "Jan 02 2002"
41
 
42
/* internal Autoconf configuration file - only used when building UCL */
43
#if defined(UCL_HAVE_CONFIG_H)
44
#  include <config.h>
45
#endif
46
#include <limits.h>
47
 
48
#ifdef __cplusplus
49
extern "C" {
50
#endif
51
 
52
 
53
/***********************************************************************
54
// UCL requires a conforming <limits.h>
55
************************************************************************/
56
 
57
#if !defined(CHAR_BIT) || (CHAR_BIT != 8)
58
#  error "invalid CHAR_BIT"
59
#endif
60
#if !defined(UCHAR_MAX) || !defined(UINT_MAX) || !defined(ULONG_MAX)
61
#  error "check your compiler installation"
62
#endif
63
#if (USHRT_MAX < 1) || (UINT_MAX < 1) || (ULONG_MAX < 1)
64
#  error "your limits.h macros are broken"
65
#endif
66
 
67
/* workaround a compiler bug under hpux 10.20 */
68
#define UCL_0xffffffffL         4294967295ul
69
 
70
#if !defined(UCL_UINT32_C)
71
#  if (UINT_MAX < UCL_0xffffffffL)
72
#    define UCL_UINT32_C(c)     c ## UL
73
#  else
74
#    define UCL_UINT32_C(c)     c ## U
75
#  endif
76
#endif
77
 
78
 
79
/***********************************************************************
80
// architecture defines
81
************************************************************************/
82
 
83
#if !defined(__UCL_WIN) && !defined(__UCL_DOS) && !defined(__UCL_OS2)
84
#  if defined(__WINDOWS__) || defined(_WINDOWS) || defined(_Windows)
85
#    define __UCL_WIN
86
#  elif defined(__WIN32__) || defined(_WIN32) || defined(WIN32)
87
#    define __UCL_WIN
88
#  elif defined(__NT__) || defined(__NT_DLL__) || defined(__WINDOWS_386__)
89
#    define __UCL_WIN
90
#  elif defined(__DOS__) || defined(__MSDOS__) || defined(MSDOS)
91
#    define __UCL_DOS
92
#  elif defined(__OS2__) || defined(__OS2V2__) || defined(OS2)
93
#    define __UCL_OS2
94
#  elif defined(__palmos__)
95
#    define __UCL_PALMOS
96
#  elif defined(__TOS__) || defined(__atarist__)
97
#    define __UCL_TOS
98
#  endif
99
#endif
100
 
101
#if (UINT_MAX < UCL_0xffffffffL)
102
#  if defined(__UCL_WIN)
103
#    define __UCL_WIN16
104
#  elif defined(__UCL_DOS)
105
#    define __UCL_DOS16
106
#  elif defined(__UCL_PALMOS)
107
#    define __UCL_PALMOS16
108
#  elif defined(__UCL_TOS)
109
#    define __UCL_TOS16
110
#  elif defined(__C166__)
111
#  else
112
#    error "16-bit target not supported - contact me for porting hints"
113
#  endif
114
#endif
115
 
116
#if !defined(__UCL_i386)
117
#  if defined(__UCL_DOS) || defined(__UCL_WIN16)
118
#    define __UCL_i386
119
#  elif defined(__i386__) || defined(__386__) || defined(_M_IX86)
120
#    define __UCL_i386
121
#  endif
122
#endif
123
 
124
#if defined(__UCL_STRICT_16BIT)
125
#  if (UINT_MAX < UCL_0xffffffffL)
126
#    include <ucl/ucl16bit.h>
127
#  endif
128
#endif
129
 
130
/* memory checkers */
131
#if !defined(__UCL_CHECKER)
132
#  if defined(__BOUNDS_CHECKING_ON)
133
#    define __UCL_CHECKER
134
#  elif defined(__CHECKER__)
135
#    define __UCL_CHECKER
136
#  elif defined(__INSURE__)
137
#    define __UCL_CHECKER
138
#  elif defined(__PURIFY__)
139
#    define __UCL_CHECKER
140
#  endif
141
#endif
142
 
143
 
144
/***********************************************************************
145
// integral and pointer types
146
************************************************************************/
147
 
148
/* Integral types with 32 bits or more */
149
#if !defined(UCL_UINT32_MAX)
150
#  if (UINT_MAX >= UCL_0xffffffffL)
151
     typedef unsigned int       ucl_uint32;
152
     typedef int                ucl_int32;
153
#    define UCL_UINT32_MAX      UINT_MAX
154
#    define UCL_INT32_MAX       INT_MAX
155
#    define UCL_INT32_MIN       INT_MIN
156
#  elif (ULONG_MAX >= UCL_0xffffffffL)
157
     typedef unsigned long      ucl_uint32;
158
     typedef long               ucl_int32;
159
#    define UCL_UINT32_MAX      ULONG_MAX
160
#    define UCL_INT32_MAX       LONG_MAX
161
#    define UCL_INT32_MIN       LONG_MIN
162
#  else
163
#    error "ucl_uint32"
164
#  endif
165
#endif
166
 
167
/* ucl_uint is used like size_t */
168
#if !defined(UCL_UINT_MAX)
169
#  if (UINT_MAX >= UCL_0xffffffffL)
170
     typedef unsigned int       ucl_uint;
171
     typedef int                ucl_int;
172
#    define UCL_UINT_MAX        UINT_MAX
173
#    define UCL_INT_MAX         INT_MAX
174
#    define UCL_INT_MIN         INT_MIN
175
#  elif (ULONG_MAX >= UCL_0xffffffffL)
176
     typedef unsigned long      ucl_uint;
177
     typedef long               ucl_int;
178
#    define UCL_UINT_MAX        ULONG_MAX
179
#    define UCL_INT_MAX         LONG_MAX
180
#    define UCL_INT_MIN         LONG_MIN
181
#  else
182
#    error "ucl_uint"
183
#  endif
184
#endif
185
 
186
/* Memory model that allows to access memory at offsets of ucl_uint. */
187
#if !defined(__UCL_MMODEL)
188
#  if (UCL_UINT_MAX <= UINT_MAX)
189
#    define __UCL_MMODEL
190
#  elif defined(__UCL_DOS16) || defined(__UCL_WIN16)
191
#    define __UCL_MMODEL        __huge
192
#    define UCL_999_UNSUPPORTED
193
#  elif defined(__UCL_PALMOS16) || defined(__UCL_TOS16)
194
#    define __UCL_MMODEL
195
#  else
196
#    error "__UCL_MMODEL"
197
#  endif
198
#endif
199
 
200
/* no typedef here because of const-pointer issues */
201
#define ucl_byte                unsigned char __UCL_MMODEL
202
#define ucl_bytep               unsigned char __UCL_MMODEL *
203
#define ucl_charp               char __UCL_MMODEL *
204
#define ucl_voidp               void __UCL_MMODEL *
205
#define ucl_shortp              short __UCL_MMODEL *
206
#define ucl_ushortp             unsigned short __UCL_MMODEL *
207
#define ucl_uint32p             ucl_uint32 __UCL_MMODEL *
208
#define ucl_int32p              ucl_int32 __UCL_MMODEL *
209
#define ucl_uintp               ucl_uint __UCL_MMODEL *
210
#define ucl_intp                ucl_int __UCL_MMODEL *
211
#define ucl_voidpp              ucl_voidp __UCL_MMODEL *
212
#define ucl_bytepp              ucl_bytep __UCL_MMODEL *
213
 
214
typedef int ucl_bool;
215
 
216
 
217
/***********************************************************************
218
// function types
219
************************************************************************/
220
 
221
/* linkage */
222
#if !defined(__UCL_EXTERN_C)
223
#  ifdef __cplusplus
224
#    define __UCL_EXTERN_C      extern "C"
225
#  else
226
#    define __UCL_EXTERN_C      extern
227
#  endif
228
#endif
229
 
230
/* calling conventions */
231
#if !defined(__UCL_CDECL)
232
#  if defined(__UCL_DOS16) || defined(__UCL_WIN16)
233
#    define __UCL_CDECL         __far __cdecl
234
#  elif defined(__UCL_i386) && defined(_MSC_VER)
235
#    define __UCL_CDECL         __cdecl
236
#  elif defined(__UCL_i386) && defined(__WATCOMC__)
237
#    define __UCL_CDECL         __near __cdecl
238
#  else
239
#    define __UCL_CDECL
240
#  endif
241
#endif
242
#if !defined(__UCL_ENTRY)
243
#  define __UCL_ENTRY           __UCL_CDECL
244
#endif
245
 
246
/* DLL export information */
247
#if !defined(__UCL_EXPORT1)
248
#  define __UCL_EXPORT1
249
#endif
250
#if !defined(__UCL_EXPORT2)
251
#  define __UCL_EXPORT2
252
#endif
253
 
254
/* calling convention for C functions */
255
#if !defined(UCL_PUBLIC)
256
#  define UCL_PUBLIC(_rettype)  __UCL_EXPORT1 _rettype __UCL_EXPORT2 __UCL_ENTRY
257
#endif
258
#if !defined(UCL_EXTERN)
259
#  define UCL_EXTERN(_rettype)  __UCL_EXTERN_C UCL_PUBLIC(_rettype)
260
#endif
261
#if !defined(UCL_PRIVATE)
262
#  define UCL_PRIVATE(_rettype) static _rettype __UCL_ENTRY
263
#endif
264
 
265
/* cdecl calling convention for assembler functions */
266
#if !defined(UCL_PUBLIC_CDECL)
267
#  define UCL_PUBLIC_CDECL(_rettype) \
268
                __UCL_EXPORT1 _rettype __UCL_EXPORT2 __UCL_CDECL
269
#endif
270
#if !defined(UCL_EXTERN_CDECL)
271
#  define UCL_EXTERN_CDECL(_rettype)  __UCL_EXTERN_C UCL_PUBLIC_CDECL(_rettype)
272
#endif
273
 
274
/* C++ exception specification for extern "C" function types */
275
#if !defined(__cplusplus)
276
#  undef UCL_NOTHROW
277
#  define UCL_NOTHROW
278
#elif !defined(UCL_NOTHROW)
279
#  define UCL_NOTHROW
280
#endif
281
 
282
 
283
typedef int
284
(__UCL_ENTRY *ucl_compress_t)   ( const ucl_bytep src, ucl_uint  src_len,
285
                                        ucl_bytep dst, ucl_uintp dst_len,
286
                                        ucl_voidp wrkmem );
287
 
288
typedef int
289
(__UCL_ENTRY *ucl_decompress_t) ( const ucl_bytep src, ucl_uint  src_len,
290
                                        ucl_bytep dst, ucl_uintp dst_len,
291
                                        ucl_voidp wrkmem );
292
 
293
typedef int
294
(__UCL_ENTRY *ucl_optimize_t)   (       ucl_bytep src, ucl_uint  src_len,
295
                                        ucl_bytep dst, ucl_uintp dst_len,
296
                                        ucl_voidp wrkmem );
297
 
298
typedef int
299
(__UCL_ENTRY *ucl_compress_dict_t)(const ucl_bytep src, ucl_uint  src_len,
300
                                        ucl_bytep dst, ucl_uintp dst_len,
301
                                        ucl_voidp wrkmem,
302
                                  const ucl_bytep dict, ucl_uint dict_len );
303
 
304
typedef int
305
(__UCL_ENTRY *ucl_decompress_dict_t)(const ucl_bytep src, ucl_uint  src_len,
306
                                        ucl_bytep dst, ucl_uintp dst_len,
307
                                        ucl_voidp wrkmem,
308
                                  const ucl_bytep dict, ucl_uint dict_len );
309
 
310
 
311
/* a progress indicator callback function */
312
typedef struct
313
{
314
    void (__UCL_ENTRY *callback) (ucl_uint, ucl_uint, int, ucl_voidp user);
315
    ucl_voidp user;
316
}
317
ucl_progress_callback_t;
318
#define ucl_progress_callback_p ucl_progress_callback_t __UCL_MMODEL *
319
 
320
 
321
/***********************************************************************
322
// error codes and prototypes
323
************************************************************************/
324
 
325
/* Error codes for the compression/decompression functions. Negative
326
 * values are errors, positive values will be used for special but
327
 * normal events.
328
 */
329
#define UCL_E_OK                    0
330
#define UCL_E_ERROR                 (-1)
331
#define UCL_E_INVALID_ARGUMENT      (-2)
332
#define UCL_E_OUT_OF_MEMORY         (-3)
333
/* compression errors */
334
#define UCL_E_NOT_COMPRESSIBLE      (-101)
335
/* decompression errors */
336
#define UCL_E_INPUT_OVERRUN         (-201)
337
#define UCL_E_OUTPUT_OVERRUN        (-202)
338
#define UCL_E_LOOKBEHIND_OVERRUN    (-203)
339
#define UCL_E_EOF_NOT_FOUND         (-204)
340
#define UCL_E_INPUT_NOT_CONSUMED    (-205)
341
#define UCL_E_OVERLAP_OVERRUN       (-206)
342
 
343
 
344
/* ucl_init() should be the first function you call.
345
 * Check the return code !
346
 *
347
 * ucl_init() is a macro to allow checking that the library and the
348
 * compiler's view of various types are consistent.
349
 */
350
#define ucl_init() __ucl_init2(UCL_VERSION,(int)sizeof(short),(int)sizeof(int),\
351
    (int)sizeof(long),(int)sizeof(ucl_uint32),(int)sizeof(ucl_uint),\
352
    (int)-1,(int)sizeof(char *),(int)sizeof(ucl_voidp),\
353
    (int)sizeof(ucl_compress_t))
354
UCL_EXTERN(int) __ucl_init2(ucl_uint32,int,int,int,int,int,int,int,int,int);
355
 
356
/* version functions (useful for shared libraries) */
357
UCL_EXTERN(ucl_uint32) ucl_version(void);
358
UCL_EXTERN(const char *) ucl_version_string(void);
359
UCL_EXTERN(const char *) ucl_version_date(void);
360
UCL_EXTERN(const ucl_charp) _ucl_version_string(void);
361
UCL_EXTERN(const ucl_charp) _ucl_version_date(void);
362
 
363
/* string functions */
364
UCL_EXTERN(int)
365
ucl_memcmp(const ucl_voidp _s1, const ucl_voidp _s2, ucl_uint _len);
366
UCL_EXTERN(ucl_voidp)
367
ucl_memcpy(ucl_voidp _dest, const ucl_voidp _src, ucl_uint _len);
368
UCL_EXTERN(ucl_voidp)
369
ucl_memmove(ucl_voidp _dest, const ucl_voidp _src, ucl_uint _len);
370
UCL_EXTERN(ucl_voidp)
371
ucl_memset(ucl_voidp _s, int _c, ucl_uint _len);
372
 
373
/* checksum functions */
374
UCL_EXTERN(ucl_uint32)
375
ucl_adler32(ucl_uint32 _adler, const ucl_bytep _buf, ucl_uint _len);
376
UCL_EXTERN(ucl_uint32)
377
ucl_crc32(ucl_uint32 _c, const ucl_bytep _buf, ucl_uint _len);
378
 
379
/* memory allocation functions */
380
UCL_EXTERN(ucl_voidp) ucl_alloc(ucl_uint _nelems, ucl_uint _size);
381
UCL_EXTERN(ucl_voidp) ucl_malloc(ucl_uint _size);
382
UCL_EXTERN(void) ucl_free(ucl_voidp _ptr);
383
 
384
typedef ucl_voidp (__UCL_ENTRY *ucl_alloc_hook_t) (ucl_uint, ucl_uint);
385
typedef void (__UCL_ENTRY *ucl_free_hook_t) (ucl_voidp);
386
 
387
extern ucl_alloc_hook_t ucl_alloc_hook;
388
extern ucl_free_hook_t ucl_free_hook;
389
 
390
/* misc. */
391
UCL_EXTERN(ucl_bool) ucl_assert(int _expr);
392
UCL_EXTERN(int) _ucl_config_check(void);
393
typedef union { ucl_bytep p; ucl_uint u; } __ucl_pu_u;
394
typedef union { ucl_bytep p; ucl_uint32 u32; } __ucl_pu32_u;
395
 
396
/* align a char pointer on a boundary that is a multiple of `size' */
397
UCL_EXTERN(unsigned) __ucl_align_gap(const ucl_voidp _ptr, ucl_uint _size);
398
#define UCL_PTR_ALIGN_UP(_ptr,_size) \
399
    ((_ptr) + (ucl_uint) __ucl_align_gap((const ucl_voidp)(_ptr),(ucl_uint)(_size)))
400
 
401
 
402
#ifdef __cplusplus
403
} /* extern "C" */
404
#endif
405
 
406
#endif /* already included */
407