NCBI C++ ToolKit
platform_time.h
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /**
2  * \file platform_time.h
3  *
4  * \brief Mbed TLS Platform time abstraction
5  */
6 /*
7  * Copyright The Mbed TLS Contributors
8  * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
9  */
10 #ifndef MBEDTLS_PLATFORM_TIME_H
11 #define MBEDTLS_PLATFORM_TIME_H
12 
13 #include "mbedtls/build_info.h"
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 /*
20  * The time_t datatype
21  */
22 #if defined(MBEDTLS_PLATFORM_TIME_TYPE_MACRO)
23 typedef MBEDTLS_PLATFORM_TIME_TYPE_MACRO mbedtls_time_t;
24 #else
25 /* For time_t */
26 #include <time.h>
27 typedef time_t mbedtls_time_t;
28 #endif /* MBEDTLS_PLATFORM_TIME_TYPE_MACRO */
29 
30 #if defined(MBEDTLS_PLATFORM_MS_TIME_TYPE_MACRO)
31 typedef MBEDTLS_PLATFORM_MS_TIME_TYPE_MACRO mbedtls_ms_time_t;
32 #else
33 #include <stdint.h>
34 #include <inttypes.h>
36 #endif /* MBEDTLS_PLATFORM_MS_TIME_TYPE_MACRO */
37 
38 /**
39  * \brief Get time in milliseconds.
40  *
41  * \return Monotonically-increasing current time in milliseconds.
42  *
43  * \note Define MBEDTLS_PLATFORM_MS_TIME_ALT to be able to provide an
44  * alternative implementation
45  *
46  * \warning This function returns a monotonically-increasing time value from a
47  * start time that will differ from platform to platform, and possibly
48  * from run to run of the process.
49  *
50  */
52 
53 /*
54  * The function pointers for time
55  */
56 #if defined(MBEDTLS_PLATFORM_TIME_ALT)
58 
59 /**
60  * \brief Set your own time function pointer
61  *
62  * \param time_func the time function implementation
63  *
64  * \return 0
65  */
66 int mbedtls_platform_set_time(mbedtls_time_t (*time_func)(mbedtls_time_t *time));
67 #else
68 #if defined(MBEDTLS_PLATFORM_TIME_MACRO)
69 #define mbedtls_time MBEDTLS_PLATFORM_TIME_MACRO
70 #else
71 #define mbedtls_time time
72 #endif /* MBEDTLS_PLATFORM_TIME_MACRO */
73 #endif /* MBEDTLS_PLATFORM_TIME_ALT */
74 
75 #ifdef __cplusplus
76 }
77 #endif
78 
79 #endif /* platform_time.h */
Int8 int64_t
Build-time configuration info.
int64_t mbedtls_ms_time_t
Definition: platform_time.h:35
mbedtls_ms_time_t mbedtls_ms_time(void)
Get time in milliseconds.
#define mbedtls_time
Definition: platform_time.h:71
time_t mbedtls_time_t
Definition: platform_time.h:27
Modified on Mon May 20 05:04:54 2024 by modify_doxy.py rev. 669887