Commit aa3f9d5f authored by Andre Maroneze's avatar Andre Maroneze 💬
Browse files

[zlib] new case study

parent d496a077
Pipeline #36497 passed with stage
in 60 minutes and 45 seconds
......@@ -83,6 +83,7 @@ TARGETS=\
tsvc \
tweetnacl-usable \
x509-parser \
zlib \
help::
@echo ""
......
......@@ -161,3 +161,4 @@ when available. We also summarize the license of each directory below.
- `tsvc`: MIT, see `license.txt`
- `tweetnacl-usable`: public domain, see `LICENSE.txt`
- `x509-parser` : GPLv2 / BSD, see `LICENSE`
- `zlib` : zlib licence, see `README`
# Makefile template for Frama-C/Eva case studies.
# For details and usage information, see the Frama-C User Manual.
### Prologue. Do not modify this block. #######################################
-include path.mk
FRAMAC ?= frama-c
include $(shell $(FRAMAC)-config -print-share-path)/analysis-scripts/prologue.mk
###############################################################################
# Edit below as needed. Suggested flags are optional.
MACHDEP = x86_64
## Preprocessing flags (for -cpp-extra-args)
CPPFLAGS += \
-I .. \
## General flags
FCFLAGS += \
-add-symbolic-path=..:. \
-kernel-warn-key annot:missing-spec=abort \
-kernel-warn-key typing:implicit-function-declaration=abort \
## Eva-specific flags
EVAFLAGS += \
-eva-warn-key builtins:missing-spec=abort \
-eva-precision 4 \
## GUI-only flags
FCGUIFLAGS += \
## Analysis targets (suffixed with .eva)
TARGETS = zlib-example.eva
### Each target <t>.eva needs a rule <t>.parse with source files as prerequisites
zlib-example.parse: \
../test/example.c \
$(sort $(wildcard ../*.c)) \
### Epilogue. Do not modify this block. #######################################
include $(shell $(FRAMAC)-config -print-share-path)/analysis-scripts/epilogue.mk
###############################################################################
# optional, for OSCS
-include ../../Makefile.common
../../path.mk
\ No newline at end of file
directory file line function property kind status property
. deflate.c 1958 deflate_slow initialization Invalid or unreachable \initialized(&s->match_start)
[metrics] Eva coverage statistics
=======================
Syntactically reachable functions = 113 (out of 159)
Semantically reached functions = 28
Coverage estimation = 24.8%
Unreached functions (85) =
<crc32.c>: crc32; crc32_big; crc32_little; crc32_z;
<deflate.c>: deflate_fast; deflate_huff; deflate_rle; deflate_stored;
deflateParams; deflateSetDictionary; longest_match; slide_hash;
<gzclose.c>: gzclose;
<gzlib.c>: gz_error; gz_open; gz_reset; gzerror; gzopen; gzrewind; gzseek;
gzseek64; gztell; gztell64;
<gzread.c>: gz_avail; gz_decomp; gz_fetch; gz_load; gz_look; gz_read;
gz_skip; gzclose_r; gzgetc; gzgets; gzread; gzungetc;
<gzwrite.c>: gz_comp; gz_init; gz_write; gz_zero; gzclose_w; gzprintf;
gzputc; gzputs; gzvprintf;
<inffast.c>: inflate_fast;
<inflate.c>: fixedtables_0; inflate; inflateEnd; inflateInit2_;
inflateInit_; inflateReset; inflateReset2; inflateResetKeep;
inflateSetDictionary; inflateStateCheck; inflateSync; syncsearch;
updatewindow;
<inftrees.c>: inflate_table;
<test/example.c>: test_deflate; test_dict_deflate; test_dict_inflate;
test_flush; test_gzio; test_inflate; test_large_deflate;
test_large_inflate; test_sync;
<trees.c>: _tr_align; _tr_flush_block; _tr_stored_block; bi_reverse;
bi_windup; build_bl_tree; build_tree; compress_block; detect_data_type;
gen_bitlen; gen_codes; pqdownheap; scan_tree; send_all_trees; send_tree;
<uncompr.c>: uncompress; uncompress2;
[metrics] References to non-analyzed functions
------------------------------------
Function deflate calls crc32 (at deflate.c:851)
Function deflate calls crc32 (at deflate.c:894)
Function deflate calls crc32 (at deflate.c:909)
Function deflate calls crc32 (at deflate.c:922)
Function deflate calls crc32 (at deflate.c:933)
Function deflate calls crc32 (at deflate.c:944)
Function deflate calls crc32 (at deflate.c:955)
Function deflate calls crc32 (at deflate.c:966)
Function deflate calls crc32 (at deflate.c:981)
Function deflate calls deflate_stored (at deflate.c:1000)
Function deflate calls deflate_huff (at deflate.c:1001)
Function deflate calls deflate_rle (at deflate.c:1002)
Function deflate calls _tr_align (at deflate.c:1023)
Function deflate calls _tr_stored_block (at deflate.c:1025)
Function deflate_slow calls longest_match (at deflate.c:1967)
Function deflate_slow calls _tr_flush_block (at deflate.c:2011)
Function deflate_slow calls _tr_flush_block (at deflate.c:2021)
Function deflate_slow calls _tr_flush_block (at deflate.c:2043)
Function deflate_slow calls _tr_flush_block (at deflate.c:2047)
Function deflateResetKeep calls crc32 (at deflate.c:494)
Function fill_window calls slide_hash (at deflate.c:1516)
Function main calls test_gzio (at test/example.c:581)
Function main calls test_deflate (at test/example.c:585)
Function main calls test_inflate (at test/example.c:586)
Function main calls test_large_deflate (at test/example.c:588)
Function main calls test_large_inflate (at test/example.c:589)
Function main calls test_flush (at test/example.c:591)
Function main calls test_sync (at test/example.c:592)
Function main calls test_dict_deflate (at test/example.c:595)
Function main calls test_dict_inflate (at test/example.c:596)
Function read_buf calls crc32 (at deflate.c:1182)
Function test_compress calls uncompress (at test/example.c:100)
Initializer of configuration_table references deflate_stored (at deflate.c:136)
Initializer of configuration_table references deflate_fast (at deflate.c:137)
Initializer of configuration_table references deflate_fast (at deflate.c:138)
Initializer of configuration_table references deflate_fast (at deflate.c:139)
[metrics] Statements analyzed by Eva
--------------------------
1363 stmts in analyzed functions, 448 stmts analyzed (32.9%)
_tr_flush_bits: 2 stmts out of 2 (100.0%)
_tr_init: 11 stmts out of 11 (100.0%)
adler32: 2 stmts out of 2 (100.0%)
compress: 2 stmts out of 2 (100.0%)
deflateInit_: 2 stmts out of 2 (100.0%)
deflateReset: 4 stmts out of 4 (100.0%)
init_block: 30 stmts out of 30 (100.0%)
lm_init: 19 stmts out of 19 (100.0%)
putShortMSB: 11 stmts out of 11 (100.0%)
tr_static_init: 1 stmts out of 1 (100.0%)
zcfree: 2 stmts out of 2 (100.0%)
zlibVersion: 2 stmts out of 2 (100.0%)
deflateEnd: 21 stmts out of 25 (84.0%)
flush_pending: 14 stmts out of 17 (82.4%)
deflateResetKeep: 25 stmts out of 32 (78.1%)
zcalloc: 3 stmts out of 4 (75.0%)
compress2: 30 stmts out of 41 (73.2%)
deflateInit2_: 73 stmts out of 101 (72.3%)
read_buf: 11 stmts out of 17 (64.7%)
main: 21 stmts out of 44 (47.7%)
fill_window: 28 stmts out of 59 (47.5%)
deflateStateCheck: 16 stmts out of 34 (47.1%)
zlibCompileFlags: 14 stmts out of 30 (46.7%)
test_compress: 7 stmts out of 19 (36.8%)
adler32_z: 27 stmts out of 170 (15.9%)
bi_flush: 3 stmts out of 23 (13.0%)
deflate: 50 stmts out of 484 (10.3%)
deflate_slow: 17 stmts out of 175 (9.7%)
test/example.c:109:[nonterm:unreachable] warning: unreachable return
test/example.c:601:[nonterm:unreachable] warning: unreachable return
compress.c:49:[nonterm:stmt] warning: non-terminating loop
stack: compress2 :: compress.c:74 <-
compress :: test/example.c:95 <-
test_compress :: test/example.c:579 <-
main
deflate.c:1003:[nonterm:stmt] warning: non-terminating function call
stack: deflate :: compress.c:58 <-
compress2 :: compress.c:74 <-
compress :: test/example.c:95 <-
test_compress :: test/example.c:579 <-
main
deflate.c:1934:[nonterm:stmt] warning: non-terminating loop
stack: deflate_slow :: deflate.c:1003 <-
deflate :: compress.c:58 <-
compress2 :: compress.c:74 <-
compress :: test/example.c:95 <-
test_compress :: test/example.c:579 <-
main
deflate.c:1958:[nonterm:stmt] warning: non-terminating statement
stack: deflate_slow :: deflate.c:1003 <-
deflate :: compress.c:58 <-
compress2 :: compress.c:74 <-
compress :: test/example.c:95 <-
test_compress :: test/example.c:579 <-
main
compress.c:74:[eva:locals-escaping] warning: locals {stream} escaping the scope of compress2 through __malloc_zcalloc_l311
This diff is collapsed.
[metrics] Defined functions (159)
=======================
_tr_align (1 call); _tr_flush_bits (2 calls); _tr_flush_block (13 calls);
_tr_init (1 call); _tr_stored_block (4 calls); _tr_tally (0 call);
adler32 (10 calls); adler32_combine (0 call); adler32_combine64 (0 call);
adler32_combine_ (2 calls); adler32_z (1 call); bi_flush (2 calls);
bi_reverse (1 call); bi_windup (2 calls); build_bl_tree (1 call);
build_tree (3 calls); compress (1 call); compress2 (1 call);
compressBound (0 call); compress_block (2 calls); crc32 (23 calls);
crc32_big (1 call); crc32_combine (0 call); crc32_combine64 (0 call);
crc32_combine_ (2 calls); crc32_little (1 call); crc32_z (1 call);
deflate (12 calls); deflateBound (0 call); deflateCopy (0 call);
deflateEnd (8 calls); deflateGetDictionary (0 call);
deflateInit2_ (2 calls); deflateInit_ (5 calls); deflateParams (3 calls);
deflatePending (0 call); deflatePrime (0 call); deflateReset (2 calls);
deflateResetKeep (1 call); deflateSetDictionary (1 call);
deflateSetHeader (0 call); deflateStateCheck (12 calls);
deflateTune (0 call); deflate_fast (address taken) (0 call);
deflate_huff (1 call); deflate_rle (1 call);
deflate_slow (address taken) (0 call);
deflate_stored (address taken) (1 call); detect_data_type (1 call);
fill_window (6 calls); fixedtables (1 call); fixedtables_0 (1 call);
flush_pending (25 calls); gen_bitlen (1 call); gen_codes (1 call);
get_crc_table (0 call); gf2_matrix_square (4 calls);
gf2_matrix_times (3 calls); gz_avail (2 calls); gz_comp (9 calls);
gz_decomp (2 calls); gz_error (23 calls); gz_fetch (3 calls);
gz_init (3 calls); gz_load (3 calls); gz_look (2 calls); gz_open (3 calls);
gz_read (3 calls); gz_reset (2 calls); gz_skip (3 calls);
gz_write (4 calls); gz_zero (6 calls); gzbuffer (0 call);
gzclearerr (0 call); gzclose (2 calls); gzclose_r (1 call);
gzclose_w (1 call); gzdirect (0 call); gzdopen (0 call); gzeof (0 call);
gzerror (4 calls); gzflush (0 call); gzfread (0 call); gzfwrite (0 call);
gzgetc (2 calls); gzgetc_ (0 call); gzgets (1 call); gzoffset (0 call);
gzoffset64 (1 call); gzopen (2 calls); gzopen64 (0 call); gzprintf (1 call);
gzputc (1 call); gzputs (1 call); gzread (1 call); gzrewind (1 call);
gzseek (2 calls); gzseek64 (1 call); gzsetparams (0 call); gztell (2 calls);
gztell64 (1 call); gzungetc (1 call); gzvprintf (1 call); gzwrite (0 call);
inflate (7 calls); inflateBack (0 call); inflateBackEnd (0 call);
inflateBackInit_ (0 call); inflateCodesUsed (0 call); inflateCopy (0 call);
inflateEnd (6 calls); inflateGetDictionary (0 call);
inflateGetHeader (0 call); inflateInit2_ (2 calls); inflateInit_ (5 calls);
inflateMark (0 call); inflatePrime (0 call); inflateReset (3 calls);
inflateReset2 (1 call); inflateResetKeep (1 call);
inflateSetDictionary (1 call); inflateStateCheck (16 calls);
inflateSync (1 call); inflateSyncPoint (0 call); inflateUndermine (0 call);
inflateValidate (0 call); inflate_fast (2 calls); inflate_table (6 calls);
init_block (2 calls); lm_init (1 call); longest_match (2 calls);
main (0 call); pqdownheap (3 calls); putShortMSB (5 calls);
read_buf (3 calls); scan_tree (2 calls); send_all_trees (1 call);
send_tree (2 calls); slide_hash (2 calls); syncsearch (2 calls);
test_compress (1 call); test_deflate (1 call); test_dict_deflate (1 call);
test_dict_inflate (1 call); test_flush (1 call); test_gzio (1 call);
test_inflate (1 call); test_large_deflate (1 call);
test_large_inflate (1 call); test_sync (1 call); tr_static_init (1 call);
uncompress (1 call); uncompress2 (1 call); updatewindow (2 calls);
zError (0 call); zcalloc (address taken) (0 call);
zcfree (address taken) (0 call); zlibCompileFlags (1 call);
zlibVersion (2 calls);
Specified-only functions (0)
============================
Undefined and unspecified functions (0)
=======================================
'Extern' global variables (0)
=============================
Potential entry points (41)
===========================
_tr_tally; adler32_combine; adler32_combine64; compressBound; crc32_combine;
crc32_combine64; deflateBound; deflateCopy; deflateGetDictionary;
deflatePending; deflatePrime; deflateSetHeader; deflateTune; get_crc_table;
gzbuffer; gzclearerr; gzdirect; gzdopen; gzeof; gzflush; gzfread; gzfwrite;
gzgetc_; gzoffset; gzopen64; gzsetparams; gzwrite; inflateBack;
inflateBackEnd; inflateBackInit_; inflateCodesUsed; inflateCopy;
inflateGetDictionary; inflateGetHeader; inflateMark; inflatePrime;
inflateSyncPoint; inflateUndermine; inflateValidate; main; zError;
Global metrics
==============
Sloc = 8092
Decision point = 1491
Global variables = 35
If = 1413
Loop = 161
Goto = 454
Assignment = 3857
Exit point = 159
Function = 159
Function call = 639
Pointer dereferencing = 4157
Cyclomatic complexity = 1650
test/example.c:365:[variadic] warning: Incorrect type for argument 3. The argument will be cast from uLong to long.
cmake_minimum_required(VERSION 2.4.4)
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
project(zlib C)
set(VERSION "1.2.11")
option(ASM686 "Enable building i686 assembly implementation")
option(AMD64 "Enable building amd64 assembly implementation")
set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables")
set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries")
set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers")
set(INSTALL_MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man" CACHE PATH "Installation directory for manual pages")
set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/share/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files")
include(CheckTypeSize)
include(CheckFunctionExists)
include(CheckIncludeFile)
include(CheckCSourceCompiles)
enable_testing()
check_include_file(sys/types.h HAVE_SYS_TYPES_H)
check_include_file(stdint.h HAVE_STDINT_H)
check_include_file(stddef.h HAVE_STDDEF_H)
#
# Check to see if we have large file support
#
set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1)
# We add these other definitions here because CheckTypeSize.cmake
# in CMake 2.4.x does not automatically do so and we want
# compatibility with CMake 2.4.x.
if(HAVE_SYS_TYPES_H)
list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_SYS_TYPES_H)
endif()
if(HAVE_STDINT_H)
list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDINT_H)
endif()
if(HAVE_STDDEF_H)
list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDDEF_H)
endif()
check_type_size(off64_t OFF64_T)
if(HAVE_OFF64_T)
add_definitions(-D_LARGEFILE64_SOURCE=1)
endif()
set(CMAKE_REQUIRED_DEFINITIONS) # clear variable
#
# Check for fseeko
#
check_function_exists(fseeko HAVE_FSEEKO)
if(NOT HAVE_FSEEKO)
add_definitions(-DNO_FSEEKO)
endif()
#
# Check for unistd.h
#
check_include_file(unistd.h Z_HAVE_UNISTD_H)
if(MSVC)
set(CMAKE_DEBUG_POSTFIX "d")
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
endif()
if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
# If we're doing an out of source build and the user has a zconf.h
# in their source tree...
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h)
message(STATUS "Renaming")
message(STATUS " ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h")
message(STATUS "to 'zconf.h.included' because this file is included with zlib")
message(STATUS "but CMake generates it automatically in the build directory.")
file(RENAME ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.included)
endif()
endif()
set(ZLIB_PC ${CMAKE_CURRENT_BINARY_DIR}/zlib.pc)
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zlib.pc.cmakein
${ZLIB_PC} @ONLY)
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein
${CMAKE_CURRENT_BINARY_DIR}/zconf.h @ONLY)
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR})
#============================================================================
# zlib
#============================================================================
set(ZLIB_PUBLIC_HDRS
${CMAKE_CURRENT_BINARY_DIR}/zconf.h
zlib.h
)
set(ZLIB_PRIVATE_HDRS
crc32.h
deflate.h
gzguts.h
inffast.h
inffixed.h
inflate.h
inftrees.h
trees.h
zutil.h
)
set(ZLIB_SRCS
adler32.c
compress.c
crc32.c
deflate.c
gzclose.c
gzlib.c
gzread.c
gzwrite.c
inflate.c
infback.c
inftrees.c
inffast.c
trees.c
uncompr.c
zutil.c
)
if(NOT MINGW)
set(ZLIB_DLL_SRCS
win32/zlib1.rc # If present will override custom build rule below.
)
endif()
if(CMAKE_COMPILER_IS_GNUCC)
if(ASM686)
set(ZLIB_ASMS contrib/asm686/match.S)
elseif (AMD64)
set(ZLIB_ASMS contrib/amd64/amd64-match.S)
endif ()
if(ZLIB_ASMS)
add_definitions(-DASMV)
set_source_files_properties(${ZLIB_ASMS} PROPERTIES LANGUAGE C COMPILE_FLAGS -DNO_UNDERLINE)
endif()
endif()
if(MSVC)
if(ASM686)
ENABLE_LANGUAGE(ASM_MASM)
set(ZLIB_ASMS
contrib/masmx86/inffas32.asm
contrib/masmx86/match686.asm
)
elseif (AMD64)
ENABLE_LANGUAGE(ASM_MASM)
set(ZLIB_ASMS
contrib/masmx64/gvmat64.asm
contrib/masmx64/inffasx64.asm
)
endif()
if(ZLIB_ASMS)
add_definitions(-DASMV -DASMINF)
endif()
endif()
# parse the full version number from zlib.h and include in ZLIB_FULL_VERSION
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents)
string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*"
"\\1" ZLIB_FULL_VERSION ${_zlib_h_contents})
if(MINGW)
# This gets us DLL resource information when compiling on MinGW.
if(NOT CMAKE_RC_COMPILER)
set(CMAKE_RC_COMPILER windres.exe)
endif()
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
COMMAND ${CMAKE_RC_COMPILER}
-D GCC_WINDRES
-I ${CMAKE_CURRENT_SOURCE_DIR}
-I ${CMAKE_CURRENT_BINARY_DIR}
-o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
-i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc)
set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
endif(MINGW)
add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
set_target_properties(zlib PROPERTIES SOVERSION 1)
if(NOT CYGWIN)
# This property causes shared libraries on Linux to have the full version
# encoded into their final filename. We disable this on Cygwin because
# it causes cygz-${ZLIB_FULL_VERSION}.dll to be created when cygz.dll
# seems to be the default.
#
# This has no effect with MSVC, on that platform the version info for
# the DLL comes from the resource file win32/zlib1.rc
set_target_properties(zlib PROPERTIES VERSION ${ZLIB_FULL_VERSION})
endif()
if(UNIX)
# On unix-like platforms the library is almost always called libz
set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z)
if(NOT APPLE)
set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"")
endif()
elseif(BUILD_SHARED_LIBS AND WIN32)
# Creates zlib1.dll when building shared library version
set_target_properties(zlib PROPERTIES SUFFIX "1.dll")
endif()
if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
install(TARGETS zlib zlibstatic
RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
LIBRARY DESTINATION "${INSTALL_LIB_DIR}" )
endif()
if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL )
install(FILES ${ZLIB_PUBLIC_HDRS} DESTINATION "${INSTALL_INC_DIR}")
endif()
if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
install(FILES zlib.3 DESTINATION "${INSTALL_MAN_DIR}/man3")
endif()
if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
install(FILES ${ZLIB_PC} DESTINATION "${INSTALL_PKGCONFIG_DIR}")
endif()
#============================================================================
# Example binaries
#============================================================================
add_executable(example test/example.c)
target_link_libraries(example zlib)
add_test(example example)
add_executable(minigzip test/minigzip.c)
target_link_libraries(minigzip zlib)
if(HAVE_OFF64_T)
add_executable(example64 test/example.c)
target_link_libraries(example64 zlib)
set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
add_test(example64 example64)
add_executable(minigzip64 test/minigzip.c)
target_link_libraries(minigzip64 zlib)
set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
endif()
This diff is collapsed.
Frequently Asked Questions about zlib
If your question is not there, please check the zlib home page
http://zlib.net/ which may have more recent information.
The lastest zlib FAQ is at http://zlib.net/zlib_faq.html
1. Is zlib Y2K-compliant?
Yes. zlib doesn't handle dates.
2. Where can I get a Windows DLL version?
The zlib sources can be compiled without change to produce a DLL. See the
file win32/DLL_FAQ.txt in the zlib distribution. Pointers to the
precompiled DLL are found in the zlib web site at http://zlib.net/ .
3. Where can I get a Visual Basic interface to zlib?
See
* http://marknelson.us/1997/01/01/zlib-engine/
* win32/DLL_FAQ.txt in the zlib distribution
4. compress() returns Z_BUF_ERROR.
Make sure that before the call of compress(), the length of the compressed
buffer is equal to the available size of the compressed buffer and not
zero. For Visual Basic, check that this parameter is passed by reference
("as any"), not by value ("as long").
5. deflate() or inflate() returns Z_BUF_ERROR.
Before making the call, make sure that avail_in and avail_out are not zero.
When setting the parameter flush equal to Z_FINISH, also make sure that
avail_out is big enough to allow processing all pending input. Note that a
Z_BUF_ERROR is not fatal--another call to deflate() or inflate() can be
made with more input or output space. A Z_BUF_ERROR may in fact be
unavoidable depending on how the functions are used, since it is not
possible to tell whether or not there is more output pending when
strm.avail_out returns with zero. See http://zlib.net/zlib_how.html for a
heavily annotated example.
6. Where's the zlib documentation (man pages, etc.)?
It's in zlib.h . Examples of zlib usage are in the files test/example.c
and test/minigzip.c, with more in examples/ .
7. Why don't you use GNU autoconf or libtool or ...?
Because we would like to keep zlib as a very small and simple package.
zlib is rather portable and doesn't need much configuration.
8. I found a bug in zlib.
Most of the time, such problems are due to an incorrect usage of zlib.
Please try to reproduce the problem with a small program and send the
corresponding source to us at zlib@gzip.org . Do not send multi-megabyte
data files without prior agreement.
9. Why do I get "undefined reference to gzputc"?
If "make test" produces something like
example.o(.text+0x154): undefined reference to `gzputc'
check that you don't have old files libz.* in /usr/lib, /usr/local/lib or
/usr/X11R6/lib. Remove any old versions, then do "make install".
10. I need a Delphi interface to zlib.
See the contrib/delphi directory in the zlib distribution.
11. Can zlib handle .zip archives?
Not by itself, no. See the directory contrib/minizip in the zlib
distribution.
12. Can zlib handle .Z files?