src/lzoconf.h
changeset 5475 2e6990a8c7c4
parent 4432 372316ca7924
child 6201 bee01dc45e39
equal deleted inserted replaced
5474:ac55aefc54f3 5475:2e6990a8c7c4
       
     1 /* $Id$ */
       
     2 
       
     3 /* lzoconf.h -- configuration for the LZO real-time data compression library
       
     4 
       
     5    This file is part of the LZO real-time data compression library.
       
     6 
       
     7    Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
       
     8    Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
       
     9    Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
       
    10    Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
       
    11    Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
       
    12    Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
       
    13    Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
       
    14    All Rights Reserved.
       
    15 
       
    16    The LZO library is free software; you can redistribute it and/or
       
    17    modify it under the terms of the GNU General Public License as
       
    18    published by the Free Software Foundation; either version 2 of
       
    19    the License, or (at your option) any later version.
       
    20 
       
    21    The LZO library is distributed in the hope that it will be useful,
       
    22    but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    23    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    24    GNU General Public License for more details.
       
    25 
       
    26    You should have received a copy of the GNU General Public License
       
    27    along with the LZO library; see the file COPYING.
       
    28    If not, write to the Free Software Foundation, Inc.,
       
    29    59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
       
    30 
       
    31    Markus F.X.J. Oberhumer
       
    32    <markus@oberhumer.com>
       
    33    http://www.oberhumer.com/opensource/lzo/
       
    34  */
       
    35 
       
    36 
       
    37 #ifndef LZOCONF_H
       
    38 #define LZOCONF_H
       
    39 
       
    40 #define LZO_VERSION             0x1080
       
    41 #define LZO_VERSION_STRING      "1.08"
       
    42 #define LZO_VERSION_DATE        "Jul 12 2002"
       
    43 
       
    44 /* internal Autoconf configuration file - only used when building LZO */
       
    45 #if defined(LZO_HAVE_CONFIG_H)
       
    46 #  include <config.h>
       
    47 #endif
       
    48 #include <limits.h>
       
    49 
       
    50 #ifdef __cplusplus
       
    51 extern "C" {
       
    52 #endif
       
    53 
       
    54 
       
    55 /***********************************************************************
       
    56  * LZO requires a conforming <limits.h>
       
    57  ***********************************************************************/
       
    58 
       
    59 #if !defined(CHAR_BIT) || (CHAR_BIT != 8)
       
    60 #  error "invalid CHAR_BIT"
       
    61 #endif
       
    62 #if !defined(UCHAR_MAX) || !defined(UINT_MAX) || !defined(ULONG_MAX)
       
    63 #  error "check your compiler installation"
       
    64 #endif
       
    65 #if (USHRT_MAX < 1) || (UINT_MAX < 1) || (ULONG_MAX < 1)
       
    66 #  error "your limits.h macros are broken"
       
    67 #endif
       
    68 
       
    69 /* workaround a cpp bug under hpux 10.20 */
       
    70 #define LZO_0xffffffffL         4294967295ul
       
    71 
       
    72 #if !defined(LZO_UINT32_C)
       
    73 #  if (UINT_MAX < LZO_0xffffffffL)
       
    74 #    define LZO_UINT32_C(c)     c ## UL
       
    75 #  else
       
    76 #    define LZO_UINT32_C(c)     c ## U
       
    77 #  endif
       
    78 #endif
       
    79 
       
    80 
       
    81 /***********************************************************************
       
    82  * architecture defines
       
    83  ***********************************************************************/
       
    84 
       
    85 #if !defined(__LZO_WIN) && !defined(__LZO_DOS) && !defined(__LZO_OS2)
       
    86 #  if defined(__WINDOWS__) || defined(_WINDOWS) || defined(_Windows)
       
    87 #    define __LZO_WIN
       
    88 #  elif defined(__WIN32__) || defined(_WIN32) || defined(WIN32)
       
    89 #    define __LZO_WIN
       
    90 #  elif defined(__NT__) || defined(__NT_DLL__) || defined(__WINDOWS_386__)
       
    91 #    define __LZO_WIN
       
    92 #  elif defined(__DOS__) || defined(__MSDOS__) || defined(MSDOS)
       
    93 #    define __LZO_DOS
       
    94 #  elif defined(__OS2__) || defined(__OS2V2__) || defined(OS2)
       
    95 #    define __LZO_OS2
       
    96 #  elif defined(__palmos__)
       
    97 #    define __LZO_PALMOS
       
    98 #  elif defined(__TOS__) || defined(__atarist__)
       
    99 #    define __LZO_TOS
       
   100 #  endif
       
   101 #endif
       
   102 
       
   103 #if (UINT_MAX < LZO_0xffffffffL)
       
   104 #  if defined(__LZO_WIN)
       
   105 #    define __LZO_WIN16
       
   106 #  elif defined(__LZO_DOS)
       
   107 #    define __LZO_DOS16
       
   108 #  elif defined(__LZO_PALMOS)
       
   109 #    define __LZO_PALMOS16
       
   110 #  elif defined(__LZO_TOS)
       
   111 #    define __LZO_TOS16
       
   112 #  elif defined(__C166__)
       
   113 #  else
       
   114      /* porting hint: for pure 16-bit architectures try compiling
       
   115       * everything with -D__LZO_STRICT_16BIT */
       
   116 #    error "16-bit target not supported - contact me for porting hints"
       
   117 #  endif
       
   118 #endif
       
   119 
       
   120 #if !defined(__LZO_i386)
       
   121 #  if defined(__LZO_DOS) || defined(__LZO_WIN16)
       
   122 #    define __LZO_i386
       
   123 #  elif defined(__i386__) || defined(__386__) || defined(_M_IX86)
       
   124 #    define __LZO_i386
       
   125 #  endif
       
   126 #endif
       
   127 
       
   128 #if defined(__LZO_STRICT_16BIT)
       
   129 #  if (UINT_MAX < LZO_0xffffffffL)
       
   130 #    include <lzo16bit.h>
       
   131 #  endif
       
   132 #endif
       
   133 
       
   134 /* memory checkers */
       
   135 #if !defined(__LZO_CHECKER)
       
   136 #  if defined(__BOUNDS_CHECKING_ON)
       
   137 #    define __LZO_CHECKER
       
   138 #  elif defined(__CHECKER__)
       
   139 #    define __LZO_CHECKER
       
   140 #  elif defined(__INSURE__)
       
   141 #    define __LZO_CHECKER
       
   142 #  elif defined(__PURIFY__)
       
   143 #    define __LZO_CHECKER
       
   144 #  endif
       
   145 #endif
       
   146 
       
   147 
       
   148 /***********************************************************************
       
   149  * integral and pointer types
       
   150  ***********************************************************************/
       
   151 
       
   152 /* Integral types with 32 bits or more */
       
   153 #if !defined(LZO_UINT32_MAX)
       
   154 #  if (UINT_MAX >= LZO_0xffffffffL)
       
   155      typedef unsigned int       lzo_uint32;
       
   156      typedef int                lzo_int32;
       
   157 #    define LZO_UINT32_MAX      UINT_MAX
       
   158 #    define LZO_INT32_MAX       INT_MAX
       
   159 #    define LZO_INT32_MIN       INT_MIN
       
   160 #  elif (ULONG_MAX >= LZO_0xffffffffL)
       
   161      typedef unsigned long      lzo_uint32;
       
   162      typedef long               lzo_int32;
       
   163 #    define LZO_UINT32_MAX      ULONG_MAX
       
   164 #    define LZO_INT32_MAX       LONG_MAX
       
   165 #    define LZO_INT32_MIN       LONG_MIN
       
   166 #  else
       
   167 #    error "lzo_uint32"
       
   168 #  endif
       
   169 #endif
       
   170 
       
   171 /* lzo_uint is used like size_t */
       
   172 #if !defined(LZO_UINT_MAX)
       
   173 #  if (UINT_MAX >= LZO_0xffffffffL)
       
   174      typedef unsigned int       lzo_uint;
       
   175      typedef int                lzo_int;
       
   176 #    define LZO_UINT_MAX        UINT_MAX
       
   177 #    define LZO_INT_MAX         INT_MAX
       
   178 #    define LZO_INT_MIN         INT_MIN
       
   179 #  elif (ULONG_MAX >= LZO_0xffffffffL)
       
   180      typedef unsigned long      lzo_uint;
       
   181      typedef long               lzo_int;
       
   182 #    define LZO_UINT_MAX        ULONG_MAX
       
   183 #    define LZO_INT_MAX         LONG_MAX
       
   184 #    define LZO_INT_MIN         LONG_MIN
       
   185 #  else
       
   186 #    error "lzo_uint"
       
   187 #  endif
       
   188 #endif
       
   189 
       
   190 typedef int lzo_bool;
       
   191 
       
   192 
       
   193 /***********************************************************************
       
   194  * memory models
       
   195  ***********************************************************************/
       
   196 
       
   197 /* Memory model for the public code segment. */
       
   198 #if !defined(__LZO_CMODEL)
       
   199 #  if defined(__LZO_DOS16) || defined(__LZO_WIN16)
       
   200 #    define __LZO_CMODEL        __far
       
   201 #  elif defined(__LZO_i386) && defined(__WATCOMC__)
       
   202 #    define __LZO_CMODEL        __near
       
   203 #  else
       
   204 #    define __LZO_CMODEL
       
   205 #  endif
       
   206 #endif
       
   207 
       
   208 /* Memory model for the public data segment. */
       
   209 #if !defined(__LZO_DMODEL)
       
   210 #  if defined(__LZO_DOS16) || defined(__LZO_WIN16)
       
   211 #    define __LZO_DMODEL        __far
       
   212 #  elif defined(__LZO_i386) && defined(__WATCOMC__)
       
   213 #    define __LZO_DMODEL        __near
       
   214 #  else
       
   215 #    define __LZO_DMODEL
       
   216 #  endif
       
   217 #endif
       
   218 
       
   219 /* Memory model that allows to access memory at offsets of lzo_uint. */
       
   220 #if !defined(__LZO_MMODEL)
       
   221 #  if (LZO_UINT_MAX <= UINT_MAX)
       
   222 #    define __LZO_MMODEL
       
   223 #  elif defined(__LZO_DOS16) || defined(__LZO_WIN16)
       
   224 #    define __LZO_MMODEL        __huge
       
   225 #    define LZO_999_UNSUPPORTED
       
   226 #  elif defined(__LZO_PALMOS16) || defined(__LZO_TOS16)
       
   227 #    define __LZO_MMODEL
       
   228 #  else
       
   229 #    error "__LZO_MMODEL"
       
   230 #  endif
       
   231 #endif
       
   232 
       
   233 /* no typedef here because of const-pointer issues */
       
   234 #define lzo_byte                unsigned char __LZO_MMODEL
       
   235 #define lzo_bytep               unsigned char __LZO_MMODEL *
       
   236 #define lzo_charp               char __LZO_MMODEL *
       
   237 #define lzo_voidp               void __LZO_MMODEL *
       
   238 #define lzo_shortp              short __LZO_MMODEL *
       
   239 #define lzo_ushortp             unsigned short __LZO_MMODEL *
       
   240 #define lzo_uint32p             lzo_uint32 __LZO_MMODEL *
       
   241 #define lzo_int32p              lzo_int32 __LZO_MMODEL *
       
   242 #define lzo_uintp               lzo_uint __LZO_MMODEL *
       
   243 #define lzo_intp                lzo_int __LZO_MMODEL *
       
   244 #define lzo_voidpp              lzo_voidp __LZO_MMODEL *
       
   245 #define lzo_bytepp              lzo_bytep __LZO_MMODEL *
       
   246 
       
   247 #ifndef lzo_sizeof_dict_t
       
   248 #  define lzo_sizeof_dict_t     sizeof(lzo_bytep)
       
   249 #endif
       
   250 
       
   251 
       
   252 /***********************************************************************
       
   253  * calling conventions and function types
       
   254  ***********************************************************************/
       
   255 
       
   256 /* linkage */
       
   257 #if !defined(__LZO_EXTERN_C)
       
   258 #  ifdef __cplusplus
       
   259 #    define __LZO_EXTERN_C      extern "C"
       
   260 #  else
       
   261 #    define __LZO_EXTERN_C      extern
       
   262 #  endif
       
   263 #endif
       
   264 
       
   265 /* calling convention */
       
   266 #if !defined(__LZO_CDECL)
       
   267 #  if defined(__LZO_DOS16) || defined(__LZO_WIN16)
       
   268 #    define __LZO_CDECL         __LZO_CMODEL __cdecl
       
   269 #  elif defined(__LZO_i386) && defined(_MSC_VER)
       
   270 #    define __LZO_CDECL         __LZO_CMODEL __cdecl
       
   271 #  elif defined(__LZO_i386) && defined(__WATCOMC__)
       
   272 #    define __LZO_CDECL         __LZO_CMODEL __cdecl
       
   273 #  else
       
   274 #    define __LZO_CDECL         __LZO_CMODEL
       
   275 #  endif
       
   276 #endif
       
   277 #if !defined(__LZO_ENTRY)
       
   278 #  define __LZO_ENTRY           __LZO_CDECL
       
   279 #endif
       
   280 
       
   281 /* C++ exception specification for extern "C" function types */
       
   282 #if !defined(__cplusplus)
       
   283 #  undef LZO_NOTHROW
       
   284 #  define LZO_NOTHROW
       
   285 #elif !defined(LZO_NOTHROW)
       
   286 #  define LZO_NOTHROW
       
   287 #endif
       
   288 
       
   289 
       
   290 typedef int
       
   291 (__LZO_ENTRY *lzo_compress_t)   ( const lzo_byte *src, lzo_uint  src_len,
       
   292                                         lzo_byte *dst, lzo_uintp dst_len,
       
   293                                         lzo_voidp wrkmem );
       
   294 
       
   295 typedef int
       
   296 (__LZO_ENTRY *lzo_decompress_t) ( const lzo_byte *src, lzo_uint  src_len,
       
   297                                         lzo_byte *dst, lzo_uintp dst_len,
       
   298                                         lzo_voidp wrkmem );
       
   299 
       
   300 typedef int
       
   301 (__LZO_ENTRY *lzo_optimize_t)   (       lzo_byte *src, lzo_uint  src_len,
       
   302                                         lzo_byte *dst, lzo_uintp dst_len,
       
   303                                         lzo_voidp wrkmem );
       
   304 
       
   305 typedef int
       
   306 (__LZO_ENTRY *lzo_compress_dict_t)(const lzo_byte *src, lzo_uint  src_len,
       
   307                                         lzo_byte *dst, lzo_uintp dst_len,
       
   308                                         lzo_voidp wrkmem,
       
   309                                   const lzo_byte *dict, lzo_uint dict_len );
       
   310 
       
   311 typedef int
       
   312 (__LZO_ENTRY *lzo_decompress_dict_t)(const lzo_byte *src, lzo_uint  src_len,
       
   313                                         lzo_byte *dst, lzo_uintp dst_len,
       
   314                                         lzo_voidp wrkmem,
       
   315                                   const lzo_byte *dict, lzo_uint dict_len );
       
   316 
       
   317 
       
   318 /* assembler versions always use __cdecl */
       
   319 typedef int
       
   320 (__LZO_CDECL *lzo_compress_asm_t)( const lzo_byte *src, lzo_uint  src_len,
       
   321                                         lzo_byte *dst, lzo_uintp dst_len,
       
   322                                         lzo_voidp wrkmem );
       
   323 
       
   324 typedef int
       
   325 (__LZO_CDECL *lzo_decompress_asm_t)( const lzo_byte *src, lzo_uint  src_len,
       
   326                                         lzo_byte *dst, lzo_uintp dst_len,
       
   327                                         lzo_voidp wrkmem );
       
   328 
       
   329 
       
   330 /* a progress indicator callback function */
       
   331 typedef void (__LZO_ENTRY *lzo_progress_callback_t) (lzo_uint, lzo_uint);
       
   332 
       
   333 
       
   334 /***********************************************************************
       
   335  * export information
       
   336  ***********************************************************************/
       
   337 
       
   338 /* DLL export information */
       
   339 #if !defined(__LZO_EXPORT1)
       
   340 #  define __LZO_EXPORT1
       
   341 #endif
       
   342 #if !defined(__LZO_EXPORT2)
       
   343 #  define __LZO_EXPORT2
       
   344 #endif
       
   345 
       
   346 /* exported calling convention for C functions */
       
   347 #if !defined(LZO_PUBLIC)
       
   348 #  define LZO_PUBLIC(_rettype) \
       
   349                 __LZO_EXPORT1 _rettype __LZO_EXPORT2 __LZO_ENTRY
       
   350 #endif
       
   351 #if !defined(LZO_EXTERN)
       
   352 #  define LZO_EXTERN(_rettype)          __LZO_EXTERN_C LZO_PUBLIC(_rettype)
       
   353 #endif
       
   354 #if !defined(LZO_PRIVATE)
       
   355 #  define LZO_PRIVATE(_rettype)         static _rettype __LZO_ENTRY
       
   356 #endif
       
   357 
       
   358 /* exported __cdecl calling convention for assembler functions */
       
   359 #if !defined(LZO_PUBLIC_CDECL)
       
   360 #  define LZO_PUBLIC_CDECL(_rettype) \
       
   361                 __LZO_EXPORT1 _rettype __LZO_EXPORT2 __LZO_CDECL
       
   362 #endif
       
   363 #if !defined(LZO_EXTERN_CDECL)
       
   364 #  define LZO_EXTERN_CDECL(_rettype)    __LZO_EXTERN_C LZO_PUBLIC_CDECL(_rettype)
       
   365 #endif
       
   366 
       
   367 /* exported global variables (LZO currently uses no static variables and
       
   368  * is fully thread safe) */
       
   369 #if !defined(LZO_PUBLIC_VAR)
       
   370 #  define LZO_PUBLIC_VAR(_type) \
       
   371                 __LZO_EXPORT1 _type __LZO_EXPORT2 __LZO_DMODEL
       
   372 #endif
       
   373 #if !defined(LZO_EXTERN_VAR)
       
   374 #  define LZO_EXTERN_VAR(_type)         extern LZO_PUBLIC_VAR(_type)
       
   375 #endif
       
   376 
       
   377 
       
   378 /***********************************************************************
       
   379  * error codes and prototypes
       
   380  ***********************************************************************/
       
   381 
       
   382 /* Error codes for the compression/decompression functions. Negative
       
   383  * values are errors, positive values will be used for special but
       
   384  * normal events.
       
   385  */
       
   386 #define LZO_E_OK                    0
       
   387 #define LZO_E_ERROR                 (-1)
       
   388 #define LZO_E_OUT_OF_MEMORY         (-2)    /* not used right now */
       
   389 #define LZO_E_NOT_COMPRESSIBLE      (-3)    /* not used right now */
       
   390 #define LZO_E_INPUT_OVERRUN         (-4)
       
   391 #define LZO_E_OUTPUT_OVERRUN        (-5)
       
   392 #define LZO_E_LOOKBEHIND_OVERRUN    (-6)
       
   393 #define LZO_E_EOF_NOT_FOUND         (-7)
       
   394 #define LZO_E_INPUT_NOT_CONSUMED    (-8)
       
   395 
       
   396 
       
   397 /* lzo_init() should be the first function you call.
       
   398  * Check the return code !
       
   399  *
       
   400  * lzo_init() is a macro to allow checking that the library and the
       
   401  * compiler's view of various types are consistent.
       
   402  */
       
   403 #define lzo_init() __lzo_init2(LZO_VERSION,(int)sizeof(short),(int)sizeof(int),\
       
   404     (int)sizeof(long),(int)sizeof(lzo_uint32),(int)sizeof(lzo_uint),\
       
   405     (int)lzo_sizeof_dict_t,(int)sizeof(char *),(int)sizeof(lzo_voidp),\
       
   406     (int)sizeof(lzo_compress_t))
       
   407 LZO_EXTERN(int) __lzo_init2(unsigned,int,int,int,int,int,int,int,int,int);
       
   408 
       
   409 /* version functions (useful for shared libraries) */
       
   410 LZO_EXTERN(unsigned) lzo_version(void);
       
   411 LZO_EXTERN(const char *) lzo_version_string(void);
       
   412 LZO_EXTERN(const char *) lzo_version_date(void);
       
   413 LZO_EXTERN(const lzo_charp) _lzo_version_string(void);
       
   414 LZO_EXTERN(const lzo_charp) _lzo_version_date(void);
       
   415 
       
   416 /* string functions */
       
   417 LZO_EXTERN(int)
       
   418 lzo_memcmp(const lzo_voidp _s1, const lzo_voidp _s2, lzo_uint _len);
       
   419 LZO_EXTERN(lzo_voidp)
       
   420 lzo_memcpy(lzo_voidp _dest, const lzo_voidp _src, lzo_uint _len);
       
   421 LZO_EXTERN(lzo_voidp)
       
   422 lzo_memmove(lzo_voidp _dest, const lzo_voidp _src, lzo_uint _len);
       
   423 LZO_EXTERN(lzo_voidp)
       
   424 lzo_memset(lzo_voidp _s, int _c, lzo_uint _len);
       
   425 
       
   426 /* checksum functions */
       
   427 LZO_EXTERN(lzo_uint32)
       
   428 lzo_adler32(lzo_uint32 _adler, const lzo_byte *_buf, lzo_uint _len);
       
   429 LZO_EXTERN(lzo_uint32)
       
   430 lzo_crc32(lzo_uint32 _c, const lzo_byte *_buf, lzo_uint _len);
       
   431 
       
   432 /* misc. */
       
   433 LZO_EXTERN(lzo_bool) lzo_assert(int _expr);
       
   434 LZO_EXTERN(int) _lzo_config_check(void);
       
   435 typedef union { lzo_bytep p; lzo_uint u; } __lzo_pu_u;
       
   436 typedef union { lzo_bytep p; lzo_uint32 u32; } __lzo_pu32_u;
       
   437 typedef union { void *vp; lzo_bytep bp; lzo_uint32 u32; long l; } lzo_align_t;
       
   438 
       
   439 /* align a char pointer on a boundary that is a multiple of `size' */
       
   440 LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp _ptr, lzo_uint _size);
       
   441 #define LZO_PTR_ALIGN_UP(_ptr,_size) \
       
   442     ((_ptr) + (lzo_uint) __lzo_align_gap((const lzo_voidp)(_ptr),(lzo_uint)(_size)))
       
   443 
       
   444 /* deprecated - only for backward compatibility */
       
   445 #define LZO_ALIGN(_ptr,_size) LZO_PTR_ALIGN_UP(_ptr,_size)
       
   446 
       
   447 
       
   448 #ifdef __cplusplus
       
   449 } /* extern "C" */
       
   450 #endif
       
   451 
       
   452 #endif /* LZOCONF_H */