uclconf.h 13 KB

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