Line | Count | Source |
1 | | /* functable.h -- Struct containing function pointers to optimized functions |
2 | | * Copyright (C) 2017 Hans Kristian Rosbach |
3 | | * For conditions of distribution and use, see copyright notice in zlib.h |
4 | | */ |
5 | | |
6 | | #ifndef FUNCTABLE_H_ |
7 | | #define FUNCTABLE_H_ |
8 | | |
9 | | #include "deflate.h" |
10 | | #include "crc32.h" |
11 | | |
12 | | #ifdef DISABLE_RUNTIME_CPU_DETECTION |
13 | | |
14 | | # include "arch_functions.h" |
15 | | |
16 | | /* When compiling with native instructions it is not necessary to use functable. |
17 | | * Instead we use native_ macro indicating the best available variant of arch-specific |
18 | | * functions for the current platform. |
19 | | */ |
20 | | # define FUNCTABLE_INIT ((void)0) |
21 | | # define FUNCTABLE_CALL(name) native_ ## name |
22 | | # define FUNCTABLE_FPTR(name) &native_ ## name |
23 | | |
24 | | #else |
25 | | |
26 | | struct functable_s { |
27 | | void (* force_init) (void); |
28 | | uint32_t (* adler32) (uint32_t adler, const uint8_t *buf, size_t len); |
29 | | uint32_t (* adler32_fold_copy) (uint32_t adler, uint8_t *dst, const uint8_t *src, size_t len); |
30 | | uint8_t* (* chunkmemset_safe) (uint8_t *out, uint8_t *from, unsigned len, unsigned left); |
31 | | uint32_t (* chunksize) (void); |
32 | | uint32_t (* compare256) (const uint8_t *src0, const uint8_t *src1); |
33 | | uint32_t (* crc32) (uint32_t crc, const uint8_t *buf, size_t len); |
34 | | void (* crc32_fold) (struct crc32_fold_s *crc, const uint8_t *src, size_t len, uint32_t init_crc); |
35 | | void (* crc32_fold_copy) (struct crc32_fold_s *crc, uint8_t *dst, const uint8_t *src, size_t len); |
36 | | uint32_t (* crc32_fold_final) (struct crc32_fold_s *crc); |
37 | | uint32_t (* crc32_fold_reset) (struct crc32_fold_s *crc); |
38 | | void (* inflate_fast) (PREFIX3(stream) *strm, uint32_t start); |
39 | | uint32_t (* longest_match) (deflate_state *const s, Pos cur_match); |
40 | | uint32_t (* longest_match_slow) (deflate_state *const s, Pos cur_match); |
41 | | void (* slide_hash) (deflate_state *s); |
42 | | }; |
43 | | |
44 | | Z_INTERNAL extern struct functable_s functable; |
45 | | |
46 | | |
47 | | /* Explicitly indicate functions are conditionally dispatched. |
48 | | */ |
49 | 12.5k | # define FUNCTABLE_INIT functable.force_init() |
50 | 15.3M | # define FUNCTABLE_CALL(name) functable.name |
51 | 2.68k | # define FUNCTABLE_FPTR(name) functable.name |
52 | | |
53 | | #endif |
54 | | |
55 | | #endif |