Coverage Report

Created: 2026-10-28 06:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openssl41/include/crypto/sparse_array.h
Line
Count
Source
1
/*
2
 * Copyright 2019-2026 The OpenSSL Project Authors. All Rights Reserved.
3
 * Copyright (c) 2019, Oracle and/or its affiliates.  All rights reserved.
4
 *
5
 * Licensed under the Apache License 2.0 (the "License").  You may not use
6
 * this file except in compliance with the License.  You can obtain a copy
7
 * in the file LICENSE in the source distribution or at
8
 * https://www.openssl.org/source/license.html
9
 */
10
11
#ifndef OSSL_CRYPTO_SPARSE_ARRAY_H
12
#define OSSL_CRYPTO_SPARSE_ARRAY_H
13
#pragma once
14
15
#include <openssl/e_os2.h>
16
17
#ifdef __cplusplus
18
extern "C" {
19
#endif
20
21
379k
#define SPARSE_ARRAY_OF(type) struct sparse_array_st_##type
22
23
#define DEFINE_SPARSE_ARRAY_OF_INTERNAL(type, ctype)                                                              \
24
    SPARSE_ARRAY_OF(type);                                                                                        \
25
    typedef void (*sa_##type##_leaffunc)(ossl_uintmax_t idx, type *t);                                            \
26
    typedef void (*sa_##type##_leaffunc_arg)(ossl_uintmax_t idx, type *t, void *arg);                             \
27
    static ossl_unused ossl_inline SPARSE_ARRAY_OF(type) *ossl_sa_##type##_new(void)                              \
28
364k
    {                                                                                                             \
29
364k
        return (SPARSE_ARRAY_OF(type) *)ossl_sa_new();                                                            \
30
364k
    }                                                                                                             \
threads_common.c:ossl_sa_CTX_TABLE_ENTRY_new
Line
Count
Source
28
383
    {                                                                                                             \
29
383
        return (SPARSE_ARRAY_OF(type) *)ossl_sa_new();                                                            \
30
383
    }                                                                                                             \
property.c:ossl_sa_ALGORITHM_new
Line
Count
Source
28
4.80k
    {                                                                                                             \
29
4.80k
        return (SPARSE_ARRAY_OF(type) *)ossl_sa_new();                                                            \
30
4.80k
    }                                                                                                             \
rsa_ossl.c:ossl_sa_BN_BLINDING_new
Line
Count
Source
28
359k
    {                                                                                                             \
29
359k
        return (SPARSE_ARRAY_OF(type) *)ossl_sa_new();                                                            \
30
359k
    }                                                                                                             \
31
    static ossl_unused ossl_inline void                                                                           \
32
    ossl_sa_##type##_free(SPARSE_ARRAY_OF(type) *sa)                                                              \
33
359k
    {                                                                                                             \
34
359k
        ossl_sa_free((OPENSSL_SA *)sa);                                                                           \
35
359k
    }                                                                                                             \
threads_common.c:ossl_sa_CTX_TABLE_ENTRY_free
Line
Count
Source
33
86
    {                                                                                                             \
34
86
        ossl_sa_free((OPENSSL_SA *)sa);                                                                           \
35
86
    }                                                                                                             \
property.c:ossl_sa_ALGORITHM_free
Line
Count
Source
33
616
    {                                                                                                             \
34
616
        ossl_sa_free((OPENSSL_SA *)sa);                                                                           \
35
616
    }                                                                                                             \
rsa_ossl.c:ossl_sa_BN_BLINDING_free
Line
Count
Source
33
359k
    {                                                                                                             \
34
359k
        ossl_sa_free((OPENSSL_SA *)sa);                                                                           \
35
359k
    }                                                                                                             \
36
    static ossl_unused ossl_inline void                                                                           \
37
    ossl_sa_##type##_free_leaves(SPARSE_ARRAY_OF(type) *sa)                                                       \
38
0
    {                                                                                                             \
39
0
        ossl_sa_free_leaves((OPENSSL_SA *)sa);                                                                    \
40
0
    }                                                                                                             \
Unexecuted instantiation: threads_common.c:ossl_sa_CTX_TABLE_ENTRY_free_leaves
Unexecuted instantiation: property.c:ossl_sa_ALGORITHM_free_leaves
Unexecuted instantiation: rsa_ossl.c:ossl_sa_BN_BLINDING_free_leaves
41
    static ossl_unused ossl_inline size_t                                                                         \
42
    ossl_sa_##type##_num(const SPARSE_ARRAY_OF(type) *sa)                                                         \
43
547k
    {                                                                                                             \
44
547k
        return ossl_sa_num((OPENSSL_SA *)sa);                                                                     \
45
547k
    }                                                                                                             \
Unexecuted instantiation: threads_common.c:ossl_sa_CTX_TABLE_ENTRY_num
property.c:ossl_sa_ALGORITHM_num
Line
Count
Source
43
547k
    {                                                                                                             \
44
547k
        return ossl_sa_num((OPENSSL_SA *)sa);                                                                     \
45
547k
    }                                                                                                             \
Unexecuted instantiation: rsa_ossl.c:ossl_sa_BN_BLINDING_num
46
    static ossl_unused void                                                                                       \
47
    ossl_sa_##type##_doall_thunk(ossl_uintmax_t idx, void *leaf, void *arg)                                       \
48
0
    {                                                                                                             \
49
0
        sa_##type##_leaffunc fn = *(sa_##type##_leaffunc *)arg;                                                   \
50
0
        (*fn)(idx, (type *)leaf);                                                                                 \
51
0
    }                                                                                                             \
Unexecuted instantiation: threads_common.c:ossl_sa_CTX_TABLE_ENTRY_doall_thunk
Unexecuted instantiation: property.c:ossl_sa_ALGORITHM_doall_thunk
Unexecuted instantiation: rsa_ossl.c:ossl_sa_BN_BLINDING_doall_thunk
52
    static ossl_unused ossl_inline void                                                                           \
53
    ossl_sa_##type##_doall(const SPARSE_ARRAY_OF(type) *sa,                                                       \
54
        void (*leaf)(ossl_uintmax_t, type *))                                                                     \
55
0
    {                                                                                                             \
56
0
        ossl_sa_doall_arg((OPENSSL_SA *)sa, ossl_sa_##type##_doall_thunk, &leaf);                                 \
57
0
    }                                                                                                             \
Unexecuted instantiation: threads_common.c:ossl_sa_CTX_TABLE_ENTRY_doall
Unexecuted instantiation: rsa_ossl.c:ossl_sa_BN_BLINDING_doall
58
    struct ossl_sa_##type##_doall_thunk {                                                                         \
59
        sa_##type##_leaffunc_arg fn;                                                                              \
60
        void *arg;                                                                                                \
61
    };                                                                                                            \
62
    static ossl_unused void                                                                                       \
63
    ossl_sa_##type##_doall_arg_thunk(ossl_uintmax_t idx, void *leaf, void *arg)                                   \
64
3.21M
    {                                                                                                             \
65
3.21M
        struct ossl_sa_##type##_doall_thunk *t = arg;                                                             \
66
3.21M
                                                                                                                  \
67
3.21M
        (*t->fn)(idx, (type *)leaf, t->arg);                                                                      \
68
3.21M
    }                                                                                                             \
Unexecuted instantiation: threads_common.c:ossl_sa_CTX_TABLE_ENTRY_doall_arg_thunk
property.c:ossl_sa_ALGORITHM_doall_arg_thunk
Line
Count
Source
64
3.21M
    {                                                                                                             \
65
3.21M
        struct ossl_sa_##type##_doall_thunk *t = arg;                                                             \
66
3.21M
                                                                                                                  \
67
3.21M
        (*t->fn)(idx, (type *)leaf, t->arg);                                                                      \
68
3.21M
    }                                                                                                             \
rsa_ossl.c:ossl_sa_BN_BLINDING_doall_arg_thunk
Line
Count
Source
64
5.83k
    {                                                                                                             \
65
5.83k
        struct ossl_sa_##type##_doall_thunk *t = arg;                                                             \
66
5.83k
                                                                                                                  \
67
5.83k
        (*t->fn)(idx, (type *)leaf, t->arg);                                                                      \
68
5.83k
    }                                                                                                             \
69
    static ossl_unused ossl_inline void                                                                           \
70
    ossl_sa_##type##_doall_arg(const SPARSE_ARRAY_OF(type) *sa,                                                   \
71
        void (*leaf)(ossl_uintmax_t, type *, void *),                                                             \
72
        void *arg)                                                                                                \
73
906k
    {                                                                                                             \
74
906k
        struct ossl_sa_##type##_doall_thunk t;                                                                    \
75
906k
                                                                                                                  \
76
906k
        t.fn = leaf;                                                                                              \
77
906k
        t.arg = arg;                                                                                              \
78
906k
        ossl_sa_doall_arg((OPENSSL_SA *)sa,                                                                       \
79
906k
            ossl_sa_##type##_doall_arg_thunk, &t);                                                                \
80
906k
    }                                                                                                             \
Unexecuted instantiation: threads_common.c:ossl_sa_CTX_TABLE_ENTRY_doall_arg
property.c:ossl_sa_ALGORITHM_doall_arg
Line
Count
Source
73
547k
    {                                                                                                             \
74
547k
        struct ossl_sa_##type##_doall_thunk t;                                                                    \
75
547k
                                                                                                                  \
76
547k
        t.fn = leaf;                                                                                              \
77
547k
        t.arg = arg;                                                                                              \
78
547k
        ossl_sa_doall_arg((OPENSSL_SA *)sa,                                                                       \
79
547k
            ossl_sa_##type##_doall_arg_thunk, &t);                                                                \
80
547k
    }                                                                                                             \
rsa_ossl.c:ossl_sa_BN_BLINDING_doall_arg
Line
Count
Source
73
359k
    {                                                                                                             \
74
359k
        struct ossl_sa_##type##_doall_thunk t;                                                                    \
75
359k
                                                                                                                  \
76
359k
        t.fn = leaf;                                                                                              \
77
359k
        t.arg = arg;                                                                                              \
78
359k
        ossl_sa_doall_arg((OPENSSL_SA *)sa,                                                                       \
79
359k
            ossl_sa_##type##_doall_arg_thunk, &t);                                                                \
80
359k
    }                                                                                                             \
81
    static ossl_unused ossl_inline ctype *ossl_sa_##type##_get(const SPARSE_ARRAY_OF(type) *sa, ossl_uintmax_t n) \
82
2.10G
    {                                                                                                             \
83
2.10G
        return (type *)ossl_sa_get((OPENSSL_SA *)sa, n);                                                          \
84
2.10G
    }                                                                                                             \
threads_common.c:ossl_sa_CTX_TABLE_ENTRY_get
Line
Count
Source
82
2.08G
    {                                                                                                             \
83
2.08G
        return (type *)ossl_sa_get((OPENSSL_SA *)sa, n);                                                          \
84
2.08G
    }                                                                                                             \
property.c:ossl_sa_ALGORITHM_get
Line
Count
Source
82
18.6M
    {                                                                                                             \
83
18.6M
        return (type *)ossl_sa_get((OPENSSL_SA *)sa, n);                                                          \
84
18.6M
    }                                                                                                             \
rsa_ossl.c:ossl_sa_BN_BLINDING_get
Line
Count
Source
82
10.2k
    {                                                                                                             \
83
10.2k
        return (type *)ossl_sa_get((OPENSSL_SA *)sa, n);                                                          \
84
10.2k
    }                                                                                                             \
85
    static ossl_unused ossl_inline int                                                                            \
86
    ossl_sa_##type##_set(SPARSE_ARRAY_OF(type) *sa,                                                               \
87
        ossl_uintmax_t n, ctype *val)                                                                             \
88
49.3k
    {                                                                                                             \
89
49.3k
        return ossl_sa_set((OPENSSL_SA *)sa, n, (void *)val);                                                     \
90
49.3k
    }                                                                                                             \
threads_common.c:ossl_sa_CTX_TABLE_ENTRY_set
Line
Count
Source
88
1.17k
    {                                                                                                             \
89
1.17k
        return ossl_sa_set((OPENSSL_SA *)sa, n, (void *)val);                                                     \
90
1.17k
    }                                                                                                             \
property.c:ossl_sa_ALGORITHM_set
Line
Count
Source
88
37.9k
    {                                                                                                             \
89
37.9k
        return ossl_sa_set((OPENSSL_SA *)sa, n, (void *)val);                                                     \
90
37.9k
    }                                                                                                             \
rsa_ossl.c:ossl_sa_BN_BLINDING_set
Line
Count
Source
88
10.2k
    {                                                                                                             \
89
10.2k
        return ossl_sa_set((OPENSSL_SA *)sa, n, (void *)val);                                                     \
90
10.2k
    }                                                                                                             \
91
    SPARSE_ARRAY_OF(type)
92
93
#define DEFINE_SPARSE_ARRAY_OF(type) \
94
    DEFINE_SPARSE_ARRAY_OF_INTERNAL(type, type)
95
#define DEFINE_SPARSE_ARRAY_OF_CONST(type) \
96
    DEFINE_SPARSE_ARRAY_OF_INTERNAL(type, const type)
97
98
typedef struct sparse_array_st OPENSSL_SA;
99
OPENSSL_SA *ossl_sa_new(void);
100
void ossl_sa_free(OPENSSL_SA *sa);
101
void ossl_sa_free_leaves(OPENSSL_SA *sa);
102
size_t ossl_sa_num(const OPENSSL_SA *sa);
103
void ossl_sa_doall(const OPENSSL_SA *sa, void (*leaf)(ossl_uintmax_t, void *));
104
void ossl_sa_doall_arg(const OPENSSL_SA *sa,
105
    void (*leaf)(ossl_uintmax_t, void *, void *), void *);
106
void *ossl_sa_get(const OPENSSL_SA *sa, ossl_uintmax_t n);
107
int ossl_sa_set(OPENSSL_SA *sa, ossl_uintmax_t n, void *val);
108
109
#ifdef __cplusplus
110
}
111
#endif
112
#endif