lzoconf.h 15 KB

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