lzoconf.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  1. /* lzoconf.h -- configuration for the LZO real-time data compression library
  2. This file is part of the LZO real-time data compression library.
  3. Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer
  4. Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer
  5. Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer
  6. Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer
  7. Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer
  8. Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer
  9. Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer
  10. Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer
  11. Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
  12. Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
  13. Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
  14. Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
  15. Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
  16. Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
  17. Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
  18. All Rights Reserved.
  19. The LZO library is free software; you can redistribute it and/or
  20. modify it under the terms of the GNU General Public License as
  21. published by the Free Software Foundation; either version 2 of
  22. the License, or (at your option) any later version.
  23. The LZO library is distributed in the hope that it will be useful,
  24. but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  26. GNU General Public License for more details.
  27. You should have received a copy of the GNU General Public License
  28. along with the LZO library; see the file COPYING.
  29. If not, write to the Free Software Foundation, Inc.,
  30. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  31. Markus F.X.J. Oberhumer
  32. <markus@oberhumer.com>
  33. http://www.oberhumer.com/opensource/lzo/
  34. */
  35. #ifndef __LZOCONF_H_INCLUDED
  36. #define __LZOCONF_H_INCLUDED 1
  37. #define LZO_VERSION 0x2040
  38. #define LZO_VERSION_STRING "2.04"
  39. #define LZO_VERSION_DATE "Oct 31 2010"
  40. /* internal Autoconf configuration file - only used when building LZO */
  41. #if defined(LZO_HAVE_CONFIG_H)
  42. # include <config.h>
  43. #endif
  44. #include <limits.h>
  45. #include <stddef.h>
  46. /***********************************************************************
  47. // LZO requires a conforming <limits.h>
  48. ************************************************************************/
  49. #if !defined(CHAR_BIT) || (CHAR_BIT != 8)
  50. # error "invalid CHAR_BIT"
  51. #endif
  52. #if !defined(UCHAR_MAX) || !defined(UINT_MAX) || !defined(ULONG_MAX)
  53. # error "check your compiler installation"
  54. #endif
  55. #if (USHRT_MAX < 1) || (UINT_MAX < 1) || (ULONG_MAX < 1)
  56. # error "your limits.h macros are broken"
  57. #endif
  58. /* get OS and architecture defines */
  59. #ifndef __LZODEFS_H_INCLUDED
  60. #include "lzodefs.h"
  61. #endif
  62. #ifdef __cplusplus
  63. extern "C" {
  64. #endif
  65. /***********************************************************************
  66. // some core defines
  67. ************************************************************************/
  68. #if !defined(LZO_UINT32_C)
  69. # if (UINT_MAX < LZO_0xffffffffL)
  70. # define LZO_UINT32_C(c) c ## UL
  71. # else
  72. # define LZO_UINT32_C(c) ((c) + 0U)
  73. # endif
  74. #endif
  75. /* memory checkers */
  76. #if !defined(__LZO_CHECKER)
  77. # if defined(__BOUNDS_CHECKING_ON)
  78. # define __LZO_CHECKER 1
  79. # elif defined(__CHECKER__)
  80. # define __LZO_CHECKER 1
  81. # elif defined(__INSURE__)
  82. # define __LZO_CHECKER 1
  83. # elif defined(__PURIFY__)
  84. # define __LZO_CHECKER 1
  85. # endif
  86. #endif
  87. /***********************************************************************
  88. // integral and pointer types
  89. ************************************************************************/
  90. /* lzo_uint should match size_t */
  91. #if !defined(LZO_UINT_MAX)
  92. # if defined(LZO_ABI_LLP64) /* WIN64 */
  93. # if defined(LZO_OS_WIN64)
  94. typedef unsigned __int64 lzo_uint;
  95. typedef __int64 lzo_int;
  96. # else
  97. typedef unsigned long long lzo_uint;
  98. typedef long long lzo_int;
  99. # endif
  100. # define LZO_UINT_MAX 0xffffffffffffffffull
  101. # define LZO_INT_MAX 9223372036854775807LL
  102. # define LZO_INT_MIN (-1LL - LZO_INT_MAX)
  103. # elif defined(LZO_ABI_IP32L64) /* MIPS R5900 */
  104. typedef unsigned int lzo_uint;
  105. typedef int lzo_int;
  106. # define LZO_UINT_MAX UINT_MAX
  107. # define LZO_INT_MAX INT_MAX
  108. # define LZO_INT_MIN INT_MIN
  109. # elif (ULONG_MAX >= LZO_0xffffffffL)
  110. typedef unsigned long lzo_uint;
  111. typedef long lzo_int;
  112. # define LZO_UINT_MAX ULONG_MAX
  113. # define LZO_INT_MAX LONG_MAX
  114. # define LZO_INT_MIN LONG_MIN
  115. # else
  116. # error "lzo_uint"
  117. # endif
  118. #endif
  119. /* Integral types with 32 bits or more. */
  120. #if !defined(LZO_UINT32_MAX)
  121. # if (UINT_MAX >= LZO_0xffffffffL)
  122. typedef unsigned int lzo_uint32;
  123. typedef int lzo_int32;
  124. # define LZO_UINT32_MAX UINT_MAX
  125. # define LZO_INT32_MAX INT_MAX
  126. # define LZO_INT32_MIN INT_MIN
  127. # elif (ULONG_MAX >= LZO_0xffffffffL)
  128. typedef unsigned long lzo_uint32;
  129. typedef long lzo_int32;
  130. # define LZO_UINT32_MAX ULONG_MAX
  131. # define LZO_INT32_MAX LONG_MAX
  132. # define LZO_INT32_MIN LONG_MIN
  133. # else
  134. # error "lzo_uint32"
  135. # endif
  136. #endif
  137. /* The larger type of lzo_uint and lzo_uint32. */
  138. #if (LZO_UINT_MAX >= LZO_UINT32_MAX)
  139. # define lzo_xint lzo_uint
  140. #else
  141. # define lzo_xint lzo_uint32
  142. #endif
  143. /* Memory model that allows to access memory at offsets of lzo_uint. */
  144. #if !defined(__LZO_MMODEL)
  145. # if (LZO_UINT_MAX <= UINT_MAX)
  146. # define __LZO_MMODEL /*empty*/
  147. # elif defined(LZO_HAVE_MM_HUGE_PTR)
  148. # define __LZO_MMODEL_HUGE 1
  149. # define __LZO_MMODEL __huge
  150. # else
  151. # define __LZO_MMODEL /*empty*/
  152. # endif
  153. #endif
  154. /* no typedef here because of const-pointer issues */
  155. #define lzo_bytep unsigned char __LZO_MMODEL *
  156. #define lzo_charp char __LZO_MMODEL *
  157. #define lzo_voidp void __LZO_MMODEL *
  158. #define lzo_shortp short __LZO_MMODEL *
  159. #define lzo_ushortp unsigned short __LZO_MMODEL *
  160. #define lzo_uint32p lzo_uint32 __LZO_MMODEL *
  161. #define lzo_int32p lzo_int32 __LZO_MMODEL *
  162. #define lzo_uintp lzo_uint __LZO_MMODEL *
  163. #define lzo_intp lzo_int __LZO_MMODEL *
  164. #define lzo_xintp lzo_xint __LZO_MMODEL *
  165. #define lzo_voidpp lzo_voidp __LZO_MMODEL *
  166. #define lzo_bytepp lzo_bytep __LZO_MMODEL *
  167. /* deprecated - use 'lzo_bytep' instead of 'lzo_byte *' */
  168. #define lzo_byte unsigned char __LZO_MMODEL
  169. typedef int lzo_bool;
  170. /***********************************************************************
  171. // function types
  172. ************************************************************************/
  173. /* name mangling */
  174. #if !defined(__LZO_EXTERN_C)
  175. # ifdef __cplusplus
  176. # define __LZO_EXTERN_C extern "C"
  177. # else
  178. # define __LZO_EXTERN_C extern
  179. # endif
  180. #endif
  181. /* calling convention */
  182. #if !defined(__LZO_CDECL)
  183. # define __LZO_CDECL __lzo_cdecl
  184. #endif
  185. /* DLL export information */
  186. #if !defined(__LZO_EXPORT1)
  187. # define __LZO_EXPORT1 /*empty*/
  188. #endif
  189. #if !defined(__LZO_EXPORT2)
  190. # define __LZO_EXPORT2 /*empty*/
  191. #endif
  192. /* __cdecl calling convention for public C and assembly functions */
  193. #if !defined(LZO_PUBLIC)
  194. # define LZO_PUBLIC(_rettype) __LZO_EXPORT1 _rettype __LZO_EXPORT2 __LZO_CDECL
  195. #endif
  196. #if !defined(LZO_EXTERN)
  197. # define LZO_EXTERN(_rettype) __LZO_EXTERN_C LZO_PUBLIC(_rettype)
  198. #endif
  199. #if !defined(LZO_PRIVATE)
  200. # define LZO_PRIVATE(_rettype) static _rettype __LZO_CDECL
  201. #endif
  202. /* function types */
  203. typedef int
  204. (__LZO_CDECL *lzo_compress_t) ( const lzo_bytep src, lzo_uint src_len,
  205. lzo_bytep dst, lzo_uintp dst_len,
  206. lzo_voidp wrkmem );
  207. typedef int
  208. (__LZO_CDECL *lzo_decompress_t) ( const lzo_bytep src, lzo_uint src_len,
  209. lzo_bytep dst, lzo_uintp dst_len,
  210. lzo_voidp wrkmem );
  211. typedef int
  212. (__LZO_CDECL *lzo_optimize_t) ( lzo_bytep src, lzo_uint src_len,
  213. lzo_bytep dst, lzo_uintp dst_len,
  214. lzo_voidp wrkmem );
  215. typedef int
  216. (__LZO_CDECL *lzo_compress_dict_t)(const lzo_bytep src, lzo_uint src_len,
  217. lzo_bytep dst, lzo_uintp dst_len,
  218. lzo_voidp wrkmem,
  219. const lzo_bytep dict, lzo_uint dict_len );
  220. typedef int
  221. (__LZO_CDECL *lzo_decompress_dict_t)(const lzo_bytep src, lzo_uint src_len,
  222. lzo_bytep dst, lzo_uintp dst_len,
  223. lzo_voidp wrkmem,
  224. const lzo_bytep dict, lzo_uint dict_len );
  225. /* Callback interface. Currently only the progress indicator ("nprogress")
  226. * is used, but this may change in a future release. */
  227. struct lzo_callback_t;
  228. typedef struct lzo_callback_t lzo_callback_t;
  229. #define lzo_callback_p lzo_callback_t __LZO_MMODEL *
  230. /* malloc & free function types */
  231. typedef lzo_voidp (__LZO_CDECL *lzo_alloc_func_t)
  232. (lzo_callback_p self, lzo_uint items, lzo_uint size);
  233. typedef void (__LZO_CDECL *lzo_free_func_t)
  234. (lzo_callback_p self, lzo_voidp ptr);
  235. /* a progress indicator callback function */
  236. typedef void (__LZO_CDECL *lzo_progress_func_t)
  237. (lzo_callback_p, lzo_uint, lzo_uint, int);
  238. struct lzo_callback_t
  239. {
  240. /* custom allocators (set to 0 to disable) */
  241. lzo_alloc_func_t nalloc; /* [not used right now] */
  242. lzo_free_func_t nfree; /* [not used right now] */
  243. /* a progress indicator callback function (set to 0 to disable) */
  244. lzo_progress_func_t nprogress;
  245. /* NOTE: the first parameter "self" of the nalloc/nfree/nprogress
  246. * callbacks points back to this struct, so you are free to store
  247. * some extra info in the following variables. */
  248. lzo_voidp user1;
  249. lzo_xint user2;
  250. lzo_xint user3;
  251. };
  252. /***********************************************************************
  253. // error codes and prototypes
  254. ************************************************************************/
  255. /* Error codes for the compression/decompression functions. Negative
  256. * values are errors, positive values will be used for special but
  257. * normal events.
  258. */
  259. #define LZO_E_OK 0
  260. #define LZO_E_ERROR (-1)
  261. #define LZO_E_OUT_OF_MEMORY (-2) /* [not used right now] */
  262. #define LZO_E_NOT_COMPRESSIBLE (-3) /* [not used right now] */
  263. #define LZO_E_INPUT_OVERRUN (-4)
  264. #define LZO_E_OUTPUT_OVERRUN (-5)
  265. #define LZO_E_LOOKBEHIND_OVERRUN (-6)
  266. #define LZO_E_EOF_NOT_FOUND (-7)
  267. #define LZO_E_INPUT_NOT_CONSUMED (-8)
  268. #define LZO_E_NOT_YET_IMPLEMENTED (-9) /* [not used right now] */
  269. #ifndef lzo_sizeof_dict_t
  270. # define lzo_sizeof_dict_t ((unsigned)sizeof(lzo_bytep))
  271. #endif
  272. /* lzo_init() should be the first function you call.
  273. * Check the return code !
  274. *
  275. * lzo_init() is a macro to allow checking that the library and the
  276. * compiler's view of various types are consistent.
  277. */
  278. #define lzo_init() __lzo_init_v2(LZO_VERSION,(int)sizeof(short),(int)sizeof(int),\
  279. (int)sizeof(long),(int)sizeof(lzo_uint32),(int)sizeof(lzo_uint),\
  280. (int)lzo_sizeof_dict_t,(int)sizeof(char *),(int)sizeof(lzo_voidp),\
  281. (int)sizeof(lzo_callback_t))
  282. LZO_EXTERN(int) __lzo_init_v2(unsigned,int,int,int,int,int,int,int,int,int);
  283. /* version functions (useful for shared libraries) */
  284. LZO_EXTERN(unsigned) lzo_version(void);
  285. LZO_EXTERN(const char *) lzo_version_string(void);
  286. LZO_EXTERN(const char *) lzo_version_date(void);
  287. LZO_EXTERN(const lzo_charp) _lzo_version_string(void);
  288. LZO_EXTERN(const lzo_charp) _lzo_version_date(void);
  289. /* string functions */
  290. LZO_EXTERN(int)
  291. lzo_memcmp(const lzo_voidp a, const lzo_voidp b, lzo_uint len);
  292. LZO_EXTERN(lzo_voidp)
  293. lzo_memcpy(lzo_voidp dst, const lzo_voidp src, lzo_uint len);
  294. LZO_EXTERN(lzo_voidp)
  295. lzo_memmove(lzo_voidp dst, const lzo_voidp src, lzo_uint len);
  296. LZO_EXTERN(lzo_voidp)
  297. lzo_memset(lzo_voidp buf, int c, lzo_uint len);
  298. /* checksum functions */
  299. LZO_EXTERN(lzo_uint32)
  300. lzo_adler32(lzo_uint32 c, const lzo_bytep buf, lzo_uint len);
  301. LZO_EXTERN(lzo_uint32)
  302. lzo_crc32(lzo_uint32 c, const lzo_bytep buf, lzo_uint len);
  303. LZO_EXTERN(const lzo_uint32p)
  304. lzo_get_crc32_table(void);
  305. /* misc. */
  306. LZO_EXTERN(int) _lzo_config_check(void);
  307. typedef union { lzo_bytep p; lzo_uint u; } __lzo_pu_u;
  308. typedef union { lzo_bytep p; lzo_uint32 u32; } __lzo_pu32_u;
  309. typedef union { void *vp; lzo_bytep bp; lzo_uint u; lzo_uint32 u32; unsigned long l; } lzo_align_t;
  310. /* align a char pointer on a boundary that is a multiple of 'size' */
  311. LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp p, lzo_uint size);
  312. #define LZO_PTR_ALIGN_UP(p,size) \
  313. ((p) + (lzo_uint) __lzo_align_gap((const lzo_voidp)(p),(lzo_uint)(size)))
  314. /***********************************************************************
  315. // deprecated macros - only for backward compatibility with LZO v1.xx
  316. ************************************************************************/
  317. #if defined(LZO_CFG_COMPAT)
  318. #define __LZOCONF_H 1
  319. #if defined(LZO_ARCH_I086)
  320. # define __LZO_i386 1
  321. #elif defined(LZO_ARCH_I386)
  322. # define __LZO_i386 1
  323. #endif
  324. #if defined(LZO_OS_DOS16)
  325. # define __LZO_DOS 1
  326. # define __LZO_DOS16 1
  327. #elif defined(LZO_OS_DOS32)
  328. # define __LZO_DOS 1
  329. #elif defined(LZO_OS_WIN16)
  330. # define __LZO_WIN 1
  331. # define __LZO_WIN16 1
  332. #elif defined(LZO_OS_WIN32)
  333. # define __LZO_WIN 1
  334. #endif
  335. #define __LZO_CMODEL /*empty*/
  336. #define __LZO_DMODEL /*empty*/
  337. #define __LZO_ENTRY __LZO_CDECL
  338. #define LZO_EXTERN_CDECL LZO_EXTERN
  339. #define LZO_ALIGN LZO_PTR_ALIGN_UP
  340. #define lzo_compress_asm_t lzo_compress_t
  341. #define lzo_decompress_asm_t lzo_decompress_t
  342. #endif /* LZO_CFG_COMPAT */
  343. #ifdef __cplusplus
  344. } /* extern "C" */
  345. #endif
  346. #endif /* already included */
  347. /* vim:set ts=4 et: */