• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #if !defined(MBEDTLS_CONFIG_FILE)
14 #include "mbedtls/config.h"
15 #else
16 #include MBEDTLS_CONFIG_FILE
17 #endif
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 /*
24  * The time_t datatype
25  */
26 #if defined(MBEDTLS_PLATFORM_TIME_TYPE_MACRO)
27 typedef MBEDTLS_PLATFORM_TIME_TYPE_MACRO mbedtls_time_t;
28 #else
29 /* For time_t */
30 #include <time.h>
31 typedef time_t mbedtls_time_t;
32 #endif /* MBEDTLS_PLATFORM_TIME_TYPE_MACRO */
33 
34 /*
35  * The function pointers for time
36  */
37 #if defined(MBEDTLS_PLATFORM_TIME_ALT)
38 extern mbedtls_time_t (*mbedtls_time)(mbedtls_time_t *time);
39 
40 /**
41  * \brief   Set your own time function pointer
42  *
43  * \param   time_func   the time function implementation
44  *
45  * \return              0
46  */
47 int mbedtls_platform_set_time(mbedtls_time_t (*time_func)(mbedtls_time_t *time));
48 #else
49 #if defined(MBEDTLS_PLATFORM_TIME_MACRO)
50 #define mbedtls_time    MBEDTLS_PLATFORM_TIME_MACRO
51 #else
52 #define mbedtls_time   time
53 #endif /* MBEDTLS_PLATFORM_TIME_MACRO */
54 #endif /* MBEDTLS_PLATFORM_TIME_ALT */
55 
56 #ifdef __cplusplus
57 }
58 #endif
59 
60 #endif /* platform_time.h */
61