From 963bb810f4116f5ab8ad90cbc1cfb66677a69b52 Mon Sep 17 00:00:00 2001 From: TRodziewicz Date: Fri, 18 Jun 2021 13:22:57 +0200 Subject: [PATCH] Removing global variable and moving variant function comment block Signed-off-by: TRodziewicz --- include/mbedtls/timing.h | 2 -- library/timing.c | 40 +++++++++++++++++++--------------------- 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/include/mbedtls/timing.h b/include/mbedtls/timing.h index 5289889f98..6ffc812d8b 100644 --- a/include/mbedtls/timing.h +++ b/include/mbedtls/timing.h @@ -61,8 +61,6 @@ typedef struct mbedtls_timing_delay_context #include "timing_alt.h" #endif /* MBEDTLS_TIMING_ALT */ -extern volatile int mbedtls_timing_alarmed; - /* Internal use */ unsigned long mbedtls_timing_get_timer( struct mbedtls_timing_hr_time *val, int reset ); diff --git a/library/timing.c b/library/timing.c index e6dfc72d18..a85ce67b83 100644 --- a/library/timing.c +++ b/library/timing.c @@ -56,8 +56,25 @@ struct _hr_time #endif /* _WIN32 && !EFIX64 && !EFI32 */ -volatile int mbedtls_timing_alarmed = 0; - +/** + * \brief Return the elapsed time in milliseconds + * + * \warning May change without notice + * + * \param val points to a timer structure + * \param reset If 0, query the elapsed time. Otherwise (re)start the timer. + * + * \return Elapsed time since the previous reset in ms. When + * restarting, this is always 0. + * + * \note To initialize a timer, call this function with reset=1. + * + * Determining the elapsed time and resetting the timer is not + * atomic on all platforms, so after the sequence + * `{ get_timer(1); ...; time1 = get_timer(1); ...; time2 = + * get_timer(0) }` the value time1+time2 is only approximately + * the delay since the first reset. + */ #if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32) unsigned long mbedtls_timing_get_timer( struct mbedtls_timing_hr_time *val, int reset ) @@ -83,25 +100,6 @@ unsigned long mbedtls_timing_get_timer( struct mbedtls_timing_hr_time *val, int #else /* _WIN32 && !EFIX64 && !EFI32 */ -/** - * \brief Return the elapsed time in milliseconds - * - * \warning May change without notice - * - * \param val points to a timer structure - * \param reset If 0, query the elapsed time. Otherwise (re)start the timer. - * - * \return Elapsed time since the previous reset in ms. When - * restarting, this is always 0. - * - * \note To initialize a timer, call this function with reset=1. - * - * Determining the elapsed time and resetting the timer is not - * atomic on all platforms, so after the sequence - * `{ get_timer(1); ...; time1 = get_timer(1); ...; time2 = - * get_timer(0) }` the value time1+time2 is only approximately - * the delay since the first reset. - */ unsigned long mbedtls_timing_get_timer( struct mbedtls_timing_hr_time *val, int reset ) { struct _hr_time *t = (struct _hr_time *) val;