1 /* uclconf.h -- configuration for the UCL real-time data compression library
3 This file is part of the UCL data compression library.
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
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.
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.
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.
29 Markus F.X.J. Oberhumer
30 <markus@oberhumer.com>
31 http://www.oberhumer.com/opensource/ucl/
38 #define UCL_VERSION 0x010100L
39 #define UCL_VERSION_STRING "1.01"
40 #define UCL_VERSION_DATE "Jan 02 2002"
42 /* internal Autoconf configuration file - only used when building UCL */
43 #if defined(UCL_HAVE_CONFIG_H)
53 /***********************************************************************
54 // UCL requires a conforming <limits.h>
55 ************************************************************************/
57 #if !defined(CHAR_BIT) || (CHAR_BIT != 8)
58 # error "invalid CHAR_BIT"
60 #if !defined(UCHAR_MAX) || !defined(UINT_MAX) || !defined(ULONG_MAX)
61 # error "check your compiler installation"
63 #if (USHRT_MAX < 1) || (UINT_MAX < 1) || (ULONG_MAX < 1)
64 # error "your limits.h macros are broken"
67 /* workaround a compiler bug under hpux 10.20 */
68 #define UCL_0xffffffffL 4294967295ul
70 #if !defined(UCL_UINT32_C)
71 # if (UINT_MAX < UCL_0xffffffffL)
72 # define UCL_UINT32_C(c) c ## UL
74 # define UCL_UINT32_C(c) c ## U
79 /***********************************************************************
80 // architecture defines
81 ************************************************************************/
83 #if !defined(__UCL_WIN) && !defined(__UCL_DOS) && !defined(__UCL_OS2)
84 # if defined(__WINDOWS__) || defined(_WINDOWS) || defined(_Windows)
86 # elif defined(__WIN32__) || defined(_WIN32) || defined(WIN32)
88 # elif defined(__NT__) || defined(__NT_DLL__) || defined(__WINDOWS_386__)
90 # elif defined(__DOS__) || defined(__MSDOS__) || defined(MSDOS)
92 # elif defined(__OS2__) || defined(__OS2V2__) || defined(OS2)
94 # elif defined(__palmos__)
96 # elif defined(__TOS__) || defined(__atarist__)
101 #if (UINT_MAX < UCL_0xffffffffL)
102 # if defined(__UCL_WIN)
104 # elif defined(__UCL_DOS)
106 # elif defined(__UCL_PALMOS)
107 # define __UCL_PALMOS16
108 # elif defined(__UCL_TOS)
110 # elif defined(__C166__)
112 # error "16-bit target not supported - contact me for porting hints"
116 #if !defined(__UCL_i386)
117 # if defined(__UCL_DOS) || defined(__UCL_WIN16)
119 # elif defined(__i386__) || defined(__386__) || defined(_M_IX86)
124 #if defined(__UCL_STRICT_16BIT)
125 # if (UINT_MAX < UCL_0xffffffffL)
126 # include <ucl/ucl16bit.h>
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
144 /***********************************************************************
145 // integral and pointer types
146 ************************************************************************/
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
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
;
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
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
196 # error "__UCL_MMODEL"
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 *
214 typedef int ucl_bool
;
217 /***********************************************************************
219 ************************************************************************/
222 #if !defined(__UCL_EXTERN_C)
224 # define __UCL_EXTERN_C extern "C"
226 # define __UCL_EXTERN_C extern
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
242 #if !defined(__UCL_ENTRY)
243 # define __UCL_ENTRY __UCL_CDECL
246 /* DLL export information */
247 #if !defined(__UCL_EXPORT1)
248 # define __UCL_EXPORT1
250 #if !defined(__UCL_EXPORT2)
251 # define __UCL_EXPORT2
254 /* calling convention for C functions */
255 #if !defined(UCL_PUBLIC)
256 # define UCL_PUBLIC(_rettype) __UCL_EXPORT1 _rettype __UCL_EXPORT2 __UCL_ENTRY
258 #if !defined(UCL_EXTERN)
259 # define UCL_EXTERN(_rettype) __UCL_EXTERN_C UCL_PUBLIC(_rettype)
261 #if !defined(UCL_PRIVATE)
262 # define UCL_PRIVATE(_rettype) static _rettype __UCL_ENTRY
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
270 #if !defined(UCL_EXTERN_CDECL)
271 # define UCL_EXTERN_CDECL(_rettype) __UCL_EXTERN_C UCL_PUBLIC_CDECL(_rettype)
274 /* C++ exception specification for extern "C" function types */
275 #if !defined(__cplusplus)
278 #elif !defined(UCL_NOTHROW)
284 (__UCL_ENTRY
*ucl_compress_t
) ( const ucl_bytep src
, ucl_uint src_len
,
285 ucl_bytep dst
, ucl_uintp dst_len
,
289 (__UCL_ENTRY
*ucl_decompress_t
) ( const ucl_bytep src
, ucl_uint src_len
,
290 ucl_bytep dst
, ucl_uintp dst_len
,
294 (__UCL_ENTRY
*ucl_optimize_t
) ( ucl_bytep src
, ucl_uint src_len
,
295 ucl_bytep dst
, ucl_uintp dst_len
,
299 (__UCL_ENTRY
*ucl_compress_dict_t
)(const ucl_bytep src
, ucl_uint src_len
,
300 ucl_bytep dst
, ucl_uintp dst_len
,
302 const ucl_bytep dict
, ucl_uint dict_len
);
305 (__UCL_ENTRY
*ucl_decompress_dict_t
)(const ucl_bytep src
, ucl_uint src_len
,
306 ucl_bytep dst
, ucl_uintp dst_len
,
308 const ucl_bytep dict
, ucl_uint dict_len
);
311 /* a progress indicator callback function */
314 void (__UCL_ENTRY
*callback
) (ucl_uint
, ucl_uint
, int, ucl_voidp user
);
317 ucl_progress_callback_t
;
318 #define ucl_progress_callback_p ucl_progress_callback_t __UCL_MMODEL *
321 /***********************************************************************
322 // error codes and prototypes
323 ************************************************************************/
325 /* Error codes for the compression/decompression functions. Negative
326 * values are errors, positive values will be used for special but
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)
344 /* ucl_init() should be the first function you call.
345 * Check the return code !
347 * ucl_init() is a macro to allow checking that the library and the
348 * compiler's view of various types are consistent.
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);
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);
363 /* string functions */
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
);
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
);
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
);
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
);
387 extern ucl_alloc_hook_t ucl_alloc_hook
;
388 extern ucl_free_hook_t ucl_free_hook
;
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
;
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)))
406 #endif /* already included */