diff options
author | David Cole <david.cole@kitware.com> | 2007-09-11 15:22:29 (GMT) |
---|---|---|
committer | David Cole <david.cole@kitware.com> | 2007-09-11 15:22:29 (GMT) |
commit | 3edcd70754afe7c6b2ff71e0010c6b3d64b4fe37 (patch) | |
tree | 0dca962765d94496432c628b96dbfeef7a252064 /Utilities/cmzlib/zutil.c | |
parent | f262298bb037b683c995f239d1ca9fc00aaec3f3 (diff) | |
download | CMake-3edcd70754afe7c6b2ff71e0010c6b3d64b4fe37.zip CMake-3edcd70754afe7c6b2ff71e0010c6b3d64b4fe37.tar.gz CMake-3edcd70754afe7c6b2ff71e0010c6b3d64b4fe37.tar.bz2 |
ENH: Update zlib to 1.2.3. Addresses bugs #5445 and #3473.
Diffstat (limited to 'Utilities/cmzlib/zutil.c')
-rw-r--r-- | Utilities/cmzlib/zutil.c | 121 |
1 files changed, 107 insertions, 14 deletions
diff --git a/Utilities/cmzlib/zutil.c b/Utilities/cmzlib/zutil.c index dfc38ec..d55f594 100644 --- a/Utilities/cmzlib/zutil.c +++ b/Utilities/cmzlib/zutil.c @@ -1,19 +1,17 @@ /* zutil.c -- target dependent utility functions for the compression library - * Copyright (C) 1995-2002 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h + * Copyright (C) 1995-2005 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h */ /* @(#) $Id$ */ #include "zutil.h" +#ifndef NO_DUMMY_DECL struct internal_state {int dummy;}; /* for buggy compilers */ - -#ifndef STDC -extern void exit OF((int)); #endif -const char *z_errmsg[10] = { +const char * const z_errmsg[10] = { "need dictionary", /* Z_NEED_DICT 2 */ "stream end", /* Z_STREAM_END 1 */ "", /* Z_OK 0 */ @@ -31,6 +29,89 @@ const char * ZEXPORT zlibVersion() return ZLIB_VERSION; } +uLong ZEXPORT zlibCompileFlags() +{ + uLong flags; + + flags = 0; + switch (sizeof(uInt)) { + case 2: break; + case 4: flags += 1; break; + case 8: flags += 2; break; + default: flags += 3; + } + switch (sizeof(uLong)) { + case 2: break; + case 4: flags += 1 << 2; break; + case 8: flags += 2 << 2; break; + default: flags += 3 << 2; + } + switch (sizeof(voidpf)) { + case 2: break; + case 4: flags += 1 << 4; break; + case 8: flags += 2 << 4; break; + default: flags += 3 << 4; + } + switch (sizeof(z_off_t)) { + case 2: break; + case 4: flags += 1 << 6; break; + case 8: flags += 2 << 6; break; + default: flags += 3 << 6; + } +#ifdef DEBUG + flags += 1 << 8; +#endif +#if defined(ASMV) || defined(ASMINF) + flags += 1 << 9; +#endif +#ifdef ZLIB_WINAPI + flags += 1 << 10; +#endif +#ifdef BUILDFIXED + flags += 1 << 12; +#endif +#ifdef DYNAMIC_CRC_TABLE + flags += 1 << 13; +#endif +#ifdef NO_GZCOMPRESS + flags += 1L << 16; +#endif +#ifdef NO_GZIP + flags += 1L << 17; +#endif +#ifdef PKZIP_BUG_WORKAROUND + flags += 1L << 20; +#endif +#ifdef FASTEST + flags += 1L << 21; +#endif +#ifdef STDC +# ifdef NO_vsnprintf + flags += 1L << 25; +# ifdef HAS_vsprintf_void + flags += 1L << 26; +# endif +# else +# ifdef HAS_vsnprintf_void + flags += 1L << 26; +# endif +# endif +#else + flags += 1L << 24; +# ifdef NO_snprintf + flags += 1L << 25; +# ifdef HAS_sprintf_void + flags += 1L << 26; +# endif +# else +# ifdef HAS_snprintf_void + flags += 1L << 26; +# endif +# endif +#endif + return flags; +} + #ifdef DEBUG # ifndef verbose @@ -55,6 +136,13 @@ const char * ZEXPORT zError(err) return ERR_MSG(err); } +#if defined(_WIN32_WCE) + /* The Microsoft C Run-Time Library for Windows CE doesn't have + * errno. We define it as a global variable to simplify porting. + * Its value is always 0 and should not be used. + */ + int errno = 0; +#endif #ifndef HAVE_MEMCPY @@ -93,11 +181,12 @@ void zmemzero(dest, len) } #endif + +#ifdef SYS16BIT + #ifdef __TURBOC__ -#if (defined( __BORLANDC__) || !defined(SMALL_MEDIUM)) && !defined(__32BIT__) -/* Small and medium model in Turbo C are for now limited to near allocation - * with reduced MAX_WBITS and MAX_MEM_LEVEL - */ +/* Turbo C in 16-bit mode */ + # define MY_ZCALLOC /* Turbo C malloc() does not allow dynamic allocation of 64K bytes @@ -169,11 +258,11 @@ void zcfree (voidpf opaque, voidpf ptr) ptr = opaque; /* just to make some compilers happy */ Assert(0, "zcfree: ptr not found"); } -#endif + #endif /* __TURBOC__ */ -#if defined(M_I86) && !defined(__32BIT__) +#ifdef M_I86 /* Microsoft C in 16-bit mode */ # define MY_ZCALLOC @@ -195,12 +284,15 @@ void zcfree (voidpf opaque, voidpf ptr) _hfree(ptr); } -#endif /* MSC */ +#endif /* M_I86 */ + +#endif /* SYS16BIT */ #ifndef MY_ZCALLOC /* Any system without a special alloc function */ #ifndef STDC +extern voidp malloc OF((uInt size)); extern voidp calloc OF((uInt items, uInt size)); extern void free OF((voidpf ptr)); #endif @@ -211,7 +303,8 @@ voidpf zcalloc (opaque, items, size) unsigned size; { if (opaque) items += size - size; /* make compiler happy */ - return (voidpf)calloc(items, size); + return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) : + (voidpf)calloc(items, size); } void zcfree (opaque, ptr) |