Skip to content

Commit dfd3a2d

Browse files
committed
Make Chorba configurable,and add a few missing header files to CMake config.
Add CI run without chorba enabled.
1 parent 0bf99cb commit dfd3a2d

5 files changed

Lines changed: 30 additions & 8 deletions

File tree

.github/workflows/cmake.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,13 @@ jobs:
9797
packages: gcc-multilib g++-multilib
9898
codecov: ubuntu_gcc_m32
9999

100+
- name: Ubuntu GCC No Chorba
101+
os: ubuntu-latest
102+
compiler: gcc
103+
cxx-compiler: g++
104+
cmake-args: -DWITH_CHORBA=OFF
105+
codecov: ubuntu_gcc_no_chorba
106+
100107
- name: Ubuntu GCC No CTZLL
101108
os: ubuntu-latest
102109
compiler: gcc

CMakeLists.txt

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ option(WITH_BENCHMARK_APPS "Build application benchmarks" OFF)
8686
option(WITH_OPTIM "Build with optimisation" ON)
8787
option(WITH_REDUCED_MEM "Reduced memory usage for special cases (reduces performance)" OFF)
8888
option(WITH_NEW_STRATEGIES "Use new strategies" ON)
89+
option(WITH_CRC32_CHORBA "Enable optimized CRC32 algorithm Chorba" ON)
8990
option(WITH_NATIVE_INSTRUCTIONS
9091
"Instruct the compiler to use the full instruction set on this host (gcc/clang -march=native)" OFF)
9192
option(WITH_RUNTIME_CPU_DETECTION "Build with runtime detection of CPU architecture" ON)
@@ -137,6 +138,7 @@ option(INSTALL_UTILS "Copy minigzip and minideflate during install" OFF)
137138
mark_as_advanced(FORCE
138139
ZLIB_SYMBOL_PREFIX
139140
WITH_REDUCED_MEM
141+
WITH_CRC32_CHORBA
140142
WITH_ARMV8 WITH_NEON
141143
WITH_ARMV6
142144
WITH_DFLTCC_DEFLATE
@@ -170,6 +172,10 @@ if(WITH_GZFILEOP)
170172
add_definitions(-DWITH_GZFILEOP)
171173
endif()
172174

175+
if(NOT WITH_CRC32_CHORBA)
176+
add_definitions(-DWITHOUT_CHORBA)
177+
endif()
178+
173179
if(CMAKE_C_COMPILER_ID MATCHES "^Intel")
174180
if(CMAKE_HOST_UNIX)
175181
set(WARNFLAGS -Wall)
@@ -1092,14 +1098,16 @@ set(ZLIB_PRIVATE_HDRS
10921098
arch/generic/compare256_p.h
10931099
arch/generic/generic_functions.h
10941100
adler32_p.h
1101+
arch_functions.h
10951102
chunkset_tpl.h
10961103
compare256_rle.h
1097-
arch_functions.h
1104+
crc32.h
10981105
crc32_braid_p.h
10991106
crc32_braid_comb_p.h
11001107
crc32_braid_tbl.h
11011108
deflate.h
11021109
deflate_p.h
1110+
fallback_builtins.h
11031111
functable.h
11041112
inffast_tpl.h
11051113
inffixed_tbl.h
@@ -1113,7 +1121,9 @@ set(ZLIB_PRIVATE_HDRS
11131121
trees_tbl.h
11141122
zbuild.h
11151123
zendian.h
1124+
zmemory.h
11161125
zutil.h
1126+
zutil_p.h
11171127
)
11181128
set(ZLIB_SRCS
11191129
arch/generic/adler32_c.c
@@ -1122,7 +1132,6 @@ set(ZLIB_SRCS
11221132
arch/generic/compare256_c.c
11231133
arch/generic/crc32_braid_c.c
11241134
arch/generic/crc32_c.c
1125-
arch/generic/crc32_chorba_c.c
11261135
arch/generic/crc32_fold_c.c
11271136
arch/generic/slide_hash_c.c
11281137
adler32.c
@@ -1148,6 +1157,10 @@ set(ZLIB_SRCS
11481157
zutil.c
11491158
)
11501159

1160+
if(WITH_CRC32_CHORBA)
1161+
list(APPEND ZLIB_SRCS arch/generic/crc32_chorba_c.c)
1162+
endif()
1163+
11511164
if(WITH_RUNTIME_CPU_DETECTION)
11521165
list(APPEND ZLIB_PRIVATE_HDRS cpu_features.h)
11531166
list(APPEND ZLIB_SRCS cpu_features.c)
@@ -1390,6 +1403,7 @@ add_feature_info(WITH_BENCHMARKS WITH_BENCHMARKS "Build test/benchmarks")
13901403
add_feature_info(WITH_BENCHMARK_APPS WITH_BENCHMARK_APPS "Build application benchmarks")
13911404
add_feature_info(WITH_OPTIM WITH_OPTIM "Build with optimisation")
13921405
add_feature_info(WITH_NEW_STRATEGIES WITH_NEW_STRATEGIES "Use new strategies")
1406+
add_feature_info(WITH_CRC32_CHORBA WITH_CRC32_CHORBA "Use optimized CRC32 algorithm Chorba")
13931407
add_feature_info(WITH_NATIVE_INSTRUCTIONS WITH_NATIVE_INSTRUCTIONS
13941408
"Instruct the compiler to use the full instruction set on this host (gcc/clang -march=native)")
13951409
add_feature_info(WITH_RUNTIME_CPU_DETECTION WITH_RUNTIME_CPU_DETECTION "Build with runtime CPU detection")

Makefile.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ OBJZ = \
8181
arch/generic/compare256_c.o \
8282
arch/generic/crc32_braid_c.o \
8383
arch/generic/crc32_c.o \
84-
arch/generic/crc32_chorba_c.o \
8584
arch/generic/crc32_fold_c.o \
8685
arch/generic/slide_hash_c.o \
8786
adler32.o \
@@ -105,6 +104,7 @@ OBJZ = \
105104
trees.o \
106105
uncompr.o \
107106
zutil.o \
107+
arch/generic/crc32_chorba_c.o \
108108
cpu_features.o \
109109
$(ARCH_STATIC_OBJS)
110110

@@ -123,7 +123,6 @@ PIC_OBJZ = \
123123
arch/generic/compare256_c.lo \
124124
arch/generic/crc32_braid_c.lo \
125125
arch/generic/crc32_c.lo \
126-
arch/generic/crc32_chorba_c.lo \
127126
arch/generic/crc32_fold_c.lo \
128127
arch/generic/slide_hash_c.lo \
129128
adler32.lo \
@@ -147,6 +146,7 @@ PIC_OBJZ = \
147146
trees.lo \
148147
uncompr.lo \
149148
zutil.lo \
149+
arch/generic/crc32_chorba_c.lo \
150150
cpu_features.lo \
151151
$(ARCH_SHARED_OBJS)
152152

arch/generic/crc32_c.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44
#include "generic_functions.h"
55

66
Z_INTERNAL uint32_t crc32_c(uint32_t crc, const uint8_t *buf, size_t len) {
7-
uint32_t c;
8-
uint64_t* aligned_buf;
9-
size_t aligned_len;
7+
uint32_t c = (~crc) & 0xffffffff;
108

11-
c = (~crc) & 0xffffffff;
129
#ifndef WITHOUT_CHORBA
10+
uint64_t* aligned_buf;
11+
size_t aligned_len;
1312
unsigned long algn_diff = ((uintptr_t)8 - ((uintptr_t)buf & 0xF)) & 0xF;
1413
if (algn_diff < len) {
1514
if (algn_diff) {

arch/x86/crc32_pclmulqdq_tpl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ static void fold_4(__m128i *xmm_crc0, __m128i *xmm_crc1, __m128i *xmm_crc2, __m1
168168
*xmm_crc3 = _mm_castps_si128(ps_res3);
169169
}
170170

171+
#ifndef WITHOUT_CHORBA
171172
static void fold_12(__m128i *xmm_crc0, __m128i *xmm_crc1, __m128i *xmm_crc2, __m128i *xmm_crc3) {
172173
const __m128i xmm_fold12 = _mm_set_epi64x(0x596C8D81, 0xF5E48C85);
173174
__m128i x_tmp0, x_tmp1, x_tmp2, x_tmp3;
@@ -209,6 +210,7 @@ static void fold_12(__m128i *xmm_crc0, __m128i *xmm_crc1, __m128i *xmm_crc2, __m
209210
*xmm_crc2 = _mm_castps_si128(ps_res2);
210211
*xmm_crc3 = _mm_castps_si128(ps_res3);
211212
}
213+
#endif
212214

213215
static const unsigned ALIGNED_(32) pshufb_shf_table[60] = {
214216
0x84838281, 0x88878685, 0x8c8b8a89, 0x008f8e8d, /* shl 15 (16 - 1)/shr1 */

0 commit comments

Comments
 (0)