lzoconf.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  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-2017 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 0x20a0 /* 2.10 */
  24. #define LZO_VERSION_STRING "2.10"
  25. #define LZO_VERSION_DATE "Mar 01 2017"
  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 <minilzo/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. # define LZO_TYPEOF_LZO_INT LZO_TYPEOF___INT64
  76. # else
  77. typedef lzo_ullong_t lzo_uint;
  78. typedef lzo_llong_t lzo_int;
  79. # define LZO_TYPEOF_LZO_INT LZO_TYPEOF_LONG_LONG
  80. # endif
  81. # define LZO_SIZEOF_LZO_INT 8
  82. # define LZO_UINT_MAX 0xffffffffffffffffull
  83. # define LZO_INT_MAX 9223372036854775807LL
  84. # define LZO_INT_MIN (-1LL - LZO_INT_MAX)
  85. # elif (LZO_ABI_IP32L64) /* MIPS R5900 */
  86. typedef unsigned int lzo_uint;
  87. typedef int lzo_int;
  88. # define LZO_SIZEOF_LZO_INT LZO_SIZEOF_INT
  89. # define LZO_TYPEOF_LZO_INT LZO_TYPEOF_INT
  90. # define LZO_UINT_MAX UINT_MAX
  91. # define LZO_INT_MAX INT_MAX
  92. # define LZO_INT_MIN INT_MIN
  93. # elif (ULONG_MAX >= LZO_0xffffffffL)
  94. typedef unsigned long lzo_uint;
  95. typedef long lzo_int;
  96. # define LZO_SIZEOF_LZO_INT LZO_SIZEOF_LONG
  97. # define LZO_TYPEOF_LZO_INT LZO_TYPEOF_LONG
  98. # define LZO_UINT_MAX ULONG_MAX
  99. # define LZO_INT_MAX LONG_MAX
  100. # define LZO_INT_MIN LONG_MIN
  101. # else
  102. # error "lzo_uint"
  103. # endif
  104. #endif
  105. /* The larger type of lzo_uint and lzo_uint32_t. */
  106. #if (LZO_SIZEOF_LZO_INT >= 4)
  107. # define lzo_xint lzo_uint
  108. #else
  109. # define lzo_xint lzo_uint32_t
  110. #endif
  111. typedef int lzo_bool;
  112. /* sanity checks */
  113. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int) == LZO_SIZEOF_LZO_INT)
  114. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == LZO_SIZEOF_LZO_INT)
  115. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_xint) >= sizeof(lzo_uint))
  116. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_xint) >= sizeof(lzo_uint32_t))
  117. #ifndef __LZO_MMODEL
  118. #define __LZO_MMODEL /*empty*/
  119. #endif
  120. /* no typedef here because of const-pointer issues */
  121. #define lzo_bytep unsigned char __LZO_MMODEL *
  122. #define lzo_charp char __LZO_MMODEL *
  123. #define lzo_voidp void __LZO_MMODEL *
  124. #define lzo_shortp short __LZO_MMODEL *
  125. #define lzo_ushortp unsigned short __LZO_MMODEL *
  126. #define lzo_intp lzo_int __LZO_MMODEL *
  127. #define lzo_uintp lzo_uint __LZO_MMODEL *
  128. #define lzo_xintp lzo_xint __LZO_MMODEL *
  129. #define lzo_voidpp lzo_voidp __LZO_MMODEL *
  130. #define lzo_bytepp lzo_bytep __LZO_MMODEL *
  131. #define lzo_int8_tp lzo_int8_t __LZO_MMODEL *
  132. #define lzo_uint8_tp lzo_uint8_t __LZO_MMODEL *
  133. #define lzo_int16_tp lzo_int16_t __LZO_MMODEL *
  134. #define lzo_uint16_tp lzo_uint16_t __LZO_MMODEL *
  135. #define lzo_int32_tp lzo_int32_t __LZO_MMODEL *
  136. #define lzo_uint32_tp lzo_uint32_t __LZO_MMODEL *
  137. #if defined(lzo_int64_t)
  138. #define lzo_int64_tp lzo_int64_t __LZO_MMODEL *
  139. #define lzo_uint64_tp lzo_uint64_t __LZO_MMODEL *
  140. #endif
  141. /* Older LZO versions used to support ancient systems and memory models
  142. * such as 16-bit MSDOS with __huge pointers or Cray PVP, but these
  143. * obsolete configurations are not supported any longer.
  144. */
  145. #if defined(__LZO_MMODEL_HUGE)
  146. #error "__LZO_MMODEL_HUGE memory model is unsupported"
  147. #endif
  148. #if (LZO_MM_PVP)
  149. #error "LZO_MM_PVP memory model is unsupported"
  150. #endif
  151. #if (LZO_SIZEOF_INT < 4)
  152. #error "LZO_SIZEOF_INT < 4 is unsupported"
  153. #endif
  154. #if (__LZO_UINTPTR_T_IS_POINTER)
  155. #error "__LZO_UINTPTR_T_IS_POINTER is unsupported"
  156. #endif
  157. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) >= 4)
  158. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) >= 4)
  159. /* Strange configurations where sizeof(lzo_uint) != sizeof(size_t) should
  160. * work but have not received much testing lately, so be strict here.
  161. */
  162. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(size_t))
  163. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(ptrdiff_t))
  164. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(lzo_uintptr_t))
  165. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(void *) == sizeof(lzo_uintptr_t))
  166. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(char *) == sizeof(lzo_uintptr_t))
  167. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long *) == sizeof(lzo_uintptr_t))
  168. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(void *) == sizeof(lzo_voidp))
  169. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(char *) == sizeof(lzo_bytep))
  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(r) __LZO_EXPORT1 r __LZO_EXPORT2 __LZO_CDECL
  195. #endif
  196. #if !defined(LZO_EXTERN)
  197. # define LZO_EXTERN(r) __LZO_EXTERN_C LZO_PUBLIC(r)
  198. #endif
  199. #if !defined(LZO_PRIVATE)
  200. # define LZO_PRIVATE(r) static r __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. /* INFO: 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) /* [lzo_alloc_func_t failure] */
  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. #define LZO_E_INVALID_ARGUMENT (-10)
  270. #define LZO_E_INVALID_ALIGNMENT (-11) /* pointer argument is not properly aligned */
  271. #define LZO_E_OUTPUT_NOT_CONSUMED (-12)
  272. #define LZO_E_INTERNAL_ERROR (-99)
  273. #ifndef lzo_sizeof_dict_t
  274. # define lzo_sizeof_dict_t ((unsigned)sizeof(lzo_bytep))
  275. #endif
  276. /* lzo_init() should be the first function you call.
  277. * Check the return code !
  278. *
  279. * lzo_init() is a macro to allow checking that the library and the
  280. * compiler's view of various types are consistent.
  281. */
  282. #define lzo_init() __lzo_init_v2(LZO_VERSION,(int)sizeof(short),(int)sizeof(int),\
  283. (int)sizeof(long),(int)sizeof(lzo_uint32_t),(int)sizeof(lzo_uint),\
  284. (int)lzo_sizeof_dict_t,(int)sizeof(char *),(int)sizeof(lzo_voidp),\
  285. (int)sizeof(lzo_callback_t))
  286. LZO_EXTERN(int) __lzo_init_v2(unsigned,int,int,int,int,int,int,int,int,int);
  287. /* version functions (useful for shared libraries) */
  288. LZO_EXTERN(unsigned) lzo_version(void);
  289. LZO_EXTERN(const char *) lzo_version_string(void);
  290. LZO_EXTERN(const char *) lzo_version_date(void);
  291. LZO_EXTERN(const lzo_charp) _lzo_version_string(void);
  292. LZO_EXTERN(const lzo_charp) _lzo_version_date(void);
  293. /* string functions */
  294. LZO_EXTERN(int)
  295. lzo_memcmp(const lzo_voidp a, const lzo_voidp b, lzo_uint len);
  296. LZO_EXTERN(lzo_voidp)
  297. lzo_memcpy(lzo_voidp dst, const lzo_voidp src, lzo_uint len);
  298. LZO_EXTERN(lzo_voidp)
  299. lzo_memmove(lzo_voidp dst, const lzo_voidp src, lzo_uint len);
  300. LZO_EXTERN(lzo_voidp)
  301. lzo_memset(lzo_voidp buf, int c, lzo_uint len);
  302. /* checksum functions */
  303. LZO_EXTERN(lzo_uint32_t)
  304. lzo_adler32(lzo_uint32_t c, const lzo_bytep buf, lzo_uint len);
  305. LZO_EXTERN(lzo_uint32_t)
  306. lzo_crc32(lzo_uint32_t c, const lzo_bytep buf, lzo_uint len);
  307. LZO_EXTERN(const lzo_uint32_tp)
  308. lzo_get_crc32_table(void);
  309. /* misc. */
  310. LZO_EXTERN(int) _lzo_config_check(void);
  311. typedef union {
  312. lzo_voidp a00; lzo_bytep a01; lzo_uint a02; lzo_xint a03; lzo_uintptr_t a04;
  313. void *a05; unsigned char *a06; unsigned long a07; size_t a08; ptrdiff_t a09;
  314. #if defined(lzo_int64_t)
  315. lzo_uint64_t a10;
  316. #endif
  317. } lzo_align_t;
  318. /* align a char pointer on a boundary that is a multiple of 'size' */
  319. LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp p, lzo_uint size);
  320. #define LZO_PTR_ALIGN_UP(p,size) \
  321. ((p) + (lzo_uint) __lzo_align_gap((const lzo_voidp)(p),(lzo_uint)(size)))
  322. /***********************************************************************
  323. // deprecated macros - only for backward compatibility
  324. ************************************************************************/
  325. /* deprecated - use 'lzo_bytep' instead of 'lzo_byte *' */
  326. #define lzo_byte unsigned char
  327. /* deprecated type names */
  328. #define lzo_int32 lzo_int32_t
  329. #define lzo_uint32 lzo_uint32_t
  330. #define lzo_int32p lzo_int32_t __LZO_MMODEL *
  331. #define lzo_uint32p lzo_uint32_t __LZO_MMODEL *
  332. #define LZO_INT32_MAX LZO_INT32_C(2147483647)
  333. #define LZO_UINT32_MAX LZO_UINT32_C(4294967295)
  334. #if defined(lzo_int64_t)
  335. #define lzo_int64 lzo_int64_t
  336. #define lzo_uint64 lzo_uint64_t
  337. #define lzo_int64p lzo_int64_t __LZO_MMODEL *
  338. #define lzo_uint64p lzo_uint64_t __LZO_MMODEL *
  339. #define LZO_INT64_MAX LZO_INT64_C(9223372036854775807)
  340. #define LZO_UINT64_MAX LZO_UINT64_C(18446744073709551615)
  341. #endif
  342. /* deprecated types */
  343. typedef union { lzo_bytep a; lzo_uint b; } __lzo_pu_u;
  344. typedef union { lzo_bytep a; lzo_uint32_t b; } __lzo_pu32_u;
  345. /* deprecated defines */
  346. #if !defined(LZO_SIZEOF_LZO_UINT)
  347. # define LZO_SIZEOF_LZO_UINT LZO_SIZEOF_LZO_INT
  348. #endif
  349. #if defined(LZO_CFG_COMPAT)
  350. #define __LZOCONF_H 1
  351. #if defined(LZO_ARCH_I086)
  352. # define __LZO_i386 1
  353. #elif defined(LZO_ARCH_I386)
  354. # define __LZO_i386 1
  355. #endif
  356. #if defined(LZO_OS_DOS16)
  357. # define __LZO_DOS 1
  358. # define __LZO_DOS16 1
  359. #elif defined(LZO_OS_DOS32)
  360. # define __LZO_DOS 1
  361. #elif defined(LZO_OS_WIN16)
  362. # define __LZO_WIN 1
  363. # define __LZO_WIN16 1
  364. #elif defined(LZO_OS_WIN32)
  365. # define __LZO_WIN 1
  366. #endif
  367. #define __LZO_CMODEL /*empty*/
  368. #define __LZO_DMODEL /*empty*/
  369. #define __LZO_ENTRY __LZO_CDECL
  370. #define LZO_EXTERN_CDECL LZO_EXTERN
  371. #define LZO_ALIGN LZO_PTR_ALIGN_UP
  372. #define lzo_compress_asm_t lzo_compress_t
  373. #define lzo_decompress_asm_t lzo_decompress_t
  374. #endif /* LZO_CFG_COMPAT */
  375. #ifdef __cplusplus
  376. } /* extern "C" */
  377. #endif
  378. #endif /* already included */
  379. /* vim:set ts=4 sw=4 et: */