mirror of
https://github.com/GerbilSoft/zlib-ng.git
synced 2025-06-18 19:45:37 -04:00
Clean up internal crc32 function handling.
Mark crc32_c and crc32_braid functions as internal, and remove prefix. Reorder contents of generic_functions, and remove Z_INTERNAL hints from declarations. Add test/benchmark output to indicate whether Chorba is used.
This commit is contained in:
parent
ed30965e29
commit
f411580733
@ -1,9 +1,9 @@
|
||||
#include "zbuild.h"
|
||||
#include "crc32.h"
|
||||
#include "crc32_braid_p.h"
|
||||
#include "crc32_c.h"
|
||||
#include "generic_functions.h"
|
||||
|
||||
uint32_t PREFIX(crc32_c)(uint32_t crc, const uint8_t *buf, size_t len) {
|
||||
Z_INTERNAL uint32_t crc32_c(uint32_t crc, const uint8_t *buf, size_t len) {
|
||||
uint32_t c;
|
||||
uint64_t* aligned_buf;
|
||||
size_t aligned_len;
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "zbuild.h"
|
||||
#include "crc32_braid_p.h"
|
||||
#include "crc32_braid_tbl.h"
|
||||
#include "crc32_c.h"
|
||||
#include "generic_functions.h"
|
||||
|
||||
/* Implement Chorba algorithm from https://arxiv.org/abs/2412.16398 */
|
||||
#define bitbuffersizebytes (16 * 1024 * sizeof(z_word_t))
|
||||
|
@ -6,38 +6,46 @@
|
||||
#define GENERIC_FUNCTIONS_H_
|
||||
|
||||
#include "zendian.h"
|
||||
|
||||
Z_INTERNAL uint32_t crc32_fold_reset_c(crc32_fold *crc);
|
||||
Z_INTERNAL void crc32_fold_copy_c(crc32_fold *crc, uint8_t *dst, const uint8_t *src, size_t len);
|
||||
Z_INTERNAL void crc32_fold_c(crc32_fold *crc, const uint8_t *src, size_t len, uint32_t init_crc);
|
||||
Z_INTERNAL uint32_t crc32_fold_final_c(crc32_fold *crc);
|
||||
|
||||
Z_INTERNAL uint32_t adler32_fold_copy_c(uint32_t adler, uint8_t *dst, const uint8_t *src, size_t len);
|
||||
|
||||
#include "deflate.h"
|
||||
#include "crc32_braid_p.h"
|
||||
|
||||
typedef uint32_t (*adler32_func)(uint32_t adler, const uint8_t *buf, size_t len);
|
||||
typedef uint32_t (*compare256_func)(const uint8_t *src0, const uint8_t *src1);
|
||||
typedef uint32_t (*crc32_func)(uint32_t crc32, const uint8_t *buf, size_t len);
|
||||
typedef void (*slide_hash_func)(deflate_state *s);
|
||||
|
||||
|
||||
uint32_t adler32_c(uint32_t adler, const uint8_t *buf, size_t len);
|
||||
uint32_t adler32_fold_copy_c(uint32_t adler, uint8_t *dst, const uint8_t *src, size_t len);
|
||||
|
||||
uint32_t chunksize_c(void);
|
||||
uint8_t* chunkmemset_safe_c(uint8_t *out, uint8_t *from, unsigned len, unsigned left);
|
||||
void inflate_fast_c(PREFIX3(stream) *strm, uint32_t start);
|
||||
|
||||
uint32_t PREFIX(crc32_c)(uint32_t crc, const uint8_t *buf, size_t len);
|
||||
uint32_t PREFIX(crc32_braid)(uint32_t c, const uint8_t *buf, size_t len);
|
||||
Z_INTERNAL uint32_t crc32_braid_internal(uint32_t c, const uint8_t *buf, size_t len);
|
||||
uint32_t chunksize_c(void);
|
||||
|
||||
uint32_t compare256_c(const uint8_t *src0, const uint8_t *src1);
|
||||
|
||||
typedef void (*slide_hash_func)(deflate_state *s);
|
||||
uint32_t crc32_c(uint32_t crc, const uint8_t *buf, size_t len);
|
||||
uint32_t crc32_braid(uint32_t c, const uint8_t *buf, size_t len);
|
||||
uint32_t crc32_braid_internal(uint32_t c, const uint8_t *buf, size_t len);
|
||||
|
||||
void slide_hash_c(deflate_state *s);
|
||||
#ifndef WITHOUT_CHORBA
|
||||
uint32_t crc32_chorba_118960_nondestructive (uint32_t crc, const z_word_t* input, size_t len);
|
||||
uint32_t crc32_chorba_32768_nondestructive (uint32_t crc, const uint64_t* buf, size_t len);
|
||||
uint32_t crc32_chorba_small_nondestructive (uint32_t crc, const uint64_t* buf, size_t len);
|
||||
uint32_t crc32_chorba_small_nondestructive_32bit (uint32_t crc, const uint32_t* buf, size_t len);
|
||||
#endif
|
||||
|
||||
uint32_t crc32_fold_reset_c(crc32_fold *crc);
|
||||
void crc32_fold_copy_c(crc32_fold *crc, uint8_t *dst, const uint8_t *src, size_t len);
|
||||
void crc32_fold_c(crc32_fold *crc, const uint8_t *src, size_t len, uint32_t init_crc);
|
||||
uint32_t crc32_fold_final_c(crc32_fold *crc);
|
||||
|
||||
void inflate_fast_c(PREFIX3(stream) *strm, uint32_t start);
|
||||
|
||||
uint32_t longest_match_c(deflate_state *const s, Pos cur_match);
|
||||
uint32_t longest_match_slow_c(deflate_state *const s, Pos cur_match);
|
||||
|
||||
void slide_hash_c(deflate_state *s);
|
||||
|
||||
#ifdef DISABLE_RUNTIME_CPU_DETECTION
|
||||
// Generic code
|
||||
# define native_adler32 adler32_c
|
||||
|
@ -202,12 +202,12 @@ uint32_t Z_INTERNAL crc32_s390_vx(uint32_t crc, const unsigned char *buf, size_t
|
||||
size_t prealign, aligned, remaining;
|
||||
|
||||
if (len < VX_MIN_LEN + VX_ALIGN_MASK)
|
||||
return PREFIX(crc32_c)(crc, buf, len);
|
||||
return crc32_c(crc, buf, len);
|
||||
|
||||
if ((uintptr_t)buf & VX_ALIGN_MASK) {
|
||||
prealign = VX_ALIGNMENT - ((uintptr_t)buf & VX_ALIGN_MASK);
|
||||
len -= prealign;
|
||||
crc = PREFIX(crc32_c)(crc, buf, prealign);
|
||||
crc = crc32_c(crc, buf, prealign);
|
||||
buf += prealign;
|
||||
}
|
||||
aligned = len & ~VX_ALIGN_MASK;
|
||||
@ -216,7 +216,7 @@ uint32_t Z_INTERNAL crc32_s390_vx(uint32_t crc, const unsigned char *buf, size_t
|
||||
crc = crc32_le_vgfm_16(crc ^ 0xffffffff, buf, aligned) ^ 0xffffffff;
|
||||
|
||||
if (remaining)
|
||||
crc = PREFIX(crc32_c)(crc, buf + aligned, remaining);
|
||||
crc = crc32_c(crc, buf + aligned, remaining);
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
@ -1,4 +0,0 @@
|
||||
Z_INTERNAL uint32_t crc32_chorba_118960_nondestructive (uint32_t crc, const z_word_t* input, size_t len);
|
||||
Z_INTERNAL uint32_t crc32_chorba_32768_nondestructive (uint32_t crc, const uint64_t* buf, size_t len);
|
||||
Z_INTERNAL uint32_t crc32_chorba_small_nondestructive (uint32_t crc, const uint64_t* buf, size_t len);
|
||||
Z_INTERNAL uint32_t crc32_chorba_small_nondestructive_32bit (uint32_t crc, const uint32_t* buf, size_t len);
|
@ -54,7 +54,7 @@ static void init_functable(void) {
|
||||
ft.adler32_fold_copy = &adler32_fold_copy_c;
|
||||
ft.chunkmemset_safe = &chunkmemset_safe_c;
|
||||
ft.chunksize = &chunksize_c;
|
||||
ft.crc32 = &PREFIX(crc32_c);
|
||||
ft.crc32 = &crc32_c;
|
||||
ft.crc32_fold = &crc32_fold_c;
|
||||
ft.crc32_fold_copy = &crc32_fold_copy_c;
|
||||
ft.crc32_fold_final = &crc32_fold_final_c;
|
||||
|
@ -56,8 +56,13 @@ public:
|
||||
} \
|
||||
BENCHMARK_REGISTER_F(crc32, name)->Arg(1)->Arg(8)->Arg(12)->Arg(16)->Arg(32)->Arg(64)->Arg(512)->Arg(4<<10)->Arg(32<<10)->Arg(256<<10)->Arg(4096<<10);
|
||||
|
||||
BENCHMARK_CRC32(braid, PREFIX(crc32_braid), 1);
|
||||
BENCHMARK_CRC32(generic, PREFIX(crc32_c), 1);
|
||||
#ifndef WITHOUT_CHORBA
|
||||
BENCHMARK_CRC32(generic_chorba, crc32_c, 1);
|
||||
#else
|
||||
BENCHMARK_CRC32(generic, crc32_c, 1);
|
||||
#endif
|
||||
|
||||
BENCHMARK_CRC32(braid, crc32_braid, 1);
|
||||
|
||||
#ifdef DISABLE_RUNTIME_CPU_DETECTION
|
||||
BENCHMARK_CRC32(native, native_crc32, 1);
|
||||
|
@ -224,8 +224,13 @@ INSTANTIATE_TEST_SUITE_P(crc32, crc32_variant, testing::ValuesIn(tests));
|
||||
hash(GetParam(), func); \
|
||||
}
|
||||
|
||||
TEST_CRC32(generic, PREFIX(crc32_c), 1)
|
||||
TEST_CRC32(braid, PREFIX(crc32_braid), 1)
|
||||
#ifndef WITHOUT_CHORBA
|
||||
TEST_CRC32(generic_chorba, crc32_c, 1)
|
||||
#else
|
||||
TEST_CRC32(generic, crc32_c, 1)
|
||||
#endif
|
||||
|
||||
TEST_CRC32(braid, crc32_braid, 1)
|
||||
|
||||
#ifdef DISABLE_RUNTIME_CPU_DETECTION
|
||||
TEST_CRC32(native, native_crc32, 1)
|
||||
|
Loading…
Reference in New Issue
Block a user