minilzo.c.svn-base

来自「ffshow源码」· SVN-BASE 代码 · 共 1,956 行 · 第 1/5 页

SVN-BASE
1,956
字号
#endif#if defined(LZO_CFG_FREESTANDING)#  undef HAVE_MEMCMP#  undef HAVE_MEMCPY#  undef HAVE_MEMMOVE#  undef HAVE_MEMSET#endif#if !defined(HAVE_MEMCMP)#  undef memcmp#  define memcmp(a,b,c)         lzo_memcmp(a,b,c)#elif !defined(__LZO_MMODEL_HUGE)#  define lzo_memcmp(a,b,c)     memcmp(a,b,c)#endif#if !defined(HAVE_MEMCPY)#  undef memcpy#  define memcpy(a,b,c)         lzo_memcpy(a,b,c)#elif !defined(__LZO_MMODEL_HUGE)#  define lzo_memcpy(a,b,c)     memcpy(a,b,c)#endif#if !defined(HAVE_MEMMOVE)#  undef memmove#  define memmove(a,b,c)        lzo_memmove(a,b,c)#elif !defined(__LZO_MMODEL_HUGE)#  define lzo_memmove(a,b,c)    memmove(a,b,c)#endif#if !defined(HAVE_MEMSET)#  undef memset#  define memset(a,b,c)         lzo_memset(a,b,c)#elif !defined(__LZO_MMODEL_HUGE)#  define lzo_memset(a,b,c)     memset(a,b,c)#endif#undef NDEBUG#if defined(LZO_CFG_FREESTANDING)#  undef LZO_DEBUG#  define NDEBUG 1#  undef assert#  define assert(e) ((void)0)#else#  if !defined(LZO_DEBUG)#    define NDEBUG 1#  endif#  include <assert.h>#endif#if 0 && defined(__BOUNDS_CHECKING_ON)#  include <unchecked.h>#else#  define BOUNDS_CHECKING_OFF_DURING(stmt)      stmt#  define BOUNDS_CHECKING_OFF_IN_EXPR(expr)     (expr)#endif#if !defined(__lzo_inline)#  define __lzo_inline#endif#if !defined(__lzo_forceinline)#  define __lzo_forceinline#endif#if !defined(__lzo_noinline)#  define __lzo_noinline#endif#if 1#  define LZO_BYTE(x)       ((unsigned char) (x))#else#  define LZO_BYTE(x)       ((unsigned char) ((x) & 0xff))#endif#define LZO_MAX(a,b)        ((a) >= (b) ? (a) : (b))#define LZO_MIN(a,b)        ((a) <= (b) ? (a) : (b))#define LZO_MAX3(a,b,c)     ((a) >= (b) ? LZO_MAX(a,c) : LZO_MAX(b,c))#define LZO_MIN3(a,b,c)     ((a) <= (b) ? LZO_MIN(a,c) : LZO_MIN(b,c))#define lzo_sizeof(type)    ((lzo_uint) (sizeof(type)))#define LZO_HIGH(array)     ((lzo_uint) (sizeof(array)/sizeof(*(array))))#define LZO_SIZE(bits)      (1u << (bits))#define LZO_MASK(bits)      (LZO_SIZE(bits) - 1)#define LZO_LSIZE(bits)     (1ul << (bits))#define LZO_LMASK(bits)     (LZO_LSIZE(bits) - 1)#define LZO_USIZE(bits)     ((lzo_uint) 1 << (bits))#define LZO_UMASK(bits)     (LZO_USIZE(bits) - 1)#if !defined(DMUL)#if 0#  define DMUL(a,b) ((lzo_xint) ((lzo_uint32)(a) * (lzo_uint32)(b)))#else#  define DMUL(a,b) ((lzo_xint) ((a) * (b)))#endif#endif#if 1 && !defined(LZO_CFG_NO_UNALIGNED)#if 1 && (LZO_ARCH_AMD64 || LZO_ARCH_I386)#  if (LZO_SIZEOF_SHORT == 2)#    define LZO_UNALIGNED_OK_2#  endif#  if (LZO_SIZEOF_INT == 4)#    define LZO_UNALIGNED_OK_4#  endif#endif#endif#if defined(LZO_UNALIGNED_OK_2)  LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(short) == 2)#endif#if defined(LZO_UNALIGNED_OK_4)  LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint32) == 4)#elif defined(LZO_ALIGNED_OK_4)  LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint32) == 4)#endif#define MEMCPY8_DS(dest,src,len) \    lzo_memcpy(dest,src,len); dest += len; src += len#define BZERO8_PTR(s,l,n) \    lzo_memset((lzo_voidp)(s),0,(lzo_uint)(l)*(n))#define MEMCPY_DS(dest,src,len) \    do *dest++ = *src++; while (--len > 0)__LZO_EXTERN_C int __lzo_init_done;__LZO_EXTERN_C const char __lzo_copyright[];LZO_EXTERN(const lzo_bytep) lzo_copyright(void);#ifndef __LZO_PTR_H#define __LZO_PTR_H#ifdef __cplusplusextern "C" {#endif#if !defined(lzo_uintptr_t)#  if defined(__LZO_MMODEL_HUGE)#    define lzo_uintptr_t   unsigned long#  else#    define lzo_uintptr_t   acc_uintptr_t#    ifdef __ACC_INTPTR_T_IS_POINTER#      define __LZO_UINTPTR_T_IS_POINTER 1#    endif#  endif#endif#if (LZO_ARCH_I086)#define PTR(a)              ((lzo_bytep) (a))#define PTR_ALIGNED_4(a)    ((ACC_PTR_FP_OFF(a) & 3) == 0)#define PTR_ALIGNED2_4(a,b) (((ACC_PTR_FP_OFF(a) | ACC_PTR_FP_OFF(b)) & 3) == 0)#else#define PTR(a)              ((lzo_uintptr_t) (a))#define PTR_LINEAR(a)       PTR(a)#define PTR_ALIGNED_4(a)    ((PTR_LINEAR(a) & 3) == 0)#define PTR_ALIGNED_8(a)    ((PTR_LINEAR(a) & 7) == 0)#define PTR_ALIGNED2_4(a,b) (((PTR_LINEAR(a) | PTR_LINEAR(b)) & 3) == 0)#define PTR_ALIGNED2_8(a,b) (((PTR_LINEAR(a) | PTR_LINEAR(b)) & 7) == 0)#endif#define PTR_LT(a,b)         (PTR(a) < PTR(b))#define PTR_GE(a,b)         (PTR(a) >= PTR(b))#define PTR_DIFF(a,b)       (PTR(a) - PTR(b))#define pd(a,b)             ((lzo_uint) ((a)-(b)))LZO_EXTERN(lzo_uintptr_t)__lzo_ptr_linear(const lzo_voidp ptr);typedef union{    char            a_char;    unsigned char   a_uchar;    short           a_short;    unsigned short  a_ushort;    int             a_int;    unsigned int    a_uint;    long            a_long;    unsigned long   a_ulong;    lzo_int         a_lzo_int;    lzo_uint        a_lzo_uint;    lzo_int32       a_lzo_int32;    lzo_uint32      a_lzo_uint32;    ptrdiff_t       a_ptrdiff_t;    lzo_uintptr_t   a_lzo_uintptr_t;    lzo_voidp       a_lzo_voidp;    void *          a_void_p;    lzo_bytep       a_lzo_bytep;    lzo_bytepp      a_lzo_bytepp;    lzo_uintp       a_lzo_uintp;    lzo_uint *      a_lzo_uint_p;    lzo_uint32p     a_lzo_uint32p;    lzo_uint32 *    a_lzo_uint32_p;    unsigned char * a_uchar_p;    char *          a_char_p;}lzo_full_align_t;#ifdef __cplusplus}#endif#endif#define LZO_DETERMINISTIC#define LZO_DICT_USE_PTR#if 0 && (LZO_ARCH_I086)#  undef LZO_DICT_USE_PTR#endif#if defined(LZO_DICT_USE_PTR)#  define lzo_dict_t    const lzo_bytep#  define lzo_dict_p    lzo_dict_t __LZO_MMODEL *#else#  define lzo_dict_t    lzo_uint#  define lzo_dict_p    lzo_dict_t __LZO_MMODEL *#endif#endifLZO_PUBLIC(lzo_uintptr_t)__lzo_ptr_linear(const lzo_voidp ptr){    lzo_uintptr_t p;#if (LZO_ARCH_I086)    p = (((lzo_uintptr_t)(ACC_PTR_FP_SEG(ptr))) << (16 - ACC_MM_AHSHIFT)) + (ACC_PTR_FP_OFF(ptr));#else    p = (lzo_uintptr_t) PTR_LINEAR(ptr);#endif    return p;}LZO_PUBLIC(unsigned)__lzo_align_gap(const lzo_voidp ptr, lzo_uint size){#if defined(__LZO_UINTPTR_T_IS_POINTER)    size_t n = (size_t) ptr;    n = (((n + size - 1) / size) * size) - n;#else    lzo_uintptr_t p, n;    p = __lzo_ptr_linear(ptr);    n = (((p + size - 1) / size) * size) - p;#endif    assert(size > 0);    assert((long)n >= 0);    assert(n <= s);    return (unsigned)n;}/* If you use the LZO library in a product, you *must* keep this * copyright string in the executable of your product. */const char __lzo_copyright[] =#if !defined(__LZO_IN_MINLZO)    LZO_VERSION_STRING;#else    "\r\n\n"    "LZO data compression library.\n"    "$Copyright: LZO (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Markus Franz Xaver Johannes Oberhumer\n"    "<markus@oberhumer.com>\n"    "http://www.oberhumer.com $\n\n"    "$Built: " __DATE__ " " __TIME__ " $\n"    "$Info: " LZO_INFO_STRING " $\n";#endifLZO_PUBLIC(const lzo_bytep)lzo_copyright(void){#if (LZO_OS_DOS16 && LZO_CC_TURBOC)    return (lzo_voidp) __lzo_copyright;#else    return (const lzo_bytep) __lzo_copyright;#endif}LZO_PUBLIC(unsigned)lzo_version(void){    return LZO_VERSION;}LZO_PUBLIC(const char *)lzo_version_string(void){    return LZO_VERSION_STRING;}LZO_PUBLIC(const char *)lzo_version_date(void){    return LZO_VERSION_DATE;}LZO_PUBLIC(const lzo_charp)_lzo_version_string(void){    return LZO_VERSION_STRING;}LZO_PUBLIC(const lzo_charp)_lzo_version_date(void){    return LZO_VERSION_DATE;}#define LZO_BASE 65521u#define LZO_NMAX 5552#define LZO_DO1(buf,i)  {s1 += buf[i]; s2 += s1;}#define LZO_DO2(buf,i)  LZO_DO1(buf,i); LZO_DO1(buf,i+1);#define LZO_DO4(buf,i)  LZO_DO2(buf,i); LZO_DO2(buf,i+2);#define LZO_DO8(buf,i)  LZO_DO4(buf,i); LZO_DO4(buf,i+4);#define LZO_DO16(buf,i) LZO_DO8(buf,i); LZO_DO8(buf,i+8);LZO_PUBLIC(lzo_uint32)lzo_adler32(lzo_uint32 adler, const lzo_bytep buf, lzo_uint len){    lzo_uint32 s1 = adler & 0xffff;    lzo_uint32 s2 = (adler >> 16) & 0xffff;    unsigned k;    if (buf == NULL)        return 1;    while (len > 0)    {        k = len < LZO_NMAX ? (unsigned) len : LZO_NMAX;        len -= k;        if (k >= 16) do        {            LZO_DO16(buf,0);            buf += 16;            k -= 16;        } while (k >= 16);        if (k != 0) do        {            s1 += *buf++;            s2 += s1;        } while (--k > 0);        s1 %= LZO_BASE;        s2 %= LZO_BASE;    }    return (s2 << 16) | s1;}#undef lzo_memcmp#undef lzo_memcpy#undef lzo_memmove#undef lzo_memset#if !defined(__LZO_MMODEL_HUGE)#  undef LZO_HAVE_MM_HUGE_PTR#endif#define lzo_hsize_t             lzo_uint#define lzo_hvoid_p             lzo_voidp#define lzo_hbyte_p             lzo_bytep#define LZOLIB_PUBLIC(r,f)      LZO_PUBLIC(r) f#define lzo_hmemcmp             lzo_memcmp#define lzo_hmemcpy             lzo_memcpy#define lzo_hmemmove            lzo_memmove#define lzo_hmemset             lzo_memset#define LZO_WANT_ACCLIB_HMEMCPY 1#define __LZOLIB_HMEMCPY_CH_INCLUDED 1#if !defined(LZOLIB_PUBLIC)#  define LZOLIB_PUBLIC(r,f)    r __LZOLIB_FUNCNAME(f)#endifLZOLIB_PUBLIC(int, lzo_hmemcmp) (const lzo_hvoid_p s1, const lzo_hvoid_p s2, lzo_hsize_t len){#if (LZO_HAVE_MM_HUGE_PTR) || !defined(HAVE_MEMCMP)    const lzo_hbyte_p p1 = (const lzo_hbyte_p) s1;    const lzo_hbyte_p p2 = (const lzo_hbyte_p) s2;    if __lzo_likely(len > 0) do    {        int d = *p1 - *p2;        if (d != 0)            return d;        p1++; p2++;    } while __lzo_likely(--len > 0);    return 0;#else    return memcmp(s1, s2, len);#endif}LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemcp

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?