lzoconf.h 15 KB

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