libdeflate 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/test.yml +34 -0
  3. data/README.md +1 -6
  4. data/ext/libdeflate/extconf.rb +18 -7
  5. data/ext/libdeflate/libdeflate_ext.c +17 -17
  6. data/lib/libdeflate/version.rb +1 -1
  7. data/libdeflate.gemspec +2 -1
  8. metadata +13 -84
  9. data/.gitmodules +0 -3
  10. data/.travis.yml +0 -5
  11. data/ext/libdeflate/libdeflate/.gitignore +0 -19
  12. data/ext/libdeflate/libdeflate/COPYING +0 -21
  13. data/ext/libdeflate/libdeflate/Makefile +0 -231
  14. data/ext/libdeflate/libdeflate/Makefile.msc +0 -64
  15. data/ext/libdeflate/libdeflate/NEWS +0 -57
  16. data/ext/libdeflate/libdeflate/README.md +0 -170
  17. data/ext/libdeflate/libdeflate/common/common_defs.h +0 -351
  18. data/ext/libdeflate/libdeflate/common/compiler_gcc.h +0 -134
  19. data/ext/libdeflate/libdeflate/common/compiler_msc.h +0 -95
  20. data/ext/libdeflate/libdeflate/lib/adler32.c +0 -213
  21. data/ext/libdeflate/libdeflate/lib/adler32_impl.h +0 -281
  22. data/ext/libdeflate/libdeflate/lib/aligned_malloc.c +0 -57
  23. data/ext/libdeflate/libdeflate/lib/aligned_malloc.h +0 -13
  24. data/ext/libdeflate/libdeflate/lib/bt_matchfinder.h +0 -357
  25. data/ext/libdeflate/libdeflate/lib/crc32.c +0 -368
  26. data/ext/libdeflate/libdeflate/lib/crc32_impl.h +0 -286
  27. data/ext/libdeflate/libdeflate/lib/crc32_table.h +0 -526
  28. data/ext/libdeflate/libdeflate/lib/decompress_impl.h +0 -404
  29. data/ext/libdeflate/libdeflate/lib/deflate_compress.c +0 -2817
  30. data/ext/libdeflate/libdeflate/lib/deflate_compress.h +0 -14
  31. data/ext/libdeflate/libdeflate/lib/deflate_constants.h +0 -66
  32. data/ext/libdeflate/libdeflate/lib/deflate_decompress.c +0 -889
  33. data/ext/libdeflate/libdeflate/lib/gzip_compress.c +0 -95
  34. data/ext/libdeflate/libdeflate/lib/gzip_constants.h +0 -45
  35. data/ext/libdeflate/libdeflate/lib/gzip_decompress.c +0 -130
  36. data/ext/libdeflate/libdeflate/lib/hc_matchfinder.h +0 -405
  37. data/ext/libdeflate/libdeflate/lib/lib_common.h +0 -35
  38. data/ext/libdeflate/libdeflate/lib/matchfinder_avx2.h +0 -53
  39. data/ext/libdeflate/libdeflate/lib/matchfinder_common.h +0 -205
  40. data/ext/libdeflate/libdeflate/lib/matchfinder_neon.h +0 -61
  41. data/ext/libdeflate/libdeflate/lib/matchfinder_sse2.h +0 -53
  42. data/ext/libdeflate/libdeflate/lib/unaligned.h +0 -202
  43. data/ext/libdeflate/libdeflate/lib/x86_cpu_features.c +0 -169
  44. data/ext/libdeflate/libdeflate/lib/x86_cpu_features.h +0 -48
  45. data/ext/libdeflate/libdeflate/lib/zlib_compress.c +0 -87
  46. data/ext/libdeflate/libdeflate/lib/zlib_constants.h +0 -21
  47. data/ext/libdeflate/libdeflate/lib/zlib_decompress.c +0 -91
  48. data/ext/libdeflate/libdeflate/libdeflate.h +0 -274
  49. data/ext/libdeflate/libdeflate/programs/benchmark.c +0 -558
  50. data/ext/libdeflate/libdeflate/programs/checksum.c +0 -197
  51. data/ext/libdeflate/libdeflate/programs/detect.sh +0 -62
  52. data/ext/libdeflate/libdeflate/programs/gzip.c +0 -603
  53. data/ext/libdeflate/libdeflate/programs/prog_util.c +0 -530
  54. data/ext/libdeflate/libdeflate/programs/prog_util.h +0 -162
  55. data/ext/libdeflate/libdeflate/programs/test_checksums.c +0 -135
  56. data/ext/libdeflate/libdeflate/programs/tgetopt.c +0 -118
  57. data/ext/libdeflate/libdeflate/tools/afl-fuzz/Makefile +0 -12
  58. data/ext/libdeflate/libdeflate/tools/afl-fuzz/deflate_compress/fuzz.c +0 -40
  59. data/ext/libdeflate/libdeflate/tools/afl-fuzz/deflate_compress/inputs/0 +0 -0
  60. data/ext/libdeflate/libdeflate/tools/afl-fuzz/deflate_decompress/fuzz.c +0 -28
  61. data/ext/libdeflate/libdeflate/tools/afl-fuzz/deflate_decompress/inputs/0 +0 -3
  62. data/ext/libdeflate/libdeflate/tools/afl-fuzz/gzip_decompress/fuzz.c +0 -28
  63. data/ext/libdeflate/libdeflate/tools/afl-fuzz/gzip_decompress/inputs/0 +0 -0
  64. data/ext/libdeflate/libdeflate/tools/afl-fuzz/prepare_for_fuzz.sh +0 -14
  65. data/ext/libdeflate/libdeflate/tools/afl-fuzz/zlib_decompress/fuzz.c +0 -28
  66. data/ext/libdeflate/libdeflate/tools/afl-fuzz/zlib_decompress/inputs/0 +0 -3
  67. data/ext/libdeflate/libdeflate/tools/android_build.sh +0 -104
  68. data/ext/libdeflate/libdeflate/tools/checksum_benchmarks.sh +0 -76
  69. data/ext/libdeflate/libdeflate/tools/exec_tests.sh +0 -30
  70. data/ext/libdeflate/libdeflate/tools/gen_crc32_multipliers.c +0 -108
  71. data/ext/libdeflate/libdeflate/tools/gen_crc32_table.c +0 -100
  72. data/ext/libdeflate/libdeflate/tools/gzip_tests.sh +0 -412
  73. data/ext/libdeflate/libdeflate/tools/make-windows-releases +0 -21
  74. data/ext/libdeflate/libdeflate/tools/mips_build.sh +0 -9
  75. data/ext/libdeflate/libdeflate/tools/msc_test.bat +0 -3
  76. data/ext/libdeflate/libdeflate/tools/pgo_build.sh +0 -23
  77. data/ext/libdeflate/libdeflate/tools/produce_gzip_benchmark_table.sh +0 -37
  78. data/ext/libdeflate/libdeflate/tools/run_tests.sh +0 -305
  79. data/ext/libdeflate/libdeflate/tools/windows_build.sh +0 -10
