Commit 8731623c authored by Andre Maroneze's avatar Andre Maroneze 💬
Browse files

Merge branch 'feature/add-miniz' into 'master'

[miniz] new case study

See merge request !8
parents c066fe79 e485640a
......@@ -67,6 +67,7 @@ TARGETS=\
libspng \
microstrain \
mini-gmp \
miniz \
monocypher \
papabench \
polarssl \
......
......@@ -137,6 +137,7 @@ when available. We also summarize the license of each directory below.
- `libspng`: BSD 2-clause, see `LICENSE`
- `mibench`: several (see `LICENSE` file inside each subdirectory)
- `mini-gmp`: LGPL or GPL
- `miniz`: MIT
- `microstrain`: GPL and others, see `LICENSE`
- `monocypher`: see `README`
- `papabench`: GPL
......
# 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 -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 \
## GUI-only flags
FCGUIFLAGS += \
-add-symbolic-path=.:.. \
## Analysis targets (suffixed with .eva)
TARGETS = miniz.eva
### Each target <t>.eva needs a rule <t>.parse with source files as prerequisites
miniz.parse: \
../examples/example1.c \
../miniz.c \
../miniz_tdef.c \
### Epilogue. Do not modify this block. #######################################
include $(shell $(FRAMAC)-config -scripts)/epilogue.mk
###############################################################################
# optional, for OSCS
-include ../../Makefile.common
directory file line function property kind status property
. miniz.c 253 mz_deflate initialization Unknown \initialized(&((tdefl_compressor *)pStream->state)->m_prev_return_status)
. miniz_tdef.c 744 TDEFL_READ_UNALIGNED_WORD initialization Unknown \initialized(&ret)
. miniz_tdef.c 750 TDEFL_READ_UNALIGNED_WORD2 initialization Unknown \initialized(&ret)
. miniz_tdef.c 759 tdefl_find_match initialization Unknown \initialized(&d->m_max_probes[(int)(match_len ≥ 32? 1: 0)])
. miniz_tdef.c 762 tdefl_find_match precondition of __FC_assert Unknown nonnull_c: c ≢ 0
. miniz_tdef.c 778 tdefl_find_match initialization Unknown \initialized(&d->m_next[probe_pos])
. miniz_tdef.c 1041 tdefl_record_literal initialization Unknown \initialized(&d->m_total_lz_bytes)
. miniz_tdef.c 1042 tdefl_record_literal initialization Unknown \initialized(&d->m_pLZ_code_buf)
. miniz_tdef.c 1043 tdefl_record_literal initialization Unknown \initialized(&d->m_pLZ_flags)
. miniz_tdef.c 1043 tdefl_record_literal initialization Unknown \initialized(d->m_pLZ_flags)
. miniz_tdef.c 1092 tdefl_compress_normal initialization Unknown \initialized(&d->m_dict_size)
. miniz_tdef.c 1092 tdefl_compress_normal initialization Unknown \initialized(&d->m_lookahead_size)
. miniz_tdef.c 1117 tdefl_compress_normal mem_access Unknown \valid_read(tmp_1)
. miniz_tdef.c 1118 tdefl_compress_normal initialization Unknown \initialized(&d->m_lookahead_pos)
. miniz_tdef.c 1126 tdefl_compress_normal initialization Unknown \initialized(&d->m_dict[(unsigned int)((mz_uint)(ins_pos_0 + 1) & TDEFL_LZ_DICT_SIZE_MASK)])
. miniz_tdef.c 1126 tdefl_compress_normal initialization Unknown \initialized(&d->m_dict[(unsigned int)(ins_pos_0 & TDEFL_LZ_DICT_SIZE_MASK)])
. miniz_tdef.c 1127 tdefl_compress_normal initialization Unknown \initialized(&d->m_hash[hash_0])
. miniz_tdef.c 1139 tdefl_compress_normal initialization Unknown \initialized(&d->m_saved_match_len)
. miniz_tdef.c 1140 tdefl_compress_normal initialization Unknown \initialized(&d->m_lookahead_pos)
. miniz_tdef.c 1193 tdefl_compress_normal initialization Unknown \initialized(&d->m_dict[tmp_2])
. miniz_tdef.c 1268 tdefl_compress initialization Unknown \initialized(&d->m_pPut_buf_func)
. miniz_tdef.c 1269 tdefl_compress initialization Unknown \initialized(&d->m_wants_to_finish)
. miniz_tdef.c 1279 tdefl_compress initialization Unknown \initialized(&d->m_output_flush_remaining)
. miniz_tdef.c 1279 tdefl_compress initialization Unknown \initialized(&d->m_finished)
. miniz_tdef.c 1283 tdefl_compress initialization Unknown \initialized(&d->m_flags)
FRAMAC_SHARE/libc assert.h 31 __FC_assert precondition Unknown nonnull_c: c ≢ 0
[metrics] Eva coverage statistics
=======================
Syntactically reachable functions = 41 (out of 58)
Semantically reached functions = 18
Coverage estimation = 43.9%
Unreached functions (23) =
<miniz.c>: miniz_def_free_func; mz_adler32; mz_inflate; mz_inflateEnd;
mz_inflateInit; mz_inflateInit2; mz_uncompress; mz_uncompress2;
<miniz_tdef.c>: tdefl_calculate_minimum_redundancy; tdefl_compress_block;
tdefl_compress_fast; tdefl_compress_lz_codes; tdefl_flush_block;
tdefl_flush_output_buffer; tdefl_get_adler32;
tdefl_huffman_enforce_max_code_size; tdefl_optimize_huffman_table;
tdefl_radix_sort_syms; TDEFL_READ_UNALIGNED_WORD32; tdefl_record_match;
tdefl_start_dynamic_block; tdefl_start_static_block;
<miniz_tinfl.h>: tinfl_decompress;
[metrics] References to non-analyzed functions
------------------------------------
Function main calls mz_uncompress (at examples/example1.c:66)
Function mz_deflate calls tdefl_get_adler32 (at miniz.c:268)
Function mz_deflateInit2 references miniz_def_free_func (at miniz.c:213)
Function tdefl_compress calls tdefl_flush_output_buffer (at miniz_tdef.c:1280)
Function tdefl_compress calls tdefl_compress_fast (at miniz_tdef.c:1287)
Function tdefl_compress calls mz_adler32 (at miniz_tdef.c:1298)
Function tdefl_compress calls tdefl_flush_block (at miniz_tdef.c:1302)
Function tdefl_compress calls tdefl_flush_output_buffer (at miniz_tdef.c:1313)
Function tdefl_compress_normal calls tdefl_record_match (at miniz_tdef.c:1174)
Function tdefl_compress_normal calls tdefl_record_match (at miniz_tdef.c:1187)
Function tdefl_compress_normal calls tdefl_record_match (at miniz_tdef.c:1196)
Function tdefl_compress_normal calls tdefl_flush_block (at miniz_tdef.c:1217)
[metrics] Statements analyzed by Eva
--------------------------
781 stmts in analyzed functions, 334 stmts analyzed (42.8%)
TDEFL_READ_UNALIGNED_WORD: 2 stmts out of 2 (100.0%)
TDEFL_READ_UNALIGNED_WORD2: 2 stmts out of 2 (100.0%)
miniz_def_alloc_func: 2 stmts out of 2 (100.0%)
mz_compress: 2 stmts out of 2 (100.0%)
mz_compressBound: 2 stmts out of 2 (100.0%)
mz_deflateInit: 2 stmts out of 2 (100.0%)
tdefl_init: 80 stmts out of 80 (100.0%)
mz_deflateBound: 4 stmts out of 5 (80.0%)
mz_compress2: 20 stmts out of 27 (74.1%)
tdefl_create_comp_flags_from_zip_params: 17 stmts out of 29 (58.6%)
mz_deflateInit2: 27 stmts out of 47 (57.4%)
mz_deflateEnd: 4 stmts out of 9 (44.4%)
tdefl_record_literal: 6 stmts out of 15 (40.0%)
main: 27 stmts out of 74 (36.5%)
tdefl_compress_normal: 57 stmts out of 166 (34.3%)
tdefl_compress: 33 stmts out of 103 (32.0%)
mz_deflate: 20 stmts out of 72 (27.8%)
tdefl_find_match: 27 stmts out of 142 (19.0%)
miniz_tdef.c:1043:[nonterm] warning: non-terminating statement
stack: tdefl_record_literal :: miniz_tdef.c:1193 <-
tdefl_compress_normal :: miniz_tdef.c:1293 <-
tdefl_compress :: miniz.c:264 <-
mz_deflate :: miniz.c:335 <-
mz_compress2 :: miniz.c:348 <-
mz_compress :: examples/example1.c:43 <-
main
miniz_tdef.c:1088:[nonterm] warning: non-terminating loop
stack: tdefl_compress_normal :: miniz_tdef.c:1293 <-
tdefl_compress :: miniz.c:264 <-
mz_deflate :: miniz.c:335 <-
mz_compress2 :: miniz.c:348 <-
mz_compress :: examples/example1.c:43 <-
main
miniz_tdef.c:1313:[nonterm] warning: unreachable return
This diff is collapsed.
[metrics] Defined functions (57)
======================
TDEFL_READ_UNALIGNED_WORD (5 calls); TDEFL_READ_UNALIGNED_WORD2 (18 calls);
TDEFL_READ_UNALIGNED_WORD32 (2 calls); main (0 call);
miniz_def_alloc_func (address taken) (0 call);
miniz_def_free_func (address taken) (0 call);
miniz_def_realloc_func (0 call); mz_adler32 (1 call); mz_compress (1 call);
mz_compress2 (1 call); mz_compressBound (1 call); mz_crc32 (2 calls);
mz_deflate (1 call); mz_deflateBound (1 call); mz_deflateEnd (3 calls);
mz_deflateInit (1 call); mz_deflateInit2 (1 call); mz_deflateReset (0 call);
mz_error (0 call); mz_free (0 call); mz_inflate (1 call);
mz_inflateEnd (2 calls); mz_inflateInit (1 call); mz_inflateInit2 (1 call);
mz_inflateReset (0 call); mz_uncompress (1 call); mz_uncompress2 (1 call);
mz_version (0 call); tdefl_calculate_minimum_redundancy (1 call);
tdefl_compress (2 calls); tdefl_compress_block (2 calls);
tdefl_compress_buffer (4 calls); tdefl_compress_fast (1 call);
tdefl_compress_lz_codes (1 call); tdefl_compress_mem_to_heap (0 call);
tdefl_compress_mem_to_mem (0 call); tdefl_compress_mem_to_output (2 calls);
tdefl_compress_normal (1 call); tdefl_compressor_alloc (0 call);
tdefl_compressor_free (0 call);
tdefl_create_comp_flags_from_zip_params (1 call); tdefl_find_match (1 call);
tdefl_flush_block (4 calls); tdefl_flush_output_buffer (2 calls);
tdefl_get_adler32 (1 call); tdefl_get_prev_return_status (0 call);
tdefl_huffman_enforce_max_code_size (1 call); tdefl_init (4 calls);
tdefl_optimize_huffman_table (5 calls);
tdefl_output_buffer_putter (address taken) (2 calls);
tdefl_radix_sort_syms (1 call); tdefl_record_literal (2 calls);
tdefl_record_match (3 calls); tdefl_start_dynamic_block (1 call);
tdefl_start_static_block (1 call);
tdefl_write_image_to_png_file_in_memory (0 call);
tdefl_write_image_to_png_file_in_memory_ex (1 call);
Specified-only functions (0)
============================
Undefined and unspecified functions (1)
=======================================
tinfl_decompress (2 calls);
'Extern' global variables (0)
=============================
Potential entry points (13)
===========================
main; miniz_def_realloc_func; mz_deflateReset; mz_error; mz_free;
mz_inflateReset; mz_version; tdefl_compress_mem_to_heap;
tdefl_compress_mem_to_mem; tdefl_compressor_alloc; tdefl_compressor_free;
tdefl_get_prev_return_status; tdefl_write_image_to_png_file_in_memory;
Global metrics
==============
Sloc = 2795
Decision point = 457
Global variables = 14
If = 457
Loop = 94
Goto = 117
Assignment = 1405
Exit point = 57
Function = 58
Function call = 206
Pointer dereferencing = 1239
Cyclomatic complexity = 514
../../path.mk
\ No newline at end of file
cmake_minimum_required(VERSION 3.0)
if(CMAKE_MINOR_VERSION LESS 12)
project(miniz)
# see issue https://gitlab.kitware.com/cmake/cmake/merge_requests/1799
else()
project(miniz C)
endif()
include(GNUInstallDirs)
set(MINIZ_API_VERSION 2)
set(MINIZ_MINOR_VERSION 1)
set(MINIZ_PATCH_VERSION 0)
set(MINIZ_VERSION
${MINIZ_API_VERSION}.${MINIZ_MINOR_VERSION}.${MINIZ_PATCH_VERSION})
if(CMAKE_BUILD_TYPE STREQUAL "")
# CMake defaults to leaving CMAKE_BUILD_TYPE empty. This screws up
# differentiation between debug and release builds.
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
"Choose the type of build, options are: None (CMAKE_CXX_FLAGS or \
CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif ()
option(BUILD_EXAMPLES "Build examples" ON)
option(BUILD_FUZZERS "Build fuzz targets" OFF)
option(AMALGAMATE_SOURCES "Amalgamate sources into miniz.h/c" OFF)
option(BUILD_HEADER_ONLY "Build a header-only version" OFF)
option(BUILD_SHARED_LIBS "Build shared library instead of static" ON)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin)
if(BUILD_HEADER_ONLY)
set(AMALGAMATE_SOURCES ON CACHE BOOL "Build a header-only version" FORCE)
endif(BUILD_HEADER_ONLY)
if(AMALGAMATE_SOURCES)
# Amalgamate
file(COPY miniz.h DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/amalgamation/)
file(READ miniz.h MINIZ_H)
file(READ miniz_common.h MINIZ_COMMON_H)
file(READ miniz_tdef.h MINIZ_TDEF_H)
file(READ miniz_tinfl.h MINIZ_TINFL_H)
file(READ miniz_zip.h MINIZ_ZIP_H)
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/amalgamation/miniz.h
"${MINIZ_COMMON_H} ${MINIZ_TDEF_H} ${MINIZ_TINFL_H} ${MINIZ_ZIP_H}")
file(COPY miniz.c DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/amalgamation/)
file(READ miniz_tdef.c MINIZ_TDEF_C)
file(READ miniz_tinfl.c MINIZ_TINFL_C)
file(READ miniz_zip.c MINIZ_ZIP_C)
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/amalgamation/miniz.c
"${MINIZ_TDEF_C} ${MINIZ_TINFL_C} ${MINIZ_ZIP_C}")
file(READ ${CMAKE_CURRENT_BINARY_DIR}/amalgamation/miniz.h AMAL_MINIZ_H)
file(READ ${CMAKE_CURRENT_BINARY_DIR}/amalgamation/miniz.c AMAL_MINIZ_C)
foreach(REPLACE_STRING miniz;miniz_common;miniz_tdef;miniz_tinfl;miniz_zip;miniz_export)
string(REPLACE "#include \"${REPLACE_STRING}.h\"" "" AMAL_MINIZ_H "${AMAL_MINIZ_H}")
string(REPLACE "#include \"${REPLACE_STRING}.h\"" "" AMAL_MINIZ_C "${AMAL_MINIZ_C}")
endforeach()
string(CONCAT AMAL_MINIZ_H "#define MINIZ_EXPORT\n" "${AMAL_MINIZ_H}")
if(BUILD_HEADER_ONLY)
string(CONCAT AMAL_MINIZ_H "${AMAL_MINIZ_H}" "\n#ifndef MINIZ_HEADER_FILE_ONLY\n"
"${AMAL_MINIZ_C}" "\n#endif // MINIZ_HEADER_FILE_ONLY\n")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/amalgamation/miniz.h "${AMAL_MINIZ_H}")
add_library(${PROJECT_NAME} INTERFACE)
# Might not be a good idea to force this on the library user
# as it could bloat the global namespace
# https://github.com/libevent/libevent/issues/460
# target_compile_definitions(${PROJECT_NAME}
# INTERFACE $<$<C_COMPILER_ID:GNU>:_GNU_SOURCE>)
set_property(TARGET ${PROJECT_NAME} APPEND
PROPERTY INTERFACE_INCLUDE_DIRECTORIES
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/amalgamation>
$<INSTALL_INTERFACE:include>
)
else(BUILD_HEADER_ONLY)
string(CONCAT AMAL_MINIZ_C "#include \"miniz.h\"\n" "${AMAL_MINIZ_C}")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/amalgamation/miniz.h "${AMAL_MINIZ_H}")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/amalgamation/miniz.c "${AMAL_MINIZ_C}")
set(miniz_SOURCE ${CMAKE_CURRENT_BINARY_DIR}/amalgamation/miniz.h
${CMAKE_CURRENT_BINARY_DIR}/amalgamation/miniz.c)
add_library(${PROJECT_NAME} STATIC ${miniz_SOURCE})
target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/amalgamation>
$<INSTALL_INTERFACE:include>
)
endif(BUILD_HEADER_ONLY)
set(INSTALL_HEADERS ${CMAKE_CURRENT_BINARY_DIR}/amalgamation/miniz.h)
else(AMALGAMATE_SOURCES)
include(GenerateExportHeader)
set(miniz_SOURCE miniz.c miniz_zip.c miniz_tinfl.c miniz_tdef.c)
add_library(${PROJECT_NAME} ${miniz_SOURCE})
generate_export_header(${PROJECT_NAME})
if(NOT BUILD_SHARED_LIBS)
string(TOUPPER ${PROJECT_NAME} PROJECT_UPPER)
set_target_properties(${PROJECT_NAME}
PROPERTIES INTERFACE_COMPILE_DEFINITIONS ${PROJECT_UPPER}_STATIC_DEFINE)
else()
set_property(TARGET ${PROJECT_NAME} PROPERTY C_VISIBILITY_PRESET hidden)
endif()
set_property(TARGET ${PROJECT_NAME} PROPERTY VERSION ${MINIZ_VERSION})
set_property(TARGET ${PROJECT_NAME} PROPERTY SOVERSION ${MINIZ_API_VERSION})
target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
$<INSTALL_INTERFACE:include>
)
file(GLOB INSTALL_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/*.h)
list(APPEND
INSTALL_HEADERS ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_export.h)
endif(AMALGAMATE_SOURCES)
if(NOT BUILD_HEADER_ONLY)
target_compile_definitions(${PROJECT_NAME}
PRIVATE $<$<C_COMPILER_ID:GNU>:_GNU_SOURCE>)
# pkg-config file
configure_file(miniz.pc.in ${CMAKE_BINARY_DIR}/miniz.pc @ONLY)
install(FILES
${CMAKE_BINARY_DIR}/miniz.pc
DESTINATION ${CMAKE_INSTALL_DATADIR}/pkgconfig)
endif()
set_property(TARGET ${PROJECT_NAME} PROPERTY
INTERFACE_${PROJECT_NAME}_MAJOR_VERSION ${MINIZ_API_VERSION})
set_property(TARGET ${PROJECT_NAME} APPEND PROPERTY
COMPATIBLE_INTERFACE_STRING ${PROJECT_NAME}_MAJOR_VERSION
)
install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}Targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
# users can use <miniz.h> or <miniz/miniz.h>
INCLUDES DESTINATION include ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}ConfigVersion.cmake"
VERSION ${MINIZ_VERSION}
COMPATIBILITY AnyNewerVersion
)
export(EXPORT ${PROJECT_NAME}Targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}Targets.cmake"
NAMESPACE ${PROJECT_NAME}::
)
configure_file(Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}Config.cmake"
@ONLY
)
set(ConfigPackageLocation ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
install(EXPORT ${PROJECT_NAME}Targets
FILE
${PROJECT_NAME}Targets.cmake
NAMESPACE
${PROJECT_NAME}::
DESTINATION
${ConfigPackageLocation}
)
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}Config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION
${ConfigPackageLocation}
COMPONENT
Devel
)
if(BUILD_EXAMPLES)
set(EXAMPLE1_SRC_LIST "${CMAKE_CURRENT_SOURCE_DIR}/examples/example1.c")
set(EXAMPLE2_SRC_LIST "${CMAKE_CURRENT_SOURCE_DIR}/examples/example2.c")
set(EXAMPLE3_SRC_LIST "${CMAKE_CURRENT_SOURCE_DIR}/examples/example3.c")
set(EXAMPLE4_SRC_LIST "${CMAKE_CURRENT_SOURCE_DIR}/examples/example4.c")
set(EXAMPLE5_SRC_LIST "${CMAKE_CURRENT_SOURCE_DIR}/examples/example5.c")
set(EXAMPLE6_SRC_LIST "${CMAKE_CURRENT_SOURCE_DIR}/examples/example6.c")
set(MINIZ_TESTER_SRC_LIST
"${CMAKE_CURRENT_SOURCE_DIR}/tests/miniz_tester.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/tests/timer.cpp")
add_executable(example1 ${EXAMPLE1_SRC_LIST})
target_link_libraries(example1 miniz)
add_executable(example2 ${EXAMPLE2_SRC_LIST})
target_link_libraries(example2 miniz)
add_executable(example3 ${EXAMPLE3_SRC_LIST})
target_link_libraries(example3 miniz)
add_executable(example4 ${EXAMPLE4_SRC_LIST})
target_link_libraries(example4 miniz)
add_executable(example5 ${EXAMPLE5_SRC_LIST})
target_link_libraries(example5 miniz)
add_executable(example6 ${EXAMPLE6_SRC_LIST})
target_link_libraries(example6 miniz)
if(${UNIX})
target_link_libraries(example6 m)
endif()
# add_executable(miniz_tester ${MINIZ_TESTER_SRC_LIST})
# target_link_libraries(miniz_tester miniz)
endif(BUILD_EXAMPLES)
if(BUILD_FUZZERS)
set(FUZZ_MAIN_SRC "${CMAKE_CURRENT_SOURCE_DIR}/tests/fuzz_main.c")
set(CHECKSUM_FUZZER_SRC_LIST "${FUZZ_MAIN_SRC}" "${CMAKE_CURRENT_SOURCE_DIR}/tests/checksum_fuzzer.c")
set(FLUSH_FUZZER_SRC_LIST "${FUZZ_MAIN_SRC}" "${CMAKE_CURRENT_SOURCE_DIR}/tests/flush_fuzzer.c")
set(UNCOMPRESS_FUZZER_SRC_LIST "${FUZZ_MAIN_SRC}" "${CMAKE_CURRENT_SOURCE_DIR}/tests/uncompress_fuzzer.c")
add_executable(checksum_fuzzer ${CHECKSUM_FUZZER_SRC_LIST})
target_link_libraries(checksum_fuzzer miniz)
add_executable(flush_fuzzer ${FLUSH_FUZZER_SRC_LIST})
target_link_libraries(flush_fuzzer miniz)
add_executable(uncompress_fuzzer ${UNCOMPRESS_FUZZER_SRC_LIST})
target_link_libraries(uncompress_fuzzer miniz)
endif()
set(INCLUDE_INSTALL_DIR "include")
install(FILES ${INSTALL_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})
## Changelog
### 2.1.0
- More instances of memcpy instead of cast and use memcpy per default
- Remove inline for c90 support
- New function to read files via callback functions when adding them
- Fix out of bounds read while reading Zip64 extended information
- guard memcpy when n == 0 because buffer may be NULL
- Implement inflateReset() function
- Move comp/decomp alloc/free prototypes under guarding #ifndef MZ_NO_MALLOC
- Fix large file support under Windows
- Don't warn if _LARGEFILE64_SOURCE is not defined to 1
- Fixes for MSVC warnings
- Remove check that path of file added to archive contains ':' or '\'
- Add !defined check on MINIZ_USE_ALIGNED_LOADS_AND_STORES
### 2.0.8
- Remove unimplemented functions (mz_zip_locate_file and mz_zip_locate_file_v2)
- Add license, changelog, readme and example files to release zip
- Fix heap overflow to user buffer in tinfl_status tinfl_decompress
- Fix corrupt archive if uncompressed file smaller than 4 byte and the file is added by mz_zip_writer_add_mem*
### 2.0.7
- Removed need in C++ compiler in cmake build
- Fixed a lot of uninitialized value errors found with Valgrind by memsetting m_dict to 0 in tdefl_init
- Fix resource leak in mz_zip_reader_init_file_v2
- Fix assert with mz_zip_writer_add_mem* w/MZ_DEFAULT_COMPRESSION
- cmake build: install library and headers
- Remove _LARGEFILE64_SOURCE requirement from apple defines for large files
### 2.0.6
- Improve MZ_ZIP_FLAG_WRITE_ZIP64 documentation
- Remove check for cur_archive_file_ofs > UINT_MAX because cur_archive_file_ofs is not used after this point
- Add cmake debug configuration
- Fix PNG height when creating png files
- Add "iterative" file extraction method based on mz_zip_reader_extract_to_callback.
- Option to use memcpy for unaligned data access
- Define processor/arch macros as zero if not set to one
### 2.0.4/2.0.5
- Fix compilation with the various omission compile definitions
### 2.0.3
- Fix GCC/clang compile warnings
- Added callback for periodic flushes (for ZIP file streaming)
- Use UTF-8 for file names in ZIP files per default
### 2.0.2
- Fix source backwards compatibility with 1.x
- Fix a ZIP bit not being set correctly
### 2.0.1
- Added some tests
- Added CI
- Make source code ANSI C compatible
### 2.0.0 beta
- Matthew Sitton merged miniz 1.x to Rich Geldreich's vogl ZIP64 changes. Miniz is now licensed as MIT since the vogl code base is MIT licensed
- Miniz is now split into several files
- Miniz does now not seek backwards when creating ZIP files. That is the ZIP files can be streamed
- Miniz automatically switches to the ZIP64 format when the created ZIP files goes over ZIP file limits
- Similar to [SQLite](https://www.sqlite.org/amalgamation.html) the Miniz source code is amalgamated into one miniz.c/miniz.h pair in a build step (amalgamate.sh). Please use miniz.c/miniz.h in your projects
- Miniz 2 is only source back-compatible with miniz 1.x. It breaks binary compatibility because structures changed
### v1.16 BETA Oct 19, 2013
Still testing, this release is downloadable from [here](http://www.tenacioussoftware.com/miniz_v116_beta_r1.7z). Two key inflator-only robustness and streaming related changes. Also merged in tdefl_compressor_alloc(), tdefl_compressor_free() helpers to make script bindings easier for rustyzip. I would greatly appreciate any help with testing or any feedback.
The inflator in raw (non-zlib) mode is now usable on gzip or similar streams that have a bunch of bytes following the raw deflate data (problem discovered by rustyzip author williamw520). This version should never read beyond the last byte of the raw deflate data independent of how many bytes you pass into the input buffer.
The inflator now has a new failure status TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS (-4). Previously, if the inflator was starved of bytes and could not make progress (because the input buffer was empty and the caller did not set the TINFL_FLAG_HAS_MORE_INPUT flag - say on truncated or corrupted compressed data stream) it would append all 0's to the input and try to soldier on. This is scary behavior if the caller didn't know when to stop accepting output (because it didn't know how much uncompressed data was expected, or didn't enforce a sane maximum). v1.16 will instead return TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS immediately if it needs 1 or more bytes to make progress, the input buf is empty, and the caller has indicated that no more input is available. This is a "soft" failure, so you can call the inflator again with more input and it will try to continue, or you can give up and fail. This could be very useful in network streaming scenarios.
- The inflator coroutine func. is subtle and complex so I'm being cautious about this release. I would greatly appreciate any help with testing or any feedback.
I feel good about these changes, and they've been through several hours of automated testing, but they will probably not fix anything for the majority of prev. users so I'm
going to mark this release as beta for a few weeks and continue testing it at work/home on various things.
- The inflator in raw (non-zlib) mode is now usable on gzip or similiar data streams that have a bunch of bytes following the raw deflate data (problem discovered by rustyzip author williamw520).
This version should *never* read beyond the last byte of the raw deflate data independent of how many bytes you pass into the input buffer. This issue was caused by the various Huffman bitbuffer lookahead optimizations, and
would not be an issue if the caller knew and enforced the precise size of the raw compressed data *or* if the compressed data was in zlib format (i.e. always followed by the byte aligned zlib adler32).
So in other words, you can now call the inflator on deflate streams that are followed by arbitrary amounts of data and it's guaranteed that decompression will stop exactly on the last byte.
- The inflator now has a new failure status: TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS (-4). Previously, if the inflator was starved of bytes and could not make progress (because the input buffer was empty and the
caller did not set the TINFL_FLAG_HAS_MORE_INPUT flag - say on truncated or corrupted compressed data stream) it would append all 0's to the input and try to soldier on.
This is scary, because in the worst case, I believe it was possible for the prev. inflator to start outputting large amounts of literal data. If the caller didn't know when to stop accepting output
(because it didn't know how much uncompressed data was expected, or didn't enforce a sane maximum) it could continue forever. v1.16 cannot fall into this failure mode, instead it'll return
TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS immediately if it needs 1 or more bytes to make progress, the input buf is empty, and the caller has indicated that no more input is available. This is a "soft"
failure, so you can call the inflator again with more input and it will try to continue, or you can give up and fail. This could be very useful in network streaming scenarios.
- Added documentation to all the tinfl return status codes, fixed miniz_tester so it accepts double minus params for Linux, tweaked example1.c, added a simple "follower bytes" test to miniz_tester.cpp.
### v1.15 r4 STABLE - Oct 13, 2013
Merged over a few very minor bug fixes that I fixed in the zip64 branch. This is downloadable from [here](http://code.google.com/p/miniz/downloads/list) and also in SVN head (as of 10/19/13).
### v1.15 - Oct. 13, 2013
Interim bugfix release while I work on the next major release with zip64 and streaming compression/decompression support. Fixed the MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY bug (thanks kahmyong.moon@hp.com), which could cause the locate files func to not find files when this flag was specified. Also fixed a bug in mz_zip_reader_extract_to_mem_no_alloc() with user provided read buffers (thanks kymoon). I also merged lots of compiler fixes from various github repo branches and Google Code issue reports. I finally added cmake support (only tested under for Linux so far), compiled and tested with clang v3.3 and gcc 4.6 (under Linux), added defl_write_image_to_png_file_in_memory_ex() (supports Y flipping for OpenGL use, real-time compression), added a new PNG example (example6.c - Mandelbrot), and I added 64-bit file I/O support (stat64(), etc.) for glibc.
- Critical fix for the MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY bug (thanks kahmyong.moon@hp.com) which could cause locate files to not find files. This bug
would only have occured in earlier versions if you explicitly used this flag, OR if you used mz_zip_extract_archive_file_to_heap() or mz_zip_add_mem_to_archive_file_in_place()
(which used this flag). If you can't switch to v1.15 but want to fix this bug, just remove the uses of this flag from both helper funcs (and of course don't use the flag).
- Bugfix in mz_zip_reader_extract_to_mem_no_alloc() from kymoon when pUser_read_buf is not NULL and compressed size is > uncompressed size
- Fixing mz_zip_reader_extract_*() funcs so they don't try to extract compressed data from directory entries, to account for weird zipfiles which contain zero-size compressed data on dir entries.
Hopefully this fix won't cause any issues on weird zip archives, because it assumes the low 16-bits of zip external attributes are DOS attributes (which I believe they always are in practice).
- Fixing mz_zip_reader_is_file_a_directory() so it doesn't check the internal attributes, just the filename and external attributes
- mz_zip_reader_init_file() - missing MZ_FCLOSE() call if the seek failed
- Added cmake support for Linux builds which builds all the examples, tested with clang v3.3 and gcc v4.6.
- Clang fix for tdefl_write_image_to_png_file_in_memory() from toffaletti
- Merged MZ_FORCEINLINE fix from hdeanclark
- Fix <time.h> include before config #ifdef, thanks emil.brink
- Added tdefl_write_image_to_png_file_in_memory_ex(): supports Y flipping (super useful for OpenGL apps), and explicit control over the compression level (so you can
set it to 1 for real-time compression).
- Merged in some compiler fixes from paulharris's github repro.
- Retested this build under Windows (VS 2010, including static analysis), tcc 0.9.26, gcc v4.6 and clang v3.3.
- Added example6.c, which dumps an image of the mandelbrot set to a PNG file.
- Modified example2 to help test the MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY flag more.
- In r3: Bugfix to mz_zip_writer_add_file() found during merge: Fix possible src file fclose() leak if alignment bytes+local header file write faiiled
- In r4: Minor bugfix to mz_zip_writer_add_from_zip_reader(): Was pushing the wrong central dir header offset, appears harmless in this release, but it became a problem in the zip64 branch
### v1.14 - May 20, 2012
(SVN Only) Minor tweaks to get miniz.c compiling with the Tiny C Compiler, added #ifndef MINIZ_NO_TIME guards around utime.h includes. Adding mz_free() function, so the caller can free heap blocks returned by miniz using whatever heap functions it has been configured to use, MSVC specific fixes to use "safe" variants of several functions (localtime_s, fopen_s, freopen_s).
MinGW32/64 GCC 4.6.1 compiler fixes: added MZ_FORCEINLINE, #include <time.h> (thanks fermtect).
Compiler specific fixes, some from fermtect. I upgraded to TDM GCC 4.6.1 and now static __forceinline is giving it fits, so I'm changing all usage of __forceinline to MZ_FORCEINLINE and forcing gcc to use __attribute__((__always_inline__)) (and MSVC to use __forceinline). Also various fixes from fermtect for MinGW32: added #include , 64-bit ftell/fseek fixes.
### v1.13 - May 19, 2012
From jason@cornsyrup.org and kelwert@mtu.edu - Most importantly, fixed mz_crc32() so it doesn't compute the wrong CRC-32's when mz_ulong is 64-bits. Temporarily/locally slammed in "typedef unsigned long mz_ulong" and re-ran a randomized regression test on ~500k files. Other stuff:
Eliminated a bunch of warnings when compiling with GCC 32-bit/64. Ran all examples, miniz.c, and tinfl.c through MSVC 2008's /analyze (static analysis) option and fixed all warnings (except for the silly "Use of the comma-operator in a tested expression.." analysis warning, which I purposely use to work around a MSVC compiler warning).
Created 32-bit and 64-bit Codeblocks projects/workspace. Built and tested Linux executables. The codeblocks workspace is compatible with Linux+Win32/x64. Added miniz_tester solution/project, which is a useful little app derived from LZHAM's tester app that I use as part of the regression test. Ran miniz.c and tinfl.c through another series of regression testing on ~500,000 files and archives. Modified example5.c so it purposely disables a bunch of high-level functionality (MINIZ_NO_STDIO, etc.). (Thanks to corysama for the MINIZ_NO_STDIO bug report.)
Fix ftell() usage in a few of the examples so they exit with an error on files which are too large (a limitation of the examples, not miniz itself). Fix fail logic handling in mz_zip_add_mem_to_archive_file_in_place() so it always calls mz_zip_writer_finalize_archive() and mz_zip_writer_end(), even if the file add fails.
- From jason@cornsyrup.org and kelwert@mtu.edu - Fix mz_crc32() so it doesn't compute the wrong CRC-32's when mz_ulong is 64-bit.
- Temporarily/locally slammed in "typedef unsigned long mz_ulong" and re-ran a randomized regression test on ~500k files.
- Eliminated a bunch of warnings when compiling with GCC 32-bit/64.
- Ran all examples, miniz.c, and tinfl.c through MSVC 2008's /analyze (static analysis) option and fixed all warnings (except for the silly
"Use of the comma-operator in a tested expression.." analysis warning, which I purposely use to work around a MSVC compiler warning).
- Crea