deflate-ruby 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CLAUDE.md +138 -0
- data/LICENSE.txt +21 -0
- data/README.md +117 -0
- data/ext/deflate_ruby/deflate_ruby.c +301 -0
- data/ext/deflate_ruby/extconf.rb +34 -0
- data/ext/deflate_ruby/libdeflate/CMakeLists.txt +270 -0
- data/ext/deflate_ruby/libdeflate/COPYING +22 -0
- data/ext/deflate_ruby/libdeflate/NEWS.md +494 -0
- data/ext/deflate_ruby/libdeflate/README.md +228 -0
- data/ext/deflate_ruby/libdeflate/common_defs.h +747 -0
- data/ext/deflate_ruby/libdeflate/lib/adler32.c +162 -0
- data/ext/deflate_ruby/libdeflate/lib/arm/adler32_impl.h +358 -0
- data/ext/deflate_ruby/libdeflate/lib/arm/cpu_features.c +230 -0
- data/ext/deflate_ruby/libdeflate/lib/arm/cpu_features.h +214 -0
- data/ext/deflate_ruby/libdeflate/lib/arm/crc32_impl.h +600 -0
- data/ext/deflate_ruby/libdeflate/lib/arm/crc32_pmull_helpers.h +156 -0
- data/ext/deflate_ruby/libdeflate/lib/arm/crc32_pmull_wide.h +226 -0
- data/ext/deflate_ruby/libdeflate/lib/arm/matchfinder_impl.h +78 -0
- data/ext/deflate_ruby/libdeflate/lib/bt_matchfinder.h +342 -0
- data/ext/deflate_ruby/libdeflate/lib/cpu_features_common.h +93 -0
- data/ext/deflate_ruby/libdeflate/lib/crc32.c +262 -0
- data/ext/deflate_ruby/libdeflate/lib/crc32_multipliers.h +377 -0
- data/ext/deflate_ruby/libdeflate/lib/crc32_tables.h +587 -0
- data/ext/deflate_ruby/libdeflate/lib/decompress_template.h +777 -0
- data/ext/deflate_ruby/libdeflate/lib/deflate_compress.c +4129 -0
- data/ext/deflate_ruby/libdeflate/lib/deflate_compress.h +15 -0
- data/ext/deflate_ruby/libdeflate/lib/deflate_constants.h +56 -0
- data/ext/deflate_ruby/libdeflate/lib/deflate_decompress.c +1208 -0
- data/ext/deflate_ruby/libdeflate/lib/gzip_compress.c +90 -0
- data/ext/deflate_ruby/libdeflate/lib/gzip_constants.h +45 -0
- data/ext/deflate_ruby/libdeflate/lib/gzip_decompress.c +144 -0
- data/ext/deflate_ruby/libdeflate/lib/hc_matchfinder.h +401 -0
- data/ext/deflate_ruby/libdeflate/lib/ht_matchfinder.h +234 -0
- data/ext/deflate_ruby/libdeflate/lib/lib_common.h +106 -0
- data/ext/deflate_ruby/libdeflate/lib/matchfinder_common.h +224 -0
- data/ext/deflate_ruby/libdeflate/lib/riscv/matchfinder_impl.h +97 -0
- data/ext/deflate_ruby/libdeflate/lib/utils.c +141 -0
- data/ext/deflate_ruby/libdeflate/lib/x86/adler32_impl.h +134 -0
- data/ext/deflate_ruby/libdeflate/lib/x86/adler32_template.h +518 -0
- data/ext/deflate_ruby/libdeflate/lib/x86/cpu_features.c +183 -0
- data/ext/deflate_ruby/libdeflate/lib/x86/cpu_features.h +169 -0
- data/ext/deflate_ruby/libdeflate/lib/x86/crc32_impl.h +160 -0
- data/ext/deflate_ruby/libdeflate/lib/x86/crc32_pclmul_template.h +495 -0
- data/ext/deflate_ruby/libdeflate/lib/x86/decompress_impl.h +57 -0
- data/ext/deflate_ruby/libdeflate/lib/x86/matchfinder_impl.h +122 -0
- data/ext/deflate_ruby/libdeflate/lib/zlib_compress.c +82 -0
- data/ext/deflate_ruby/libdeflate/lib/zlib_constants.h +21 -0
- data/ext/deflate_ruby/libdeflate/lib/zlib_decompress.c +104 -0
- data/ext/deflate_ruby/libdeflate/libdeflate-config.cmake.in +3 -0
- data/ext/deflate_ruby/libdeflate/libdeflate.h +411 -0
- data/ext/deflate_ruby/libdeflate/libdeflate.pc.in +18 -0
- data/ext/deflate_ruby/libdeflate/programs/CMakeLists.txt +105 -0
- data/ext/deflate_ruby/libdeflate/programs/benchmark.c +696 -0
- data/ext/deflate_ruby/libdeflate/programs/checksum.c +218 -0
- data/ext/deflate_ruby/libdeflate/programs/config.h.in +19 -0
- data/ext/deflate_ruby/libdeflate/programs/gzip.c +688 -0
- data/ext/deflate_ruby/libdeflate/programs/prog_util.c +521 -0
- data/ext/deflate_ruby/libdeflate/programs/prog_util.h +225 -0
- data/ext/deflate_ruby/libdeflate/programs/test_checksums.c +200 -0
- data/ext/deflate_ruby/libdeflate/programs/test_custom_malloc.c +155 -0
- data/ext/deflate_ruby/libdeflate/programs/test_incomplete_codes.c +385 -0
- data/ext/deflate_ruby/libdeflate/programs/test_invalid_streams.c +130 -0
- data/ext/deflate_ruby/libdeflate/programs/test_litrunlen_overflow.c +72 -0
- data/ext/deflate_ruby/libdeflate/programs/test_overread.c +95 -0
- data/ext/deflate_ruby/libdeflate/programs/test_slow_decompression.c +472 -0
- data/ext/deflate_ruby/libdeflate/programs/test_trailing_bytes.c +151 -0
- data/ext/deflate_ruby/libdeflate/programs/test_util.c +237 -0
- data/ext/deflate_ruby/libdeflate/programs/test_util.h +61 -0
- data/ext/deflate_ruby/libdeflate/programs/tgetopt.c +118 -0
- data/ext/deflate_ruby/libdeflate/scripts/android_build.sh +118 -0
- data/ext/deflate_ruby/libdeflate/scripts/android_tests.sh +69 -0
- data/ext/deflate_ruby/libdeflate/scripts/benchmark.sh +10 -0
- data/ext/deflate_ruby/libdeflate/scripts/checksum.sh +10 -0
- data/ext/deflate_ruby/libdeflate/scripts/checksum_benchmarks.sh +253 -0
- data/ext/deflate_ruby/libdeflate/scripts/cmake-helper.sh +17 -0
- data/ext/deflate_ruby/libdeflate/scripts/deflate_benchmarks.sh +119 -0
- data/ext/deflate_ruby/libdeflate/scripts/exec_tests.sh +38 -0
- data/ext/deflate_ruby/libdeflate/scripts/gen-release-archives.sh +37 -0
- data/ext/deflate_ruby/libdeflate/scripts/gen_bitreverse_tab.py +19 -0
- data/ext/deflate_ruby/libdeflate/scripts/gen_crc32_multipliers.c +199 -0
- data/ext/deflate_ruby/libdeflate/scripts/gen_crc32_tables.c +105 -0
- data/ext/deflate_ruby/libdeflate/scripts/gen_default_litlen_costs.py +44 -0
- data/ext/deflate_ruby/libdeflate/scripts/gen_offset_slot_map.py +29 -0
- data/ext/deflate_ruby/libdeflate/scripts/gzip_tests.sh +523 -0
- data/ext/deflate_ruby/libdeflate/scripts/libFuzzer/deflate_compress/corpus/0 +0 -0
- data/ext/deflate_ruby/libdeflate/scripts/libFuzzer/deflate_compress/fuzz.c +95 -0
- data/ext/deflate_ruby/libdeflate/scripts/libFuzzer/deflate_decompress/corpus/0 +3 -0
- data/ext/deflate_ruby/libdeflate/scripts/libFuzzer/deflate_decompress/fuzz.c +62 -0
- data/ext/deflate_ruby/libdeflate/scripts/libFuzzer/fuzz.sh +108 -0
- data/ext/deflate_ruby/libdeflate/scripts/libFuzzer/gzip_decompress/corpus/0 +0 -0
- data/ext/deflate_ruby/libdeflate/scripts/libFuzzer/gzip_decompress/fuzz.c +19 -0
- data/ext/deflate_ruby/libdeflate/scripts/libFuzzer/zlib_decompress/corpus/0 +3 -0
- data/ext/deflate_ruby/libdeflate/scripts/libFuzzer/zlib_decompress/fuzz.c +19 -0
- data/ext/deflate_ruby/libdeflate/scripts/run_tests.sh +416 -0
- data/ext/deflate_ruby/libdeflate/scripts/toolchain-i686-w64-mingw32.cmake +8 -0
- data/ext/deflate_ruby/libdeflate/scripts/toolchain-x86_64-w64-mingw32.cmake +8 -0
- data/lib/deflate_ruby/version.rb +5 -0
- data/lib/deflate_ruby.rb +71 -0
- metadata +191 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
include(CheckSymbolExists)
|
|
2
|
+
|
|
3
|
+
# Check for the availability of OS functionality and generate the config.h file.
|
|
4
|
+
#
|
|
5
|
+
# Keep CMAKE_REQUIRED_DEFINITIONS in sync with what prog_util.h does.
|
|
6
|
+
if(LINUX)
|
|
7
|
+
set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE -D_POSIX_C_SOURCE=200809L)
|
|
8
|
+
elseif(APPLE)
|
|
9
|
+
set(CMAKE_REQUIRED_DEFINITIONS -D_DARWIN_C_SOURCE -U_POSIX_C_SOURCE)
|
|
10
|
+
else()
|
|
11
|
+
set(CMAKE_REQUIRED_DEFINITIONS -U_POSIX_C_SOURCE)
|
|
12
|
+
endif()
|
|
13
|
+
check_symbol_exists(clock_gettime "time.h" HAVE_CLOCK_GETTIME)
|
|
14
|
+
check_symbol_exists(futimens "fcntl.h;sys/stat.h" HAVE_FUTIMENS)
|
|
15
|
+
check_symbol_exists(posix_fadvise "fcntl.h" HAVE_POSIX_FADVISE)
|
|
16
|
+
check_symbol_exists(posix_madvise "sys/mman.h" HAVE_POSIX_MADVISE)
|
|
17
|
+
check_c_source_compiles("#include <sys/types.h>
|
|
18
|
+
#include <sys/stat.h>
|
|
19
|
+
int main() { struct stat st; (void)st.st_atim; }"
|
|
20
|
+
HAVE_STAT_NANOSECOND_PRECISION)
|
|
21
|
+
configure_file(config.h.in config.h)
|
|
22
|
+
|
|
23
|
+
# Build a utility library for the programs. This library is not installed.
|
|
24
|
+
add_library(libdeflate_prog_utils STATIC prog_util.c tgetopt.c ../common_defs.h)
|
|
25
|
+
set_target_properties(libdeflate_prog_utils PROPERTIES
|
|
26
|
+
OUTPUT_NAME deflate_prog_utils)
|
|
27
|
+
if(LIBDEFLATE_USE_SHARED_LIB)
|
|
28
|
+
target_link_libraries(libdeflate_prog_utils PUBLIC libdeflate_shared)
|
|
29
|
+
else()
|
|
30
|
+
target_link_libraries(libdeflate_prog_utils PUBLIC libdeflate_static)
|
|
31
|
+
endif()
|
|
32
|
+
target_include_directories(libdeflate_prog_utils PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
|
|
33
|
+
target_compile_definitions(libdeflate_prog_utils PUBLIC HAVE_CONFIG_H)
|
|
34
|
+
if(WIN32)
|
|
35
|
+
if(MINGW)
|
|
36
|
+
target_compile_options(libdeflate_prog_utils PUBLIC -municode)
|
|
37
|
+
target_link_libraries(libdeflate_prog_utils PUBLIC -municode)
|
|
38
|
+
else()
|
|
39
|
+
target_compile_definitions(libdeflate_prog_utils PUBLIC UNICODE _UNICODE)
|
|
40
|
+
endif()
|
|
41
|
+
endif()
|
|
42
|
+
|
|
43
|
+
# Build and install libdeflate-gzip and its alias libdeflate-gunzip.
|
|
44
|
+
if(LIBDEFLATE_BUILD_GZIP)
|
|
45
|
+
add_executable(libdeflate-gzip gzip.c)
|
|
46
|
+
target_link_libraries(libdeflate-gzip PRIVATE libdeflate_prog_utils)
|
|
47
|
+
install(TARGETS libdeflate-gzip DESTINATION ${CMAKE_INSTALL_BINDIR})
|
|
48
|
+
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.14")
|
|
49
|
+
# Install libdeflate-gunzip as a hard link to libdeflate-gzip.
|
|
50
|
+
# Fall back to a copy if hard links are unsupported.
|
|
51
|
+
#
|
|
52
|
+
# Note: on Windows, prepending DESTDIR like this doesn't work correctly
|
|
53
|
+
# when ${CMAKE_INSTALL_FULL_BINDIR} includes a drive letter. But that
|
|
54
|
+
# is fine since DESTDIR is unsupported on Windows anyway, according to
|
|
55
|
+
# the CMake documentation.
|
|
56
|
+
set(GZIP "${CMAKE_INSTALL_FULL_BINDIR}/libdeflate-gzip${CMAKE_EXECUTABLE_SUFFIX}")
|
|
57
|
+
set(GUNZIP "${CMAKE_INSTALL_FULL_BINDIR}/libdeflate-gunzip${CMAKE_EXECUTABLE_SUFFIX}")
|
|
58
|
+
install(CODE "message(\"-- Installing: \$ENV{DESTDIR}${GUNZIP}\")")
|
|
59
|
+
install(CODE "file(CREATE_LINK \"\$ENV{DESTDIR}${GZIP}\"
|
|
60
|
+
\"\$ENV{DESTDIR}${GUNZIP}\" COPY_ON_ERROR)")
|
|
61
|
+
else()
|
|
62
|
+
# The cmake version is too old to support file(CREATE_LINK).
|
|
63
|
+
# Just compile gzip.c again to build libdeflate-gunzip.
|
|
64
|
+
add_executable(libdeflate-gunzip gzip.c)
|
|
65
|
+
target_link_libraries(libdeflate-gunzip PRIVATE libdeflate_prog_utils)
|
|
66
|
+
install(TARGETS libdeflate-gunzip DESTINATION ${CMAKE_INSTALL_BINDIR})
|
|
67
|
+
endif()
|
|
68
|
+
endif()
|
|
69
|
+
|
|
70
|
+
# Build the test programs, if requested.
|
|
71
|
+
if(LIBDEFLATE_BUILD_TESTS)
|
|
72
|
+
|
|
73
|
+
# The test programs depend on zlib for comparison tests.
|
|
74
|
+
find_package(ZLIB REQUIRED)
|
|
75
|
+
|
|
76
|
+
# Build a utility library for the test programs.
|
|
77
|
+
add_library(libdeflate_test_utils STATIC test_util.c)
|
|
78
|
+
set_target_properties(libdeflate_test_utils PROPERTIES
|
|
79
|
+
OUTPUT_NAME deflate_test_utils)
|
|
80
|
+
target_link_libraries(libdeflate_test_utils PUBLIC
|
|
81
|
+
libdeflate_prog_utils ZLIB::ZLIB)
|
|
82
|
+
|
|
83
|
+
# Build the benchmark and checksum programs.
|
|
84
|
+
add_executable(benchmark benchmark.c)
|
|
85
|
+
target_link_libraries(benchmark PRIVATE libdeflate_test_utils)
|
|
86
|
+
add_executable(checksum checksum.c)
|
|
87
|
+
target_link_libraries(checksum PRIVATE libdeflate_test_utils)
|
|
88
|
+
|
|
89
|
+
# Build the unit test programs and register them with CTest.
|
|
90
|
+
set(UNIT_TEST_PROGS
|
|
91
|
+
test_checksums
|
|
92
|
+
test_custom_malloc
|
|
93
|
+
test_incomplete_codes
|
|
94
|
+
test_invalid_streams
|
|
95
|
+
test_litrunlen_overflow
|
|
96
|
+
test_overread
|
|
97
|
+
test_slow_decompression
|
|
98
|
+
test_trailing_bytes
|
|
99
|
+
)
|
|
100
|
+
foreach(PROG ${UNIT_TEST_PROGS})
|
|
101
|
+
add_executable(${PROG} ${PROG}.c)
|
|
102
|
+
target_link_libraries(${PROG} PRIVATE libdeflate_test_utils)
|
|
103
|
+
add_test(NAME ${PROG} COMMAND ${PROG})
|
|
104
|
+
endforeach()
|
|
105
|
+
endif()
|