Coverage Report

Created: 2022-12-08 06:10

/src/libgcrypt/random/jitterentropy-timer.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright (C) 2021, Stephan Mueller <smueller@chronox.de>
3
 *
4
 * License: see LICENSE file in root directory
5
 *
6
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
7
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
8
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
9
 * WHICH ARE HEREBY DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE
10
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
11
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
12
 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
13
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
14
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
15
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
16
 * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
17
 * DAMAGE.
18
 */
19
20
#ifndef JITTERENTROPY_TIMER_H
21
#define JITTERENTROPY_TIMER_H
22
23
#include "jitterentropy.h"
24
25
#ifdef __cplusplus
26
extern "C"
27
{
28
#endif
29
30
#ifdef JENT_CONF_ENABLE_INTERNAL_TIMER
31
32
void jent_notime_block_switch(void);
33
int jent_notime_settick(struct rand_data *ec);
34
void jent_notime_unsettick(struct rand_data *ec);
35
void jent_get_nstime_internal(struct rand_data *ec, uint64_t *out);
36
int jent_notime_enable(struct rand_data *ec, unsigned int flags);
37
void jent_notime_disable(struct rand_data *ec);
38
int jent_notime_switch(struct jent_notime_thread *new_thread);
39
void jent_notime_force(void);
40
int jent_notime_forced(void);
41
42
#else /* JENT_CONF_ENABLE_INTERNAL_TIMER */
43
44
0
static inline void jent_notime_block_switch(void) { }
45
46
static inline int jent_notime_settick(struct rand_data *ec)
47
0
{
48
0
  (void)ec;
49
0
  return 0;
50
0
}
51
52
0
static inline void jent_notime_unsettick(struct rand_data *ec) { (void)ec; }
53
54
static inline void jent_get_nstime_internal(struct rand_data *ec, uint64_t *out)
55
0
{
56
0
  (void)ec;
57
0
  jent_get_nstime(out);
58
0
}
59
60
static inline int jent_notime_enable(struct rand_data *ec, unsigned int flags)
61
0
{
62
0
  (void)ec;
63
64
  /* If we force the timer-less noise source, we return an error */
65
0
  if (flags & JENT_FORCE_INTERNAL_TIMER)
66
0
    return EHEALTH;
67
68
0
  return 0;
69
0
}
70
71
static inline void jent_notime_disable(struct rand_data *ec)
72
0
{
73
0
  (void)ec;
74
0
}
75
76
static inline int jent_notime_switch(struct jent_notime_thread *new_thread)
77
0
{
78
0
  (void)new_thread;
79
0
  return -EOPNOTSUPP;
80
0
}
81
82
0
static inline void jent_notime_force(void) { }
83
84
0
static inline int jent_notime_forced(void) { return 0; }
85
86
#endif /* JENT_CONF_ENABLE_INTERNAL_TIMER */
87
88
#ifdef __cplusplus
89
}
90
#endif
91
92
#endif /* JITTERENTROPY-TIMER_H */