@@ -1,197 +0,0 @@
1
- /*
2
- * checksum.c - Adler-32 and CRC-32 checksumming program
3
- *
4
- * Copyright 2016 Eric Biggers
5
- *
6
- * Permission is hereby granted, free of charge, to any person
7
- * obtaining a copy of this software and associated documentation
8
- * files (the "Software"), to deal in the Software without
9
- * restriction, including without limitation the rights to use,
10
- * copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- * copies of the Software, and to permit persons to whom the
12
- * Software is furnished to do so, subject to the following
13
- * conditions:
14
- *
15
- * The above copyright notice and this permission notice shall be
16
- * included in all copies or substantial portions of the Software.
17
- *
18
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20
- * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25
- * OTHER DEALINGS IN THE SOFTWARE.
26
- */
27
-
28
- #include <zlib.h>
29
-
30
- #include "prog_util.h"
31
-
32
- static const tchar *const optstring = T("Ahs:tZ");
33
-
34
- static void
35
- show_usage(FILE *fp)
36
- {
37
- fprintf(fp,
38
- "Usage: %"TS" [-A] [-h] [-s SIZE] [-t] [-Z] [FILE]...\n"
39
- "Calculate Adler-32 or CRC-32 checksums of the specified FILEs.\n"
40
- "\n"
41
- "Options:\n"
42
- " -A use Adler-32 (default is CRC-32)\n"
43
- " -h print this help\n"
44
- " -s SIZE chunk size\n"
45
- " -t show checksum speed, excluding I/O\n"
46
- " -Z use zlib implementation instead of libdeflate\n",
47
- program_invocation_name);
48
- }
49
-
50
- static u32
51
- zlib_adler32(u32 adler, const void *buf, size_t len)
52
- {
53
- return adler32(adler, buf, len);
54
- }
55
-
56
- static u32
57
- zlib_crc32(u32 crc, const void *buf, size_t len)
58
- {
59
- return crc32(crc, buf, len);
60
- }
61
-
62
- typedef u32 (*cksum_fn_t)(u32, const void *, size_t);
63
-
64
- static int
65
- checksum_stream(struct file_stream *in, cksum_fn_t cksum, u32 *sum,
66
- void *buf, size_t bufsize, u64 *size_ret, u64 *elapsed_ret)
67
- {
68
- u64 size = 0;
69
- u64 elapsed = 0;
70
-
71
- for (;;) {
72
- ssize_t ret;
73
- u64 start_time;
74
-
75
- ret = xread(in, buf, bufsize);
76
- if (ret < 0)
77
- return ret;
78
- if (ret == 0)
79
- break;
80
-
81
- size += ret;
82
- start_time = timer_ticks();
83
- *sum = cksum(*sum, buf, ret);
84
- elapsed += timer_ticks() - start_time;
85
- }
86
-
87
- if (elapsed == 0)
88
- elapsed = 1;
89
- *size_ret = size;
90
- *elapsed_ret = elapsed;
91
- return 0;
92
- }
93
-
94
- int
95
- tmain(int argc, tchar *argv[])
96
- {
97
- bool use_adler32 = false;
98
- bool use_zlib_impl = false;
99
- bool do_timing = false;
100
- void *buf;
101
- size_t bufsize = 131072;
102
- tchar *default_file_list[] = { NULL };
103
- cksum_fn_t cksum;
104
- int opt_char;
105
- int i;
106
- int ret;
107
-
108
- program_invocation_name = get_filename(argv[0]);
109
-
110
- while ((opt_char = tgetopt(argc, argv, optstring)) != -1) {
111
- switch (opt_char) {
112
- case 'A':
113
- use_adler32 = true;
114
- break;
115
- case 'h':
116
- show_usage(stdout);
117
- return 0;
118
- case 's':
119
- bufsize = tstrtoul(toptarg, NULL, 10);
120
- if (bufsize == 0) {
121
- msg("invalid chunk size: \"%"TS"\"", toptarg);
122
- return 1;
123
- }
124
- break;
125
- case 't':
126
- do_timing = true;
127
- break;
128
- case 'Z':
129
- use_zlib_impl = true;
130
- break;
131
- default:
132
- show_usage(stderr);
133
- return 1;
134
- }
135
- }
136
-
137
- argc -= toptind;
138
- argv += toptind;
139
-
140
- if (use_adler32) {
141
- if (use_zlib_impl)
142
- cksum = zlib_adler32;
143
- else
144
- cksum = libdeflate_adler32;
145
- } else {
146
- if (use_zlib_impl)
147
- cksum = zlib_crc32;
148
- else
149
- cksum = libdeflate_crc32;
150
- }
151
-
152
- buf = xmalloc(bufsize);
153
- if (buf == NULL)
154
- return 1;
155
-
156
- if (argc == 0) {
157
- argv = default_file_list;
158
- argc = ARRAY_LEN(default_file_list);
159
- } else {
160
- for (i = 0; i < argc; i++)
161
- if (argv[i][0] == '-' && argv[i][1] == '\0')
162
- argv[i] = NULL;
163
- }
164
-
165
- for (i = 0; i < argc; i++) {
166
- struct file_stream in;
167
- u32 sum = cksum(0, NULL, 0);
168
- u64 size = 0;
169
- u64 elapsed = 0;
170
-
171
- ret = xopen_for_read(argv[i], true, &in);
172
- if (ret != 0)
173
- goto out;
174
-
175
- ret = checksum_stream(&in, cksum, &sum, buf, bufsize,
176
- &size, &elapsed);
177
- if (ret == 0) {
178
- if (do_timing) {
179
- printf("%08"PRIx32"\t%"TS"\t"
180
- "%"PRIu64" ms\t%"PRIu64" MB/s\n",
181
- sum, in.name, timer_ticks_to_ms(elapsed),
182
- timer_MB_per_s(size, elapsed));
183
- } else {
184
- printf("%08"PRIx32"\t%"TS"\t\n", sum, in.name);
185
- }
186
- }
187
-
188
- xclose(&in);
189
-
190
- if (ret != 0)
191
- goto out;
192
- }
193
- ret = 0;
194
- out:
195
- free(buf);
196
- return -ret;
197
- }
@@ -1,62 +0,0 @@
1
- #!/bin/sh
2
-
3
- if [ -z "$CC" ]; then
4
- CC=cc
5
- fi
6
-
7
- echo "/* THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. */"
8
- echo "#ifndef CONFIG_H"
9
- echo "#define CONFIG_H"
10
-
11
- tmpfile="$(mktemp -t libdeflate_config.XXXXXXXX)"
12
- trap "rm -f \"$tmpfile\"" EXIT
13
-
14
- program_compiles() {
15
- echo "$1" > "$tmpfile"
16
- $CC $CFLAGS -x c "$tmpfile" -o /dev/null > /dev/null 2>&1
17
- }
18
-
19
- check_function() {
20
- funcname="$1"
21
- macro="HAVE_$(echo $funcname | tr a-z A-Z)"
22
- echo
23
- echo "/* Is the $funcname() function available? */"
24
- if program_compiles "int main() { $funcname(); }"; then
25
- echo "#define $macro 1"
26
- else
27
- echo "/* $macro is not set */"
28
- fi
29
- }
30
-
31
- have_stat_field() {
32
- program_compiles "#include <sys/types.h>
33
- #include <sys/stat.h>
34
- int main() { struct stat st; st.$1; }"
35
- }
36
-
37
- check_stat_nanosecond_precision() {
38
- echo
39
- echo "/* Does stat() provide nanosecond-precision timestamps? */"
40
- if have_stat_field st_atim; then
41
- echo "#define HAVE_STAT_NANOSECOND_PRECISION 1"
42
- elif have_stat_field st_atimespec; then
43
- # Nonstandard field names used by OS X and older BSDs
44
- echo "#define HAVE_STAT_NANOSECOND_PRECISION 1"
45
- echo "#define st_atim st_atimespec"
46
- echo "#define st_mtim st_mtimespec"
47
- echo "#define st_ctim st_ctimespec"
48
- else
49
- echo "/* HAVE_STAT_NANOSECOND_PRECISION is not set */"
50
- fi
51
- }
52
-
53
- check_function clock_gettime
54
- check_function futimens
55
- check_function futimes
56
- check_function posix_fadvise
57
- check_function posix_madvise
58
-
59
- check_stat_nanosecond_precision
60
-
61
- echo
62
- echo "#endif /* CONFIG_H */"