diff options
| author | Mehmet Samet Duman <yongdohyun@projecttick.org> | 2026-04-02 19:56:09 +0300 |
|---|---|---|
| committer | Mehmet Samet Duman <yongdohyun@projecttick.org> | 2026-04-02 19:56:09 +0300 |
| commit | 7fb132859fda54aa96bc9dd46d302b343eeb5a02 (patch) | |
| tree | b43ae77d7451fb470a260c03349a1caf2846c5e5 /neozip/functable.h | |
| parent | b1e34e861b5d732afe828d58aad2c638135061fd (diff) | |
| parent | c2712b8a345191f6ed79558c089777df94590087 (diff) | |
| download | Project-Tick-7fb132859fda54aa96bc9dd46d302b343eeb5a02.tar.gz Project-Tick-7fb132859fda54aa96bc9dd46d302b343eeb5a02.zip | |
Add 'neozip/' from commit 'c2712b8a345191f6ed79558c089777df94590087'
git-subtree-dir: neozip
git-subtree-mainline: b1e34e861b5d732afe828d58aad2c638135061fd
git-subtree-split: c2712b8a345191f6ed79558c089777df94590087
Diffstat (limited to 'neozip/functable.h')
| -rw-r--r-- | neozip/functable.h | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/neozip/functable.h b/neozip/functable.h new file mode 100644 index 0000000000..95e05d5ed7 --- /dev/null +++ b/neozip/functable.h @@ -0,0 +1,50 @@ +/* functable.h -- Struct containing function pointers to optimized functions + * Copyright (C) 2017 Hans Kristian Rosbach + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +#ifndef FUNCTABLE_H_ +#define FUNCTABLE_H_ + +#include "deflate.h" + +#ifdef DISABLE_RUNTIME_CPU_DETECTION + +# include "arch_functions.h" + +/* When compiling with native instructions it is not necessary to use functable. + * Instead we use native_ macro indicating the best available variant of arch-specific + * functions for the current platform. + */ +# define FUNCTABLE_INIT ((void)0) +# define FUNCTABLE_CALL(name) native_ ## name +# define FUNCTABLE_FPTR(name) &native_ ## name + +#else + +struct functable_s { + int (* force_init) (void); + uint32_t (* adler32) (uint32_t adler, const uint8_t *buf, size_t len); + uint32_t (* adler32_copy) (uint32_t adler, uint8_t *dst, const uint8_t *src, size_t len); + uint8_t* (* chunkmemset_safe) (uint8_t *out, uint8_t *from, size_t len, size_t left); + uint32_t (* compare256) (const uint8_t *src0, const uint8_t *src1); + uint32_t (* crc32) (uint32_t crc, const uint8_t *buf, size_t len); + uint32_t (* crc32_copy) (uint32_t crc, uint8_t *dst, const uint8_t *src, size_t len); + void (* inflate_fast) (PREFIX3(stream) *strm, uint32_t start); + uint32_t (* longest_match) (deflate_state *const s, uint32_t cur_match); + uint32_t (* longest_match_slow) (deflate_state *const s, uint32_t cur_match); + void (* slide_hash) (deflate_state *s); +}; + +Z_INTERNAL extern struct functable_s functable; + + +/* Explicitly indicate functions are conditionally dispatched. + */ +# define FUNCTABLE_INIT if (functable.force_init()) {return Z_VERSION_ERROR;} +# define FUNCTABLE_CALL(name) functable.name +# define FUNCTABLE_FPTR(name) functable.name + +#endif + +#endif |
