Coverage Report

Created: 2026-09-13 06:38

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/zlib-ng/functable.h
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
11
#ifdef DISABLE_RUNTIME_CPU_DETECTION
12
13
#  include "arch_functions.h"
14
15
/* When compiling with native instructions it is not necessary to use functable.
16
 * Instead we use native_ macro indicating the best available variant of arch-specific
17
 * functions for the current platform.
18
 */
19
#  define FUNCTABLE_INIT ((void)0)
20
#  define FUNCTABLE_CALL(name) native_ ## name
21
#  define FUNCTABLE_FPTR(name) &native_ ## name
22
23
#else
24
25
struct functable_s {
26
    int      (* force_init)               (void);
27
    uint32_t (* adler32)                  (uint32_t adler, const uint8_t *buf, size_t len);
28
    uint32_t (* adler32_copy)             (uint32_t adler, uint8_t *dst, const uint8_t *src, size_t len);
29
    uint8_t* (* chunkmemset_safe)         (uint8_t *out, uint8_t *from, size_t len, size_t left);
30
    uint32_t (* compare256)               (const uint8_t *src0, const uint8_t *src1);
31
    uint32_t (* crc32)                    (uint32_t crc, const uint8_t *buf, size_t len);
32
    uint32_t (* crc32_copy)               (uint32_t crc, uint8_t *dst, const uint8_t *src, size_t len);
33
    void     (* inflate_fast)             (PREFIX3(stream) *strm, uint32_t start, int safe_mode);
34
    uint32_t (* longest_match)            (deflate_state *const s, uint32_t cur_match);
35
    uint32_t (* longest_match_slow_knuth) (deflate_state *const s, uint32_t cur_match);
36
    uint32_t (* longest_match_slow_roll)  (deflate_state *const s, uint32_t cur_match);
37
    void     (* slide_hash)               (deflate_state *s);
38
    void     (* slide_hash_head)          (deflate_state *s);
39
};
40
41
Z_INTERNAL extern struct functable_s functable;
42
43
44
/* Explicitly indicate functions are conditionally dispatched.
45
 */
46
3.13k
#  define FUNCTABLE_INIT if (functable.force_init()) {return Z_VERSION_ERROR;}
47
46.1k
#  define FUNCTABLE_CALL(name) functable.name
48
4.69k
#  define FUNCTABLE_FPTR(name) functable.name
49
50
#endif
51
52
#endif