libdeflate 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/test.yml +34 -0
- data/README.md +1 -6
- data/ext/libdeflate/extconf.rb +18 -7
- data/ext/libdeflate/libdeflate_ext.c +17 -17
- data/lib/libdeflate/version.rb +1 -1
- data/libdeflate.gemspec +2 -1
- metadata +13 -84
- data/.gitmodules +0 -3
- data/.travis.yml +0 -5
- data/ext/libdeflate/libdeflate/.gitignore +0 -19
- data/ext/libdeflate/libdeflate/COPYING +0 -21
- data/ext/libdeflate/libdeflate/Makefile +0 -231
- data/ext/libdeflate/libdeflate/Makefile.msc +0 -64
- data/ext/libdeflate/libdeflate/NEWS +0 -57
- data/ext/libdeflate/libdeflate/README.md +0 -170
- data/ext/libdeflate/libdeflate/common/common_defs.h +0 -351
- data/ext/libdeflate/libdeflate/common/compiler_gcc.h +0 -134
- data/ext/libdeflate/libdeflate/common/compiler_msc.h +0 -95
- data/ext/libdeflate/libdeflate/lib/adler32.c +0 -213
- data/ext/libdeflate/libdeflate/lib/adler32_impl.h +0 -281
- data/ext/libdeflate/libdeflate/lib/aligned_malloc.c +0 -57
- data/ext/libdeflate/libdeflate/lib/aligned_malloc.h +0 -13
- data/ext/libdeflate/libdeflate/lib/bt_matchfinder.h +0 -357
- data/ext/libdeflate/libdeflate/lib/crc32.c +0 -368
- data/ext/libdeflate/libdeflate/lib/crc32_impl.h +0 -286
- data/ext/libdeflate/libdeflate/lib/crc32_table.h +0 -526
- data/ext/libdeflate/libdeflate/lib/decompress_impl.h +0 -404
- data/ext/libdeflate/libdeflate/lib/deflate_compress.c +0 -2817
- data/ext/libdeflate/libdeflate/lib/deflate_compress.h +0 -14
- data/ext/libdeflate/libdeflate/lib/deflate_constants.h +0 -66
- data/ext/libdeflate/libdeflate/lib/deflate_decompress.c +0 -889
- data/ext/libdeflate/libdeflate/lib/gzip_compress.c +0 -95
- data/ext/libdeflate/libdeflate/lib/gzip_constants.h +0 -45
- data/ext/libdeflate/libdeflate/lib/gzip_decompress.c +0 -130
- data/ext/libdeflate/libdeflate/lib/hc_matchfinder.h +0 -405
- data/ext/libdeflate/libdeflate/lib/lib_common.h +0 -35
- data/ext/libdeflate/libdeflate/lib/matchfinder_avx2.h +0 -53
- data/ext/libdeflate/libdeflate/lib/matchfinder_common.h +0 -205
- data/ext/libdeflate/libdeflate/lib/matchfinder_neon.h +0 -61
- data/ext/libdeflate/libdeflate/lib/matchfinder_sse2.h +0 -53
- data/ext/libdeflate/libdeflate/lib/unaligned.h +0 -202
- data/ext/libdeflate/libdeflate/lib/x86_cpu_features.c +0 -169
- data/ext/libdeflate/libdeflate/lib/x86_cpu_features.h +0 -48
- data/ext/libdeflate/libdeflate/lib/zlib_compress.c +0 -87
- data/ext/libdeflate/libdeflate/lib/zlib_constants.h +0 -21
- data/ext/libdeflate/libdeflate/lib/zlib_decompress.c +0 -91
- data/ext/libdeflate/libdeflate/libdeflate.h +0 -274
- data/ext/libdeflate/libdeflate/programs/benchmark.c +0 -558
- data/ext/libdeflate/libdeflate/programs/checksum.c +0 -197
- data/ext/libdeflate/libdeflate/programs/detect.sh +0 -62
- data/ext/libdeflate/libdeflate/programs/gzip.c +0 -603
- data/ext/libdeflate/libdeflate/programs/prog_util.c +0 -530
- data/ext/libdeflate/libdeflate/programs/prog_util.h +0 -162
- data/ext/libdeflate/libdeflate/programs/test_checksums.c +0 -135
- data/ext/libdeflate/libdeflate/programs/tgetopt.c +0 -118
- data/ext/libdeflate/libdeflate/tools/afl-fuzz/Makefile +0 -12
- data/ext/libdeflate/libdeflate/tools/afl-fuzz/deflate_compress/fuzz.c +0 -40
- data/ext/libdeflate/libdeflate/tools/afl-fuzz/deflate_compress/inputs/0 +0 -0
- data/ext/libdeflate/libdeflate/tools/afl-fuzz/deflate_decompress/fuzz.c +0 -28
- data/ext/libdeflate/libdeflate/tools/afl-fuzz/deflate_decompress/inputs/0 +0 -3
- data/ext/libdeflate/libdeflate/tools/afl-fuzz/gzip_decompress/fuzz.c +0 -28
- data/ext/libdeflate/libdeflate/tools/afl-fuzz/gzip_decompress/inputs/0 +0 -0
- data/ext/libdeflate/libdeflate/tools/afl-fuzz/prepare_for_fuzz.sh +0 -14
- data/ext/libdeflate/libdeflate/tools/afl-fuzz/zlib_decompress/fuzz.c +0 -28
- data/ext/libdeflate/libdeflate/tools/afl-fuzz/zlib_decompress/inputs/0 +0 -3
- data/ext/libdeflate/libdeflate/tools/android_build.sh +0 -104
- data/ext/libdeflate/libdeflate/tools/checksum_benchmarks.sh +0 -76
- data/ext/libdeflate/libdeflate/tools/exec_tests.sh +0 -30
- data/ext/libdeflate/libdeflate/tools/gen_crc32_multipliers.c +0 -108
- data/ext/libdeflate/libdeflate/tools/gen_crc32_table.c +0 -100
- data/ext/libdeflate/libdeflate/tools/gzip_tests.sh +0 -412
- data/ext/libdeflate/libdeflate/tools/make-windows-releases +0 -21
- data/ext/libdeflate/libdeflate/tools/mips_build.sh +0 -9
- data/ext/libdeflate/libdeflate/tools/msc_test.bat +0 -3
- data/ext/libdeflate/libdeflate/tools/pgo_build.sh +0 -23
- data/ext/libdeflate/libdeflate/tools/produce_gzip_benchmark_table.sh +0 -37
- data/ext/libdeflate/libdeflate/tools/run_tests.sh +0 -305
- data/ext/libdeflate/libdeflate/tools/windows_build.sh +0 -10
@@ -1,135 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* test_checksums.c
|
3
|
-
*
|
4
|
-
* Verify that libdeflate's Adler-32 and CRC-32 functions produce the same
|
5
|
-
* results as their zlib equivalents.
|
6
|
-
*/
|
7
|
-
|
8
|
-
#include <time.h>
|
9
|
-
#include <zlib.h>
|
10
|
-
|
11
|
-
#include "prog_util.h"
|
12
|
-
|
13
|
-
static unsigned int rng_seed;
|
14
|
-
|
15
|
-
static void
|
16
|
-
assertion_failed(const char *file, int line)
|
17
|
-
{
|
18
|
-
fprintf(stderr, "Assertion failed at %s:%d\n", file, line);
|
19
|
-
fprintf(stderr, "RNG seed was %u\n", rng_seed);
|
20
|
-
abort();
|
21
|
-
}
|
22
|
-
|
23
|
-
#define ASSERT(expr) if (!(expr)) assertion_failed(__FILE__, __LINE__);
|
24
|
-
|
25
|
-
typedef u32 (*cksum_fn_t)(u32, const void *, size_t);
|
26
|
-
|
27
|
-
static u32
|
28
|
-
zlib_adler32(u32 adler, const void *buf, size_t len)
|
29
|
-
{
|
30
|
-
return adler32(adler, buf, len);
|
31
|
-
}
|
32
|
-
|
33
|
-
static u32
|
34
|
-
zlib_crc32(u32 crc, const void *buf, size_t len)
|
35
|
-
{
|
36
|
-
return crc32(crc, buf, len);
|
37
|
-
}
|
38
|
-
|
39
|
-
static u32
|
40
|
-
select_initial_crc(void)
|
41
|
-
{
|
42
|
-
if (rand() & 1)
|
43
|
-
return 0;
|
44
|
-
return ((u32)rand() << 16) | rand();
|
45
|
-
}
|
46
|
-
|
47
|
-
static u32
|
48
|
-
select_initial_adler(void)
|
49
|
-
{
|
50
|
-
if (rand() & 1)
|
51
|
-
return 1;
|
52
|
-
return ((u32)(rand() % 65521) << 16) | (rand() % 65521);
|
53
|
-
}
|
54
|
-
|
55
|
-
static void
|
56
|
-
test_initial_values(cksum_fn_t cksum, u32 expected)
|
57
|
-
{
|
58
|
-
ASSERT(cksum(0, NULL, 0) == expected);
|
59
|
-
if (cksum != zlib_adler32) /* broken */
|
60
|
-
ASSERT(cksum(0, NULL, 1) == expected);
|
61
|
-
ASSERT(cksum(0, NULL, 1234) == expected);
|
62
|
-
ASSERT(cksum(1234, NULL, 0) == expected);
|
63
|
-
ASSERT(cksum(1234, NULL, 1234) == expected);
|
64
|
-
}
|
65
|
-
|
66
|
-
static void
|
67
|
-
test_multipart(const u8 *buffer, unsigned size, const char *name,
|
68
|
-
cksum_fn_t cksum, u32 v, u32 expected)
|
69
|
-
{
|
70
|
-
unsigned division = (size != 0) ? rand() % size : 0;
|
71
|
-
v = cksum(v, buffer, division);
|
72
|
-
v = cksum(v, buffer + division, size - division);
|
73
|
-
if (v != expected) {
|
74
|
-
fprintf(stderr, "%s checksum failed multipart test\n", name);
|
75
|
-
ASSERT(0);
|
76
|
-
}
|
77
|
-
}
|
78
|
-
|
79
|
-
static void
|
80
|
-
test_checksums(const void *buffer, unsigned size, const char *name,
|
81
|
-
cksum_fn_t cksum1, cksum_fn_t cksum2, u32 initial_value)
|
82
|
-
{
|
83
|
-
u32 v1 = cksum1(initial_value, buffer, size);
|
84
|
-
u32 v2 = cksum2(initial_value, buffer, size);
|
85
|
-
|
86
|
-
if (v1 != v2) {
|
87
|
-
fprintf(stderr, "%s checksum mismatch\n", name);
|
88
|
-
fprintf(stderr, "initial_value=0x%08"PRIx32", buffer=%p, "
|
89
|
-
"contents ", initial_value, buffer);
|
90
|
-
for (unsigned i = 0; i < size; i++)
|
91
|
-
fprintf(stderr, "%02x", ((const u8 *)buffer)[i]);
|
92
|
-
fprintf(stderr, "\n");
|
93
|
-
ASSERT(0);
|
94
|
-
}
|
95
|
-
|
96
|
-
if ((rand() & 15) == 0) {
|
97
|
-
test_multipart(buffer, size, name, cksum1, initial_value, v1);
|
98
|
-
test_multipart(buffer, size, name, cksum2, initial_value, v1);
|
99
|
-
}
|
100
|
-
}
|
101
|
-
|
102
|
-
int
|
103
|
-
tmain(int argc, tchar *argv[])
|
104
|
-
{
|
105
|
-
u8 buffer[256];
|
106
|
-
|
107
|
-
rng_seed = time(NULL);
|
108
|
-
srand(rng_seed);
|
109
|
-
|
110
|
-
test_initial_values(libdeflate_adler32, 1);
|
111
|
-
test_initial_values(zlib_adler32, 1);
|
112
|
-
test_initial_values(libdeflate_crc32, 0);
|
113
|
-
test_initial_values(zlib_crc32, 0);
|
114
|
-
|
115
|
-
for (uint32_t i = 0; i < 50000; i++) {
|
116
|
-
/* test different buffer sizes and alignments */
|
117
|
-
int start = rand() % sizeof(buffer);
|
118
|
-
int len = rand() % (sizeof(buffer) - start);
|
119
|
-
|
120
|
-
for (int i = start; i < start + len; i++)
|
121
|
-
buffer[i] = rand();
|
122
|
-
|
123
|
-
test_checksums(&buffer[start], len, "Adler-32",
|
124
|
-
libdeflate_adler32, zlib_adler32,
|
125
|
-
select_initial_adler());
|
126
|
-
|
127
|
-
test_checksums(&buffer[start], len, "CRC-32",
|
128
|
-
libdeflate_crc32, zlib_crc32,
|
129
|
-
select_initial_crc());
|
130
|
-
}
|
131
|
-
|
132
|
-
printf("Adler-32 and CRC-32 checksum tests passed!\n");
|
133
|
-
|
134
|
-
return 0;
|
135
|
-
}
|
@@ -1,118 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* tgetopt.c - portable replacement for GNU getopt()
|
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 "prog_util.h"
|
29
|
-
|
30
|
-
tchar *toptarg;
|
31
|
-
int toptind = 1, topterr = 1, toptopt;
|
32
|
-
|
33
|
-
/*
|
34
|
-
* This is a simple implementation of getopt(). It can be compiled with either
|
35
|
-
* 'char' or 'wchar_t' as the character type.
|
36
|
-
*
|
37
|
-
* Do *not* use this implementation if you need any of the following features,
|
38
|
-
* as they are not supported:
|
39
|
-
* - Long options
|
40
|
-
* - Option-related arguments retained in argv, not nulled out
|
41
|
-
* - '+' and '-' characters in optstring
|
42
|
-
*/
|
43
|
-
int
|
44
|
-
tgetopt(int argc, tchar *argv[], const tchar *optstring)
|
45
|
-
{
|
46
|
-
static tchar empty[1];
|
47
|
-
static tchar *nextchar;
|
48
|
-
static bool done;
|
49
|
-
|
50
|
-
if (toptind == 1) {
|
51
|
-
/* Starting to scan a new argument vector */
|
52
|
-
nextchar = NULL;
|
53
|
-
done = false;
|
54
|
-
}
|
55
|
-
|
56
|
-
while (!done && (nextchar != NULL || toptind < argc)) {
|
57
|
-
if (nextchar == NULL) {
|
58
|
-
/* Scanning a new argument */
|
59
|
-
tchar *arg = argv[toptind++];
|
60
|
-
if (arg[0] == '-' && arg[1] != '\0') {
|
61
|
-
if (arg[1] == '-' && arg[2] == '\0') {
|
62
|
-
/* All args after "--" are nonoptions */
|
63
|
-
argv[toptind - 1] = NULL;
|
64
|
-
done = true;
|
65
|
-
} else {
|
66
|
-
/* Start of short option characters */
|
67
|
-
nextchar = &arg[1];
|
68
|
-
}
|
69
|
-
}
|
70
|
-
} else {
|
71
|
-
/* More short options in previous arg */
|
72
|
-
tchar opt = *nextchar;
|
73
|
-
tchar *p = tstrchr(optstring, opt);
|
74
|
-
if (p == NULL) {
|
75
|
-
if (topterr)
|
76
|
-
msg("invalid option -- '%"TC"'", opt);
|
77
|
-
toptopt = opt;
|
78
|
-
return '?';
|
79
|
-
}
|
80
|
-
/* 'opt' is a valid short option character */
|
81
|
-
nextchar++;
|
82
|
-
toptarg = NULL;
|
83
|
-
if (*(p + 1) == ':') {
|
84
|
-
/* 'opt' can take an argument */
|
85
|
-
if (*nextchar != '\0') {
|
86
|
-
/* Optarg is in same argv argument */
|
87
|
-
toptarg = nextchar;
|
88
|
-
nextchar = empty;
|
89
|
-
} else if (toptind < argc && *(p + 2) != ':') {
|
90
|
-
/* Optarg is next argv argument */
|
91
|
-
argv[toptind - 1] = NULL;
|
92
|
-
toptarg = argv[toptind++];
|
93
|
-
} else if (*(p + 2) != ':') {
|
94
|
-
if (topterr && *optstring != ':') {
|
95
|
-
msg("option requires an "
|
96
|
-
"argument -- '%"TC"'", opt);
|
97
|
-
}
|
98
|
-
toptopt = opt;
|
99
|
-
opt = (*optstring == ':') ? ':' : '?';
|
100
|
-
}
|
101
|
-
}
|
102
|
-
if (*nextchar == '\0') {
|
103
|
-
argv[toptind - 1] = NULL;
|
104
|
-
nextchar = NULL;
|
105
|
-
}
|
106
|
-
return opt;
|
107
|
-
}
|
108
|
-
}
|
109
|
-
|
110
|
-
/* Done scanning. Move all nonoptions to the end, set optind to the
|
111
|
-
* index of the first nonoption, and return -1. */
|
112
|
-
toptind = argc;
|
113
|
-
while (--argc > 0)
|
114
|
-
if (argv[argc] != NULL)
|
115
|
-
argv[--toptind] = argv[argc];
|
116
|
-
done = true;
|
117
|
-
return -1;
|
118
|
-
}
|
@@ -1,40 +0,0 @@
|
|
1
|
-
#include <assert.h>
|
2
|
-
#include <libdeflate.h>
|
3
|
-
#include <string.h>
|
4
|
-
#include <fcntl.h>
|
5
|
-
#include <unistd.h>
|
6
|
-
#include <sys/stat.h>
|
7
|
-
|
8
|
-
int main(int argc, char **argv)
|
9
|
-
{
|
10
|
-
struct libdeflate_decompressor *d;
|
11
|
-
struct libdeflate_compressor *c;
|
12
|
-
int ret;
|
13
|
-
int fd = open(argv[1], O_RDONLY);
|
14
|
-
struct stat stbuf;
|
15
|
-
assert(fd >= 0);
|
16
|
-
ret = fstat(fd, &stbuf);
|
17
|
-
assert(!ret);
|
18
|
-
|
19
|
-
char in[stbuf.st_size];
|
20
|
-
ret = read(fd, in, sizeof in);
|
21
|
-
assert(ret == sizeof in);
|
22
|
-
|
23
|
-
c = libdeflate_alloc_compressor(6);
|
24
|
-
d = libdeflate_alloc_decompressor();
|
25
|
-
|
26
|
-
char out[sizeof(in)];
|
27
|
-
char checkarray[sizeof(in)];
|
28
|
-
|
29
|
-
size_t csize = libdeflate_deflate_compress(c, in,sizeof in, out, sizeof out);
|
30
|
-
if (csize) {
|
31
|
-
enum libdeflate_result res;
|
32
|
-
res = libdeflate_deflate_decompress(d, out, csize, checkarray, sizeof in, NULL);
|
33
|
-
assert(!res);
|
34
|
-
assert(!memcmp(in, checkarray, sizeof in));
|
35
|
-
}
|
36
|
-
|
37
|
-
libdeflate_free_compressor(c);
|
38
|
-
libdeflate_free_decompressor(d);
|
39
|
-
return 0;
|
40
|
-
}
|
Binary file
|
@@ -1,28 +0,0 @@
|
|
1
|
-
#include <assert.h>
|
2
|
-
#include <libdeflate.h>
|
3
|
-
#include <fcntl.h>
|
4
|
-
#include <unistd.h>
|
5
|
-
#include <sys/stat.h>
|
6
|
-
|
7
|
-
int main(int argc, char **argv)
|
8
|
-
{
|
9
|
-
struct libdeflate_decompressor *d;
|
10
|
-
int ret;
|
11
|
-
int fd = open(argv[1], O_RDONLY);
|
12
|
-
struct stat stbuf;
|
13
|
-
assert(fd >= 0);
|
14
|
-
ret = fstat(fd, &stbuf);
|
15
|
-
assert(!ret);
|
16
|
-
|
17
|
-
char in[stbuf.st_size];
|
18
|
-
ret = read(fd, in, sizeof in);
|
19
|
-
assert(ret == sizeof in);
|
20
|
-
|
21
|
-
char out[sizeof(in) * 3];
|
22
|
-
|
23
|
-
d = libdeflate_alloc_decompressor();
|
24
|
-
|
25
|
-
libdeflate_deflate_decompress(d, in, sizeof in, out, sizeof out, NULL);
|
26
|
-
libdeflate_free_decompressor(d);
|
27
|
-
return 0;
|
28
|
-
}
|
@@ -1,28 +0,0 @@
|
|
1
|
-
#include <assert.h>
|
2
|
-
#include <libdeflate.h>
|
3
|
-
#include <fcntl.h>
|
4
|
-
#include <unistd.h>
|
5
|
-
#include <sys/stat.h>
|
6
|
-
|
7
|
-
int main(int argc, char **argv)
|
8
|
-
{
|
9
|
-
struct libdeflate_decompressor *d;
|
10
|
-
int ret;
|
11
|
-
int fd = open(argv[1], O_RDONLY);
|
12
|
-
struct stat stbuf;
|
13
|
-
assert(fd >= 0);
|
14
|
-
ret = fstat(fd, &stbuf);
|
15
|
-
assert(!ret);
|
16
|
-
|
17
|
-
char in[stbuf.st_size];
|
18
|
-
ret = read(fd, in, sizeof in);
|
19
|
-
assert(ret == sizeof in);
|
20
|
-
|
21
|
-
char out[sizeof(in) * 3];
|
22
|
-
|
23
|
-
d = libdeflate_alloc_decompressor();
|
24
|
-
|
25
|
-
libdeflate_gzip_decompress(d, in, sizeof in, out, sizeof out, NULL);
|
26
|
-
libdeflate_free_decompressor(d);
|
27
|
-
return 0;
|
28
|
-
}
|
Binary file
|
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/bin/sh
|
2
|
-
|
3
|
-
set -e
|
4
|
-
|
5
|
-
make -C ../../ clean
|
6
|
-
make clean
|
7
|
-
AFL_HARDEN=1 make CC=afl-gcc -C ../../
|
8
|
-
AFL_HARDEN=1 make CC=afl-gcc
|
9
|
-
|
10
|
-
for dir in $(find . -mindepth 1 -maxdepth 1 -type d); do
|
11
|
-
rm -rf /tmp/$dir
|
12
|
-
cp -va $dir /tmp/$dir
|
13
|
-
mkdir -p /tmp/$dir/outputs
|
14
|
-
done
|
@@ -1,28 +0,0 @@
|
|
1
|
-
#include <assert.h>
|
2
|
-
#include <libdeflate.h>
|
3
|
-
#include <fcntl.h>
|
4
|
-
#include <unistd.h>
|
5
|
-
#include <sys/stat.h>
|
6
|
-
|
7
|
-
int main(int argc, char **argv)
|
8
|
-
{
|
9
|
-
struct libdeflate_decompressor *d;
|
10
|
-
int ret;
|
11
|
-
int fd = open(argv[1], O_RDONLY);
|
12
|
-
struct stat stbuf;
|
13
|
-
assert(fd >= 0);
|
14
|
-
ret = fstat(fd, &stbuf);
|
15
|
-
assert(!ret);
|
16
|
-
|
17
|
-
char in[stbuf.st_size];
|
18
|
-
ret = read(fd, in, sizeof in);
|
19
|
-
assert(ret == sizeof in);
|
20
|
-
|
21
|
-
char out[sizeof(in) * 3];
|
22
|
-
|
23
|
-
d = libdeflate_alloc_decompressor();
|
24
|
-
|
25
|
-
libdeflate_zlib_decompress(d, in, sizeof in, out, sizeof out, NULL);
|
26
|
-
libdeflate_free_decompressor(d);
|
27
|
-
return 0;
|
28
|
-
}
|
@@ -1,104 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
set -eu
|
4
|
-
|
5
|
-
ARCH="arm32"
|
6
|
-
COMPILER="gcc"
|
7
|
-
NDKDIR="/opt/android-ndk"
|
8
|
-
DISABLE_NEON=
|
9
|
-
|
10
|
-
usage() {
|
11
|
-
cat << EOF
|
12
|
-
Usage: $0 [OPTION]... -- [BENCHMARK_PROGRAM_ARG]...
|
13
|
-
Build the libdeflate test programs for Android
|
14
|
-
|
15
|
-
--arch=ARCH Architecture: arm32|arm64 (default: $ARCH)
|
16
|
-
--compiler=COMPILER Compiler: gcc|clang (default: $COMPILER)
|
17
|
-
--ndkdir=NDKDIR Android NDK directory (default: $NDKDIR)
|
18
|
-
--disable-neon Disable NEON instructions
|
19
|
-
EOF
|
20
|
-
}
|
21
|
-
|
22
|
-
if ! options=$(getopt -o '' \
|
23
|
-
-l 'arch:,compiler:,ndkdir:,disable-neon,help' -- "$@"); then
|
24
|
-
usage
|
25
|
-
exit 1
|
26
|
-
fi
|
27
|
-
|
28
|
-
eval set -- "$options"
|
29
|
-
|
30
|
-
while [ $# -gt 0 ]; do
|
31
|
-
case "$1" in
|
32
|
-
--arch)
|
33
|
-
ARCH="$2"
|
34
|
-
shift
|
35
|
-
;;
|
36
|
-
--compiler)
|
37
|
-
COMPILER="$2"
|
38
|
-
shift
|
39
|
-
;;
|
40
|
-
--ndkdir)
|
41
|
-
NDKDIR="$2"
|
42
|
-
shift
|
43
|
-
;;
|
44
|
-
--disable-neon)
|
45
|
-
DISABLE_NEON=1
|
46
|
-
;;
|
47
|
-
--help)
|
48
|
-
usage
|
49
|
-
exit 0
|
50
|
-
;;
|
51
|
-
--)
|
52
|
-
shift
|
53
|
-
break
|
54
|
-
;;
|
55
|
-
*)
|
56
|
-
echo 1>&2 "Unknown option \"$1\""
|
57
|
-
usage
|
58
|
-
exit 1
|
59
|
-
esac
|
60
|
-
shift
|
61
|
-
done
|
62
|
-
|
63
|
-
CFLAGS="-fPIC -pie"
|
64
|
-
|
65
|
-
case "$ARCH" in
|
66
|
-
arm|arm32|aarch32)
|
67
|
-
GCC_TOOLCHAIN="arm-linux-androideabi-4.9"
|
68
|
-
CLANG_TARGET="armv7-none-linux-androideabi"
|
69
|
-
if [ -n "$DISABLE_NEON" ]; then
|
70
|
-
CFLAGS+=" -march=armv6"
|
71
|
-
else
|
72
|
-
CFLAGS+=" -march=armv7-a -mfpu=neon -mfloat-abi=softfp"
|
73
|
-
fi
|
74
|
-
CFLAGS+=" --sysroot=\"$NDKDIR/platforms/android-12/arch-arm\""
|
75
|
-
;;
|
76
|
-
arm64|aarch64)
|
77
|
-
GCC_TOOLCHAIN="aarch64-linux-android-4.9"
|
78
|
-
CLANG_TARGET="aarch64-none-linux-android"
|
79
|
-
CFLAGS+=" --sysroot=\"$NDKDIR/platforms/android-21/arch-arm64\""
|
80
|
-
;;
|
81
|
-
*)
|
82
|
-
echo 1>&2 "Unknown architecture: \"$ARCH\""
|
83
|
-
usage
|
84
|
-
exit 1
|
85
|
-
esac
|
86
|
-
|
87
|
-
case "$COMPILER" in
|
88
|
-
gcc)
|
89
|
-
CC="\"$NDKDIR/toolchains/$GCC_TOOLCHAIN/prebuilt/linux-x86_64/bin/${GCC_TOOLCHAIN%-*}-gcc\""
|
90
|
-
CFLAGS+=" -pie"
|
91
|
-
;;
|
92
|
-
clang)
|
93
|
-
CC="\"$NDKDIR/toolchains/llvm/prebuilt/linux-x86_64/bin/clang\""
|
94
|
-
CFLAGS+=" -target \"$CLANG_TARGET\""
|
95
|
-
CFLAGS+=" -gcc-toolchain \"$NDKDIR/toolchains/$GCC_TOOLCHAIN/prebuilt/linux-x86_64\""
|
96
|
-
;;
|
97
|
-
*)
|
98
|
-
echo 1>&2 "Unknown compiler: \"$COMPILER\""
|
99
|
-
usage
|
100
|
-
exit 1
|
101
|
-
esac
|
102
|
-
|
103
|
-
make -j$(grep -c processor /proc/cpuinfo) test_programs \
|
104
|
-
CC="$CC" CFLAGS="$CFLAGS"
|
@@ -1,76 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
set -eu
|
4
|
-
|
5
|
-
if [ $# -eq 0 ]; then
|
6
|
-
FILE="$HOME/data/silesia"
|
7
|
-
echo "Using default FILE: $FILE"
|
8
|
-
echo
|
9
|
-
elif [ $# -eq 1 ]; then
|
10
|
-
FILE="$1"
|
11
|
-
else
|
12
|
-
echo "Usage: $0 [FILE]" 1>&2
|
13
|
-
exit 1
|
14
|
-
fi
|
15
|
-
|
16
|
-
|
17
|
-
if ! grep -q '\<sse2\>' /proc/cpuinfo; then
|
18
|
-
echo "This script must be run on an x86 CPU" 1>&2
|
19
|
-
exit 1
|
20
|
-
fi
|
21
|
-
|
22
|
-
if [ -n "$(git status -s | egrep 'adler32.c|crc32.c')" ]; then
|
23
|
-
echo "This script will overwrite adler32.c and crc32.c, which" \
|
24
|
-
"have uncommitted changes. Refusing to run." 1>&2
|
25
|
-
exit 1
|
26
|
-
fi
|
27
|
-
|
28
|
-
do_benchmark() {
|
29
|
-
method="$1"
|
30
|
-
shift
|
31
|
-
speed=$(./checksum "$@" -t "$FILE" | \
|
32
|
-
grep -o '[0-9]\+ MB/s' | grep -o '[0-9]\+')
|
33
|
-
printf "%-36s%-10s\n" "$method" "$speed"
|
34
|
-
}
|
35
|
-
|
36
|
-
sort_by_speed() {
|
37
|
-
awk '{print $NF, $0}' | sort -nr | cut -f2- -d' '
|
38
|
-
}
|
39
|
-
|
40
|
-
cat << EOF
|
41
|
-
Method Speed (MB/s)
|
42
|
-
------ ------------
|
43
|
-
EOF
|
44
|
-
|
45
|
-
# CRC-32
|
46
|
-
(
|
47
|
-
if grep -q '\<pclmulqdq\>' /proc/cpuinfo; then
|
48
|
-
make checksum > /dev/null
|
49
|
-
do_benchmark "CRC-32 (libdeflate, PCLMUL/AVX)"
|
50
|
-
sed -i '/^\#if NEED_PCLMUL_IMPL && !defined(__AVX__)/,/^\#endif$/d' lib/crc32.c
|
51
|
-
make checksum > /dev/null
|
52
|
-
do_benchmark "CRC-32 (libdeflate, PCLMUL)"
|
53
|
-
fi
|
54
|
-
sed -i '/^#if defined(__PCLMUL__)/,/^\#endif$/d' lib/crc32.c
|
55
|
-
make checksum > /dev/null
|
56
|
-
do_benchmark "CRC-32 (libdeflate, generic)"
|
57
|
-
git checkout -f lib/crc32.c > /dev/null
|
58
|
-
do_benchmark "CRC-32 (zlib)" -Z
|
59
|
-
) | sort_by_speed
|
60
|
-
|
61
|
-
# Adler-32
|
62
|
-
echo
|
63
|
-
(
|
64
|
-
if grep -q '\<avx2\>' /proc/cpuinfo; then
|
65
|
-
make checksum > /dev/null
|
66
|
-
do_benchmark "Adler-32 (libdeflate, AVX2)" -A
|
67
|
-
fi
|
68
|
-
sed -i '/^#if defined(__AVX2__)/,/^\#endif$/d' lib/adler32.c
|
69
|
-
make checksum > /dev/null
|
70
|
-
do_benchmark "Adler-32 (libdeflate, SSE2)" -A
|
71
|
-
sed -i '/^#ifdef __SSE2__/,/^\#endif$/d' lib/adler32.c
|
72
|
-
make checksum > /dev/null
|
73
|
-
do_benchmark "Adler-32 (libdeflate, generic)" -A
|
74
|
-
git checkout -f lib/adler32.c > /dev/null
|
75
|
-
do_benchmark "Adler-32 (zlib)" -A -Z
|
76
|
-
) | sort_by_speed
|
@@ -1,30 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Helper script used by run_tests.sh, not intended to be run directly
|
3
|
-
#
|
4
|
-
|
5
|
-
set -eu
|
6
|
-
|
7
|
-
run_cmd() {
|
8
|
-
echo "$WRAPPER $@"
|
9
|
-
$WRAPPER "$@" > /dev/null
|
10
|
-
}
|
11
|
-
|
12
|
-
run_cmd ./test_checksums
|
13
|
-
|
14
|
-
for format in '' '-g' '-z'; do
|
15
|
-
for ref_impl in '' '-Y' '-Z'; do
|
16
|
-
run_cmd ./benchmark $format $ref_impl $SMOKEDATA
|
17
|
-
done
|
18
|
-
done
|
19
|
-
for level in 1 3 7 9; do
|
20
|
-
for ref_impl in '' '-Y'; do
|
21
|
-
run_cmd ./benchmark -$level $ref_impl $SMOKEDATA
|
22
|
-
done
|
23
|
-
done
|
24
|
-
for level in 1 3 7 9 12; do
|
25
|
-
for ref_impl in '' '-Z'; do
|
26
|
-
run_cmd ./benchmark -$level $ref_impl $SMOKEDATA
|
27
|
-
done
|
28
|
-
done
|
29
|
-
|
30
|
-
echo "exec_tests finished successfully" # Needed for 'adb shell'
|