| 1 | /* |
| 2 | * Copyright (C) 2021 - 2026, Stephan Mueller <[email protected]> |
| 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_Hcxx . . $ `lib/jitterentropy-timer.h:21:9`! |
| 22 | |
| 23 | #include "jitterentropy-internal.h"cxx . . $ `<file>/lib/jitterentropy-internal.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 | static inline void jent_notime_block_switchcxx . . $ jent_notime_block_switch(49f6e7a06ebc5aa8).(void) { } |
| 45 | |
| 46 | static inline int jent_notime_settickcxx . . $ jent_notime_settick(f97662e903a7f2e7).(struct rand_datacxx . . $ rand_data# *ec) |
| 47 | { |
| 48 | (void)ec; |
| 49 | return 0; |
| 50 | } |
| 51 | |
| 52 | static inline void jent_notime_unsettickcxx . . $ jent_notime_unsettick(dd399101f0e3ec34).(struct rand_datacxx . . $ rand_data# *ec) { (void)ec; } |
| 53 | |
| 54 | static inline void jent_get_nstime_internalcxx . . $ jent_get_nstime_internal(3d346caf36e56379).(struct rand_datacxx . . $ rand_data# *ec, uint64_tcxx . . $ uint64_t# *out) |
| 55 | { |
| 56 | (void)ec; |
| 57 | jent_get_nstimecxx . . $ jent_get_nstime(386f4d2be08c489b).(out); |
| 58 | } |
| 59 | |
| 60 | static inline int jent_notime_enablecxx . . $ jent_notime_enable(58c46746d890317d).(struct rand_datacxx . . $ rand_data# *ec, unsigned int flags) |
| 61 | { |
| 62 | (void)ec; |
| 63 | |
| 64 | /* If we force the timer-less noise source, we return an error */ |
| 65 | if (flags & JENT_FORCE_INTERNAL_TIMERcxx . . $ `jitterentropy.h:86:9`!) |
| 66 | return EHEALTHcxx . . $ `jitterentropy.h:279:9`!; |
| 67 | |
| 68 | return 0; |
| 69 | } |
| 70 | |
| 71 | static inline void jent_notime_disablecxx . . $ jent_notime_disable(dd399101f0e3ec34).(struct rand_datacxx . . $ rand_data# *ec) |
| 72 | { |
| 73 | (void)ec; |
| 74 | } |
| 75 | |
| 76 | static inline int jent_notime_switchcxx . . $ jent_notime_switch(f2e5a00d6ded4bd0).(struct jent_notime_threadcxx . . $ jent_notime_thread# *new_thread) |
| 77 | { |
| 78 | (void)new_thread; |
| 79 | return -1; |
| 80 | } |
| 81 | |
| 82 | static inline void jent_notime_forcecxx . . $ jent_notime_force(49f6e7a06ebc5aa8).(void) { } |
| 83 | |
| 84 | static inline int jent_notime_forcedcxx . . $ jent_notime_forced(b126dc7c1de90089).(void) { return 0; } |
| 85 | |
| 86 | #endif /* JENT_CONF_ENABLE_INTERNAL_TIMER */ |
| 87 | |
| 88 | #ifdef __cplusplus |
| 89 | } |
| 90 | #endif |
| 91 | |
| 92 | #endif /* JITTERENTROPY-TIMER_H */ |